svn commit: r15601 - trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/SelectionNodeClarifiers2.java

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: penyaskito
Date: 2008-08-21 16:04:40-0700
New Revision: 15601

Modified:
   trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/SelectionNodeClarifiers2.java

Log:
Issue 5338: Disallow toolbelt buttons if we aren't in Select mode. Patch provided by Bob Tarling.

Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/SelectionNodeClarifiers2.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/SelectionNodeClarifiers2.java?view=diff&rev=15601&p1=trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/SelectionNodeClarifiers2.java&p2=trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/SelectionNodeClarifiers2.java&r1=15600&r2=15601
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/SelectionNodeClarifiers2.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/SelectionNodeClarifiers2.java	2008-08-21 16:04:40-0700
@@ -32,9 +32,15 @@
 import org.apache.log4j.Logger;
 import org.tigris.gef.base.Editor;
 import org.tigris.gef.base.Globals;
+import org.tigris.gef.base.LayerDiagram;
+import org.tigris.gef.base.LayerPerspective;
+import org.tigris.gef.base.Mode;
+import org.tigris.gef.base.ModeCreate;
 import org.tigris.gef.base.ModeCreateEdgeAndNode;
 import org.tigris.gef.base.ModeManager;
 import org.tigris.gef.base.ModeModify;
+import org.tigris.gef.base.ModePlace;
+import org.tigris.gef.base.ModeSelect;
 import org.tigris.gef.base.SelectionButtons;
 import org.tigris.gef.base.SelectionManager;
 import org.tigris.gef.graph.MutableGraphModel;
@@ -94,39 +100,51 @@
      */
     @Override
     public void paint(Graphics g) {
-        ((Clarifiable) getContent()).paintClarifiers(g);
+        final Mode topMode = Globals.curEditor().getModeManager().top();
+        if (!(topMode instanceof ModePlace)) {
+            // If the user has selected ModePlace either by a diagram
+            // tool or AddToDiagram then we don't want to show the
+            // clarifiers.
+            ((Clarifiable) getContent()).paintClarifiers(g);
+        }
         super.paint(g);
     }
 
     /*
      * @see org.tigris.gef.base.SelectionButtons#paintButtons(Graphics)
      */
-    public void paintButtons(Graphics g) {
-        Icon[] icons = getIcons();
-        if (icons == null) {
-            return;
-        }
-        int cx = getContent().getX();
-        int cy = getContent().getY();
-        int cw = getContent().getWidth();
-        int ch = getContent().getHeight();
-        
-        if (icons[0] != null) {
-            paintButtonAbove(icons[0], g, cx + cw / 2, cy - OFFSET, TOP);
-        }
-        if (icons[1] != null) {
-            paintButtonBelow(icons[1], g, cx + cw / 2, cy + ch + OFFSET, 
-                    BOTTOM);
-        }
-        if (icons[2] != null) {
-            paintButtonLeft(icons[2], g, cx - OFFSET, cy + ch / 2, LEFT);
-        }
-        if (icons[3] != null) {
-            paintButtonRight(icons[3], g, cx + cw + OFFSET, cy + ch / 2,
-                    RIGHT);
-        }
-        if (icons[4] != null) {
-            paintButtonLeft(icons[4], g, cx - OFFSET, cy + ch, LOWER_LEFT);
+    public final void paintButtons(Graphics g) {
+        final Mode topMode = Globals.curEditor().getModeManager().top();
+        if (!(topMode instanceof ModePlace)) {
+            // If the user has selected ModePlace either by a diagram
+            // tool or AddToDiagram then we don't want to show the
+            // toolbelt items.
+            Icon[] icons = getIcons();
+            if (icons == null) {
+                return;
+            }
+            int cx = getContent().getX();
+            int cy = getContent().getY();
+            int cw = getContent().getWidth();
+            int ch = getContent().getHeight();
+            
+            if (icons[0] != null) {
+                paintButtonAbove(icons[0], g, cx + cw / 2, cy - OFFSET, TOP);
+            }
+            if (icons[1] != null) {
+                paintButtonBelow(icons[1], g, cx + cw / 2, cy + ch + OFFSET, 
+                        BOTTOM);
+            }
+            if (icons[2] != null) {
+                paintButtonLeft(icons[2], g, cx - OFFSET, cy + ch / 2, LEFT);
+            }
+            if (icons[3] != null) {
+                paintButtonRight(icons[3], g, cx + cw + OFFSET, cy + ch / 2,
+                        RIGHT);
+            }
+            if (icons[4] != null) {
+                paintButtonLeft(icons[4], g, cx - OFFSET, cy + ch, LOWER_LEFT);
+            }
         }
     }
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.