svn commit: r14671 - trunk/src/argouml-app/src/org/argouml/ui/cmd/GenericArgoMenuBar.java

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: tfmorris
Date: 2008-05-08 11:57:00-0700
New Revision: 14671

Modified:
   trunk/src/argouml-app/src/org/argouml/ui/cmd/GenericArgoMenuBar.java

Log:
Remove duplicate Undo menu items.  Add Javadoc for module extension points.

Modified: trunk/src/argouml-app/src/org/argouml/ui/cmd/GenericArgoMenuBar.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/ui/cmd/GenericArgoMenuBar.java?view=diff&rev=14671&p1=trunk/src/argouml-app/src/org/argouml/ui/cmd/GenericArgoMenuBar.java&p2=trunk/src/argouml-app/src/org/argouml/ui/cmd/GenericArgoMenuBar.java&r1=14670&r2=14671
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/ui/cmd/GenericArgoMenuBar.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/ui/cmd/GenericArgoMenuBar.java	2008-05-08 11:57:00-0700
@@ -24,12 +24,8 @@
 
 package org.argouml.ui.cmd;
 
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
 import java.awt.event.InputEvent;
 import java.awt.event.KeyEvent;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Iterator;
@@ -50,8 +46,6 @@
 import org.argouml.cognitive.ui.ActionOpenDecisions;
 import org.argouml.cognitive.ui.ActionOpenGoals;
 import org.argouml.i18n.Translator;
-import org.argouml.model.CommandStack;
-import org.argouml.model.Model;
 import org.argouml.ui.ActionExportXMI;
 import org.argouml.ui.ActionImportXMI;
 import org.argouml.ui.ActionProjectSettings;
@@ -392,8 +386,6 @@
 
         edit = add(new JMenu(menuLocalize("Edit")));
         setMnemonic(edit, "Edit");
-        
-        initCommandStackItems(edit);
 
         JMenuItem undoItem = edit.add(
                 ProjectActions.getInstance().getUndoAction());
@@ -474,67 +466,6 @@
                 .assignAccelerator(settingsItem, ShortcutMgr.ACTION_SETTINGS);
     }
 
-    private void initCommandStackItems(JMenu menu) {
-        if (!Model.getCommandStack().isCommandStackCapabilityAvailable()) {
-            return;
-        }
-
-        final JMenuItem undo = new JMenuItem("Undo");
-        undo.setEnabled(false);
-        menu.add(undo);
-
-        undo.addActionListener(new ActionListener() {
-
-            public void actionPerformed(ActionEvent e) {
-                Model.getCommandStack().undo();
-            }
-
-        });
-
-        final JMenuItem redo = new JMenuItem("Redo");
-        redo.setEnabled(false);
-        menu.add(redo);
-
-        redo.addActionListener(new ActionListener() {
-
-            public void actionPerformed(ActionEvent e) {
-                Model.getCommandStack().redo();
-            }
-
-        });
-
-        PropertyChangeListener listener = new PropertyChangeListener() {
-
-            public void propertyChange(PropertyChangeEvent evt) {
-                updateUndoRedo(undo, redo);
-            }
-
-        };
-
-        Model.getPump().addClassModelEventListener(listener,
-                Model.getMetaTypes().getModelElement(), (String[]) null);
-        Model.getPump().addModelEventListener(listener,
-                CommandStack.COMMAND_STACK_UPDATE_EVENT, (String[]) null);
-
-        menu.addSeparator();
-    }
-
-    private void updateUndoRedo(JMenuItem undo, JMenuItem redo) {
-        if (!Model.getCommandStack().canUndo()) {
-            undo.setText("Undo");
-            undo.setEnabled(false);
-        } else {
-            undo.setText("Undo: " + Model.getCommandStack().getUndoLabel());
-            undo.setEnabled(true);
-        }
-        if (!Model.getCommandStack().canRedo()) {
-            redo.setText("Redo");
-            redo.setEnabled(false);
-        } else {
-            redo.setText("Redo: " + Model.getCommandStack().getRedoLabel());
-            redo.setEnabled(true);
-        }
-    }
 
     /**
      * Build the menu "View".
@@ -1130,10 +1061,21 @@
         setTarget();
     }
     
+    /**
+     * Add a new menu to the main toolbar.
+     * 
+     * @param menu the menu to be added
+     */
     public static void registerMenuItem(JMenu menu) {
         moduleMenus.add(menu);
     }
 
+    /**
+     * Add a new Action to the Create Diagram toolbar.  This can be used to
+     * register create actions for new diagram types by plugin modules.
+     * 
+     * @param action the create action to be registered.
+     */
     public static void registerCreateDiagramAction(Action action) {
         moduleCreateDiagramActions.add(action);
     }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.