Author: mes
Date: 2009-07-24 17:17:08 -0700 (Fri, 24 Jul 2009)
New Revision: 17574
Added:
cytoscape3/trunk/application/src/main/java/cytoscape/internal/actions/RedoAction.java
cytoscape3/trunk/application/src/main/java/cytoscape/internal/actions/UndoAction.java
cytoscape3/trunk/application/src/main/java/cytoscape/internal/util/undo/
cytoscape3/trunk/application/src/main/java/cytoscape/internal/util/undo/UndoMonitor.java
cytoscape3/trunk/application/src/main/java/cytoscape/util/CyAbstractEdit.java
Removed:
cytoscape3/trunk/application/src/main/java/cytoscape/util/undo/
Modified:
cytoscape3/trunk/application/src/main/java/cytoscape/util/swing/FilterHistoryJList.java
cytoscape3/trunk/application/src/main/resources/META-INF/spring/bundle-context.xml
Log:
moved undo stuff into internal
Copied:
cytoscape3/trunk/application/src/main/java/cytoscape/internal/actions/RedoAction.java
(from rev 17515,
cytoscape3/trunk/application/src/main/java/cytoscape/util/undo/RedoAction.java)
===================================================================
---
cytoscape3/trunk/application/src/main/java/cytoscape/internal/actions/RedoAction.java
(rev 0)
+++
cytoscape3/trunk/application/src/main/java/cytoscape/internal/actions/RedoAction.java
2009-07-25 00:17:08 UTC (rev 17574)
@@ -0,0 +1,97 @@
+/*
+ File: RedoAction.java
+
+ Copyright (c) 2006, The Cytoscape Consortium (www.cytoscape.org)
+
+ The Cytoscape Consortium is:
+ - Institute for Systems Biology
+ - University of California San Diego
+ - Memorial Sloan-Kettering Cancer Center
+ - Institut Pasteur
+ - Agilent Technologies
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
+ MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. The software and
+ documentation provided hereunder is on an "as is" basis, and the
+ Institute for Systems Biology and the Whitehead Institute
+ have no obligations to provide maintenance, support,
+ updates, enhancements or modifications. In no event shall the
+ Institute for Systems Biology and the Whitehead Institute
+ be liable to any party for direct, indirect, special,
+ incidental or consequential damages, including lost profits, arising
+ out of the use of this software and its documentation, even if the
+ Institute for Systems Biology and the Whitehead Institute
+ have been advised of the possibility of such damage. See
+ the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+*/
+package cytoscape.internal.actions;
+
+import cytoscape.util.CytoscapeAction;
+
+import org.cytoscape.work.UndoSupport;
+import org.cytoscape.session.CyNetworkManager;
+
+import javax.swing.*;
+import javax.swing.event.MenuEvent;
+import javax.swing.undo.CannotUndoException;
+import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
+
+/**
+ * An action that calls redo for the most recent edit in the
+ * undoable edit stack.
+ */
+public class RedoAction extends CytoscapeAction {
+ private final static long serialVersionUID = 1202339875203626L;
+
+ private final UndoSupport undo;
+
+ /**
+ * Constructs the action.
+ */
+ public RedoAction(UndoSupport undo, CyNetworkManager netmgr) {
+ super("Redo",netmgr);
+ setAcceleratorCombo(KeyEvent.VK_Y, ActionEvent.CTRL_MASK);
+ setPreferredMenu("Edit");
+ setEnabled(true);
+ this.undo = undo;
+ }
+
+ /**
+ * Tries to run redo() on the top edit of the edit stack.
+ * @param e The action event that triggers this method call.
+ */
+ public void actionPerformed(ActionEvent e) {
+ try {
+ if ( undo.getUndoManager().canRedo() )
+ undo.getUndoManager().redo();
+ } catch (CannotUndoException ex) {
+ System.out.println("Unable to redo: " + ex);
+ ex.printStackTrace();
+ }
+ }
+
+ /**
+ * Called when the menu that contains this action is clicked on.
+ * @param e The menu event that triggers this method call.
+ */
+ public void menuSelected(MenuEvent e) {
+ if (undo.getUndoManager().canRedo()) {
+ setEnabled(true);
+ putValue(Action.NAME,
undo.getUndoManager().getRedoPresentationName());
+ } else {
+ setEnabled(false);
+ putValue(Action.NAME, "Redo");
+ }
+ }
+}
Copied:
cytoscape3/trunk/application/src/main/java/cytoscape/internal/actions/UndoAction.java
(from rev 17515,
cytoscape3/trunk/application/src/main/java/cytoscape/util/undo/UndoAction.java)
===================================================================
---
cytoscape3/trunk/application/src/main/java/cytoscape/internal/actions/UndoAction.java
(rev 0)
+++
cytoscape3/trunk/application/src/main/java/cytoscape/internal/actions/UndoAction.java
2009-07-25 00:17:08 UTC (rev 17574)
@@ -0,0 +1,97 @@
+/*
+ File: UndoAction.java
+
+ Copyright (c) 2006, The Cytoscape Consortium (www.cytoscape.org)
+
+ The Cytoscape Consortium is:
+ - Institute for Systems Biology
+ - University of California San Diego
+ - Memorial Sloan-Kettering Cancer Center
+ - Institut Pasteur
+ - Agilent Technologies
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
+ MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. The software and
+ documentation provided hereunder is on an "as is" basis, and the
+ Institute for Systems Biology and the Whitehead Institute
+ have no obligations to provide maintenance, support,
+ updates, enhancements or modifications. In no event shall the
+ Institute for Systems Biology and the Whitehead Institute
+ be liable to any party for direct, indirect, special,
+ incidental or consequential damages, including lost profits, arising
+ out of the use of this software and its documentation, even if the
+ Institute for Systems Biology and the Whitehead Institute
+ have been advised of the possibility of such damage. See
+ the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+*/
+package cytoscape.internal.actions;
+
+import cytoscape.util.CytoscapeAction;
+import org.cytoscape.session.CyNetworkManager;
+
+import org.cytoscape.work.UndoSupport;
+
+import javax.swing.*;
+import javax.swing.event.MenuEvent;
+import javax.swing.undo.CannotUndoException;
+import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
+
+/**
+ * An action that calls undo for the most recent edit in the
+ * undoable edit stack.
+ */
+public class UndoAction extends CytoscapeAction {
+ private final static long serialVersionUID = 1202339875212525L;
+
+ private UndoSupport undo;
+
+ /**
+ * Constructs the action.
+ */
+ public UndoAction(UndoSupport undo,CyNetworkManager netmgr) {
+ super("Undo",netmgr);
+ setAcceleratorCombo(KeyEvent.VK_Z, ActionEvent.CTRL_MASK);
+ setPreferredMenu("Edit");
+ setEnabled(true);
+ this.undo = undo;
+ }
+
+ /**
+ * Tries to run undo() on the top edit of the edit stack.
+ * @param e The action event that triggers this method call.
+ */
+ public void actionPerformed(ActionEvent e) {
+ try {
+ if ( undo.getUndoManager().canUndo() )
+ undo.getUndoManager().undo();
+ } catch (CannotUndoException ex) {
+ System.out.println("Unable to undo: " + ex);
+ ex.printStackTrace();
+ }
+ }
+
+ /**
+ * Called when the menu that contains this action is clicked on.
+ * @param e The menu event that triggers this method call.
+ */
+ public void menuSelected(MenuEvent e) {
+ if (undo.getUndoManager().canUndo()) {
+ setEnabled(true);
+ putValue(Action.NAME,
undo.getUndoManager().getUndoPresentationName());
+ } else {
+ setEnabled(false);
+ putValue(Action.NAME, "Undo");
+ }
+ }
+}
Copied:
cytoscape3/trunk/application/src/main/java/cytoscape/internal/util/undo/UndoMonitor.java
(from rev 17515,
cytoscape3/trunk/application/src/main/java/cytoscape/util/undo/UndoMonitor.java)
===================================================================
---
cytoscape3/trunk/application/src/main/java/cytoscape/internal/util/undo/UndoMonitor.java
(rev 0)
+++
cytoscape3/trunk/application/src/main/java/cytoscape/internal/util/undo/UndoMonitor.java
2009-07-25 00:17:08 UTC (rev 17574)
@@ -0,0 +1,90 @@
+/*
+ File: UndoMonitor.java
+
+ Copyright (c) 2006, The Cytoscape Consortium (www.cytoscape.org)
+
+ The Cytoscape Consortium is:
+ - Institute for Systems Biology
+ - University of California San Diego
+ - Memorial Sloan-Kettering Cancer Center
+ - Institut Pasteur
+ - Agilent Technologies
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
+ MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. The software and
+ documentation provided hereunder is on an "as is" basis, and the
+ Institute for Systems Biology and the Whitehead Institute
+ have no obligations to provide maintenance, support,
+ updates, enhancements or modifications. In no event shall the
+ Institute for Systems Biology and the Whitehead Institute
+ be liable to any party for direct, indirect, special,
+ incidental or consequential damages, including lost profits, arising
+ out of the use of this software and its documentation, even if the
+ Institute for Systems Biology and the Whitehead Institute
+ have been advised of the possibility of such damage. See
+ the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+*/
+package cytoscape.internal.util.undo;
+
+import org.cytoscape.work.UndoSupport;
+
+import org.cytoscape.session.events.SetCurrentNetworkViewEvent;
+import org.cytoscape.session.events.SetCurrentNetworkViewListener;
+
+import java.util.Properties;
+
+/**
+ * This class monitors the undoable edit stack and implements whatever
+ * discard policy we might have. Currently, we discard all edits if
+ * the network view focus changes.
+ */
+public class UndoMonitor implements SetCurrentNetworkViewListener {
+
+ private UndoSupport undo;
+ private Properties props;
+
+ public UndoMonitor(UndoSupport undo,Properties props) {
+
+ this.undo = undo;
+ this.props = props;
+
+ undo.getUndoManager().setLimit( getLimit() );
+ }
+
+ private int getLimit() {
+ int lim;
+ try {
+ lim = Integer.parseInt( props.getProperty("undo.limit") );
+ } catch ( Exception e ) {
+ e.printStackTrace();
+ lim = 10;
+ }
+
+ if ( lim < 0 )
+ lim = 10;
+
+ return lim;
+ }
+
+ /**
+ * This method listens for changes to the current network and discards
all edits
+ * when the network changes.
+ *
+ * @param e The change event.
+ */
+ public void handleEvent(SetCurrentNetworkViewEvent e) {
+ if ( e.getNetworkView() != null )
+ undo.getUndoManager().discardAllEdits();
+ }
+}
+
Copied:
cytoscape3/trunk/application/src/main/java/cytoscape/util/CyAbstractEdit.java
(from rev 17515,
cytoscape3/trunk/application/src/main/java/cytoscape/util/undo/CyAbstractEdit.java)
===================================================================
---
cytoscape3/trunk/application/src/main/java/cytoscape/util/CyAbstractEdit.java
(rev 0)
+++
cytoscape3/trunk/application/src/main/java/cytoscape/util/CyAbstractEdit.java
2009-07-25 00:17:08 UTC (rev 17574)
@@ -0,0 +1,75 @@
+
+/*
+ File: CyAbstractEdit.java
+
+ Copyright (c) 2006, The Cytoscape Consortium (www.cytoscape.org)
+
+ The Cytoscape Consortium is:
+ - Institute for Systems Biology
+ - University of California San Diego
+ - Memorial Sloan-Kettering Cancer Center
+ - Institut Pasteur
+ - Agilent Technologies
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
+ MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. The software and
+ documentation provided hereunder is on an "as is" basis, and the
+ Institute for Systems Biology and the Whitehead Institute
+ have no obligations to provide maintenance, support,
+ updates, enhancements or modifications. In no event shall the
+ Institute for Systems Biology and the Whitehead Institute
+ be liable to any party for direct, indirect, special,
+ incidental or consequential damages, including lost profits, arising
+ out of the use of this software and its documentation, even if the
+ Institute for Systems Biology and the Whitehead Institute
+ have been advised of the possibility of such damage. See
+ the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+*/
+
+package cytoscape.util;
+
+import javax.swing.undo.AbstractUndoableEdit;
+
+/**
+ * A small convenience class that can be used to create new edits. All
+ * you should have to do is implement the undo() and redo() methods. The
+ * benefit is that you don't need to worry about setting up names.
+ */
+public abstract class CyAbstractEdit extends AbstractUndoableEdit {
+
+ protected String desc;
+
+ public CyAbstractEdit(String desc) {
+ this.desc = desc;
+ }
+
+ public String getPresentationName() {
+ return desc;
+ }
+
+ public String getRedoPresentationName() {
+ return "Redo: " + desc;
+ }
+
+ public String getUndoPresentationName() {
+ return "Undo: " + desc;
+ }
+
+ public void undo() {
+ super.undo();
+ }
+
+ public void redo() {
+ super.redo();
+ }
+}
Modified:
cytoscape3/trunk/application/src/main/java/cytoscape/util/swing/FilterHistoryJList.java
===================================================================
---
cytoscape3/trunk/application/src/main/java/cytoscape/util/swing/FilterHistoryJList.java
2009-07-24 23:58:36 UTC (rev 17573)
+++
cytoscape3/trunk/application/src/main/java/cytoscape/util/swing/FilterHistoryJList.java
2009-07-25 00:17:08 UTC (rev 17574)
@@ -34,8 +34,6 @@
*/
package cytoscape.util.swing;
-import cytoscape.Cytoscape;
-
import javax.swing.*;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
Modified:
cytoscape3/trunk/application/src/main/resources/META-INF/spring/bundle-context.xml
===================================================================
---
cytoscape3/trunk/application/src/main/resources/META-INF/spring/bundle-context.xml
2009-07-24 23:58:36 UTC (rev 17573)
+++
cytoscape3/trunk/application/src/main/resources/META-INF/spring/bundle-context.xml
2009-07-25 00:17:08 UTC (rev 17574)
@@ -125,11 +125,11 @@
<bean id="exitAction" class="cytoscape.internal.actions.ExitAction">
<constructor-arg ref="cyNetworkManagerServiceRef" />
</bean>
- <bean id="undoAction" class="cytoscape.util.undo.UndoAction">
+ <bean id="undoAction" class="cytoscape.internal.actions.UndoAction">
<constructor-arg ref="undoSupportServiceRef" />
<constructor-arg ref="cyNetworkManagerServiceRef" />
</bean>
- <bean id="redoAction" class="cytoscape.util.undo.RedoAction">
+ <bean id="redoAction" class="cytoscape.internal.actions.RedoAction">
<constructor-arg ref="undoSupportServiceRef" />
<constructor-arg ref="cyNetworkManagerServiceRef" />
</bean>
@@ -237,7 +237,7 @@
-->
<!-- Other stuff to be started -->
- <bean id="undoMonitor" class="cytoscape.util.undo.UndoMonitor">
+ <bean id="undoMonitor" class="cytoscape.internal.util.undo.UndoMonitor">
<constructor-arg ref="undoSupportServiceRef" />
<constructor-arg ref="cytoscapeProperties" />
</bean>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"cytoscape-cvs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/cytoscape-cvs?hl=en
-~----------~----~----~----~------~----~------~--~---