svn commit: r13474 - trunk/src_new/org/argouml/uml/ui

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: mvw
Date: 2007-08-31 23:53:48-0700
New Revision: 13474

Modified:
   trunk/src_new/org/argouml/uml/ui/AbstractActionRemoveElement.java
   trunk/src_new/org/argouml/uml/ui/UMLMutableLinkedList.java

Log:
Reinstated the functionality that I removed wrongly in revision 13473: UMLMutableLinkedList.setPopupMenu().
Despite that ArgoUML is not using this - maybe some plugin does?

Modified: trunk/src_new/org/argouml/uml/ui/AbstractActionRemoveElement.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/ui/AbstractActionRemoveElement.java?view=diff&rev=13474&p1=trunk/src_new/org/argouml/uml/ui/AbstractActionRemoveElement.java&p2=trunk/src_new/org/argouml/uml/ui/AbstractActionRemoveElement.java&r1=13473&r2=13474
==============================================================================
--- trunk/src_new/org/argouml/uml/ui/AbstractActionRemoveElement.java	(original)
+++ trunk/src_new/org/argouml/uml/ui/AbstractActionRemoveElement.java	2007-08-31 23:53:48-0700
@@ -83,6 +83,7 @@
      */
     public void setTarget(Object theTarget) {
         target = theTarget;
+        setEnabled(isEnabled());
     }
 
     /**
@@ -101,15 +102,14 @@
      */
     public void setObjectToRemove(Object theObjectToRemove) {
         objectToRemove = theObjectToRemove;
+        setEnabled(isEnabled());
     }
 
-
-
     /*
      * @see javax.swing.Action#isEnabled()
      */
     public boolean isEnabled() {
-        return getObjectToRemove() != null;
+        return getObjectToRemove() != null && getTarget() != null;
     }
 
 }

Modified: trunk/src_new/org/argouml/uml/ui/UMLMutableLinkedList.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/ui/UMLMutableLinkedList.java?view=diff&rev=13474&p1=trunk/src_new/org/argouml/uml/ui/UMLMutableLinkedList.java&p2=trunk/src_new/org/argouml/uml/ui/UMLMutableLinkedList.java&r1=13473&r2=13474
==============================================================================
--- trunk/src_new/org/argouml/uml/ui/UMLMutableLinkedList.java	(original)
+++ trunk/src_new/org/argouml/uml/ui/UMLMutableLinkedList.java	2007-08-31 23:53:48-0700
@@ -270,6 +270,22 @@
         newAction = action;
     }
 
+    /**
+     * Tell the actions what objects they should work on.
+     */
+    protected void initActions() {
+        if (isAdd()) {
+            addAction.setTarget(getTarget());
+        }
+        if (isNew()) {
+            newAction.setTarget(getTarget());
+        }
+        if (isDelete()) {
+            deleteAction.setObjectToRemove(getSelectedValue());
+            deleteAction.setTarget(getTarget());
+        }
+    }
+
     /*
      * @see java.awt.event.MouseListener#mouseReleased(
      *      java.awt.event.MouseEvent)
@@ -285,6 +301,7 @@
                 ((UMLModelElementListModel2) model).buildPopup(popup, index);
             }
             if (popup.getComponentCount() > 0) {
+                initActions();
                 popup.show(this, e.getX(), e.getY());
             }
             e.consume();
@@ -299,6 +316,7 @@
         if (e.isPopupTrigger()) {
             JPopupMenu popup = getPopupMenu();
             if (popup.getComponentCount() > 0) {
+                initActions();
                 getPopupMenu().show(this, e.getX(), e.getY());
             }
             e.consume();
@@ -306,18 +324,23 @@
     }
 
     /**
-     * Returns a new popupMenu, initialised
-     * with the current target and selected item.
+     * Returns the popupMenu.
      *
      * @return JPopupMenu
      */
     public JPopupMenu getPopupMenu() {
-        popupMenu =  new PopupMenu();
+        if (popupMenu == null) {
+            popupMenu =  new PopupMenu();
+        }
         return popupMenu;
     }
 
     /**
-     * Sets the popupMenu.
+     * Sets the popupMenu. <p>
+     * 
+     * This allows to replace the complete default menu with a custom menu.
+     * If nobody is using this, then we better remove this functionality, and 
+     * just return a new menu all the time - that would simplify initialising it.
      *
      * @param menu
      *            The popupMenu to set
@@ -353,6 +376,7 @@
         if (e.isPopupTrigger()) {
             JPopupMenu popup = getPopupMenu();
             if (popup.getComponentCount() > 0) {
+                initActions();
                 getPopupMenu().show(this, e.getX(), e.getY());
             }
             e.consume();
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.