Skip to content
Snippets Groups Projects
Commit ef846dc4 authored by tjc's avatar tjc
Browse files

fix for attaching multiple undo/redo menus

git-svn-id: svn+ssh://svn.internal.sanger.ac.uk/repos/svn/pathsoft/artemis/trunk@7006 ee4ac58c-ac51-4696-9907-e4b3aa274f04
parent b8ccd2ee
No related branches found
No related tags found
No related merge requests found
...@@ -20,11 +20,14 @@ ...@@ -20,11 +20,14 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* *
* $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/ActionController.java,v 1.4 2008-01-29 15:20:33 tjc Exp $ * $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/ActionController.java,v 1.5 2008-01-29 15:45:26 tjc Exp $
*/ */
package uk.ac.sanger.artemis; package uk.ac.sanger.artemis;
import java.util.List;
import java.util.Vector;
import javax.swing.JMenuItem; import javax.swing.JMenuItem;
import uk.ac.sanger.artemis.sequence.SequenceChangeEvent; import uk.ac.sanger.artemis.sequence.SequenceChangeEvent;
...@@ -40,7 +43,7 @@ import uk.ac.sanger.artemis.io.EntryInformationException; ...@@ -40,7 +43,7 @@ import uk.ac.sanger.artemis.io.EntryInformationException;
* This class is maintains a Vector of Action objects to allow Undo. * This class is maintains a Vector of Action objects to allow Undo.
* *
* @author Kim Rutherford <kmr@sanger.ac.uk> * @author Kim Rutherford <kmr@sanger.ac.uk>
* @version $Id: ActionController.java,v 1.4 2008-01-29 15:20:33 tjc Exp $ * @version $Id: ActionController.java,v 1.5 2008-01-29 15:45:26 tjc Exp $
**/ **/
public class ActionController public class ActionController
...@@ -57,8 +60,8 @@ public class ActionController ...@@ -57,8 +60,8 @@ public class ActionController
private ActionVector undo_action_vector = new ActionVector (); private ActionVector undo_action_vector = new ActionVector ();
private ActionVector redo_action_vector = new ActionVector (); private ActionVector redo_action_vector = new ActionVector ();
private JMenuItem undo; private List undo;
private JMenuItem redo; private List redo;
/** /**
* Note the start of an action. Create a new Action and add all * Note the start of an action. Create a new Action and add all
...@@ -110,10 +113,7 @@ public class ActionController ...@@ -110,10 +113,7 @@ public class ActionController
{ {
undo_action_vector = new ActionVector(); undo_action_vector = new ActionVector();
redo_action_vector = new ActionVector(); redo_action_vector = new ActionVector();
if(undo != null) setEnabledMenuItems();
undo.setEnabled(false);
if(redo != null)
redo.setEnabled(false);
} }
/** /**
...@@ -161,18 +161,26 @@ public class ActionController ...@@ -161,18 +161,26 @@ public class ActionController
{ {
if(undo != null) if(undo != null)
{ {
if(undo_action_vector.size()>0) for(int i=0; i<undo.size(); i++)
undo.setEnabled(true); {
else JMenuItem undo_item = (JMenuItem) undo.get(i);
undo.setEnabled(false); if(undo_action_vector.size()>0)
undo_item.setEnabled(true);
else
undo_item.setEnabled(false);
}
} }
if(redo != null) if(redo != null)
{ {
if(redo_action_vector.size()>0) for(int i=0; i<redo.size(); i++)
redo.setEnabled(true); {
else JMenuItem redo_item = (JMenuItem) redo.get(i);
redo.setEnabled(false); if(redo_action_vector.size()>0)
redo_item.setEnabled(true);
else
redo_item.setEnabled(false);
}
} }
} }
...@@ -343,13 +351,17 @@ public class ActionController ...@@ -343,13 +351,17 @@ public class ActionController
discardUndoRedo (); discardUndoRedo ();
} }
public void addUndoMenu(final JMenuItem undo) public void addUndoMenu(final JMenuItem undo_item)
{ {
this.undo = undo; if(undo == null)
undo = new Vector();
undo.add(undo_item);
} }
public void addRedoMenu(final JMenuItem redo) public void addRedoMenu(final JMenuItem redo_item)
{ {
this.redo = redo; if(redo == null)
redo = new Vector();
redo.add(redo_item);
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment