svn commit: r13590 - trunk/src_new/org/argouml: kernel ui

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: tfmorris
Date: 2007-09-24 18:53:34-0700
New Revision: 13590

Modified:
   trunk/src_new/org/argouml/kernel/DefaultUndoManager.java
   trunk/src_new/org/argouml/kernel/UndoManager.java
   trunk/src_new/org/argouml/ui/ProjectActions.java

Log:
Issue 4863 - Move Swing dependency from UndoManager to ProjectActions which is already dependent on Swing.

Modified: trunk/src_new/org/argouml/kernel/DefaultUndoManager.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/kernel/DefaultUndoManager.java?view=diff&rev=13590&p1=trunk/src_new/org/argouml/kernel/DefaultUndoManager.java&p2=trunk/src_new/org/argouml/kernel/DefaultUndoManager.java&r1=13589&r2=13590
==============================================================================
--- trunk/src_new/org/argouml/kernel/DefaultUndoManager.java	(original)
+++ trunk/src_new/org/argouml/kernel/DefaultUndoManager.java	2007-09-24 18:53:34-0700
@@ -157,31 +157,17 @@
     }
     
     private void fire(final String property, final Object value) {
-        
-        final ArrayList<PropertyChangeListener> list =
-            new ArrayList<PropertyChangeListener>(listeners);
-        
-        SwingUtilities.invokeLater(
-            new Runnable() {
-                public void run() {
-                    Iterator<PropertyChangeListener> i = list.iterator();
-                    while (i.hasNext()) {
-                        PropertyChangeListener listener = i.next();
-                        listener.propertyChange(
-                                new PropertyChangeEvent(
-                                        this, property, "", value));
-                    }
-                }
-            }
-        );
-        
+        for (PropertyChangeListener listener : listeners) {
+            listener.propertyChange(
+                    new PropertyChangeEvent(this, property, "", value));
+        }
     }
     
     /**
-     * An Interact is a Command the contains a list of sub-commands.
-     * It represents a single user interaction and contains all the commands
+     * An Interact is a Command the contains a list of sub-commands. It
+     * represents a single user interaction and contains all the commands
      * executed as part of that interaction.
-     *
+     * 
      * @author Bob
      */
     class Interaction extends AbstractCommand {

Modified: trunk/src_new/org/argouml/kernel/UndoManager.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/kernel/UndoManager.java?view=diff&rev=13590&p1=trunk/src_new/org/argouml/kernel/UndoManager.java&p2=trunk/src_new/org/argouml/kernel/UndoManager.java&r1=13589&r2=13590
==============================================================================
--- trunk/src_new/org/argouml/kernel/UndoManager.java	(original)
+++ trunk/src_new/org/argouml/kernel/UndoManager.java	2007-09-24 18:53:34-0700
@@ -80,7 +80,12 @@
     
     /**
      * Add a new PropertyChangeListener for undo/redo events. Allow a listener
-     * to detect when the undo or redo stack changes availability.
+     * to detect when the undo or redo stack changes availability. No guarantees
+     * are made about which thread the event will be delivered on, so any
+     * specific thread requirements (e.g. Swing/AWT thread requirements) must be
+     * dealt with by the
+     * {@link PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)}
+     * method.
      * 
      * @param listener a PropertyChangeListener
      */

Modified: trunk/src_new/org/argouml/ui/ProjectActions.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/ui/ProjectActions.java?view=diff&rev=13590&p1=trunk/src_new/org/argouml/ui/ProjectActions.java&p2=trunk/src_new/org/argouml/ui/ProjectActions.java&r1=13589&r2=13590
==============================================================================
--- trunk/src_new/org/argouml/ui/ProjectActions.java	(original)
+++ trunk/src_new/org/argouml/ui/ProjectActions.java	2007-09-24 18:53:34-0700
@@ -30,6 +30,7 @@
 import java.util.List;
 
 import javax.swing.AbstractAction;
+import javax.swing.SwingUtilities;
 
 import org.argouml.application.helpers.ResourceLoaderWrapper;
 import org.argouml.i18n.Translator;
@@ -220,9 +221,9 @@
             }
             setTarget(first);
         }
-        // making it possible to jump to the modelroot
-        if (first.equals(ProjectManager.getManager().getCurrentProject()
-                         .getRoot())) {
+        // making it possible to jump to the modelroots
+        if (ProjectManager.getManager().getCurrentProject().getRoots()
+                .contains(first)) {
             setTarget(first);
         }
 
@@ -240,20 +241,26 @@
         TargetManager.getInstance().setTarget(o);
     }
 
-    public void propertyChange(PropertyChangeEvent evt) {
+    public void propertyChange(final PropertyChangeEvent evt) {
         if (evt.getSource() instanceof UndoManager) {
-            if ("undoLabel".equals(evt.getPropertyName())) {
-                undoAction.putValue(AbstractAction.NAME, evt.getNewValue());
-            }
-            if ("redoLabel".equals(evt.getPropertyName())) {
-                redoAction.putValue(AbstractAction.NAME, evt.getNewValue());
-            }
-            if ("undoable".equals(evt.getPropertyName())) {
-                undoAction.setEnabled((Boolean) evt.getNewValue());
-            }
-            if ("redoable".equals(evt.getPropertyName())) {
-                redoAction.setEnabled((Boolean) evt.getNewValue());
-            }
+            SwingUtilities.invokeLater(new Runnable() {
+                public void run() {
+                    if ("undoLabel".equals(evt.getPropertyName())) {
+                        undoAction.putValue(AbstractAction.NAME, evt
+                                .getNewValue());
+                    }
+                    if ("redoLabel".equals(evt.getPropertyName())) {
+                        redoAction.putValue(AbstractAction.NAME, evt
+                                .getNewValue());
+                    }
+                    if ("undoable".equals(evt.getPropertyName())) {
+                        undoAction.setEnabled((Boolean) evt.getNewValue());
+                    }
+                    if ("redoable".equals(evt.getPropertyName())) {
+                        redoAction.setEnabled((Boolean) evt.getNewValue());
+                    }
+                }
+            });
         }
     }
 }
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.