svn commit: r16745 - trunk/src/argouml-app/src/org/argouml: ui/cmd uml/ui

Tom Morris <[email protected]>
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: tfmorris
Date: 2009-02-02 14:51:07-0800
New Revision: 16745

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

Log:
RESOLVED - task 5678: Layout action permanently disabled 
http://argouml.tigris.org/issues/show_bug.cgi?id=5678

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&pathrev=16745&r1=16744&r2=16745
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/ui/cmd/GenericArgoMenuBar.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/ui/cmd/GenericArgoMenuBar.java	2009-02-02 14:51:07-0800
@@ -1,5 +1,5 @@
 // $Id:GenericArgoMenuBar.java 13104 2007-07-21 18:29:31Z mvw $
-// Copyright (c) 1996-2008 The Regents of the University of California. All
+// Copyright (c) 1996,2009 The Regents of the University of California. All
 // Rights Reserved. Permission to use, copy, modify, and distribute this
 // software and its documentation without fee, and without a written
 // agreement is hereby granted, provided that the above copyright notice
@@ -38,6 +38,7 @@
 import javax.swing.JRadioButtonMenuItem;
 import javax.swing.JToolBar;
 import javax.swing.KeyStroke;
+import javax.swing.SwingUtilities;
 
 import org.apache.log4j.Logger;
 import org.argouml.application.helpers.ResourceLoaderWrapper;
@@ -124,6 +125,8 @@
     private static List<Action> moduleCreateDiagramActions = 
         new ArrayList<Action>();
     
+    private Collection<Action> disableableActions = new ArrayList<Action>();
+    
     /**
      * The zoom factor - defaults to 90%/110%
      */
@@ -226,7 +229,10 @@
 
     private void initActions() {
         navigateTargetForwardAction = new NavigateTargetForwardAction();
+        disableableActions.add(navigateTargetForwardAction);
         navigateTargetBackAction = new NavigateTargetBackAction();
+        disableableActions.add(navigateTargetBackAction);
+        
         TargetManager.getInstance().addTargetListener(this);
     }
 
@@ -659,7 +665,9 @@
         ShortcutMgr.assignAccelerator(preferredSize,
                 ShortcutMgr.ACTION_PREFERRED_SIZE);
 
-        arrange.add(new ActionLayout());
+        Action layout = new ActionLayout();
+        disableableActions.add(layout);
+        arrange.add(layout);
 
         // This used to be deferred, but it's only 30-40 msec of work.
         initAlignMenu(align);
@@ -1068,10 +1076,13 @@
      * Target changed - update the actions that depend on the target.
      */
     private void setTarget() {
-        navigateTargetForwardAction.setEnabled(navigateTargetForwardAction
-                .isEnabled());
-        navigateTargetBackAction.setEnabled(navigateTargetBackAction
-                .isEnabled());
+        SwingUtilities.invokeLater(new Runnable() {
+            public void run() {
+                for (Action action : disableableActions) {
+                    action.setEnabled(action.isEnabled());
+                }
+            }
+        });        
     }
 
     public void targetAdded(TargetEvent e) {

Modified: trunk/src/argouml-app/src/org/argouml/uml/ui/ActionLayout.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/ui/ActionLayout.java?view=diff&pathrev=16745&r1=16744&r2=16745
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/ui/ActionLayout.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/uml/ui/ActionLayout.java	2009-02-02 14:51:07-0800
@@ -1,5 +1,5 @@
 // $Id$
-// Copyright (c) 1996-2008 The Regents of the University of California. All
+// Copyright (c) 1996,2009 The Regents of the University of California. All
 // Rights Reserved. Permission to use, copy, modify, and distribute this
 // software and its documentation without fee, and without a written
 // agreement is hereby granted, provided that the above copyright notice
@@ -25,12 +25,12 @@
 package org.argouml.uml.ui;
 
 import java.awt.event.ActionEvent;
-import java.util.Collection;
 
 import javax.swing.Action;
 
 import org.argouml.i18n.Translator;
 import org.argouml.ui.UndoableAction;
+import org.argouml.ui.targetmanager.TargetManager;
 import org.argouml.uml.diagram.ArgoDiagram;
 import org.argouml.uml.diagram.DiagramUtils;
 import org.argouml.uml.diagram.activity.layout.ActivityDiagramLayouter;
@@ -38,9 +38,6 @@
 import org.argouml.uml.diagram.layout.Layouter;
 import org.argouml.uml.diagram.static_structure.layout.ClassdiagramLayouter;
 import org.argouml.uml.diagram.static_structure.ui.UMLClassDiagram;
-import org.tigris.gef.base.Editor;
-import org.tigris.gef.base.Globals;
-import org.tigris.gef.base.SelectionManager;
 
 /**
  * Action to automatically lay out a diagram.
@@ -48,9 +45,6 @@
  */
 public class ActionLayout extends UndoableAction {
 
-    ////////////////////////////////////////////////////////////////
-    // constructors
-
     /**
      * The constructor.
      */
@@ -61,22 +55,26 @@
                 Translator.localize("action.layout"));
     }
 
-    ////////////////////////////////////////////////////////////////
-    // main methods
-
     /**
-     * Check whether we deal with a supported diagram type
-     * (currently only UMLClassDiagram).
+     * Check whether we deal with a supported diagram type (currently only Class
+     * and Activity diagrams).
+     * <p>
+     * NOTE: This is only called at initialization time by Swing, so the 
+     * application is responsible for checking when the current diagram changes.
+     * Currently done in 
+     * {@link org.argouml.ui.cmd.GenericArgoMenuBar#setTarget()}.
+     * 
      * @return true if the action is enabled
-     * @see org.argouml.ui.ProjectBrowser
      */
     @Override
     public boolean isEnabled() {
-        if (!super.isEnabled()) {
-            return false;
+        ArgoDiagram d;
+        Object target = TargetManager.getInstance().getTarget();
+        if (target instanceof ArgoDiagram) {
+            d = (ArgoDiagram) target;
+        } else {
+            d = DiagramUtils.getActiveDiagram(); 
         }
-
-        ArgoDiagram d = DiagramUtils.getActiveDiagram();
         if (d instanceof UMLClassDiagram 
                 || d instanceof UMLActivityDiagram) {
             return true;
@@ -103,22 +101,8 @@
             return;
         }
 
-        // Using the selection manager to force a repaint seems like a
-        // heavyweight way to do this - tfm
-        
-        // Create a selection containing all figures in diagram
-        Editor ce = Globals.curEditor();
-        SelectionManager sm = ce.getSelectionManager();
-        Collection nodes = DiagramUtils.getActiveDiagram().getLayer()
-                .getContents();                    
-        sm.select(nodes);
-
         // Rearrange the diagram layout
         layouter.layout();
-        
-        // Tell the selection manager we're done and deselect everything
-        // This will force a repaint.
-        sm.endTrans(); 
-        sm.deselectAll();
+        diagram.damage();
     }
 }

------------------------------------------------------
http://argouml.tigris.org/ds/viewMessage.do?dsForumId=5905&dsMessageId=1092860

To unsubscribe from this discussion, e-mail: [[email protected]].
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.