svn commit: r12589 - trunk/src_new/org/argouml/uml/diagram: activity/ui collaboration/ui deployment/ui sequence/ui state/ui static_structure/ui ui use_case/ui

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: tfmorris
Date: 2007-05-10 09:04:49-0700
New Revision: 12589

Modified:
   trunk/src_new/org/argouml/uml/diagram/activity/ui/SelectionActionState.java
   trunk/src_new/org/argouml/uml/diagram/collaboration/ui/SelectionClassifierRole.java
   trunk/src_new/org/argouml/uml/diagram/deployment/ui/SelectionComponent.java
   trunk/src_new/org/argouml/uml/diagram/deployment/ui/SelectionComponentInstance.java
   trunk/src_new/org/argouml/uml/diagram/deployment/ui/SelectionNode.java
   trunk/src_new/org/argouml/uml/diagram/deployment/ui/SelectionNodeInstance.java
   trunk/src_new/org/argouml/uml/diagram/deployment/ui/SelectionObject.java
   trunk/src_new/org/argouml/uml/diagram/sequence/ui/SelectionClassifierRole.java
   trunk/src_new/org/argouml/uml/diagram/state/ui/SelectionState.java
   trunk/src_new/org/argouml/uml/diagram/static_structure/ui/SelectionClass.java
   trunk/src_new/org/argouml/uml/diagram/static_structure/ui/SelectionComment.java
   trunk/src_new/org/argouml/uml/diagram/static_structure/ui/SelectionEnumeration.java
   trunk/src_new/org/argouml/uml/diagram/static_structure/ui/SelectionException.java
   trunk/src_new/org/argouml/uml/diagram/static_structure/ui/SelectionGeneralizableElement.java
   trunk/src_new/org/argouml/uml/diagram/static_structure/ui/SelectionInterface.java
   trunk/src_new/org/argouml/uml/diagram/static_structure/ui/SelectionSignal.java
   trunk/src_new/org/argouml/uml/diagram/static_structure/ui/SelectionStereotype.java
   trunk/src_new/org/argouml/uml/diagram/ui/SelectionNodeClarifiers.java
   trunk/src_new/org/argouml/uml/diagram/ui/SelectionNodeClarifiers2.java
   trunk/src_new/org/argouml/uml/diagram/use_case/ui/SelectionActor.java
   trunk/src_new/org/argouml/uml/diagram/use_case/ui/SelectionUseCase.java

Log:
Simplify selection classes using new SelectionNodeClarifiers2

Modified: trunk/src_new/org/argouml/uml/diagram/activity/ui/SelectionActionState.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/diagram/activity/ui/SelectionActionState.java?view=diff&rev=12589&p1=trunk/src_new/org/argouml/uml/diagram/activity/ui/SelectionActionState.java&p2=trunk/src_new/org/argouml/uml/diagram/activity/ui/SelectionActionState.java&r1=12588&r2=12589
==============================================================================
--- trunk/src_new/org/argouml/uml/diagram/activity/ui/SelectionActionState.java	(original)
+++ trunk/src_new/org/argouml/uml/diagram/activity/ui/SelectionActionState.java	2007-05-10 09:04:49-0700
@@ -1,5 +1,5 @@
 // $Id$
-// Copyright (c) 1996-2006 The Regents of the University of California. All
+// Copyright (c) 1996-2007 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
@@ -24,66 +24,62 @@
 
 package org.argouml.uml.diagram.activity.ui;
 
-import java.awt.Graphics;
-import java.awt.Rectangle;
-
 import javax.swing.Icon;
 
-import org.apache.log4j.Logger;
 import org.argouml.application.helpers.ResourceLoaderWrapper;
 import org.argouml.model.Model;
-import org.argouml.uml.diagram.ui.SelectionNodeClarifiers;
-import org.tigris.gef.base.Editor;
-import org.tigris.gef.base.Globals;
-import org.tigris.gef.base.ModeCreateEdgeAndNode;
-import org.tigris.gef.base.ModeManager;
-import org.tigris.gef.base.ModeModify;
-import org.tigris.gef.base.SelectionManager;
-import org.tigris.gef.graph.GraphModel;
-import org.tigris.gef.graph.MutableGraphModel;
+import org.argouml.uml.diagram.ui.SelectionNodeClarifiers2;
 import org.tigris.gef.presentation.Fig;
-import org.tigris.gef.presentation.FigNode;
-import org.tigris.gef.presentation.Handle;
 
 /**
  * @author [email protected]
  */
-public class SelectionActionState extends SelectionNodeClarifiers {
-    /**
-     * Logger.
-     */
-    private static final Logger LOG =
-        Logger.getLogger(SelectionActionState.class);
+public class SelectionActionState extends SelectionNodeClarifiers2 {
 
-    ////////////////////////////////////////////////////////////////
-    // constants
     private static Icon trans =
 	ResourceLoaderWrapper.lookupIconResource("Transition");
+    
     private static Icon transDown =
 	ResourceLoaderWrapper.lookupIconResource("TransitionDown");
+    
+    private static Icon icons[] =
+    {transDown,
+     transDown,
+     trans,
+     trans,
+     null,
+    };
+
+// TODO: I18N required
+    private static String instructions[] =
+    {"Add an incoming transition",
+     "Add an outgoing transition",
+     "Add an incoming transition",
+     "Add an outgoing transition",
+     null,
+     "Move object(s)",
+    };
 
-    ////////////////////////////////////////////////////////////////
-    // instance varables
     private boolean showIncomingLeft = true;
+
     private boolean showIncomingAbove = true;
+
     private boolean showOutgoingRight = true;
-    private boolean showOutgoingBelow = true;
 
-    ////////////////////////////////////////////////////////////////
-    // constructors
+    private boolean showOutgoingBelow = true;
 
     /**
      * Construct a new SelectionActionState for the given Fig.
      *
      * @param f The given Fig.
      */
-    public SelectionActionState(Fig f) { super(f); }
+    public SelectionActionState(Fig f) {
+        super(f);
+    }
 
-    ////////////////////////////////////////////////////////////////
-    // accessors
 
     /**
-     * @param b true if the buton is enabled
+     * @param b true if the button is enabled
      */
     public void setOutgoingButtonEnabled(boolean b) {
         setOutgoingRightButtonEnabled(b);
@@ -91,7 +87,7 @@
     }
 
     /**
-     * @param b true if the buton is enabled
+     * @param b true if the button is enabled
      */
     public void setIncomingButtonEnabled(boolean b) {
         setIncomingLeftButtonEnabled(b);
@@ -99,232 +95,77 @@
     }
 
     /**
-     * @param b true if the buton is enabled
+     * @param b true if the button is enabled
      */
     public void setIncomingLeftButtonEnabled(boolean b) {
 	showIncomingLeft = b;
     }
 
     /**
-     * @param b true if the buton is enabled
+     * @param b true if the button is enabled
      */
     public void setOutgoingRightButtonEnabled(boolean b) {
 	showOutgoingRight = b;
     }
 
     /**
-     * @param b true if the buton is enabled
+     * @param b true if the button is enabled
      */
     public void setIncomingAboveButtonEnabled(boolean b) {
 	showIncomingAbove = b;
     }
 
     /**
-     * @param b true if the buton is enabled
+     * @param b true if the button is enabled
      */
     public void setOutgoingBelowButtonEnabled(boolean b) {
 	showOutgoingBelow = b;
     }
 
-    /*
-     * @see org.tigris.gef.base.Selection#hitHandle(java.awt.Rectangle,
-     *         org.tigris.gef.presentation.Handle)
-     */
-    public void hitHandle(Rectangle r, Handle h) {
-	super.hitHandle(r, h);
-	if (h.index != -1) {
-	    return;
-	}
-	if (!isPaintButtons()) {
-	    return;
-	}
-	Editor ce = Globals.curEditor();
-	SelectionManager sm = ce.getSelectionManager();
-	if (sm.size() != 1) {
-	    return;
-	}
-	ModeManager mm = ce.getModeManager();
-	if (mm.includes(ModeModify.class) && getPressedButton() == -1) {
-	    return;
-	}
-	int cx = getContent().getX();
-	int cy = getContent().getY();
-	int cw = getContent().getWidth();
-	int ch = getContent().getHeight();
-	int iw = trans.getIconWidth();
-	int ih = trans.getIconHeight();
-	int iwd = transDown.getIconWidth();
-	int ihd = transDown.getIconHeight();
-	if (showOutgoingRight && hitLeft(cx + cw, cy + ch / 2, iw, ih, r)) {
-	    h.index = 12;
-	    h.instructions = "Add an outgoing transition";
-	} else if (showIncomingLeft && hitRight(cx, cy + ch / 2, iw, ih, r)) {
-	    h.index = 13;
-	    h.instructions = "Add an incoming transition";
-	} else if (showOutgoingBelow
-            && hitAbove(cx + cw / 2, cy, iwd, ihd, r)) {
-	    h.index = 10;
-	    h.instructions = "Add an incoming transaction";
-	} else if (showIncomingAbove
-		 && hitBelow(cx + cw / 2, cy + ch, iwd, ihd, r)) {
-	    h.index = 11;
-	    h.instructions = "Add an outgoing transaction";
-	} else {
-	    h.index = -1;
-	    h.instructions = "Move object(s)";
-	}
-    }
-
-
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#paintButtons(Graphics)
-     */
-    public void paintButtons(Graphics g) {
-	int cx = getContent().getX();
-	int cy = getContent().getY();
-	int cw = getContent().getWidth();
-	int ch = getContent().getHeight();
-	if (showOutgoingRight) {
-	    paintButtonLeft(trans, g, cx + cw, cy + ch / 2, 12);
-	}
-	if (showIncomingLeft) {
-	    paintButtonRight(trans, g, cx, cy + ch / 2, 13);
-	}
-	if (showOutgoingBelow) {
-	    paintButtonAbove(transDown, g, cx + cw / 2, cy , 14);
-	}
-	if (showIncomingAbove) {
-	    paintButtonBelow(transDown, g, cx + cw / 2, cy + ch, 15);
-	}
-    }
-
-
-    /*
-     * @see org.tigris.gef.base.Selection#dragHandle(int, int, int, int,
-     *         org.tigris.gef.presentation.Handle)
-     */
-    public void dragHandle(int mX, int mY, int anX, int anY, Handle hand) {
-	if (hand.index < 10) {
-	    setPaintButtons(false);
-	    super.dragHandle(mX, mY, anX, anY, hand);
-	    return;
-	}
-	int cx = getContent().getX(), cy = getContent().getY();
-	int cw = getContent().getWidth(), ch = getContent().getHeight();
-	Object edgeType = null;
-        Object nodeType = getNewNodeType(hand.index);
-
-	Editor ce = Globals.curEditor();
-	GraphModel gm = ce.getGraphModel();
-	if (!(gm instanceof MutableGraphModel)) {
-	    return;
-	}
-
-	int bx = mX, by = mY;
-	boolean reverse = false;
-	switch (hand.index) {
-	case 12: //add incoming
-	    edgeType = Model.getMetaTypes().getTransition();
-	    by = cy + ch / 2;
-	    bx = cx + cw;
-	    break;
-	case 13: // add outgoing
-	    edgeType = Model.getMetaTypes().getTransition();
-	    reverse = true;
-	    by = cy + ch / 2;
-	    bx = cx;
-	    break;
-	case 10: // add incoming on top
-	    edgeType = Model.getMetaTypes().getTransition();
-	    reverse = true;
-	    by = cy;
-	    bx = cx + cw / 2;
-	    break;
-	case 11: // add outgoing below
-	    edgeType = Model.getMetaTypes().getTransition();
-	    by = cy + ch;
-	    bx = cx + cw / 2;
-	    break;
-	default:
-	    LOG.warn("invalid handle number");
-	    break;
-	}
-	if (edgeType != null && nodeType != null) {
-	    ModeCreateEdgeAndNode m =
-                //This fixes issue 2400:
-	        new ModeCreateEdgeAndNode(ce, edgeType, false, this);
-	    m.setup((FigNode) getContent(), getContent().getOwner(),
-	            bx, by, reverse);
-	    ce.pushMode(m);
-	}
-    }
-
-    /**
-     * Overrule this for other kinds.
-     * 
-     * @param buttonCode unused
-     * @return the meta type class to be created when dragged and released
-     */
-    protected Object getNewNodeType(int buttonCode) {
+    @Override
+    protected Object getNewNodeType(int index) {
         return Model.getMetaTypes().getActionState();
     }
-
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#getNewNode(int)
-     */
-    protected Object getNewNode(int buttonCode) {
+    
+    @Override
+    protected Object getNewNode(int arg0) {
         return Model.getActivityGraphsFactory().createActionState();
     }
 
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#createEdgeAbove(
-     *         org.tigris.gef.graph.MutableGraphModel, java.lang.Object)
-     */
-    protected Object createEdgeAbove(MutableGraphModel mgm, Object newNode) {
-        return mgm.connect(newNode, getContent().getOwner(),
-			   (Class) Model.getMetaTypes().getTransition());
-    }
-
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#createEdgeLeft(
-     *         org.tigris.gef.graph.MutableGraphModel, java.lang.Object)
-     */
-    protected Object createEdgeLeft(MutableGraphModel gm, Object newNode) {
-        return gm.connect(newNode, getContent().getOwner(),
-			  (Class) Model.getMetaTypes().getTransition());
-    }
-
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#createEdgeRight(
-     *         org.tigris.gef.graph.MutableGraphModel, java.lang.Object)
-     */
-    protected Object createEdgeRight(MutableGraphModel gm, Object newNode) {
-        return gm.connect(getContent().getOwner(), newNode,
-			  (Class) Model.getMetaTypes().getTransition());
-    }
-
-    /*
-     * To enable this we need to add an icon.
-     *
-     * @see org.tigris.gef.base.SelectionButtons#createEdgeToSelf(
-     *         org.tigris.gef.graph.MutableGraphModel)
-     */
-    protected Object createEdgeToSelf(MutableGraphModel gm) {
-        return gm.connect(getContent().getOwner(), getContent().getOwner(),
-			  (Class) Model.getMetaTypes().getTransition());
-    }
-
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#createEdgeUnder(
-     *         org.tigris.gef.graph.MutableGraphModel, java.lang.Object)
-     */
-    protected Object createEdgeUnder(MutableGraphModel gm, Object newNode) {
-        return gm.connect(getContent().getOwner(), newNode,
-			  (Class) Model.getMetaTypes().getTransition());
+    @Override
+    protected Icon[] getIcons() {
+        Icon[] workingIcons = icons;
+        if (!showOutgoingBelow) {
+            workingIcons[11] = null;
+        }
+        if (!showIncomingAbove) {
+            workingIcons[12] = null;
+        }
+        if (!showIncomingLeft) {
+            workingIcons[12] = null;
+        }
+        if (!showOutgoingRight) {
+            workingIcons[13] = null;
+        }
+        return icons;
+    }
+
+    @Override
+    protected String getInstructions(int index) {
+        return instructions[index - 10];
+    }
+
+    @Override
+    protected Object getNewEdgeType(int index) {
+        return Model.getMetaTypes().getTransition();
+    }
+
+    @Override
+    protected boolean isDragEdgeReverse(int index) {
+        if (index == 10 || index == 13 ) {
+            return true;
+        }
+        return false;
     }
 
-} /* end class SelectionActionState */
-
-
-
-
+}

Modified: trunk/src_new/org/argouml/uml/diagram/collaboration/ui/SelectionClassifierRole.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/diagram/collaboration/ui/SelectionClassifierRole.java?view=diff&rev=12589&p1=trunk/src_new/org/argouml/uml/diagram/collaboration/ui/SelectionClassifierRole.java&p2=trunk/src_new/org/argouml/uml/diagram/collaboration/ui/SelectionClassifierRole.java&r1=12588&r2=12589
==============================================================================
--- trunk/src_new/org/argouml/uml/diagram/collaboration/ui/SelectionClassifierRole.java	(original)
+++ trunk/src_new/org/argouml/uml/diagram/collaboration/ui/SelectionClassifierRole.java	2007-05-10 09:04:49-0700
@@ -24,40 +24,19 @@
 
 package org.argouml.uml.diagram.collaboration.ui;
 
-import java.awt.Graphics;
-import java.awt.Rectangle;
-
 import javax.swing.Icon;
 
-import org.apache.log4j.Logger;
 import org.argouml.application.helpers.ResourceLoaderWrapper;
 import org.argouml.model.Model;
-import org.tigris.gef.base.ModeCreateEdgeAndNode;
-import org.argouml.uml.diagram.ui.SelectionNodeClarifiers;
-import org.tigris.gef.base.Editor;
-import org.tigris.gef.base.Globals;
-import org.tigris.gef.base.ModeManager;
-import org.tigris.gef.base.ModeModify;
-import org.tigris.gef.base.SelectionManager;
-import org.tigris.gef.graph.GraphModel;
-import org.tigris.gef.graph.MutableGraphModel;
+import org.argouml.uml.diagram.ui.SelectionNodeClarifiers2;
 import org.tigris.gef.presentation.Fig;
-import org.tigris.gef.presentation.FigNode;
-import org.tigris.gef.presentation.Handle;
 
 /**
  * The selection buttons for a classifier role.
  *
  */
-public class SelectionClassifierRole extends SelectionNodeClarifiers {
-    /**
-     * Logger.
-     */
-    private static final Logger LOG =
-        Logger.getLogger(SelectionClassifierRole.class);
+public class SelectionClassifierRole extends SelectionNodeClarifiers2 {
 
-    ////////////////////////////////////////////////////////////////
-    // constants
     private static Icon assocrole =
 	ResourceLoaderWrapper
 	    .lookupIconResource("AssociationRole");
@@ -66,13 +45,27 @@
         ResourceLoaderWrapper
 	    .lookupIconResource("SelfAssociation");
 
-    ////////////////////////////////////////////////////////////////
-    // instance varables
+    private static Icon icons[] = 
+    {null,
+     null,
+     assocrole,
+     assocrole,
+     selfassoc,
+    };
+    
+    // TODO: I18N required
+    private static String instructions[] = 
+    {null,
+     null,
+     "Add an outgoing classifierrole",
+     "Add an incoming classifierrole",
+     "Add a associationrole to this",
+     "Move object(s)",
+    };
+
     private boolean showIncoming = true;
-    private boolean showOutgoing = true;
 
-    ////////////////////////////////////////////////////////////////
-    // constructors
+    private boolean showOutgoing = true;
 
     /**
      * Construct a new SelectionClassifierRole for the given Fig.
@@ -83,9 +76,6 @@
 	super(f);
     }
 
-    ////////////////////////////////////////////////////////////////
-    // accessors
-
     /**
      * @param b true if the incoming button is enabled
      */
@@ -100,175 +90,49 @@
 	showOutgoing = b;
     }
 
-    /*
-     * @see org.tigris.gef.base.Selection#hitHandle(java.awt.Rectangle,
-     *         org.tigris.gef.presentation.Handle)
-     */
-    public void hitHandle(Rectangle r, Handle h) {
-	super.hitHandle(r, h);
-	if (h.index != -1) {
-	    return;
-	}
-	if (!isPaintButtons()) {
-	    return;
-	}
-	Editor ce = Globals.curEditor();
-	SelectionManager sm = ce.getSelectionManager();
-	if (sm.size() != 1) {
-	    return;
-	}
-	ModeManager mm = ce.getModeManager();
-	if (mm.includes(ModeModify.class) && getPressedButton() == -1) {
-	    return;
-	}
-	int cx = getContent().getX();
-	int cy = getContent().getY();
-	int cw = getContent().getWidth();
-	int ch = getContent().getHeight();
-	int iw = assocrole.getIconWidth();
-	int ih = assocrole.getIconHeight();
-	if (showOutgoing && hitLeft(cx + cw, cy + ch / 2, iw, ih, r)) {
-	    h.index = 12;
-	    h.instructions = "Add an outgoing classifierrole";
-	} else if (showIncoming && hitRight(cx, cy + ch / 2, iw, ih, r)) {
-	    h.index = 13;
-	    h.instructions = "Add an incoming classifierrole";
-        } else if (hitRight(cx, cy + ch - 10, iw, ih, r)) {
-            h.index = 14;
-            h.instructions = "Add a associationrole to this";
-	} else {
-	    h.index = -1;
-	    h.instructions = "Move object(s)";
-	}
-    }
+    @Override
+    protected Icon[] getIcons() {
+        Icon workingIcons[] = new Icon[icons.length];
+        System.arraycopy(icons, 0, workingIcons, 0, icons.length);
 
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#paintButtons(java.awt.Graphics)
-     */
-    public void paintButtons(Graphics g) {
-	int cx = getContent().getX();
-	int cy = getContent().getY();
-	int cw = getContent().getWidth();
-	int ch = getContent().getHeight();
-	if (showOutgoing) {
-	    paintButtonLeft(assocrole, g, cx + cw, cy + ch / 2, 12);
-	}
-	if (showIncoming) {
-	    paintButtonRight(assocrole, g, cx, cy + ch / 2, 13);
-	}
-        if (showOutgoing || showIncoming) {
-            paintButtonRight(selfassoc, g, cx, cy + ch - 10, 14);
+        if (!showOutgoing) {
+            workingIcons[12] = null;
         }
+        if (!showIncoming) {
+            workingIcons[13] = null;
+        }
+        if (!showOutgoing && !showIncoming) {
+            workingIcons[14] = null;
+        }
+        return workingIcons;
     }
 
-    /*
-     * @see org.tigris.gef.base.Selection#dragHandle(int, int, int, int,
-     *         org.tigris.gef.presentation.Handle)
-     */
-    public void dragHandle(int mX, int mY, int anX, int anY, Handle hand) {
-	if (hand.index < 10) {
-	    setPaintButtons(false);
-	    super.dragHandle(mX, mY, anX, anY, hand);
-	    return;
-	}
-	int cx = getContent().getX(), cy = getContent().getY();
-	int cw = getContent().getWidth(), ch = getContent().getHeight();
-	Object edgeType = null;
-	Object nodeType = Model.getMetaTypes().getClassifierRole();
-
-	Editor ce = Globals.curEditor();
-	GraphModel gm = ce.getGraphModel();
-	if (!(gm instanceof MutableGraphModel)) {
-	    return;
-	}
-
-	int bx = mX, by = mY;
-	boolean reverse = false;
-	switch (hand.index) {
-	case 12 : //add outgoing
-	    edgeType = Model.getMetaTypes().getAssociationRole();
-	    by = cy + ch / 2;
-	    bx = cx + cw;
-	    break;
-	case 13 : // add incoming
-	    edgeType = Model.getMetaTypes().getAssociationRole();
-	    reverse = true;
-	    by = cy + ch / 2;
-	    bx = cx;
-	    break;
-        case 14: // add to self
-            // do not want to drag this
-            break;
-
-	default :
-	    LOG.warn("invalid handle number");
-	    break;
-	}
-	if (edgeType != null && nodeType != null) {
-	    ModeCreateEdgeAndNode m =
-		new ModeCreateEdgeAndNode(ce, edgeType, false, this);
-	    m.setup((FigNode) getContent(), getContent().getOwner(),
-	            bx, by, reverse);
-	    ce.pushMode(m);
-	}
-    }
-
-    /**
-     * Create a new ClassifierRole object.
-     *
-     * @see org.tigris.gef.base.SelectionButtons#getNewNode(int)
-     */
-    protected Object getNewNode(int buttonCode) {
-	return Model.getCollaborationsFactory().createClassifierRole();
-    }
-
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#createEdgeAbove(
-     *         org.tigris.gef.graph.MutableGraphModel, java.lang.Object)
-     */
-    protected Object createEdgeAbove(MutableGraphModel mgm, Object newNode) {
-	return mgm.connect(newNode, getContent().getOwner(),
-			   (Class) Model.getMetaTypes().getAssociationRole());
+    @Override
+    protected String getInstructions(int index) {
+        return instructions[index - 10];
     }
 
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#createEdgeLeft(
-     *         org.tigris.gef.graph.MutableGraphModel, java.lang.Object)
-     */
-    protected Object createEdgeLeft(MutableGraphModel gm, Object newNode) {
-	return gm.connect(newNode, getContent().getOwner(),
-			  (Class) Model.getMetaTypes().getAssociationRole());
+    @Override
+    protected Object getNewEdgeType(int index) {
+        return Model.getMetaTypes().getAssociationRole();
     }
 
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#createEdgeRight(
-     *         org.tigris.gef.graph.MutableGraphModel, java.lang.Object)
-     */
-    protected Object createEdgeRight(MutableGraphModel gm, Object newNode) {
-	return gm.connect(getContent().getOwner(), newNode,
-			  (Class) Model.getMetaTypes().getAssociationRole());
+    @Override
+    protected Object getNewNodeType(int index) {
+        return Model.getMetaTypes().getClassifierRole();
     }
 
-    /*
-     * To enable this we need to add an icon.
-     *
-     * @see org.tigris.gef.base.SelectionButtons#createEdgeToSelf(
-     *         org.tigris.gef.graph.MutableGraphModel)
-     */
-    protected Object createEdgeToSelf(MutableGraphModel gm) {
-	return gm.connect(
-			  getContent().getOwner(),
-			  getContent().getOwner(),
-			  (Class) Model.getMetaTypes().getAssociationRole());
+    @Override
+    protected Object getNewNode(int index) {
+        return Model.getCollaborationsFactory().createClassifierRole();
     }
 
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#createEdgeUnder(
-     *         org.tigris.gef.graph.MutableGraphModel, java.lang.Object)
-     */
-    protected Object createEdgeUnder(MutableGraphModel gm, Object newNode) {
-	return gm.connect(getContent().getOwner(), newNode,
-			  (Class) Model.getMetaTypes().getAssociationRole());
+    @Override
+    protected boolean isDragEdgeReverse(int index) {
+        if (index == 13) {
+            return true;
+        }
+        return false;
     }
 
-} /* end class SelectionClassifierRole */
+} 

Modified: trunk/src_new/org/argouml/uml/diagram/deployment/ui/SelectionComponent.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/diagram/deployment/ui/SelectionComponent.java?view=diff&rev=12589&p1=trunk/src_new/org/argouml/uml/diagram/deployment/ui/SelectionComponent.java&p2=trunk/src_new/org/argouml/uml/diagram/deployment/ui/SelectionComponent.java&r1=12588&r2=12589
==============================================================================
--- trunk/src_new/org/argouml/uml/diagram/deployment/ui/SelectionComponent.java	(original)
+++ trunk/src_new/org/argouml/uml/diagram/deployment/ui/SelectionComponent.java	2007-05-10 09:04:49-0700
@@ -1,5 +1,5 @@
 // $Id$
-// Copyright (c) 1996-2006 The Regents of the University of California. All
+// Copyright (c) 1996-2007 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
@@ -24,278 +24,84 @@
 
 package org.argouml.uml.diagram.deployment.ui;
 
-import java.awt.Graphics;
-import java.awt.Rectangle;
-
 import javax.swing.Icon;
 
-import org.apache.log4j.Logger;
 import org.argouml.application.helpers.ResourceLoaderWrapper;
 import org.argouml.model.Model;
-import org.argouml.uml.diagram.ui.SelectionNodeClarifiers;
-import org.tigris.gef.base.Editor;
-import org.tigris.gef.base.Globals;
-import org.tigris.gef.base.ModeCreateEdgeAndNode;
-import org.tigris.gef.base.ModeManager;
-import org.tigris.gef.base.ModeModify;
-import org.tigris.gef.base.SelectionManager;
-import org.tigris.gef.graph.MutableGraphModel;
+import org.argouml.uml.diagram.ui.SelectionNodeClarifiers2;
 import org.tigris.gef.presentation.Fig;
-import org.tigris.gef.presentation.FigNode;
-import org.tigris.gef.presentation.Handle;
 
 /**
  * The selection buttons for a component.
  *
  */
-public class SelectionComponent extends SelectionNodeClarifiers {
-    /**
-     * Logger.
-     */
-    private static final Logger LOG =
-        Logger.getLogger(SelectionComponent.class);
-    ////////////////////////////////////////////////////////////////
-    // constants
+public class SelectionComponent extends SelectionNodeClarifiers2 {
+
     private static Icon dep =
-	ResourceLoaderWrapper.lookupIconResource("Dependency");
+            ResourceLoaderWrapper.lookupIconResource("Dependency");
+
     private static Icon depRight =
-	ResourceLoaderWrapper.lookupIconResource("DependencyRight");
+            ResourceLoaderWrapper.lookupIconResource("DependencyRight");
 
+    private static Icon icons[] = 
+    {dep,
+     dep,
+     depRight,
+     depRight,
+     null,
+    };
+    
+    // TODO: I18N required
+    private static String instructions[] = 
+    {"Add a component",
+     "Add a component",
+     "Add a component",
+     "Add a component",
+     null,
+     "Move object(s)",
+    };
 
-    ////////////////////////////////////////////////////////////////
-    // constructors
 
     /**
      * Construct a new SelectionComponent for the given Fig.
      *
      * @param f The given Fig.
      */
-    public SelectionComponent(Fig f) { super(f); }
-
-    /*
-     * @see org.tigris.gef.base.Selection#hitHandle(java.awt.Rectangle,
-     *      org.tigris.gef.presentation.Handle)
-     */
-    public void hitHandle(Rectangle r, Handle h) {
-	super.hitHandle(r, h);
-	if (h.index != -1) {
-	    return;
-	}
-	if (!isPaintButtons()) {
-	    return;
-	}
-	Editor ce = Globals.curEditor();
-	SelectionManager sm = ce.getSelectionManager();
-	if (sm.size() != 1) {
-	    return;
-	}
-	ModeManager mm = ce.getModeManager();
-	if (mm.includes(ModeModify.class) && getPressedButton() == -1) {
-	    return;
-	}
-	int cx = getContent().getX();
-	int cy = getContent().getY();
-	int cw = getContent().getWidth();
-	int ch = getContent().getHeight();
-	int aw = dep.getIconWidth();
-	int ah = dep.getIconHeight();
-	if (hitAbove(cx + cw / 2, cy, aw, ah, r)) {
-	    h.index = 10;
-	    h.instructions = "Add a component";
-	} else if (hitBelow(cx + cw / 2, cy + ch, aw, ah, r)) {
-	    h.index = 11;
-	    h.instructions = "Add a component";
-	} else if (hitLeft(cx + cw, cy + ch / 2, aw, ah, r)) {
-	    h.index = 12;
-	    h.instructions = "Add a component";
-	} else if (hitRight(cx, cy + ch / 2, aw, ah, r)) {
-	    h.index = 13;
-	    h.instructions = "Add a component";
-	} else {
-	    h.index = -1;
-	    h.instructions = "Move object(s)";
-	}
-    }
-
-
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#paintButtons(java.awt.Graphics)
-     */
-    public void paintButtons(Graphics g) {
-	int cx = getContent().getX();
-	int cy = getContent().getY();
-	int cw = getContent().getWidth();
-	int ch = getContent().getHeight();
-	paintButtonAbove(dep, g, cx + cw / 2, cy, 10);
-	paintButtonBelow(dep, g, cx + cw / 2, cy + ch, 11);
-	paintButtonLeft(depRight, g, cx + cw, cy + ch / 2, 12);
-	paintButtonRight(depRight, g, cx, cy + ch / 2, 13);
-    }
-
-
-    /*
-     * @see org.tigris.gef.base.Selection#dragHandle(int, int, int, int,
-     *      org.tigris.gef.presentation.Handle)
-     */
-    public void dragHandle(int mX, int mY, int anX, int anY, Handle hand) {
-	if (hand.index < 10) {
-	    setPaintButtons(false);
-	    super.dragHandle(mX, mY, anX, anY, hand);
-	    return;
-	}
-	int cx = getContent().getX(), cy = getContent().getY();
-	int cw = getContent().getWidth(), ch = getContent().getHeight();
-	Object edgeType = null;
-	Object nodeType = Model.getMetaTypes().getComponent();
-	int bx = mX, by = mY;
-	boolean reverse = false;
-	switch (hand.index) {
-	case 10: //add dep
-	    edgeType = Model.getMetaTypes().getDependency();
-	    reverse = false;
-	    by = cy;
-	    bx = cx + cw / 2;
-	    break;
-	case 11: //add dep
-	    edgeType = Model.getMetaTypes().getDependency();
-	    reverse = true;
-	    by = cy + ch;
-	    bx = cx + cw / 2;
-	    break;
-	case 12: //add dep
-	    edgeType = Model.getMetaTypes().getDependency();
-	    reverse = false;
-	    by = cy + ch / 2;
-	    bx = cx + cw;
-	    break;
-	case 13: // add dep
-	    edgeType = Model.getMetaTypes().getDependency();
-	    reverse = true;
-	    by = cy + ch / 2;
-	    bx = cx;
-	    break;
-	default:
-	    LOG.warn("invalid handle number");
-	    break;
-	}
-	if (edgeType != null && nodeType != null) {
-	    Editor ce = Globals.curEditor();
-	    ModeCreateEdgeAndNode m =
-	        new ModeCreateEdgeAndNode(ce, edgeType, false, this);
-	    m.setup((FigNode) getContent(), getContent().getOwner(),
-	            bx, by, reverse);
-	    ce.pushMode(m);
-	}
-
-    }
-
-    /**
-     * Contruct and add a new edge of the given kind: DEPENDENCY.
-     *
-     * @param mgm the graphmodel
-     * @param component the source component
-     * @param newComponent the destination component
-     * @return the added dependency
-     */
-    public Object addCompClassAbove(MutableGraphModel mgm, Object component,
-				    Object newComponent) {
-        if (!Model.getFacade().isAComponent(component)
-                || !Model.getFacade().isAComponent(newComponent)) {
-            throw new IllegalArgumentException();
-        }
-	return mgm.connect(component, newComponent,
-                            (Class) Model.getMetaTypes().getDependency());
+    public SelectionComponent(Fig f) {
+        super(f);
     }
 
-    /**
-     * @param mgm the graphmodel
-     * @param component the source component
-     * @param newComponent the destination component
-     * @return the added dependency
-     */
-    public Object addCompClassBelow(MutableGraphModel mgm, Object component,
-				    Object newComponent) {
-        if (!Model.getFacade().isAComponent(component)
-                || !Model.getFacade().isAComponent(newComponent)) {
-            throw new IllegalArgumentException();
-        }
-	return mgm.connect(component, newComponent,
-                            (Class) Model.getMetaTypes().getDependency());
+    @Override
+    protected Icon[] getIcons() {
+        return icons;
     }
 
-    /**
-     * @param mgm the graphmodel
-     * @param component the source component
-     * @param newComponent the destination component
-     * @return the added dependency
-     */
-    public Object addCompClassRight(MutableGraphModel mgm, Object component,
-				    Object newComponent) {
-        if (!Model.getFacade().isAComponent(component)
-                || !Model.getFacade().isAComponent(newComponent)) {
-            throw new IllegalArgumentException();
-        }
-	return mgm.connect(component, newComponent,
-                            (Class) Model.getMetaTypes().getDependency());
+    @Override
+    protected String getInstructions(int index) {
+        return instructions[index - 10];
     }
 
-    /**
-     * @param mgm the graphmodel
-     * @param component the source component
-     * @param newComponent the destination component
-     * @return the added dependency
-     */
-    public Object addCompClassLeft(MutableGraphModel mgm, Object component,
-				    Object newComponent) {
-        if (!Model.getFacade().isAComponent(component)
-	    || !Model.getFacade().isAComponent(newComponent)) {
-            throw new IllegalArgumentException();
-        }
-	return mgm.connect(component, newComponent,
-                            (Class) Model.getMetaTypes().getDependency());
+    @Override
+    protected Object getNewEdgeType(int index) {
+        return Model.getMetaTypes().getDependency();
     }
 
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#getNewNode(int)
-     */
-    protected Object getNewNode(int buttonCode) {
+    @Override
+    protected Object getNewNode(int index) {
         return Model.getCoreFactory().createComponent();
     }
-
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#createEdgeAbove(
-     *         org.tigris.gef.graph.MutableGraphModel, java.lang.Object)
-     */
-    protected Object createEdgeAbove(MutableGraphModel gm, Object newNode) {
-        return gm.connect(getContent().getOwner(), newNode,
-                            (Class) Model.getMetaTypes().getDependency());
-    }
-
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#createEdgeLeft(
-     *         org.tigris.gef.graph.MutableGraphModel, java.lang.Object)
-     */
-    protected Object createEdgeLeft(MutableGraphModel gm, Object newNode) {
-        return gm.connect(newNode, getContent().getOwner(),
-                            (Class) Model.getMetaTypes().getDependency());
+    
+    @Override
+    protected Object getNewNodeType(int index) {
+        return Model.getMetaTypes().getComponent();
     }
 
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#createEdgeRight(
-     *         org.tigris.gef.graph.MutableGraphModel, java.lang.Object)
-     */
-    protected Object createEdgeRight(MutableGraphModel gm, Object newNode) {
-        return gm.connect(getContent().getOwner(), newNode,
-                            (Class) Model.getMetaTypes().getDependency());
-    }
-
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#createEdgeUnder(
-     *         org.tigris.gef.graph.MutableGraphModel, java.lang.Object)
-     */
-    protected Object createEdgeUnder(MutableGraphModel gm, Object newNode) {
-        return gm.connect(newNode, getContent().getOwner(),
-                            (Class) Model.getMetaTypes().getDependency());
+    @Override
+    protected boolean isDragEdgeReverse(int index) {
+        if (index == 11 || index == 13) {
+            return true;
+        }
+        return false;
     }
 
-} /* end class SelectionComponent */
+}

Modified: trunk/src_new/org/argouml/uml/diagram/deployment/ui/SelectionComponentInstance.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/diagram/deployment/ui/SelectionComponentInstance.java?view=diff&rev=12589&p1=trunk/src_new/org/argouml/uml/diagram/deployment/ui/SelectionComponentInstance.java&p2=trunk/src_new/org/argouml/uml/diagram/deployment/ui/SelectionComponentInstance.java&r1=12588&r2=12589
==============================================================================
--- trunk/src_new/org/argouml/uml/diagram/deployment/ui/SelectionComponentInstance.java	(original)
+++ trunk/src_new/org/argouml/uml/diagram/deployment/ui/SelectionComponentInstance.java	2007-05-10 09:04:49-0700
@@ -1,5 +1,5 @@
 // $Id$
-// Copyright (c) 1996-2006 The Regents of the University of California. All
+// Copyright (c) 1996-2007 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
@@ -24,43 +24,41 @@
 
 package org.argouml.uml.diagram.deployment.ui;
 
-import java.awt.Graphics;
-import java.awt.Rectangle;
-
 import javax.swing.Icon;
 
-import org.apache.log4j.Logger;
 import org.argouml.application.helpers.ResourceLoaderWrapper;
 import org.argouml.model.Model;
-import org.argouml.uml.diagram.ui.SelectionNodeClarifiers;
-import org.tigris.gef.base.Editor;
-import org.tigris.gef.base.Globals;
-import org.tigris.gef.base.ModeCreateEdgeAndNode;
-import org.tigris.gef.base.ModeManager;
-import org.tigris.gef.base.ModeModify;
-import org.tigris.gef.base.SelectionManager;
-import org.tigris.gef.graph.MutableGraphModel;
+import org.argouml.uml.diagram.ui.SelectionNodeClarifiers2;
 import org.tigris.gef.presentation.Fig;
-import org.tigris.gef.presentation.FigNode;
-import org.tigris.gef.presentation.Handle;
 
 /**
  * @author [email protected]
  */
-public class SelectionComponentInstance extends SelectionNodeClarifiers {
+public class SelectionComponentInstance extends SelectionNodeClarifiers2 {
 
-    private static final Logger LOG =
-        Logger.getLogger(SelectionComponentInstance.class);
-    ////////////////////////////////////////////////////////////////
-    // constants
     private static Icon dep =
-	ResourceLoaderWrapper.lookupIconResource("Dependency");
-    private static Icon depRight =
-	ResourceLoaderWrapper.lookupIconResource("DependencyRight");
+            ResourceLoaderWrapper.lookupIconResource("Dependency");
 
+    private static Icon depRight =
+            ResourceLoaderWrapper.lookupIconResource("DependencyRight");
 
-    ////////////////////////////////////////////////////////////////
-    // constructors
+    private static Icon icons[] = 
+    {dep,
+     dep,
+     depRight,
+     depRight,
+     null,
+    };
+    
+    // TODO: I18N required
+    private static String instructions[] = 
+    {"Add a component-instance",
+     "Add a component-instance",
+     "Add a component-instance",
+     "Add a component-instance",
+     null,
+     "Move object(s)",
+    };
 
     /**
      * Construct a new SelectionComponentInstanceInstance for the given Fig.
@@ -69,168 +67,39 @@
      */
     public SelectionComponentInstance(Fig f) { super(f); }
 
-    /*
-     * @see org.tigris.gef.base.Selection#hitHandle(java.awt.Rectangle,
-     * org.tigris.gef.presentation.Handle)
-     */
-    public void hitHandle(Rectangle r, Handle h) {
-	super.hitHandle(r, h);
-	if (h.index != -1) {
-	    return;
-	}
-	if (!isPaintButtons()) {
-	    return;
-	}
-	Editor ce = Globals.curEditor();
-	SelectionManager sm = ce.getSelectionManager();
-	if (sm.size() != 1) {
-	    return;
-	}
-	ModeManager mm = ce.getModeManager();
-	if (mm.includes(ModeModify.class) && getPressedButton() == -1) {
-	    return;
-	}
-	int cx = getContent().getX();
-	int cy = getContent().getY();
-	int cw = getContent().getWidth();
-	int ch = getContent().getHeight();
-	int aw = dep.getIconWidth();
-	int ah = dep.getIconHeight();
-	if (hitAbove(cx + cw / 2, cy, aw, ah, r)) {
-	    h.index = 10;
-	    h.instructions = "Add a component-instance";
-	} else if (hitBelow(cx + cw / 2, cy + ch, aw, ah, r)) {
-	    h.index = 11;
-	    h.instructions = "Add a component-instance";
-	} else if (hitLeft(cx + cw, cy + ch / 2, aw, ah, r)) {
-	    h.index = 12;
-	    h.instructions = "Add a component-instance";
-	} else if (hitRight(cx, cy + ch / 2, aw, ah, r)) {
-	    h.index = 13;
-	    h.instructions = "Add a component-instance";
-	} else {
-	    h.index = -1;
-	    h.instructions = "Move object(s)";
-	}
-    }
-
-
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#paintButtons(Graphics)
-     */
-    public void paintButtons(Graphics g) {
-	int cx = getContent().getX();
-	int cy = getContent().getY();
-	int cw = getContent().getWidth();
-	int ch = getContent().getHeight();
-	paintButtonAbove(dep, g, cx + cw / 2, cy, 10);
-	paintButtonBelow(dep, g, cx + cw / 2, cy + ch, 11);
-	paintButtonLeft(depRight, g, cx + cw, cy + ch / 2, 12);
-	paintButtonRight(depRight, g, cx, cy + ch / 2, 13);
-    }
-
-
-    /*
-     * @see org.tigris.gef.base.Selection#dragHandle(int, int, int, int,
-     * org.tigris.gef.presentation.Handle)
-     */
-    public void dragHandle(int mX, int mY, int anX, int anY, Handle hand) {
-	if (hand.index < 10) {
-	    setPaintButtons(false);
-	    super.dragHandle(mX, mY, anX, anY, hand);
-	    return;
-	}
-	int cx = getContent().getX(), cy = getContent().getY();
-	int cw = getContent().getWidth(), ch = getContent().getHeight();
-	Object edgeType = null;
-	Object nodeType = Model.getMetaTypes().getComponentInstance();
-	int bx = mX, by = mY;
-	boolean reverse = false;
-	switch (hand.index) {
-	case 10: //add dep
-	    edgeType = Model.getMetaTypes().getDependency();
-	    // reverse = true;
-	    by = cy;
-	    bx = cx + cw / 2;
-	    break;
-	case 11: //add dep
-	    edgeType = Model.getMetaTypes().getDependency();
-	    reverse = true;
-	    by = cy + ch;
-	    bx = cx + cw / 2;
-	    break;
-	case 12: //add dep
-	    edgeType = Model.getMetaTypes().getDependency();
-	    // reverse = true;
-	    by = cy + ch / 2;
-	    bx = cx + cw;
-	    break;
-	case 13: // add dep
-	    edgeType = Model.getMetaTypes().getDependency();
-	    reverse = true;
-	    by = cy + ch / 2;
-	    bx = cx;
-	    break;
-	default:
-	    LOG.warn("invalid handle number");
-	    break;
-	}
-	if (edgeType != null && nodeType != null) {
-	    Editor ce = Globals.curEditor();
-	    ModeCreateEdgeAndNode m =
-	        new ModeCreateEdgeAndNode(ce, edgeType, false, this);
-	    m.setup((FigNode) getContent(), getContent().getOwner(),
-	            bx, by, reverse);
-	    ce.pushMode(m);
-	}
 
+    @Override
+    protected Icon[] getIcons() {
+        return icons;
     }
 
-
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#getNewNode(int)
-     */
-    protected Object getNewNode(int buttonCode) {
-        return Model.getCommonBehaviorFactory()
-	    .createComponentInstance();
+    @Override
+    protected String getInstructions(int index) {
+        return instructions[index - 10];
     }
 
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#createEdgeAbove(
-     *         org.tigris.gef.graph.MutableGraphModel, java.lang.Object)
-     */
-    protected Object createEdgeAbove(MutableGraphModel gm, Object newNode) {
-        return gm.connect(getContent().getOwner(), newNode,
-			  (Class) Model.getMetaTypes().getDependency());
+    @Override
+    protected Object getNewEdgeType(int index) {
+        return Model.getMetaTypes().getDependency();
     }
 
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#createEdgeLeft(
-     *         org.tigris.gef.graph.MutableGraphModel, java.lang.Object)
-     */
-    protected Object createEdgeLeft(MutableGraphModel gm, Object newNode) {
-        return gm.connect(newNode, getContent().getOwner(),
-			  (Class) Model.getMetaTypes().getDependency());
+    @Override
+    protected Object getNewNode(int index) {
+        return Model.getCommonBehaviorFactory().createComponentInstance();
     }
-
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#createEdgeRight(
-     *         org.tigris.gef.graph.MutableGraphModel, java.lang.Object)
-     */
-    protected Object createEdgeRight(MutableGraphModel gm, Object newNode) {
-        return gm.connect(getContent().getOwner(), newNode,
-			  (Class) Model.getMetaTypes().getDependency());
+    
+    @Override
+    protected Object getNewNodeType(int index) {
+        return Model.getMetaTypes().getComponentInstance();
     }
 
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#createEdgeUnder(
-     *         org.tigris.gef.graph.MutableGraphModel, java.lang.Object)
-     */
-    protected Object createEdgeUnder(MutableGraphModel gm, Object newNode) {
-        return gm.connect(newNode, getContent().getOwner(),
-			  (Class) Model.getMetaTypes().getDependency());
+    @Override
+    protected boolean isDragEdgeReverse(int index) {
+        if (index == 11 || index == 13) {
+            return true;
+        }
+        return false;
     }
 
-
-} /* end class SelectionComponentInstanceInstance */
+}
 

Modified: trunk/src_new/org/argouml/uml/diagram/deployment/ui/SelectionNode.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/diagram/deployment/ui/SelectionNode.java?view=diff&rev=12589&p1=trunk/src_new/org/argouml/uml/diagram/deployment/ui/SelectionNode.java&p2=trunk/src_new/org/argouml/uml/diagram/deployment/ui/SelectionNode.java&r1=12588&r2=12589
==============================================================================
--- trunk/src_new/org/argouml/uml/diagram/deployment/ui/SelectionNode.java	(original)
+++ trunk/src_new/org/argouml/uml/diagram/deployment/ui/SelectionNode.java	2007-05-10 09:04:49-0700
@@ -1,5 +1,5 @@
 // $Id$
-// Copyright (c) 1996-2006 The Regents of the University of California. All
+// Copyright (c) 1996-2007 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
@@ -24,216 +24,80 @@
 
 package org.argouml.uml.diagram.deployment.ui;
 
-import java.awt.Graphics;
-import java.awt.Rectangle;
-
 import javax.swing.Icon;
 
-import org.apache.log4j.Logger;
 import org.argouml.application.helpers.ResourceLoaderWrapper;
 import org.argouml.model.Model;
-import org.tigris.gef.base.ModeCreateEdgeAndNode;
-import org.argouml.uml.diagram.ui.SelectionNodeClarifiers;
-import org.tigris.gef.base.Editor;
-import org.tigris.gef.base.Globals;
-import org.tigris.gef.base.ModeManager;
-import org.tigris.gef.base.ModeModify;
-import org.tigris.gef.base.SelectionManager;
-import org.tigris.gef.graph.MutableGraphModel;
+import org.argouml.uml.diagram.ui.SelectionNodeClarifiers2;
 import org.tigris.gef.presentation.Fig;
-import org.tigris.gef.presentation.FigNode;
-import org.tigris.gef.presentation.Handle;
 
 /**
  * @author [email protected]
  */
-public class SelectionNode extends SelectionNodeClarifiers {
-    /**
-     * Logger.
-     */
-    private static final Logger LOG =
-        Logger.getLogger(SelectionNode.class);
-    ////////////////////////////////////////////////////////////////
-    // constants
-    private static Icon dep =
-	ResourceLoaderWrapper.lookupIconResource("Association");
-
+public class SelectionNode extends SelectionNodeClarifiers2 {
 
+    private static Icon associationIcon =
+            ResourceLoaderWrapper.lookupIconResource("Association");
 
-    ////////////////////////////////////////////////////////////////
-    // constructors
+    private static Icon icons[] = 
+    {associationIcon,
+     associationIcon,
+     associationIcon,
+     associationIcon,
+     null,
+    };
+    
+    // TODO: I18N required
+    private static String instructions[] = 
+    {"Add a node",
+     "Add a node",
+     "Add a node",
+     "Add a node",
+     null,
+     "Move object(s)",
+    };
 
     /**
      * Construct a new SelectionNode for the given Fig.
      *
      * @param f The given Fig.
      */
-    public SelectionNode(Fig f) { super(f); }
-
-    /*
-     * @see org.tigris.gef.base.Selection#hitHandle(java.awt.Rectangle,
-     *      org.tigris.gef.presentation.Handle)
-     */
-    public void hitHandle(Rectangle r, Handle h) {
-	super.hitHandle(r, h);
-	if (h.index != -1) {
-	    return;
-	}
-	if (!isPaintButtons()) {
-	    return;
-	}
-	Editor ce = Globals.curEditor();
-	SelectionManager sm = ce.getSelectionManager();
-	if (sm.size() != 1) {
-	    return;
-	}
-	ModeManager mm = ce.getModeManager();
-	if (mm.includes(ModeModify.class) && getPressedButton() == -1) {
-	    return;
-	}
-	int cx = getContent().getX();
-	int cy = getContent().getY();
-	int cw = getContent().getWidth();
-	int ch = getContent().getHeight();
-	int aw = dep.getIconWidth();
-	int ah = dep.getIconHeight();
-	if (hitAbove(cx + cw / 2, cy, aw, ah, r)) {
-	    h.index = 10;
-	    h.instructions = "Add a node";
-	} else if (hitBelow(cx + cw / 2, cy + ch, aw, ah, r)) {
-	    h.index = 11;
-	    h.instructions = "Add a node";
-	} else if (hitLeft(cx + cw, cy + ch / 2, aw, ah, r)) {
-	    h.index = 12;
-	    h.instructions = "Add a node";
-	} else if (hitRight(cx, cy + ch / 2, aw, ah, r)) {
-	    h.index = 13;
-	    h.instructions = "Add a node";
-	} else {
-	    h.index = -1;
-	    h.instructions = "Move object(s)";
-	}
+    public SelectionNode(Fig f) {
+        super(f);
     }
 
-
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#paintButtons(Graphics)
-     */
-    public void paintButtons(Graphics g) {
-	int cx = getContent().getX();
-	int cy = getContent().getY();
-	int cw = getContent().getWidth();
-	int ch = getContent().getHeight();
-	paintButtonAbove(dep, g, cx + cw / 2, cy, 10);
-	paintButtonBelow(dep, g, cx + cw / 2, cy + ch, 11);
-	paintButtonLeft(dep, g, cx + cw, cy + ch / 2, 12);
-	paintButtonRight(dep, g, cx, cy + ch / 2, 13);
-    }
-
-
-    /*
-     * @see org.tigris.gef.base.Selection#dragHandle(int, int, int, int,
-     *      org.tigris.gef.presentation.Handle)
-     */
-    public void dragHandle(int mX, int mY, int anX, int anY, Handle hand) {
-	if (hand.index < 10) {
-	    setPaintButtons(false);
-	    super.dragHandle(mX, mY, anX, anY, hand);
-	    return;
-	}
-	int cx = getContent().getX(), cy = getContent().getY();
-	int cw = getContent().getWidth(), ch = getContent().getHeight();
-	Object edgeType = null;
-	Object nodeType = Model.getMetaTypes().getNode();
-	int bx = mX, by = mY;
-	boolean reverse = false;
-	switch (hand.index) {
-	case 10: //add dep
-	    edgeType = Model.getMetaTypes().getAssociation();
-	    by = cy;
-	    bx = cx + cw / 2;
-	    break;
-	case 11: //add dep
-	    edgeType = Model.getMetaTypes().getAssociation();
-	    reverse = true;
-	    by = cy + ch;
-	    bx = cx + cw / 2;
-	    break;
-	case 12: //add dep
-	    edgeType = Model.getMetaTypes().getAssociation();
-	    by = cy + ch / 2;
-	    bx = cx + cw;
-	    break;
-	case 13: // add dep
-	    edgeType = Model.getMetaTypes().getAssociation();
-	    reverse = true;
-	    by = cy + ch / 2;
-	    bx = cx;
-	    break;
-	default:
-	    LOG.warn("invalid handle number");
-	    break;
-	}
-	if (edgeType != null && nodeType != null) {
-	    Editor ce = Globals.curEditor();
-	    ModeCreateEdgeAndNode m =
-	        new ModeCreateEdgeAndNode(ce, edgeType, false, this);
-	    m.setup((FigNode) getContent(), getContent().getOwner(),
-                    bx, by, reverse);
-	    ce.pushMode(m);
-	}
-
+    @Override
+    protected Icon[] getIcons() {
+        return icons;
     }
 
-
-
-
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#createEdgeAbove(
-     *         org.tigris.gef.graph.MutableGraphModel, java.lang.Object)
-     */
-    protected Object createEdgeAbove(MutableGraphModel gm, Object newNode) {
-        return gm.connect(getContent().getOwner(), newNode,
-			  (Class) Model.getMetaTypes().getAssociation());
+    @Override
+    protected String getInstructions(int index) {
+        return instructions[index - 10];
     }
 
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#createEdgeLeft(
-     *         org.tigris.gef.graph.MutableGraphModel, java.lang.Object)
-     */
-    protected Object createEdgeLeft(MutableGraphModel gm, Object newNode) {
-        return gm.connect(newNode, getContent().getOwner(),
-			  (Class) Model.getMetaTypes().getAssociation());
+    @Override
+    protected Object getNewEdgeType(int index) {
+        return Model.getMetaTypes().getAssociation();
     }
 
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#createEdgeRight(
-     *         org.tigris.gef.graph.MutableGraphModel, java.lang.Object)
-     */
-    protected Object createEdgeRight(MutableGraphModel gm, Object newNode) {
-        return gm.connect(getContent().getOwner(), newNode,
-			  (Class) Model.getMetaTypes().getAssociation());
+    @Override
+    protected Object getNewNode(int index) {
+        return Model.getCoreFactory().createNode();
     }
-
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#createEdgeUnder(
-     *         org.tigris.gef.graph.MutableGraphModel, java.lang.Object)
-     */
-    protected Object createEdgeUnder(MutableGraphModel gm, Object newNode) {
-        return gm.connect(newNode, getContent().getOwner(),
-			  (Class) Model.getMetaTypes().getAssociation());
+    
+    @Override
+    protected Object getNewNodeType(int index) {
+        return Model.getMetaTypes().getNode();
     }
 
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#getNewNode(int)
-     */
-    protected Object getNewNode(int buttonCode) {
-        return Model.getCoreFactory().createNode();
+    @Override
+    protected boolean isDragEdgeReverse(int index) {
+        if (index == 11 || index == 13) {
+            return true;
+        }
+        return false;
     }
 
-    /**
-     * The UID.
-     */
-    private static final long serialVersionUID = -89995395353007445L;
-} /* end class SelectionNode */
+}
 

Modified: trunk/src_new/org/argouml/uml/diagram/deployment/ui/SelectionNodeInstance.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/diagram/deployment/ui/SelectionNodeInstance.java?view=diff&rev=12589&p1=trunk/src_new/org/argouml/uml/diagram/deployment/ui/SelectionNodeInstance.java&p2=trunk/src_new/org/argouml/uml/diagram/deployment/ui/SelectionNodeInstance.java&r1=12588&r2=12589
==============================================================================
--- trunk/src_new/org/argouml/uml/diagram/deployment/ui/SelectionNodeInstance.java	(original)
+++ trunk/src_new/org/argouml/uml/diagram/deployment/ui/SelectionNodeInstance.java	2007-05-10 09:04:49-0700
@@ -1,5 +1,5 @@
 // $Id$
-// Copyright (c) 1996-2006 The Regents of the University of California. All
+// Copyright (c) 1996-2007 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
@@ -24,43 +24,40 @@
 
 package org.argouml.uml.diagram.deployment.ui;
 
-import java.awt.Graphics;
-import java.awt.Rectangle;
-
 import javax.swing.Icon;
 
-import org.apache.log4j.Logger;
 import org.argouml.application.helpers.ResourceLoaderWrapper;
 import org.argouml.model.Model;
-import org.argouml.uml.diagram.ui.SelectionNodeClarifiers;
-import org.tigris.gef.base.Editor;
-import org.tigris.gef.base.Globals;
-import org.tigris.gef.base.ModeCreateEdgeAndNode;
-import org.tigris.gef.base.ModeManager;
-import org.tigris.gef.base.ModeModify;
-import org.tigris.gef.base.SelectionManager;
-import org.tigris.gef.graph.MutableGraphModel;
+import org.argouml.uml.diagram.ui.SelectionNodeClarifiers2;
 import org.tigris.gef.presentation.Fig;
-import org.tigris.gef.presentation.FigNode;
-import org.tigris.gef.presentation.Handle;
 
 /**
  * @author [email protected]
  */
-public class SelectionNodeInstance extends SelectionNodeClarifiers {
+public class SelectionNodeInstance extends SelectionNodeClarifiers2 {
 
-    private static final Logger LOG =
-        Logger.getLogger(SelectionNodeInstance.class);
-    ////////////////////////////////////////////////////////////////
-    // constants
-    private static Icon dep =
+    private static Icon linkIcon =
 	ResourceLoaderWrapper.lookupIconResource("Link");
 
+    private static Icon icons[] = 
+    {linkIcon,
+     linkIcon,
+     linkIcon,
+     linkIcon,
+     null,
+    };
+    
+    // TODO: I18N required
+    private static String instructions[] = 
+    {"Add a component",
+     "Add a component",
+     "Add a component",
+     "Add a component",
+     null,
+     "Move object(s)",
+    };
 
-
-    ////////////////////////////////////////////////////////////////
-    // constructors
-
+    
     /**
      * Construct a new SelectionNodeInstance for the given Fig.
      *
@@ -68,165 +65,38 @@
      */
     public SelectionNodeInstance(Fig f) { super(f); }
 
-    /*
-     * @see org.tigris.gef.base.Selection#hitHandle(java.awt.Rectangle,
-     *      org.tigris.gef.presentation.Handle)
-     */
-    public void hitHandle(Rectangle r, Handle h) {
-	super.hitHandle(r, h);
-	if (h.index != -1) {
-	    return;
-	}
-	if (!isPaintButtons()) {
-	    return;
-	}
-	Editor ce = Globals.curEditor();
-	SelectionManager sm = ce.getSelectionManager();
-	if (sm.size() != 1) {
-	    return;
-	}
-	ModeManager mm = ce.getModeManager();
-	if (mm.includes(ModeModify.class) && getPressedButton() == -1) {
-	    return;
-	}
-	int cx = getContent().getX();
-	int cy = getContent().getY();
-	int cw = getContent().getWidth();
-	int ch = getContent().getHeight();
-	int aw = dep.getIconWidth();
-	int ah = dep.getIconHeight();
-	if (hitAbove(cx + cw / 2, cy, aw, ah, r)) {
-	    h.index = 10;
-	    h.instructions = "Add a component";
-	} else if (hitBelow(cx + cw / 2, cy + ch, aw, ah, r)) {
-	    h.index = 11;
-	    h.instructions = "Add a component";
-	} else if (hitLeft(cx + cw, cy + ch / 2, aw, ah, r)) {
-	    h.index = 12;
-	    h.instructions = "Add a component";
-	} else if (hitRight(cx, cy + ch / 2, aw, ah, r)) {
-	    h.index = 13;
-	    h.instructions = "Add a component";
-	} else {
-	    h.index = -1;
-	    h.instructions = "Move object(s)";
-	}
+    @Override
+    protected Icon[] getIcons() {
+        return icons;
     }
 
-
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#paintButtons(Graphics)
-     */
-    public void paintButtons(Graphics g) {
-	int cx = getContent().getX();
-	int cy = getContent().getY();
-	int cw = getContent().getWidth();
-	int ch = getContent().getHeight();
-	paintButtonAbove(dep, g, cx + cw / 2, cy, 10);
-	paintButtonBelow(dep, g, cx + cw / 2, cy + ch, 11);
-	paintButtonLeft(dep, g, cx + cw, cy + ch / 2, 12);
-	paintButtonRight(dep, g, cx, cy + ch / 2, 13);
+    @Override
+    protected String getInstructions(int index) {
+        return instructions[index - 10];
     }
 
-
-    /*
-     * @see org.tigris.gef.base.Selection#dragHandle(int, int, int, int,
-     *      org.tigris.gef.presentation.Handle)
-     */
-    public void dragHandle(int mX, int mY, int anX, int anY, Handle hand) {
-	if (hand.index < 10) {
-	    setPaintButtons(false);
-	    super.dragHandle(mX, mY, anX, anY, hand);
-	    return;
-	}
-	int cx = getContent().getX(), cy = getContent().getY();
-	int cw = getContent().getWidth(), ch = getContent().getHeight();
-	Object edgeType = null;
-	Object nodeType = Model.getMetaTypes().getNodeInstance();
-	int bx = mX, by = mY;
-	boolean reverse = false;
-	switch (hand.index) {
-	case 10: //add dep
-	    edgeType = Model.getMetaTypes().getLink();
-	    by = cy;
-	    bx = cx + cw / 2;
-	    break;
-	case 11: //add dep
-	    edgeType = Model.getMetaTypes().getLink();
-	    reverse = true;
-	    by = cy + ch;
-	    bx = cx + cw / 2;
-	    break;
-	case 12: //add dep
-	    edgeType = Model.getMetaTypes().getLink();
-	    by = cy + ch / 2;
-	    bx = cx + cw;
-	    break;
-	case 13: // add dep
-	    edgeType = Model.getMetaTypes().getLink();
-	    reverse = true;
-	    by = cy + ch / 2;
-	    bx = cx;
-	    break;
-	default:
-	    LOG.warn("invalid handle number");
-	    break;
-	}
-	if (edgeType != null && nodeType != null) {
-	    Editor ce = Globals.curEditor();
-	    ModeCreateEdgeAndNode m =
-	        new ModeCreateEdgeAndNode(ce, edgeType, false, this);
-	    m.setup((FigNode) getContent(), getContent().getOwner(),
-	            bx, by, reverse);
-	    ce.pushMode(m);
-	}
-
+    @Override
+    protected Object getNewEdgeType(int index) {
+        return Model.getMetaTypes().getLink();
     }
 
-
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#createEdgeAbove(
-     *         org.tigris.gef.graph.MutableGraphModel, java.lang.Object)
-     */
-    protected Object createEdgeAbove(MutableGraphModel gm, Object newNode) {
-        return gm.connect(getContent().getOwner(), newNode,
-			  (Class) Model.getMetaTypes().getLink());
-    }
-
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#createEdgeLeft(
-     *         org.tigris.gef.graph.MutableGraphModel, java.lang.Object)
-     */
-    protected Object createEdgeLeft(MutableGraphModel gm, Object newNode) {
-        return gm.connect(newNode, getContent().getOwner(),
-			  (Class) Model.getMetaTypes().getLink());
+    @Override
+    protected Object getNewNode(int index) {
+        return Model.getCommonBehaviorFactory().createNodeInstance();
     }
-
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#createEdgeRight(
-     *         org.tigris.gef.graph.MutableGraphModel, java.lang.Object)
-     */
-    protected Object createEdgeRight(MutableGraphModel gm, Object newNode) {
-        return gm.connect(getContent().getOwner(), newNode,
-			  (Class) Model.getMetaTypes().getLink());
+    
+    @Override
+    protected Object getNewNodeType(int index) {
+        return Model.getMetaTypes().getNodeInstance();
     }
 
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#createEdgeUnder(
-     *         org.tigris.gef.graph.MutableGraphModel, java.lang.Object)
-     */
-    protected Object createEdgeUnder(MutableGraphModel gm, Object newNode) {
-        return gm.connect(newNode, getContent().getOwner(),
-			  (Class) Model.getMetaTypes().getLink());
+    @Override
+    protected boolean isDragEdgeReverse(int index) {
+        if (index == 11 || index == 13) {
+            return true;
+        }
+        return false;
     }
 
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#getNewNode(int)
-     */
-    protected Object getNewNode(int buttonCode) {
-        return Model.getCommonBehaviorFactory().createNodeInstance();
-    }
-
-
-} /* end class SelectionNodeInstance */
+} 
 

Modified: trunk/src_new/org/argouml/uml/diagram/deployment/ui/SelectionObject.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/diagram/deployment/ui/SelectionObject.java?view=diff&rev=12589&p1=trunk/src_new/org/argouml/uml/diagram/deployment/ui/SelectionObject.java&p2=trunk/src_new/org/argouml/uml/diagram/deployment/ui/SelectionObject.java&r1=12588&r2=12589
==============================================================================
--- trunk/src_new/org/argouml/uml/diagram/deployment/ui/SelectionObject.java	(original)
+++ trunk/src_new/org/argouml/uml/diagram/deployment/ui/SelectionObject.java	2007-05-10 09:04:49-0700
@@ -1,5 +1,5 @@
 // $Id$
-// Copyright (c) 1996-2006 The Regents of the University of California. All
+// Copyright (c) 1996-2007 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
@@ -24,208 +24,82 @@
 
 package org.argouml.uml.diagram.deployment.ui;
 
-import java.awt.Graphics;
-import java.awt.Rectangle;
-
 import javax.swing.Icon;
 
-import org.apache.log4j.Logger;
 import org.argouml.application.helpers.ResourceLoaderWrapper;
 import org.argouml.model.Model;
-import org.argouml.uml.diagram.ui.SelectionNodeClarifiers;
-import org.tigris.gef.base.Editor;
-import org.tigris.gef.base.Globals;
-import org.tigris.gef.base.ModeCreateEdgeAndNode;
-import org.tigris.gef.base.ModeManager;
-import org.tigris.gef.base.ModeModify;
-import org.tigris.gef.base.SelectionManager;
-import org.tigris.gef.graph.MutableGraphModel;
+import org.argouml.uml.diagram.ui.SelectionNodeClarifiers2;
 import org.tigris.gef.presentation.Fig;
-import org.tigris.gef.presentation.FigNode;
-import org.tigris.gef.presentation.Handle;
 
 /**
  * @author [email protected]
  */
-public class SelectionObject extends SelectionNodeClarifiers {
+public class SelectionObject extends SelectionNodeClarifiers2 {
 
-    private static final Logger LOG =
-        Logger.getLogger(SelectionObject.class);
-    ////////////////////////////////////////////////////////////////
-    // constants
-    private static Icon dep =
+    private static Icon linkIcon =
 	ResourceLoaderWrapper.lookupIconResource("Link");
 
+    private static Icon icons[] = 
+    {linkIcon,
+     linkIcon,
+     linkIcon,
+     linkIcon,
+     null,
+    };
+    
+    // TODO: I18N required
+    private static String instructions[] = 
+    {"Add an object",
+     "Add an object",
+     "Add an object",
+     "Add an object",
+     null,
+     "Move object(s)",
+    };
 
 
-    ////////////////////////////////////////////////////////////////
-    // constructors
 
     /**
      * Construct a new SelectionObject for the given Fig.
      *
      * @param f The given Fig.
      */
-    public SelectionObject(Fig f) { super(f); }
-
-    /*
-     * @see org.tigris.gef.base.Selection#hitHandle(java.awt.Rectangle,
-     *      org.tigris.gef.presentation.Handle)
-     */
-    public void hitHandle(Rectangle r, Handle h) {
-	super.hitHandle(r, h);
-	if (h.index != -1) {
-	    return;
-	}
-	if (!isPaintButtons()) {
-	    return;
-	}
-	Editor ce = Globals.curEditor();
-	SelectionManager sm = ce.getSelectionManager();
-	if (sm.size() != 1) {
-	    return;
-	}
-	ModeManager mm = ce.getModeManager();
-	if (mm.includes(ModeModify.class) && getPressedButton() == -1) {
-	    return;
-	}
-	int cx = getContent().getX();
-	int cy = getContent().getY();
-	int cw = getContent().getWidth();
-	int ch = getContent().getHeight();
-	int aw = dep.getIconWidth();
-	int ah = dep.getIconHeight();
-	if (hitAbove(cx + cw / 2, cy, aw, ah, r)) {
-	    h.index = 10;
-	    h.instructions = "Add an object";
-	} else if (hitBelow(cx + cw / 2, cy + ch, aw, ah, r)) {
-	    h.index = 11;
-	    h.instructions = "Add an object";
-	} else if (hitLeft(cx + cw, cy + ch / 2, aw, ah, r)) {
-	    h.index = 12;
-	    h.instructions = "Add an object";
-	} else if (hitRight(cx, cy + ch / 2, aw, ah, r)) {
-	    h.index = 13;
-	    h.instructions = "Add an object";
-	} else {
-	    h.index = -1;
-	    h.instructions = "Move object(s)";
-	}
+    public SelectionObject(Fig f) {
+        super(f);
     }
 
-
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#paintButtons(Graphics)
-     */
-    public void paintButtons(Graphics g) {
-	int cx = getContent().getX();
-	int cy = getContent().getY();
-	int cw = getContent().getWidth();
-	int ch = getContent().getHeight();
-	paintButtonAbove(dep, g, cx + cw / 2, cy, 10);
-	paintButtonBelow(dep, g, cx + cw / 2, cy + ch, 11);
-	paintButtonLeft(dep, g, cx + cw, cy + ch / 2, 12);
-	paintButtonRight(dep, g, cx, cy + ch / 2, 13);
+    @Override
+    protected Icon[] getIcons() {
+        return icons;
     }
 
-
-    /*
-     * @see org.tigris.gef.base.Selection#dragHandle(int, int, int, int,
-     * org.tigris.gef.presentation.Handle)
-     */
-    public void dragHandle(int mX, int mY, int anX, int anY, Handle hand) {
-	if (hand.index < 10) {
-	    setPaintButtons(false);
-	    super.dragHandle(mX, mY, anX, anY, hand);
-	    return;
-	}
-	int cx = getContent().getX(), cy = getContent().getY();
-	int cw = getContent().getWidth(), ch = getContent().getHeight();
-	Object edgeType = null;
-	Object nodeType = Model.getMetaTypes().getObject();
-	int bx = mX, by = mY;
-	boolean reverse = false;
-	switch (hand.index) {
-	case 10: //add link
-	    edgeType = Model.getMetaTypes().getLink();
-	    by = cy;
-	    bx = cx + cw / 2;
-	    break;
-	case 11: //add link
-	    edgeType = Model.getMetaTypes().getLink();
-	    reverse = true;
-	    by = cy + ch;
-	    bx = cx + cw / 2;
-	    break;
-	case 12: //add link
-	    edgeType = Model.getMetaTypes().getLink();
-	    by = cy + ch / 2;
-	    bx = cx + cw;
-	    break;
-	case 13: // add link
-	    edgeType = Model.getMetaTypes().getLink();
-	    reverse = true;
-	    by = cy + ch / 2;
-	    bx = cx;
-	    break;
-	default:
-	    LOG.warn("invalid handle number");
-	    break;
-	}
-	if (edgeType != null && nodeType != null) {
-	    Editor ce = Globals.curEditor();
-	    ModeCreateEdgeAndNode m =
-	        new ModeCreateEdgeAndNode(ce, edgeType, false, this);
-	    m.setup((FigNode) getContent(), getContent().getOwner(),
-	            bx, by, reverse);
-	    ce.pushMode(m);
-	}
-
+    @Override
+    protected String getInstructions(int index) {
+        return instructions[index - 10];
     }
 
-
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#createEdgeAbove(
-     *         org.tigris.gef.graph.MutableGraphModel, java.lang.Object)
-     */
-    protected Object createEdgeAbove(MutableGraphModel gm, Object newNode) {
-        return gm.connect(getContent().getOwner(), newNode,
-			  (Class) Model.getMetaTypes().getLink());
+    @Override
+    protected Object getNewEdgeType(int index) {
+        return Model.getMetaTypes().getLink();
     }
 
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#createEdgeLeft(
-     *         org.tigris.gef.graph.MutableGraphModel, java.lang.Object)
-     */
-    protected Object createEdgeLeft(MutableGraphModel gm, Object newNode) {
-        return gm.connect(newNode, getContent().getOwner(),
-			  (Class) Model.getMetaTypes().getLink());
-    }
-
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#createEdgeRight(
-     *         org.tigris.gef.graph.MutableGraphModel, java.lang.Object)
-     */
-    protected Object createEdgeRight(MutableGraphModel gm, Object newNode) {
-        return gm.connect(getContent().getOwner(), newNode,
-			  (Class) Model.getMetaTypes().getLink());
+    @Override
+    protected Object getNewNode(int index) {
+        return Model.getCommonBehaviorFactory().createObject();
     }
     
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#createEdgeUnder(
-     *         org.tigris.gef.graph.MutableGraphModel, java.lang.Object)
-     */
-    protected Object createEdgeUnder(MutableGraphModel gm, Object newNode) {
-        return gm.connect(newNode, getContent().getOwner(),
-			  (Class) Model.getMetaTypes().getLink());
+    @Override
+    protected Object getNewNodeType(int index) {
+        return Model.getMetaTypes().getObject();
     }
 
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#getNewNode(int)
-     */
-    protected Object getNewNode(int buttonCode) {
-        return Model.getCommonBehaviorFactory().createObject();
+    @Override
+    protected boolean isDragEdgeReverse(int index) {
+        if (index == 11 || index == 13) {
+            return true;
+        }
+        return false;
     }
 
-} /* end class SelectionObject */
+} 
 

Modified: trunk/src_new/org/argouml/uml/diagram/sequence/ui/SelectionClassifierRole.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/diagram/sequence/ui/SelectionClassifierRole.java?view=diff&rev=12589&p1=trunk/src_new/org/argouml/uml/diagram/sequence/ui/SelectionClassifierRole.java&p2=trunk/src_new/org/argouml/uml/diagram/sequence/ui/SelectionClassifierRole.java&r1=12588&r2=12589
==============================================================================
--- trunk/src_new/org/argouml/uml/diagram/sequence/ui/SelectionClassifierRole.java	(original)
+++ trunk/src_new/org/argouml/uml/diagram/sequence/ui/SelectionClassifierRole.java	2007-05-10 09:04:49-0700
@@ -24,7 +24,9 @@
 
 package org.argouml.uml.diagram.sequence.ui;
 
-import org.argouml.uml.diagram.ui.SelectionNodeClarifiers;
+import javax.swing.Icon;
+
+import org.argouml.uml.diagram.ui.SelectionNodeClarifiers2;
 import org.tigris.gef.presentation.Fig;
 import org.tigris.gef.presentation.Handle;
 
@@ -34,7 +36,7 @@
  *
  * @author Bob Tarling
  */
-public class SelectionClassifierRole extends SelectionNodeClarifiers {
+public class SelectionClassifierRole extends SelectionNodeClarifiers2 {
 
     /**
      * The constructor.
@@ -67,15 +69,28 @@
         super.dragHandle(mX, mY, anX, anY, hand);
     }
 
-    /*
-     * @see org.argouml.uml.diagram.ui.SelectionNodeClarifiers#getNewNode(int)
-     */
-    protected Object getNewNode(int buttonCode) {
+    @Override
+    protected Object getNewNode(int index) {
         return null;
     }
 
-    /**
-     * The UID.
-     */
-    private static final long serialVersionUID = 3570571152608122095L;
+    @Override
+    protected Icon[] getIcons() {
+        return null;
+    }
+
+    @Override
+    protected String getInstructions(int index) {
+        return null;
+    }
+
+    @Override
+    protected Object getNewEdgeType(int index) {
+        return null;
+    }
+
+    @Override
+    protected Object getNewNodeType(int index) {
+        return null;
+    }
 }

Modified: trunk/src_new/org/argouml/uml/diagram/state/ui/SelectionState.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/diagram/state/ui/SelectionState.java?view=diff&rev=12589&p1=trunk/src_new/org/argouml/uml/diagram/state/ui/SelectionState.java&p2=trunk/src_new/org/argouml/uml/diagram/state/ui/SelectionState.java&r1=12588&r2=12589
==============================================================================
--- trunk/src_new/org/argouml/uml/diagram/state/ui/SelectionState.java	(original)
+++ trunk/src_new/org/argouml/uml/diagram/state/ui/SelectionState.java	2007-05-10 09:04:49-0700
@@ -24,45 +24,41 @@
 
 package org.argouml.uml.diagram.state.ui;
 
-import java.awt.Graphics;
-import java.awt.Rectangle;
-
 import javax.swing.Icon;
 
-import org.apache.log4j.Logger;
 import org.argouml.application.helpers.ResourceLoaderWrapper;
 import org.argouml.model.Model;
-import org.tigris.gef.base.ModeCreateEdgeAndNode;
-import org.argouml.uml.diagram.ui.SelectionNodeClarifiers;
-import org.tigris.gef.base.Editor;
-import org.tigris.gef.base.Globals;
-import org.tigris.gef.base.ModeManager;
-import org.tigris.gef.base.ModeModify;
-import org.tigris.gef.base.SelectionManager;
-import org.tigris.gef.graph.GraphModel;
-import org.tigris.gef.graph.MutableGraphModel;
+import org.argouml.uml.diagram.ui.SelectionNodeClarifiers2;
 import org.tigris.gef.presentation.Fig;
-import org.tigris.gef.presentation.FigNode;
-import org.tigris.gef.presentation.Handle;
 
 /**
  * @author [email protected]
  */
-public class SelectionState extends SelectionNodeClarifiers {
+public class SelectionState extends SelectionNodeClarifiers2 {
 
-    private static final Logger LOG = Logger.getLogger(SelectionState.class);
-    ////////////////////////////////////////////////////////////////
-    // constants
     private static Icon trans =
 	ResourceLoaderWrapper.lookupIconResource("Transition");
 
-    ////////////////////////////////////////////////////////////////
-    // instance varables
+    private static Icon icons[] = 
+    {null,
+     null,
+     trans,
+     trans,
+     null,
+    };
+    
+    // TODO: I18N required
+    private static String instructions[] = 
+    {null,
+     null,
+     "Add an outgoing transition",
+     "Add an incoming transition",
+     null,
+     "Move object(s)",
+    };
     private boolean showIncoming = true;
-    private boolean showOutgoing = true;
 
-    ////////////////////////////////////////////////////////////////
-    // constructors
+    private boolean showOutgoing = true;
 
     /**
      * Construct a new SelectionState for the given Fig.
@@ -73,9 +69,6 @@
 	super(f);
     }
 
-    ////////////////////////////////////////////////////////////////
-    // accessors
-
     /**
      * @param b true if the buton is enabled
      */
@@ -90,164 +83,47 @@
 	showOutgoing = b;
     }
 
-    /*
-     * @see org.tigris.gef.base.Selection#hitHandle(java.awt.Rectangle,
-     * org.tigris.gef.presentation.Handle)
-     */
-    public void hitHandle(Rectangle r, Handle h) {
-	super.hitHandle(r, h);
-	if (h.index != -1) {
-	    return;
-	}
-	if (!isPaintButtons()) {
-	    return;
-	}
-	Editor ce = Globals.curEditor();
-	SelectionManager sm = ce.getSelectionManager();
-	if (sm.size() != 1) {
-	    return;
-	}
-	ModeManager mm = ce.getModeManager();
-	if (mm.includes(ModeModify.class) && getPressedButton() == -1) {
-	    return;
-	}
-	int cx = getContent().getX();
-	int cy = getContent().getY();
-	int cw = getContent().getWidth();
-	int ch = getContent().getHeight();
-	int iw = trans.getIconWidth();
-	int ih = trans.getIconHeight();
-	if (showOutgoing && hitLeft(cx + cw, cy + ch / 2, iw, ih, r)) {
-	    h.index = 12;
-	    h.instructions = "Add an outgoing transition";
-	} else if (showIncoming && hitRight(cx, cy + ch / 2, iw, ih, r)) {
-	    h.index = 13;
-	    h.instructions = "Add an incoming transition";
-	} else {
-	    h.index = -1;
-	    h.instructions = "Move object(s)";
-	}
-    }
+    @Override
+    protected Icon[] getIcons() {
+        Icon workingIcons[] = new Icon[icons.length];
+        System.arraycopy(icons, 0, workingIcons, 0, icons.length);
 
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#paintButtons(Graphics)
-     */
-    public void paintButtons(Graphics g) {
-	int cx = getContent().getX();
-	int cy = getContent().getY();
-	int cw = getContent().getWidth();
-	int ch = getContent().getHeight();
-	if (showOutgoing) {
-	    paintButtonLeft(trans, g, cx + cw, cy + ch / 2, 12);
-	}
-	if (showIncoming) {
-	    paintButtonRight(trans, g, cx, cy + ch / 2, 13);
-	}
-    }
-
-    /*
-     * @see org.tigris.gef.base.Selection#dragHandle(int, int, int, int,
-     *      org.tigris.gef.presentation.Handle)
-     */
-    public void dragHandle(int mX, int mY, int anX, int anY, Handle hand) {
-	if (hand.index < 10) {
-	    setPaintButtons(false);
-	    super.dragHandle(mX, mY, anX, anY, hand);
-	    return;
-	}
-	int cx = getContent().getX(), cy = getContent().getY();
-	int cw = getContent().getWidth(), ch = getContent().getHeight();
-	Object edgeType = null;
-	Object nodeType = Model.getMetaTypes().getSimpleState();
-
-	Editor ce = Globals.curEditor();
-	GraphModel gm = ce.getGraphModel();
-	if (!(gm instanceof MutableGraphModel)) {
-	    return;
-	}
-
-	int bx = mX, by = mY;
-	boolean reverse = false;
-	switch (hand.index) {
-	case 12 : //add outgoing
-	    edgeType = Model.getMetaTypes().getTransition();
-	    by = cy + ch / 2;
-	    bx = cx + cw;
-	    break;
-	case 13 : // add incoming
-	    edgeType = Model.getMetaTypes().getTransition();
-	    reverse = true;
-	    by = cy + ch / 2;
-	    bx = cx;
-	    break;
-	default :
-	    LOG.warn("invalid handle number");
-	    break;
-	}
-	if (edgeType != null && nodeType != null) {
-	    ModeCreateEdgeAndNode m =
-		new ModeCreateEdgeAndNode(ce, edgeType, false, this);
-	    m.setup((FigNode) getContent(), getContent().getOwner(),
-	            bx, by, reverse);
-	    ce.pushMode(m);
-	}
+        if (!showOutgoing) {
+            workingIcons[12] = null;
+        }
+        if (!showIncoming) {
+            workingIcons[13] = null;
+        }
+        
+        return workingIcons;
     }
 
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#getNewNode(int)
-     */
-    protected Object getNewNode(int buttonCode) {
-	return Model.getStateMachinesFactory().createSimpleState();
+    @Override
+    protected String getInstructions(int index) {
+        return instructions[index - 10];
     }
 
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#createEdgeAbove(
-     *         org.tigris.gef.graph.MutableGraphModel, java.lang.Object)
-     */
-    protected Object createEdgeAbove(MutableGraphModel mgm, Object newNode) {
-	return mgm.connect(newNode, getContent().getOwner(),
-			   (Class) Model.getMetaTypes().getTransition());
+    @Override
+    protected Object getNewEdgeType(int index) {
+        return Model.getMetaTypes().getTransition();
     }
 
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#createEdgeLeft(
-     *         org.tigris.gef.graph.MutableGraphModel, java.lang.Object)
-     */
-    protected Object createEdgeLeft(MutableGraphModel gm, Object newNode) {
-	return gm.connect(newNode, getContent().getOwner(),
-			  (Class) Model.getMetaTypes().getTransition());
+    @Override
+    protected Object getNewNode(int index) {
+        return Model.getStateMachinesFactory().createSimpleState();
     }
-
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#createEdgeRight(
-     *         org.tigris.gef.graph.MutableGraphModel, java.lang.Object)
-     */
-    protected Object createEdgeRight(MutableGraphModel gm, Object newNode) {
-	return gm.connect(getContent().getOwner(), newNode,
-			  (Class) Model.getMetaTypes().getTransition());
+    
+    @Override
+    protected Object getNewNodeType(int index) {
+        return Model.getMetaTypes().getSimpleState();
     }
 
-    /*
-     * To enable this we need to add an icon.
-     * @see org.tigris.gef.base.SelectionButtons#createEdgeToSelf(
-     *         org.tigris.gef.graph.MutableGraphModel)
-     */
-    protected Object createEdgeToSelf(MutableGraphModel gm) {
-	return gm.connect(
-			  getContent().getOwner(),
-			  getContent().getOwner(),
-			  (Class) Model.getMetaTypes().getTransition());
+    @Override
+    protected boolean isDragEdgeReverse(int index) {
+        if (index == 13) {
+            return true;
+        }
+        return false;
     }
 
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#createEdgeUnder(
-     *         org.tigris.gef.graph.MutableGraphModel, java.lang.Object)
-     */
-    protected Object createEdgeUnder(MutableGraphModel gm, Object newNode) {
-	return gm.connect(getContent().getOwner(), newNode,
-			  (Class) Model.getMetaTypes().getTransition());
-    }
-
-
-
-} /* end class SelectionState */
+}

Modified: trunk/src_new/org/argouml/uml/diagram/static_structure/ui/SelectionClass.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/diagram/static_structure/ui/SelectionClass.java?view=diff&rev=12589&p1=trunk/src_new/org/argouml/uml/diagram/static_structure/ui/SelectionClass.java&p2=trunk/src_new/org/argouml/uml/diagram/static_structure/ui/SelectionClass.java&r1=12588&r2=12589
==============================================================================
--- trunk/src_new/org/argouml/uml/diagram/static_structure/ui/SelectionClass.java	(original)
+++ trunk/src_new/org/argouml/uml/diagram/static_structure/ui/SelectionClass.java	2007-05-10 09:04:49-0700
@@ -28,13 +28,11 @@
 
 import javax.swing.Icon;
 
-import org.apache.log4j.Logger;
 import org.argouml.application.helpers.ResourceLoaderWrapper;
 import org.argouml.model.Model;
 import org.argouml.uml.diagram.deployment.DeploymentDiagramGraphModel;
 import org.argouml.uml.diagram.ui.SelectionNodeClarifiers2;
 import org.tigris.gef.base.Globals;
-import org.tigris.gef.graph.MutableGraphModel;
 import org.tigris.gef.presentation.Fig;
 
 /**
@@ -42,12 +40,6 @@
  */
 public class SelectionClass extends SelectionNodeClarifiers2 {
 
-    /**
-     * Logger.
-     */
-    private static final Logger LOG =
-        Logger.getLogger(SelectionClass.class);
-
     private static Icon inherit =
         ResourceLoaderWrapper.lookupIconResource("Generalization");
 
@@ -62,57 +54,30 @@
 
     private boolean useComposite;
 
-    private static Icon icons[] = {null,
-                                   null,
-                                   null,
-                                   null,
-                                   null,
-                                   null,
-                                   null,                                   
-                                   null,
-                                   null,
-                                   null, // 9
-                                   inherit,
-                                   inherit,
-                                   assoc,
-                                   assoc,
-                                   selfassoc,
+    private static Icon icons[] = 
+    {inherit,
+     inherit,
+     assoc,
+     assoc,
+     selfassoc,
     };
     
     // TODO: I18N required
-    private static String instructions[] = {null,
-                                            null,
-                                            null,
-                                            null,
-                                            null,
-                                            null,
-                                            null,
-                                            null,
-                                            null,
-                                            null, // 9
-                                            "Add a superclass",
-                                            "Add a subclass",
-                                            "Add an associated class",
-                                            "Add an associated class",
-                                            "Add a self association",
-                                            "Move object(s)",
+    private static String instructions[] = 
+    {"Add a superclass",
+     "Add a subclass",
+     "Add an associated class",
+     "Add an associated class",
+     "Add a self association",
+     "Move object(s)",
     };
 
-    private static Object edgeType[] = {null,
-                                        null,
-                                        null,
-                                        null,
-                                        null,
-                                        null,
-                                        null,                                   
-                                        null,
-                                        null,
-                                        null, // 9
-                                        Model.getMetaTypes().getGeneralization(),
-                                        Model.getMetaTypes().getGeneralization(),
-                                        Model.getMetaTypes().getAssociation(),
-                                        Model.getMetaTypes().getAssociation(),
-                                        null, // no drag for self-association
+    private static Object edgeType[] = 
+    {Model.getMetaTypes().getGeneralization(),
+     Model.getMetaTypes().getGeneralization(),
+     Model.getMetaTypes().getAssociation(),
+     Model.getMetaTypes().getAssociation(),
+     null, // no drag for self-association
     };
 
     /**
@@ -124,14 +89,14 @@
         super(f);
     }
 
-    /*
-     * @see org.argouml.uml.diagram.ui.SelectionNodeClarifiers2#getIcons()
-     */
+    @Override
     protected Icon[] getIcons() {
-        Icon workingIcons[] = icons;
+        Icon workingIcons[] = new Icon[icons.length];
+        System.arraycopy(icons, 0, workingIcons, 0, icons.length);
 
         // No Generalizations on Deployment Diagram
-        if (Globals.curEditor().getGraphModel() instanceof DeploymentDiagramGraphModel) {
+        if (Globals.curEditor().getGraphModel() 
+                instanceof DeploymentDiagramGraphModel) {
             workingIcons[10] = null;
             workingIcons[11] = null;
         }
@@ -142,106 +107,43 @@
         return workingIcons;
     }
     
-    /*
-     * @see org.argouml.uml.diagram.ui.SelectionNodeClarifiers2#getInstructions(int)
-     */
+    @Override
     protected String getInstructions(int index) {
-        return instructions[index];
+        return instructions[index - 10];
     }
 
-    /*
-     * @see org.argouml.uml.diagram.ui.SelectionNodeClarifiers2#getNewNodeType(int)
-     */
+    @Override
     protected Object getNewNodeType(int i) {
         return Model.getMetaTypes().getUMLClass();
     }
-    
-    /*
-     * @see org.argouml.uml.diagram.ui.SelectionNodeClarifiers2#getNewEdgeType(int)
-     */
+
+    @Override
     protected Object getNewEdgeType(int i) {
-        return edgeType[i];
+        return edgeType[i - 10];
     }
-    
-    /*
-     * @see org.argouml.uml.diagram.ui.SelectionNodeClarifiers2#isDragEdgeReverse(int)
-     */
+
+    @Override
     protected boolean isDragEdgeReverse(int i) {
         if (i == 11 || i == 13) {
             return true;
         } 
         return false;
     }
-   
-    /*
-     * @see org.argouml.uml.diagram.ui.SelectionNodeClarifiers2#isEdgePostProcessRequested()
-     */
+
+    @Override
     protected boolean isEdgePostProcessRequested() {
         return useComposite;
     }
-    
-    /*
-     * @see java.awt.event.MouseListener#mouseEntered(java.awt.event.MouseEvent)
-     */
+
+    @Override
     public void mouseEntered(MouseEvent me) {
         super.mouseEntered(me);
         useComposite = me.isShiftDown();
     }
 
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#getNewNode(int)
-     */
-    protected Object getNewNode(int buttonCode) {
+    @Override
+    protected Object getNewNode(int index) {
         return Model.getCoreFactory().buildClass();
     }
 
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#createEdgeAbove(
-     *         org.tigris.gef.graph.MutableGraphModel, java.lang.Object)
-     */
-    protected Object createEdgeAbove(MutableGraphModel mgm, Object newNode) {
-        return mgm.connect(getContent().getOwner(), newNode,
-			   (Class) Model.getMetaTypes().getGeneralization());
-    }
-
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#createEdgeLeft(
-     *         org.tigris.gef.graph.MutableGraphModel, java.lang.Object)
-     */
-    protected Object createEdgeLeft(MutableGraphModel mgm, Object newNode) {
-        return mgm.connect(newNode, getContent().getOwner(),
-			   (Class) Model.getMetaTypes().getAssociation());
-    }
-
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#createEdgeRight(
-     *         org.tigris.gef.graph.MutableGraphModel, java.lang.Object)
-     */
-    protected Object createEdgeRight(MutableGraphModel mgm, Object newNode) {
-        return mgm.connect(getContent().getOwner(), newNode,
-			   (Class) Model.getMetaTypes().getAssociation());
-    }
-
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#createEdgeToSelf(
-     *         org.tigris.gef.graph.MutableGraphModel)
-     */
-    protected Object createEdgeToSelf(MutableGraphModel mgm) {
-        return mgm.connect(getContent().getOwner(), getContent().getOwner(),
-			   (Class) Model.getMetaTypes().getAssociation());
-    }
-
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#createEdgeUnder(
-     *         org.tigris.gef.graph.MutableGraphModel, java.lang.Object)
-     */
-    protected Object createEdgeUnder(MutableGraphModel mgm, Object newNode) {
-        return mgm.connect(newNode, getContent().getOwner(),
-			   (Class) Model.getMetaTypes().getGeneralization());
-    }
-
-    /**
-     * The UID.
-     */
-    private static final long serialVersionUID = -5724040863222115747L;
-} /* end class SelectionClass */
+}

Modified: trunk/src_new/org/argouml/uml/diagram/static_structure/ui/SelectionComment.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/diagram/static_structure/ui/SelectionComment.java?view=diff&rev=12589&p1=trunk/src_new/org/argouml/uml/diagram/static_structure/ui/SelectionComment.java&p2=trunk/src_new/org/argouml/uml/diagram/static_structure/ui/SelectionComment.java&r1=12588&r2=12589
==============================================================================
--- trunk/src_new/org/argouml/uml/diagram/static_structure/ui/SelectionComment.java	(original)
+++ trunk/src_new/org/argouml/uml/diagram/static_structure/ui/SelectionComment.java	2007-05-10 09:04:49-0700
@@ -1,5 +1,5 @@
 // $Id$
-// Copyright (c) 2005-2006 The Regents of the University of California. All
+// Copyright (c) 2005-2007 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
@@ -24,199 +24,72 @@
 
 package org.argouml.uml.diagram.static_structure.ui;
 
-import java.awt.Graphics;
-import java.awt.Rectangle;
-
 import javax.swing.Icon;
 
-import org.apache.log4j.Logger;
 import org.argouml.application.helpers.ResourceLoaderWrapper;
 import org.argouml.model.Model;
-import org.argouml.uml.diagram.ui.SelectionNodeClarifiers;
-import org.tigris.gef.base.Editor;
-import org.tigris.gef.base.Globals;
-import org.tigris.gef.base.ModeCreateEdgeAndNode;
-import org.tigris.gef.base.ModeManager;
-import org.tigris.gef.base.ModeModify;
-import org.tigris.gef.base.SelectionManager;
-import org.tigris.gef.graph.MutableGraphModel;
+import org.argouml.uml.diagram.ui.SelectionNodeClarifiers2;
 import org.tigris.gef.presentation.Fig;
-import org.tigris.gef.presentation.FigNode;
-import org.tigris.gef.presentation.Handle;
 
 /**
  * The buttons on Selection for a Comment.
  *
  * @author [email protected]
  */
-public class SelectionComment extends SelectionNodeClarifiers {
-    /**
-     * Logger.
-     */
-    private static final Logger LOG =
-        Logger.getLogger(SelectionComment.class);
+public class SelectionComment extends SelectionNodeClarifiers2 {
 
-    ////////////////////////////////////////////////////////////////
-    // constants
-    private static Icon dep =
+    private static Icon linkIcon =
         ResourceLoaderWrapper.lookupIconResource("CommentLink");
 
-
-
-    ////////////////////////////////////////////////////////////////
-    // constructors
+    private static Icon icons[] =
+    {linkIcon,
+     linkIcon,
+     linkIcon,
+     linkIcon,
+     null,
+    };
+
+    // TODO: I18N required
+    private static String instructions[] =
+    {"Link this comment",
+     "Link this comment",
+     "Link this comment",
+     "Link this comment",
+     null,
+     "Move object(s)",
+    };
 
     /**
      * Construct a new SelectionComment for the given Fig.
      *
      * @param f the given Fig
      */
-    public SelectionComment(Fig f) { super(f); }
-
-    /*
-     * @see org.tigris.gef.base.Selection#hitHandle(java.awt.Rectangle,
-     *      org.tigris.gef.presentation.Handle)
-     */
-    public void hitHandle(Rectangle r, Handle h) {
-        super.hitHandle(r, h);
-        if (h.index != -1) {
-            return;
-        }
-        if (!isPaintButtons()) {
-            return;
-        }
-        Editor ce = Globals.curEditor();
-        SelectionManager sm = ce.getSelectionManager();
-        if (sm.size() != 1) {
-            return;
-        }
-        ModeManager mm = ce.getModeManager();
-        if (mm.includes(ModeModify.class) && getPressedButton() == -1) {
-            return;
-        }
-        int cx = getContent().getX();
-        int cy = getContent().getY();
-        int cw = getContent().getWidth();
-        int ch = getContent().getHeight();
-        int aw = dep.getIconWidth();
-        int ah = dep.getIconHeight();
-        if (hitAbove(cx + cw / 2, cy, aw, ah, r)) {
-            h.index = 10;
-            h.instructions = "Link this comment";
-        } else if (hitBelow(cx + cw / 2, cy + ch, aw, ah, r)) {
-            h.index = 11;
-            h.instructions = "Link this comment";
-        } else if (hitLeft(cx + cw, cy + ch / 2, aw, ah, r)) {
-            h.index = 12;
-            h.instructions = "Link this comment";
-        } else if (hitRight(cx, cy + ch / 2, aw, ah, r)) {
-            h.index = 13;
-            h.instructions = "Link this comment";
-        } else {
-            h.index = -1;
-            h.instructions = "Move object(s)";
-        }
+    public SelectionComment(Fig f) {
+        super(f);
     }
 
-
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#paintButtons(Graphics)
-     */
-    public void paintButtons(Graphics g) {
-        int cx = getContent().getX();
-        int cy = getContent().getY();
-        int cw = getContent().getWidth();
-        int ch = getContent().getHeight();
-        paintButtonAbove(dep, g, cx + cw / 2, cy, 10);
-        paintButtonBelow(dep, g, cx + cw / 2, cy + ch, 11);
-        paintButtonLeft(dep, g, cx + cw, cy + ch / 2, 12);
-        paintButtonRight(dep, g, cx, cy + ch / 2, 13);
+    @Override
+    protected Icon[] getIcons() {
+        return icons;
     }
 
-
-    /*
-     * @see org.tigris.gef.base.Selection#dragHandle(int, int, int, int,
-     *      org.tigris.gef.presentation.Handle)
-     */
-    public void dragHandle(int mX, int mY, int anX, int anY, Handle hand) {
-        if (hand.index < 10) {
-            setPaintButtons(false);
-            super.dragHandle(mX, mY, anX, anY, hand);
-            return;
-        }
-        int cx = getContent().getX(), cy = getContent().getY();
-        int cw = getContent().getWidth(), ch = getContent().getHeight();
-        Object edgeType = CommentEdge.class;
-        Object nodeType = Model.getMetaTypes().getComment();
-        int bx = mX, by = mY;
-        boolean reverse = false;
-        switch (hand.index) {
-        case 10: //add commentlink
-            by = cy;
-            bx = cx + cw / 2;
-            break;
-        case 11: //add commentlink
-            by = cy + ch;
-            bx = cx + cw / 2;
-            break;
-        case 12: //add commentlink
-            by = cy + ch / 2;
-            bx = cx + cw;
-            break;
-        case 13: // add commentlink
-            by = cy + ch / 2;
-            bx = cx;
-            break;
-        default:
-            LOG.warn("invalid handle number");
-            break;
-        }
-        if (edgeType != null && nodeType != null) {
-            Editor ce = Globals.curEditor();
-            ModeCreateEdgeAndNode m =
-                new ModeCreateEdgeAndNode(ce, edgeType, false, this);
-            m.setup((FigNode) getContent(), getContent().getOwner(),
-                    bx, by, reverse);
-            ce.pushMode(m);
-        }
-    }
-
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#createEdgeAbove(
-     *         org.tigris.gef.graph.MutableGraphModel, java.lang.Object)
-     */
-    protected Object createEdgeAbove(MutableGraphModel gm, Object newNode) {
-        return gm.connect(getContent().getOwner(), newNode, CommentEdge.class);
+    @Override
+    protected String getInstructions(int index) {
+        return instructions[index - 10];
     }
 
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#createEdgeLeft(
-     *         org.tigris.gef.graph.MutableGraphModel, java.lang.Object)
-     */
-    protected Object createEdgeLeft(MutableGraphModel gm, Object newNode) {
-        return gm.connect(newNode, getContent().getOwner(), CommentEdge.class);
+    @Override
+    protected Object getNewEdgeType(int index) {
+        return CommentEdge.class;
     }
 
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#createEdgeRight(
-     *         org.tigris.gef.graph.MutableGraphModel, java.lang.Object)
-     */
-    protected Object createEdgeRight(MutableGraphModel gm, Object newNode) {
-        return gm.connect(getContent().getOwner(), newNode, CommentEdge.class);
+    @Override
+    protected Object getNewNodeType(int index) {
+        return Model.getMetaTypes().getComment();
     }
 
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#createEdgeUnder(
-     *         org.tigris.gef.graph.MutableGraphModel, java.lang.Object)
-     */
-    protected Object createEdgeUnder(MutableGraphModel gm, Object newNode) {
-        return gm.connect(newNode, getContent().getOwner(), CommentEdge.class);
-    }
-
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#getNewNode(int)
-     */
-    protected Object getNewNode(int buttonCode) {
+    @Override
+    protected Object getNewNode(int index) {
         /* Alternatively, we could just return null here, 
          * so that you can not create a comment just 
          * linked to a comment this way - which is a bit uncommon,
@@ -225,5 +98,6 @@
 //        return null;
         return Model.getCoreFactory().createComment();
     }
-} /* end class SelectionComment */
+
+}
 

Modified: trunk/src_new/org/argouml/uml/diagram/static_structure/ui/SelectionEnumeration.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/diagram/static_structure/ui/SelectionEnumeration.java?view=diff&rev=12589&p1=trunk/src_new/org/argouml/uml/diagram/static_structure/ui/SelectionEnumeration.java&p2=trunk/src_new/org/argouml/uml/diagram/static_structure/ui/SelectionEnumeration.java&r1=12588&r2=12589
==============================================================================
--- trunk/src_new/org/argouml/uml/diagram/static_structure/ui/SelectionEnumeration.java	(original)
+++ trunk/src_new/org/argouml/uml/diagram/static_structure/ui/SelectionEnumeration.java	2007-05-10 09:04:49-0700
@@ -34,6 +34,16 @@
  */
 class SelectionEnumeration extends SelectionDataType {
 
+    // TODO: I18N
+    private static String[] instructions =
+    {"Add a super-enumeration",
+     "Add a sub-enumeration",
+     null,
+     null,
+     null,
+     "Move object(s)",
+    };
+    
     /**
      * @param f the given fi
      */
@@ -41,35 +51,21 @@
         super(f);
     }
 
-
-    /*
-     * @see org.argouml.uml.diagram.ui.SelectionNodeClarifiers#getInstructions(int)
-     */
+    @Override
     protected String getInstructions(int i) {
-        if (i == 10) {
-            return "Add a super-enumeration";
-        } else if (i == 10) {
-            return "Add a sub-enumeration";
-        } else if (i == -1) {
-            return "Move object(s)";
-        }
-        return null;
+        return instructions[ i - 10];
+
     }
 
-    /*
-     * @see org.argouml.uml.diagram.static_structure.ui.SelectionDataType#getNewNode(int)
-     */
-    protected Object getNewNode(int buttonCode) {
+    @Override
+    protected Object getNewNode(int index) {
         Object ns = Model.getFacade().getNamespace(getContent().getOwner());
         return Model.getCoreFactory().buildEnumeration("", ns);
     }
 
-    /*
-     * @see org.argouml.uml.diagram.static_structure.ui.SelectionDataType#getNewNodeType(int)
-     */
-    protected Object getNewNodeType(int buttonCode) {
+    @Override
+    protected Object getNewNodeType(int index) {
         return Model.getMetaTypes().getEnumeration();
     }
 
-
 }

Modified: trunk/src_new/org/argouml/uml/diagram/static_structure/ui/SelectionException.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/diagram/static_structure/ui/SelectionException.java?view=diff&rev=12589&p1=trunk/src_new/org/argouml/uml/diagram/static_structure/ui/SelectionException.java&p2=trunk/src_new/org/argouml/uml/diagram/static_structure/ui/SelectionException.java&r1=12588&r2=12589
==============================================================================
--- trunk/src_new/org/argouml/uml/diagram/static_structure/ui/SelectionException.java	(original)
+++ trunk/src_new/org/argouml/uml/diagram/static_structure/ui/SelectionException.java	2007-05-10 09:04:49-0700
@@ -41,10 +41,12 @@
         super(f);
     }
 
+    @Override
     protected Object getNewNode(int buttonCode) {
         return Model.getCommonBehaviorFactory().createException();
     }
 
+    @Override
     protected Object getNewNodeType(int buttonCode) {
         return Model.getMetaTypes().getException();
     }

Modified: trunk/src_new/org/argouml/uml/diagram/static_structure/ui/SelectionGeneralizableElement.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/diagram/static_structure/ui/SelectionGeneralizableElement.java?view=diff&rev=12589&p1=trunk/src_new/org/argouml/uml/diagram/static_structure/ui/SelectionGeneralizableElement.java&p2=trunk/src_new/org/argouml/uml/diagram/static_structure/ui/SelectionGeneralizableElement.java&r1=12588&r2=12589
==============================================================================
--- trunk/src_new/org/argouml/uml/diagram/static_structure/ui/SelectionGeneralizableElement.java	(original)
+++ trunk/src_new/org/argouml/uml/diagram/static_structure/ui/SelectionGeneralizableElement.java	2007-05-10 09:04:49-0700
@@ -28,7 +28,6 @@
 
 import javax.swing.Icon;
 
-import org.apache.log4j.Logger;
 import org.argouml.application.helpers.ResourceLoaderWrapper;
 import org.argouml.model.Model;
 import org.argouml.uml.diagram.deployment.DeploymentDiagramGraphModel;
@@ -36,7 +35,6 @@
 import org.tigris.gef.base.Editor;
 import org.tigris.gef.base.Globals;
 import org.tigris.gef.graph.GraphModel;
-import org.tigris.gef.graph.MutableGraphModel;
 import org.tigris.gef.presentation.Fig;
 
 /**
@@ -47,36 +45,29 @@
 public abstract class SelectionGeneralizableElement extends
         SelectionNodeClarifiers2 {
 
-    /**
-     * Logger.
-     */
-    private static final Logger LOG =
-            Logger.getLogger(SelectionGeneralizableElement.class);
-
     private static Icon inherit =
             ResourceLoaderWrapper.lookupIconResource("Generalization");
 
-    private static Icon icons[] = {null,
-                                   null,
-                                   null,
-                                   null,
-                                   null,
-                                   null,
-                                   null,                                   
-                                   null,
-                                   null,
-                                   null, // 9
-                                   inherit,
-                                   inherit,
-                                   null,
-                                   null,
-                                   null,
+    private static Icon[] icons = 
+    {inherit,
+     inherit,
+     null,
+     null,
+     null,
     };
-    
 
-    private boolean useComposite;
+    private static String[] instructions = 
+    {"Add a supertype",
+     "Add a subtype",
+     null,
+     null,
+     null,
+     "Move object(s)",
+    };
 
     
+    private boolean useComposite;
+
     /**
      * Construct a SelectionGeneralizableElement
      * 
@@ -87,10 +78,7 @@
         super(f);
     }
 
- 
-    /*
-     * @see org.argouml.uml.diagram.ui.SelectionNodeClarifiers#getIcons()
-     */
+    @Override
     protected Icon[] getIcons() {
         Editor ce = Globals.curEditor();
         GraphModel gm = ce.getGraphModel();
@@ -102,70 +90,37 @@
             return icons;
         }
     }
-    
-    /*
-     * @see org.argouml.uml.diagram.ui.SelectionNodeClarifiers#getInstructions(int)
-     */
+
+    @Override
     protected String getInstructions(int i) {
-        if (i == 10) {
-            return "Add a supertype";
-        } else if (i == 10) {
-            return "Add a subtype";
-        } else if (i == -1) {
-            return "Move object(s)";
-        }
-        return null;
+        return instructions[ i - 10];
     }
     
-
-    /*
-     * @see org.argouml.uml.diagram.ui.SelectionNodeClarifiers2#getNewEdgeType(int)
-     */
+    @Override
     protected Object getNewEdgeType(int i) {
         if (i == 10 || i == 11) {
             return Model.getMetaTypes().getGeneralization();
         }
         return null;
     }
-    /*
-     * @see org.argouml.uml.diagram.ui.SelectionNodeClarifiers#isDragEdgeReverse(int)
-     */
+    
+    @Override
     protected boolean isDragEdgeReverse(int i) {
         if (i == 11) {
             return true;
         }
         return false;
     }
- 
-    /*
-     * @see org.argouml.uml.diagram.ui.SelectionNodeClarifiers#isEdgePostProcessRequested()
-     */
+
+    @Override
     protected boolean isEdgePostProcessRequested() {
         return useComposite;
     }
-    
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#mouseEntered(java.awt.event.MouseEvent)
-     */
+
+    @Override
     public void mouseEntered(MouseEvent me) {
         super.mouseEntered(me);
         useComposite = me.isShiftDown();
     }
 
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#createEdgeAbove(org.tigris.gef.graph.MutableGraphModel, java.lang.Object)
-     */
-    protected Object createEdgeAbove(MutableGraphModel mgm, Object newNode) {
-        return mgm.connect(getContent().getOwner(), newNode,
-                           (Class) Model.getMetaTypes().getGeneralization());
-    }
-
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#createEdgeUnder(org.tigris.gef.graph.MutableGraphModel, java.lang.Object)
-     */
-    protected Object createEdgeUnder(MutableGraphModel mgm, Object newNode) {
-        return mgm.connect(newNode, getContent().getOwner(),
-                           (Class) Model.getMetaTypes().getGeneralization());
-    }
-
 }
\ No newline at end of file

Modified: trunk/src_new/org/argouml/uml/diagram/static_structure/ui/SelectionInterface.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/diagram/static_structure/ui/SelectionInterface.java?view=diff&rev=12589&p1=trunk/src_new/org/argouml/uml/diagram/static_structure/ui/SelectionInterface.java&p2=trunk/src_new/org/argouml/uml/diagram/static_structure/ui/SelectionInterface.java&r1=12588&r2=12589
==============================================================================
--- trunk/src_new/org/argouml/uml/diagram/static_structure/ui/SelectionInterface.java	(original)
+++ trunk/src_new/org/argouml/uml/diagram/static_structure/ui/SelectionInterface.java	2007-05-10 09:04:49-0700
@@ -29,18 +29,12 @@
 import org.argouml.application.helpers.ResourceLoaderWrapper;
 import org.argouml.model.Model;
 import org.argouml.uml.diagram.ui.SelectionNodeClarifiers2;
-import org.tigris.gef.graph.MutableGraphModel;
 import org.tigris.gef.presentation.Fig;
 
 /**
  * @author [email protected]
  */
 public class SelectionInterface extends SelectionNodeClarifiers2 {
-    /**
-     * Remember the pressed button, 
-     * for the case where the mouse is released not above a fig.
-     */
-    private int code;
 
     private static Icon realiz =
         ResourceLoaderWrapper.lookupIconResource("Realization");
@@ -48,21 +42,21 @@
     private static Icon inherit =
         ResourceLoaderWrapper.lookupIconResource("Generalization");
 
-    private static Icon icons[] = {null,
-                                   null,
-                                   null,
-                                   null,
-                                   null,
-                                   null,
-                                   null,                                   
-                                   null,
-                                   null,
-                                   null, // 9
-                                   inherit,
-                                   realiz,
-                                   null,
-                                   null,
-                                   null,
+    private static Icon icons[] = 
+    {inherit,
+     realiz,
+     null,
+     null,
+     null,
+    };
+    
+    private static String instructions[] = 
+    {"Add an interface",
+     "Add a realization",
+     null,
+     null,
+     null,
+     "Move object(s)",
     };
     
     /**
@@ -75,47 +69,19 @@
         super(f);
     }
 
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#createEdgeAbove(
-     *         org.tigris.gef.graph.MutableGraphModel, java.lang.Object)
-     */
-    protected Object createEdgeAbove(MutableGraphModel gm, Object newNode) {
-        return gm.connect(getContent().getOwner(), newNode,
-               (Class) Model.getMetaTypes().getGeneralization());
-    }
-
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#createEdgeUnder(
-     *      org.tigris.gef.graph.MutableGraphModel, java.lang.Object)
-     */
-    protected Object createEdgeUnder(MutableGraphModel gm, Object newNode) {
-        return gm.connect(newNode, getContent().getOwner(), (Class) Model
-                .getMetaTypes().getAbstraction());
-    }
-
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#getNewNode(int)
-     */
-    protected Object getNewNode(int buttonCode) {
-        if (buttonCode < 10) {
-            buttonCode = code;
+    @Override
+    protected Object getNewNode(int index) {
+        if (index == 0) {
+            index = getButton();
         }
-        if (buttonCode == 10) {
+        if (index == 10) {
             return Model.getCoreFactory().buildInterface();
         } else {
             return Model.getCoreFactory().buildClass();
         }
     }
 
-    /**
-     * The UID.
-     */
-    private static final long serialVersionUID = 7209387830978444644L;
-
-
-    /*
-     * @see org.argouml.uml.diagram.ui.SelectionNodeClarifiers2#getNewEdgeType(int)
-     */
+    @Override
     protected Object getNewEdgeType(int index) {
         if (index == 10) {
             return Model.getMetaTypes().getGeneralization();
@@ -125,9 +91,8 @@
         return null;
     }
 
-    /*
-     * @see org.argouml.uml.diagram.ui.SelectionNodeClarifiers2#getNewNodeType(int)
-     */
+
+    @Override
     protected Object getNewNodeType(int index) {
         if (index == 10) {
             return Model.getMetaTypes().getInterface();
@@ -137,30 +102,17 @@
         return null;
     }
 
-    /*
-     * @see org.argouml.uml.diagram.ui.SelectionNodeClarifiers2#getIcons()
-     */
+    @Override
     protected Icon[] getIcons() {
         return icons;
     }
 
-    /*
-     * @see org.argouml.uml.diagram.ui.SelectionNodeClarifiers2#getInstructions(int)
-     */
+    @Override
     protected String getInstructions(int index) {
-        if (index == 10) {
-            return "Add an interface";
-        } else if (index == 11) {
-            return "Add a realization";
-        } else if (index == -1) {
-            return "Move object(s)";
-        }
-        return null;
+        return instructions[index - 10];
     }
 
-    /*
-     * @see org.argouml.uml.diagram.ui.SelectionNodeClarifiers2#isDragEdgeReverse(int)
-     */
+    @Override
     protected boolean isDragEdgeReverse(int index) {
         if (index == 11) {
             return true;
@@ -168,10 +120,4 @@
         return false;
     }
 
-    /*
-     * @see org.argouml.uml.diagram.ui.SelectionNodeClarifiers2#isEdgePostProcessRequested()
-     */
-    protected boolean isEdgePostProcessRequested() {
-        return false;
-    }
 }

Modified: trunk/src_new/org/argouml/uml/diagram/static_structure/ui/SelectionSignal.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/diagram/static_structure/ui/SelectionSignal.java?view=diff&rev=12589&p1=trunk/src_new/org/argouml/uml/diagram/static_structure/ui/SelectionSignal.java&p2=trunk/src_new/org/argouml/uml/diagram/static_structure/ui/SelectionSignal.java&r1=12588&r2=12589
==============================================================================
--- trunk/src_new/org/argouml/uml/diagram/static_structure/ui/SelectionSignal.java	(original)
+++ trunk/src_new/org/argouml/uml/diagram/static_structure/ui/SelectionSignal.java	2007-05-10 09:04:49-0700
@@ -41,11 +41,11 @@
         super(f);
     }
 
-    protected Object getNewNode(int buttonCode) {
+    protected Object getNewNode(int index) {
         return Model.getCommonBehaviorFactory().createSignal();
     }
 
-    protected Object getNewNodeType(int buttonCode) {
+    protected Object getNewNodeType(int index) {
         return Model.getMetaTypes().getSignal();
     }
 }

Modified: trunk/src_new/org/argouml/uml/diagram/static_structure/ui/SelectionStereotype.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/diagram/static_structure/ui/SelectionStereotype.java?view=diff&rev=12589&p1=trunk/src_new/org/argouml/uml/diagram/static_structure/ui/SelectionStereotype.java&p2=trunk/src_new/org/argouml/uml/diagram/static_structure/ui/SelectionStereotype.java&r1=12588&r2=12589
==============================================================================
--- trunk/src_new/org/argouml/uml/diagram/static_structure/ui/SelectionStereotype.java	(original)
+++ trunk/src_new/org/argouml/uml/diagram/static_structure/ui/SelectionStereotype.java	2007-05-10 09:04:49-0700
@@ -24,29 +24,18 @@
 
 package org.argouml.uml.diagram.static_structure.ui;
 
-import java.awt.Graphics;
-import java.awt.Rectangle;
 import java.awt.event.MouseEvent;
 
 import javax.swing.Icon;
 
-import org.apache.log4j.Logger;
 import org.argouml.application.helpers.ResourceLoaderWrapper;
 import org.argouml.model.Model;
 import org.argouml.notation.providers.uml.NotationUtilityUml;
 import org.argouml.uml.diagram.deployment.DeploymentDiagramGraphModel;
-import org.argouml.uml.diagram.ui.SelectionNodeClarifiers;
-import org.tigris.gef.base.Editor;
+import org.argouml.uml.diagram.ui.SelectionNodeClarifiers2;
 import org.tigris.gef.base.Globals;
-import org.tigris.gef.base.ModeCreateEdgeAndNode;
-import org.tigris.gef.base.ModeManager;
-import org.tigris.gef.base.ModeModify;
-import org.tigris.gef.base.SelectionManager;
-import org.tigris.gef.graph.GraphModel;
 import org.tigris.gef.graph.MutableGraphModel;
 import org.tigris.gef.presentation.Fig;
-import org.tigris.gef.presentation.FigNode;
-import org.tigris.gef.presentation.Handle;
 
 /**
  * The buttons on selection for a Stereotype. <p>
@@ -56,27 +45,33 @@
  * 
  * @author michiel
  */
-public class SelectionStereotype extends SelectionNodeClarifiers {
+public class SelectionStereotype extends SelectionNodeClarifiers2 {
 
-    /**
-     * Logger.
-     */
-    private static final Logger LOG =
-        Logger.getLogger(SelectionStereotype.class);
-
-    /**
-     * Remember the pressed button, 
-     * for the case where the mouse is released not above a fig.
-     */
-    private int code;
-
-    private static Icon inherit =
+    private static Icon inheritIcon =
         ResourceLoaderWrapper.lookupIconResource("Generalization");
-    private static Icon depend =
+    private static Icon dependIcon =
         ResourceLoaderWrapper.lookupIconResource("Dependency");
 
     private boolean useComposite;
     
+    private static Icon icons[] = 
+    {inheritIcon,
+     dependIcon,
+     null,
+     null,
+     null,
+    };
+
+    // TODO: I18N required
+    private static String instructions[] = 
+    {"Add a baseClass",
+     "Add a subStereotype",
+     null,
+     null,
+     null,
+     "Move object(s)",
+    };
+
     /**
      * Construct a new  SelectionStereotype for the given Fig.
      *
@@ -86,131 +81,19 @@
         super(f);
     }
 
-    /*
-     * @see org.tigris.gef.base.Selection#hitHandle(java.awt.Rectangle,
-     *      org.tigris.gef.presentation.Handle)
-     */
-    public void hitHandle(Rectangle r, Handle h) {
-        super.hitHandle(r, h);
-        if (h.index != -1) {
-            return;
-        }
-        if (!isPaintButtons()) {
-            return;
-        }
-        Editor ce = Globals.curEditor();
-        SelectionManager sm = ce.getSelectionManager();
-        if (sm.size() != 1) {
-            return;
-        }
-        ModeManager mm = ce.getModeManager();
-        if (mm.includes(ModeModify.class) && getPressedButton() == -1) {
-            return;
-        }
-        int cx = getContent().getX();
-        int cy = getContent().getY();
-        int cw = getContent().getWidth();
-        int ch = getContent().getHeight();
-        int iw = inherit.getIconWidth();
-        int ih = inherit.getIconHeight();
-        int dw = depend.getIconWidth();
-        int dh = depend.getIconHeight();
-
-        if (hitAbove(cx + cw / 2, cy, dw, dh, r)) {
-            h.index = 10;
-            h.instructions = "Add a baseClass";
-        } else if (hitBelow(cx + cw / 2, cy + ch, iw, ih, r)) {
-            h.index = 11;
-            h.instructions = "Add a subStereotype";
-        } else {
-            h.index = -1;
-            h.instructions = "Move object(s)";
-        }
-    }
-    
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#paintButtons(Graphics)
-     */
-    public void paintButtons(Graphics g) {
-        int cx = getContent().getX();
-        int cy = getContent().getY();
-        int cw = getContent().getWidth();
-        int ch = getContent().getHeight();
-
-        // The next two lines are necessary to get the GraphModel,
-        // in the DeploymentDiagram there are no Generalizations
-        Editor ce = Globals.curEditor();
-        GraphModel gm = ce.getGraphModel();
-
-        if (!(gm instanceof DeploymentDiagramGraphModel)) {
-            paintButtonAbove(depend, g, cx + cw / 2, cy, 10);
-            paintButtonBelow(inherit, g, cx + cw / 2, cy + ch + 2, 11);
-        }
-    }
-
-
-    /*
-     * @see org.tigris.gef.base.Selection#dragHandle(int, int, int, int,
-     *      org.tigris.gef.presentation.Handle)
-     */
-    public void dragHandle(int mX, int mY, int anX, int anY, Handle hand) {
-        if (hand.index < 10) {
-            setPaintButtons(false);
-            super.dragHandle(mX, mY, anX, anY, hand);
-            return;
-        }
-        int cx = getContent().getX(), cy = getContent().getY();
-        int cw = getContent().getWidth(), ch = getContent().getHeight();
-        Object edgeType = null;
-        Object nodeType = getNewNodeType(hand.index);
-        int bx = mX, by = mY;
-        boolean reverse = false;
-        switch (hand.index) {
-        case 10: //add baseclass (dependency)
-            edgeType = Model.getMetaTypes().getDependency();
-            by = cy;
-            bx = cx + cw / 2;
-            break;
-        case 11: //add subdatatype
-            edgeType = Model.getMetaTypes().getGeneralization();
-            reverse = true;
-            by = cy + ch;
-            bx = cx + cw / 2;
-            break;
-        default:
-            LOG.warn("invalid handle number");
-            break;
-        }
-        code = hand.index;
-        if (edgeType != null && nodeType != null) {
-            Editor ce = Globals.curEditor();
-            ModeCreateEdgeAndNode m =
-                new ModeCreateEdgeAndNode(ce,
-                        edgeType, useComposite, this);
-            m.setup((FigNode) getContent(), getContent().getOwner(),
-                    bx, by, reverse);
-            ce.pushMode(m);
-        }
-
-    }
-
-    /*
-     * @see java.awt.event.MouseListener#mouseEntered(java.awt.event.MouseEvent)
-     */
+    @Override
     public void mouseEntered(MouseEvent me) {
         super.mouseEntered(me);
         useComposite = me.isShiftDown();
     }
 
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#getNewNode(int)
-     */
-    protected Object getNewNode(int buttonCode) {
-        if (buttonCode < 10) {
-            buttonCode = code;
+    @Override
+    protected Object getNewNode(int index) {
+        if (index == 0) {
+            index = getButton();
         }
         Object ns = Model.getFacade().getNamespace(getContent().getOwner());
-        switch (buttonCode) {
+        switch (index) {
         case 10:
             Object clazz = Model.getCoreFactory().buildClass(ns);
             NotationUtilityUml.dealWithStereotypes(clazz, "metaclass", false);
@@ -224,12 +107,9 @@
         return null;
     }
 
-    /**
-     * @param buttonCode the code for the pressed button
-     * @return the new object type
-     */
-    protected Object getNewNodeType(int buttonCode) {
-        switch (buttonCode) {
+    @Override
+    protected Object getNewNodeType(int index) {
+        switch (index) {
         case 10:
             return Model.getMetaTypes().getClass();
         case 11:
@@ -238,24 +118,49 @@
         return null;
     }
 
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#createEdgeAbove(
-     *         org.tigris.gef.graph.MutableGraphModel, java.lang.Object)
-     */
+    @Override
     protected Object createEdgeAbove(MutableGraphModel mgm, Object newNode) {
-        Object dep = mgm.connect(getContent().getOwner(), newNode,
-                           (Class) Model.getMetaTypes().getDependency());
+        Object dep = super.createEdgeAbove(mgm, newNode);
         NotationUtilityUml.dealWithStereotypes(dep, "stereotype", false);
         return dep;
     }
 
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#createEdgeUnder(
-     *         org.tigris.gef.graph.MutableGraphModel, java.lang.Object)
-     */
-    protected Object createEdgeUnder(MutableGraphModel mgm, Object newNode) {
-        return mgm.connect(newNode, getContent().getOwner(),
-                           (Class) Model.getMetaTypes().getGeneralization());
+    @Override
+    protected Icon[] getIcons() {
+        // In the DeploymentDiagram there are no Generalizations
+        if (!(Globals.curEditor().getGraphModel() 
+                instanceof DeploymentDiagramGraphModel)) {
+            return null;
+        }
+        return icons;
+    }
+
+    @Override
+    protected String getInstructions(int index) {
+        return instructions[index - 10];
+    }
+
+    @Override
+    protected Object getNewEdgeType(int index) {
+        if (index == 10) {
+            return Model.getMetaTypes().getDependency();
+        } else if (index == 11) {
+            return Model.getMetaTypes().getGeneralization();
+        }
+        return null;
+    }
+
+    @Override
+    protected boolean isDragEdgeReverse(int index) {
+        if (index == 11) {
+            return true;
+        }
+        return false;
+    }
+
+    @Override
+    protected boolean isEdgePostProcessRequested() {
+        return useComposite;
     }
 
 }

Modified: trunk/src_new/org/argouml/uml/diagram/ui/SelectionNodeClarifiers.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/diagram/ui/SelectionNodeClarifiers.java?view=diff&rev=12589&p1=trunk/src_new/org/argouml/uml/diagram/ui/SelectionNodeClarifiers.java&p2=trunk/src_new/org/argouml/uml/diagram/ui/SelectionNodeClarifiers.java&r1=12588&r2=12589
==============================================================================
--- trunk/src_new/org/argouml/uml/diagram/ui/SelectionNodeClarifiers.java	(original)
+++ trunk/src_new/org/argouml/uml/diagram/ui/SelectionNodeClarifiers.java	2007-05-10 09:04:49-0700
@@ -45,46 +45,30 @@
         super(f);
     }
 
-    /*
-     * @see org.argouml.uml.diagram.ui.SelectionNodeClarifiers2#getIcons()
-     */
+    @Override
     protected Icon[] getIcons() {
         return null;
     }
 
-    /*
-     * @see org.argouml.uml.diagram.ui.SelectionNodeClarifiers2#getInstructions(int)
-     */
+    @Override
     protected String getInstructions(int index) {
         return null;
     }
 
-    /*
-     * @see org.argouml.uml.diagram.ui.SelectionNodeClarifiers2#getNewNodeType(int)
-     */
+    @Override
     protected Object getNewNodeType(int index) {
         return null;
     }
 
-    /*
-     * @see org.argouml.uml.diagram.ui.SelectionNodeClarifiers2#getNewEdgeType(int)
-     */
+    @Override
     protected Object getNewEdgeType(int index) {
         return null;
     }
 
-    /*
-     * @see org.argouml.uml.diagram.ui.SelectionNodeClarifiers2#isDragEdgeReverse(int)
-     */
+    @Override
     protected boolean isDragEdgeReverse(int index) {
         return false;
     }
 
-    /*
-     * @see org.argouml.uml.diagram.ui.SelectionNodeClarifiers2#isEdgePostProcessRequested()
-     */
-    protected boolean isEdgePostProcessRequested() {
-        return false;
-    }
 } 
 

Modified: trunk/src_new/org/argouml/uml/diagram/ui/SelectionNodeClarifiers2.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/diagram/ui/SelectionNodeClarifiers2.java?view=diff&rev=12589&p1=trunk/src_new/org/argouml/uml/diagram/ui/SelectionNodeClarifiers2.java&p2=trunk/src_new/org/argouml/uml/diagram/ui/SelectionNodeClarifiers2.java&r1=12588&r2=12589
==============================================================================
--- trunk/src_new/org/argouml/uml/diagram/ui/SelectionNodeClarifiers2.java	(original)
+++ trunk/src_new/org/argouml/uml/diagram/ui/SelectionNodeClarifiers2.java	2007-05-10 09:04:49-0700
@@ -37,6 +37,7 @@
 import org.tigris.gef.base.ModeModify;
 import org.tigris.gef.base.SelectionButtons;
 import org.tigris.gef.base.SelectionManager;
+import org.tigris.gef.graph.MutableGraphModel;
 import org.tigris.gef.presentation.Fig;
 import org.tigris.gef.presentation.FigNode;
 import org.tigris.gef.presentation.Handle;
@@ -46,10 +47,12 @@
  * necessary for the enhanced support marked as abstract so that implementors
  * are forced to implement them.  SelectionNodeClarifiers is simple
  * extension of this which implements null versions of the required 
- * methods for backward compatibility with.
+ * methods for backward compatibility with the previous implementation.
  * <p>
  * To upgrade subtypes of SelectionNodeClarifiers, change them to 
  * extend this class instead and implement the required abstract methods.
+ * The methods paintButtons, dragHandle, hitHandle, and createEdge* can
+ * all usually be removed.
  *
  * @author jrobbins
  * @author Tom Morris
@@ -60,6 +63,8 @@
             Logger.getLogger(SelectionNodeClarifiers2.class);
 
 
+    private int button;
+    
     /**
      * Construct a new SelectionNodeClarifiers for the given Fig
      * 
@@ -91,20 +96,20 @@
         int cw = getContent().getWidth();
         int ch = getContent().getHeight();
         
-        if (icons[10] != null) {
-            paintButtonAbove(icons[10], g, cx + cw / 2, cy, 10);
+        if (icons[0] != null) {
+            paintButtonAbove(icons[0], g, cx + cw / 2, cy, 10);
         }
-        if (icons[11] != null) {
-            paintButtonBelow(icons[11], g, cx + cw / 2, cy + ch + 2, 11);
+        if (icons[1] != null) {
+            paintButtonBelow(icons[1], g, cx + cw / 2, cy + ch + 2, 11);
         }
-        if (icons[12] != null) {
-            paintButtonLeft(icons[12], g, cx + cw + 2, cy + ch / 2, 12);
+        if (icons[2] != null) {
+            paintButtonLeft(icons[2], g, cx + cw + 2, cy + ch / 2, 12);
         }
-        if (icons[13] != null) {
-            paintButtonRight(icons[13], g, cx, cy + ch / 2, 13);
+        if (icons[3] != null) {
+            paintButtonRight(icons[3], g, cx, cy + ch / 2, 13);
         }
-        if (icons[14] != null) {
-            paintButtonRight(icons[14], g, cx, cy + ch, 14);
+        if (icons[4] != null) {
+            paintButtonRight(icons[4], g, cx, cy + ch, 14);
         }
     }
 
@@ -163,28 +168,28 @@
          *            11
          * </pre>
          */
-        if (icons[10] != null && hitAbove(cx + cw / 2, cy, 
-                icons[10].getIconWidth(), icons[10].getIconHeight(), 
+        if (icons[0] != null && hitAbove(cx + cw / 2, cy, 
+                icons[0].getIconWidth(), icons[0].getIconHeight(), 
                 r)) {
             h.index = 10;
             h.instructions = getInstructions(h.index);
-        } else if (icons[11] != null && hitBelow(cx + cw / 2, cy + ch, 
-                icons[11].getIconWidth(), icons[11].getIconHeight(), 
+        } else if (icons[1] != null && hitBelow(cx + cw / 2, cy + ch, 
+                icons[1].getIconWidth(), icons[1].getIconHeight(), 
                 r)) {
             h.index = 11;
             h.instructions = getInstructions(h.index);
-        } else if (icons[12] != null && hitLeft(cx + cw, cy + ch / 2, 
-                icons[12].getIconWidth(), icons[12].getIconHeight(), 
+        } else if (icons[2] != null && hitLeft(cx + cw, cy + ch / 2, 
+                icons[2].getIconWidth(), icons[2].getIconHeight(), 
                 r)) {
             h.index = 12;
             h.instructions = getInstructions(h.index);
-        } else if (icons[13] != null && hitRight(cx, cy + ch / 2, 
-                icons[13].getIconWidth(), icons[13].getIconHeight(), 
+        } else if (icons[3] != null && hitRight(cx, cy + ch / 2, 
+                icons[3].getIconWidth(), icons[3].getIconHeight(), 
                 r)) {
             h.index = 13;
             h.instructions = getInstructions(h.index);
-        } else if (icons[14] != null && hitRight(cx, cy + ch - 10, 
-                icons[14].getIconWidth(), icons[14].getIconHeight(), 
+        } else if (icons[4] != null && hitRight(cx, cy + ch - 10, 
+                icons[4].getIconWidth(), icons[4].getIconHeight(), 
                 r)) {
             h.index = 14;
             h.instructions = getInstructions(h.index);
@@ -208,7 +213,11 @@
         int cw = getContent().getWidth(), ch = getContent().getHeight();
 
         int bx = mX, by = mY;
-
+        
+        // Remember what handle was clicked for the case where the drag
+        // is released over empty space
+        button = hand.index;
+        
         switch (hand.index) {
         case 10:
             by = cy;
@@ -247,21 +256,45 @@
             ce.pushMode(m);
         }
     }
+    
+
+    protected Object createEdgeAbove(MutableGraphModel gm, Object newNode) {
+        return gm.connect(getContent().getOwner(), newNode, getNewEdgeType(10));
+    }
+
+    protected Object createEdgeUnder(MutableGraphModel gm, Object newNode) {
+        return gm.connect(getContent().getOwner(), newNode, getNewEdgeType(11));
+    }
+
+    protected Object createEdgeLeft(MutableGraphModel gm, Object newNode) {
+        return gm.connect(getContent().getOwner(), newNode, getNewEdgeType(12));
+    }
+
+
+    protected Object createEdgeRight(MutableGraphModel gm, Object newNode) {
+        return gm.connect(getContent().getOwner(), newNode, getNewEdgeType(13));
+    }
+
+    protected Object createEdgeToSelf(MutableGraphModel gm) {
+        return gm.connect(
+                getContent().getOwner(), getContent().getOwner(),
+                getNewEdgeType(14));
+    }
 
     /**
      * Get array of icons to use when drawing handles.
      * @return icon or null
      */
-    abstract protected Icon[] getIcons();
+    protected abstract Icon[] getIcons();
 
     /**
-     * Get the "instructoins" string to pass to GEF for the given handle number.
+     * Get the "instructions" string to pass to GEF for the given handle number.
      * 
      * @param index
      *            handle number that is being dragged from
      * @return string or null
      */
-    abstract protected String getInstructions(int index);
+    protected abstract String getInstructions(int index);
     
     /**
      * Get the node type to create when dragging from the given handle number.
@@ -270,7 +303,7 @@
      *            handle number that is being dragged from
      * @return metatype for model element. Null to disallow drag.
      */
-    abstract protected Object getNewNodeType(int index);
+    protected abstract Object getNewNodeType(int index);
 
     /**
      * Get the edge type to create when dragging from the given handle number.
@@ -279,7 +312,7 @@
      *            handle number that is being dragged from
      * @return metatype for model element. Null to disallow drag.
      */
-    abstract protected Object getNewEdgeType(int index);
+    protected abstract Object getNewEdgeType(int index);
     
     /**
      * Get the node type to create when dragging from the given handle number.
@@ -287,9 +320,12 @@
      * @param index
      *            handle number that is being dragged from
      * @return true to reverse direction of assocation from direction of drag.
-     *         eg. specialization instead of generalization
+     *         eg. specialization instead of generalization.  Default
+     *         implementation always returns false.
      */
-    abstract protected boolean isDragEdgeReverse(int index);
+    protected boolean isDragEdgeReverse(int index) {
+        return false;
+    }
     
     /**
      * Request post processing of edge by GEF after it is created using
@@ -297,7 +333,16 @@
      * 
      * @return true if postprocessing requested
      */
-    abstract protected boolean isEdgePostProcessRequested();
+    protected boolean isEdgePostProcessRequested() {
+        return false;
+    }
+    
+    /**
+     * @return index of last button/handle that was clicked
+     */
+    protected int getButton() {
+        return button;
+    }
     
 } 
 

Modified: trunk/src_new/org/argouml/uml/diagram/use_case/ui/SelectionActor.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/diagram/use_case/ui/SelectionActor.java?view=diff&rev=12589&p1=trunk/src_new/org/argouml/uml/diagram/use_case/ui/SelectionActor.java&p2=trunk/src_new/org/argouml/uml/diagram/use_case/ui/SelectionActor.java&r1=12588&r2=12589
==============================================================================
--- trunk/src_new/org/argouml/uml/diagram/use_case/ui/SelectionActor.java	(original)
+++ trunk/src_new/org/argouml/uml/diagram/use_case/ui/SelectionActor.java	2007-05-10 09:04:49-0700
@@ -24,178 +24,105 @@
 
 package org.argouml.uml.diagram.use_case.ui;
 
-import java.awt.Graphics;
-import java.awt.Rectangle;
-
 import javax.swing.Icon;
 
-import org.apache.log4j.Logger;
 import org.argouml.application.helpers.ResourceLoaderWrapper;
 import org.argouml.model.Model;
-import org.argouml.uml.diagram.ui.SelectionNodeClarifiers;
-import org.tigris.gef.base.Editor;
-import org.tigris.gef.base.Globals;
-import org.tigris.gef.base.ModeCreateEdgeAndNode;
-import org.tigris.gef.base.ModeManager;
-import org.tigris.gef.base.ModeModify;
-import org.tigris.gef.base.SelectionManager;
-import org.tigris.gef.graph.MutableGraphModel;
+import org.argouml.uml.diagram.ui.SelectionNodeClarifiers2;
 import org.tigris.gef.presentation.Fig;
-import org.tigris.gef.presentation.FigNode;
-import org.tigris.gef.presentation.Handle;
 
 /**
  * @author [email protected]
  */
-public class SelectionActor extends SelectionNodeClarifiers {
-    /**
-     * Logger.
-     */
-    private static final Logger LOG = Logger.getLogger(SelectionActor.class);
+public class SelectionActor extends SelectionNodeClarifiers2 {
 
     /**
      * The icon for an association.
      */
-    private static Icon assoc =
+    private static Icon associationIcon =
 	ResourceLoaderWrapper.lookupIconResource("Association");
 
-
-
-    ////////////////////////////////////////////////////////////////
-    // constructors
+    private static Icon generalizationIcon =
+        ResourceLoaderWrapper.lookupIconResource("Generalization");
+    
+    private static Icon icons[] =
+    {generalizationIcon,
+     generalizationIcon,
+     associationIcon,
+     associationIcon,
+     null,
+    };
+
+// TODO: I18N required
+    private static String instructions[] =
+    {"Add a more general Actor",
+     "Add a more specialized Actor",
+     "Add an associated use case",
+     "Add an associated use case",
+     null,
+     "Move object(s)",
+    };
+
+    private static Object edgeType[] =
+    {Model.getMetaTypes().getGeneralization(),
+     Model.getMetaTypes().getGeneralization(),
+     Model.getMetaTypes().getAssociation(),
+     Model.getMetaTypes().getAssociation(),
+     null, 
+    };
 
     /**
      * Construct a new SelectionActor for the given Fig.
      *
      * @param f The given Fig.
      */
-    public SelectionActor(Fig f) { super(f); }
-
-    /*
-     * @see org.tigris.gef.base.Selection#hitHandle(java.awt.Rectangle,
-     *      org.tigris.gef.presentation.Handle)
-     */
-    public void hitHandle(Rectangle r, Handle h) {
-	super.hitHandle(r, h);
-	if (h.index != -1) {
-	    return;
-	}
-	if (!isPaintButtons()) {
-	    return;
-	}
-	Editor ce = Globals.curEditor();
-	SelectionManager sm = ce.getSelectionManager();
-	if (sm.size() != 1) {
-	    return;
-	}
-	ModeManager mm = ce.getModeManager();
-	if (mm.includes(ModeModify.class) && getPressedButton() == -1) {
-	    return;
-	}
-	int cx = getContent().getX();
-	int cy = getContent().getY();
-	int cw = getContent().getWidth();
-	int ch = getContent().getHeight();
-	int aw = assoc.getIconWidth();
-	int ah = assoc.getIconHeight();
-	if (hitLeft(cx + cw, cy + ch / 2, aw, ah, r)) {
-	    h.index = 12;
-	    h.instructions = "Add an associated use case";
-	} else if (hitRight(cx, cy + ch / 2, aw, ah, r)) {
-	    h.index = 13;
-	    h.instructions = "Add an associated use case";
-	} else {
-	    h.index = -1;
-	    h.instructions = "Move object(s)";
-	}
+    public SelectionActor(Fig f) {
+        super(f);
     }
 
-
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#paintButtons(Graphics)
-     */
-    public void paintButtons(Graphics g) {
-	int cx = getContent().getX();
-	int cy = getContent().getY();
-	int cw = getContent().getWidth();
-	int ch = getContent().getHeight();
-	paintButtonLeft(assoc, g, cx + cw, cy + ch / 2, 12);
-	paintButtonRight(assoc, g, cx, cy + ch / 2, 13);
+    @Override
+    protected Icon[] getIcons() {
+        return icons;
     }
 
-
-    /*
-     * @see org.tigris.gef.base.Selection#dragHandle(int, int, int, int,
-     * org.tigris.gef.presentation.Handle)
-     */
-    public void dragHandle(int mX, int mY, int anX, int anY, Handle hand) {
-	if (hand.index < 10) {
-	    setPaintButtons(false);
-	    super.dragHandle(mX, mY, anX, anY, hand);
-	    return;
-	}
-	int cx = getContent().getX(), cy = getContent().getY();
-	int cw = getContent().getWidth(), ch = getContent().getHeight();
-	Object edgeType = null;
-	Object nodeType = Model.getMetaTypes().getUseCase();
-	int bx = mX, by = mY;
-	boolean reverse = false;
-	switch (hand.index) {
-	case 12: //add assoc
-	    edgeType = Model.getMetaTypes().getAssociation();
-	    by = cy + ch / 2;
-	    bx = cx + cw;
-	    break;
-	case 13: // add assoc
-	    edgeType = Model.getMetaTypes().getAssociation();
-	    reverse = true;
-	    by = cy + ch / 2;
-	    bx = cx;
-	    break;
-	default:
-	    LOG.warn("invalid handle number");
-	    break;
-	}
-	if (edgeType != null && nodeType != null) {
-	    Editor ce = Globals.curEditor();
-	    ModeCreateEdgeAndNode m =
-	        new ModeCreateEdgeAndNode(ce, edgeType, false, this);
-	    m.setup((FigNode) getContent(), getContent().getOwner(),
-	            bx, by, reverse);
-	    ce.pushMode(m);
-	}
-
+    @Override
+    protected String getInstructions(int index) {
+        return instructions[index - 10];
     }
 
-
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#getNewNode(int)
-     */
-    protected Object getNewNode(int buttonCode) {
-        return Model.getUseCasesFactory().createUseCase();
+    @Override
+    protected Object getNewEdgeType(int index) {
+        return edgeType[index - 10];
     }
 
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#createEdgeLeft(
-     *         org.tigris.gef.graph.MutableGraphModel, java.lang.Object)
-     */
-    protected Object createEdgeLeft(MutableGraphModel gm, Object newNode) {
-        return gm.connect(newNode, getContent().getOwner(),
-            // TODO: Remove when GEF with this fixed and incorporated
-            // http://gef.tigris.org/issues/show_bug.cgi?id=203
-		  (Class) Model.getMetaTypes().getAssociation());
+    @Override
+    protected Object getNewNodeType(int index) {
+        if (index == 10 || index == 11) {
+            return Model.getMetaTypes().getActor();
+        } else {
+            return Model.getMetaTypes().getUseCase();
+        }
+    }
+    
+    @Override
+    protected Object getNewNode(int index) {
+        if (index == 0) {
+            index = getButton();
+        }
+        if (index == 10 || index == 11) {
+            return Model.getUseCasesFactory().createActor();
+        } else {
+            return Model.getUseCasesFactory().createUseCase();
+        }
     }
 
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#createEdgeRight(
-     *         org.tigris.gef.graph.MutableGraphModel, java.lang.Object)
-     */
-    protected Object createEdgeRight(MutableGraphModel gm, Object newNode) {
-        return gm.connect(getContent().getOwner(), newNode ,
-            // TODO: Remove when GEF with this fixed and incorporated
-            // http://gef.tigris.org/issues/show_bug.cgi?id=203
-			  (Class) Model.getMetaTypes().getAssociation());
+    @Override
+    protected boolean isDragEdgeReverse(int index) {
+        if (index == 11 || index == 13) {
+            return true;
+        }
+        return false;
     }
 
-} /* end class SelectionActor */
+}
 

Modified: trunk/src_new/org/argouml/uml/diagram/use_case/ui/SelectionUseCase.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/diagram/use_case/ui/SelectionUseCase.java?view=diff&rev=12589&p1=trunk/src_new/org/argouml/uml/diagram/use_case/ui/SelectionUseCase.java&p2=trunk/src_new/org/argouml/uml/diagram/use_case/ui/SelectionUseCase.java&r1=12588&r2=12589
==============================================================================
--- trunk/src_new/org/argouml/uml/diagram/use_case/ui/SelectionUseCase.java	(original)
+++ trunk/src_new/org/argouml/uml/diagram/use_case/ui/SelectionUseCase.java	2007-05-10 09:04:49-0700
@@ -24,51 +24,49 @@
 
 package org.argouml.uml.diagram.use_case.ui;
 
-import java.awt.Graphics;
-import java.awt.Rectangle;
-
 import javax.swing.Icon;
 
-import org.apache.log4j.Logger;
 import org.argouml.application.helpers.ResourceLoaderWrapper;
 import org.argouml.model.Model;
-import org.argouml.uml.diagram.ui.SelectionNodeClarifiers;
-import org.tigris.gef.base.Editor;
-import org.tigris.gef.base.Globals;
-import org.tigris.gef.base.ModeCreateEdgeAndNode;
-import org.tigris.gef.base.ModeManager;
-import org.tigris.gef.base.ModeModify;
-import org.tigris.gef.base.SelectionManager;
-import org.tigris.gef.graph.MutableGraphModel;
+import org.argouml.uml.diagram.ui.SelectionNodeClarifiers2;
 import org.tigris.gef.presentation.Fig;
-import org.tigris.gef.presentation.FigNode;
-import org.tigris.gef.presentation.Handle;
 
 /**
  * @author [email protected]
  */
-public class SelectionUseCase extends SelectionNodeClarifiers {
-    /**
-     * Logger.
-     */
-    private static final Logger LOG =
-        Logger.getLogger(SelectionUseCase.class);
+public class SelectionUseCase extends SelectionNodeClarifiers2 {
 
-    /**
-     * Remember the pressed button, 
-     * for the case where the mouse is released not above a fig.
-     */
-    private int code;
-
-    ////////////////////////////////////////////////////////////////
-    // constants
     private static Icon inherit =
         ResourceLoaderWrapper.lookupIconResource("Generalization");
     private static Icon assoc =
         ResourceLoaderWrapper.lookupIconResource("Association");
+    
+    private static Icon icons[] =
+    {inherit,
+     inherit,
+     assoc,
+     assoc,
+     null,
+    };
+
+    // TODO: I18N required
+    private static String instructions[] =
+    {"Add a more general use case",
+     "Add a more specialized use case",
+     "Add an associated actor",
+     "Add an associated actor",
+     null,
+     "Move object(s)",
+    };
+
+    private static Object edgeType[] =
+    {Model.getMetaTypes().getGeneralization(),
+     Model.getMetaTypes().getGeneralization(),
+     Model.getMetaTypes().getAssociation(),
+     Model.getMetaTypes().getAssociation(),
+     null, 
+    };
 
-    ////////////////////////////////////////////////////////////////
-    // constructors
 
     /**
      * Construct a new SelectionUseCase for the given Fig.
@@ -79,187 +77,46 @@
         super(f);
     }
 
-    /*
-     * @see org.tigris.gef.base.Selection#hitHandle(java.awt.Rectangle,
-     *      org.tigris.gef.presentation.Handle)
-     */
-    public void hitHandle(Rectangle r, Handle h) {
-        super.hitHandle(r, h);
-        if (h.index != -1) {
-            return;
-        }
-        if (!isPaintButtons()) {
-            return;
-        }
-        Editor ce = Globals.curEditor();
-        SelectionManager sm = ce.getSelectionManager();
-        if (sm.size() != 1) {
-            return;
-        }
-        ModeManager mm = ce.getModeManager();
-        if (mm.includes(ModeModify.class) && getPressedButton() == -1) {
-            return;
-        }
-        int cx = getContent().getX();
-        int cy = getContent().getY();
-        int cw = getContent().getWidth();
-        int ch = getContent().getHeight();
-        int iw = inherit.getIconWidth();
-        int ih = inherit.getIconHeight();
-        int aw = assoc.getIconWidth();
-        int ah = assoc.getIconHeight();
-        if (hitAbove(cx + cw / 2, cy, iw, ih, r)) {
-            h.index = 10;
-            h.instructions = "Add a more general use case";
-        } else if (hitBelow(cx + cw / 2, cy + ch, iw, ih, r)) {
-            h.index = 11;
-            h.instructions = "Add a specialized use case";
-        } else if (hitLeft(cx + cw, cy + ch / 2, aw, ah, r)) {
-            h.index = 12;
-            h.instructions = "Add an associated actor";
-        } else if (hitRight(cx, cy + ch / 2, aw, ah, r)) {
-            h.index = 13;
-            h.instructions = "Add an associated actor";
-        } else {
-            h.index = -1;
-            h.instructions = "Move object(s)";
-        }
-    }
-
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#paintButtons(Graphics)
-     */
-    public void paintButtons(Graphics g) {
-        int cx = getContent().getX();
-        int cy = getContent().getY();
-        int cw = getContent().getWidth();
-        int ch = getContent().getHeight();
-        paintButtonAbove(inherit, g, cx + cw / 2, cy, 10);
-        paintButtonBelow(inherit, g, cx + cw / 2, cy + ch, 11);
-        paintButtonLeft(assoc, g, cx + cw, cy + ch / 2, 12);
-        paintButtonRight(assoc, g, cx, cy + ch / 2, 13);
-    }
-
-    /*
-     * @see org.tigris.gef.base.Selection#dragHandle(int, int, int, int,
-     * org.tigris.gef.presentation.Handle)
-     */
-    public void dragHandle(int mX, int mY, int anX, int anY, Handle hand) {
-        if (hand.index < 10) {
-            setPaintButtons(false);
-            super.dragHandle(mX, mY, anX, anY, hand);
-            return;
-        }
-        int cx = getContent().getX(), cy = getContent().getY();
-        int cw = getContent().getWidth(), ch = getContent().getHeight();
-        Object edgeType = null;
-        Object nodeType = null;
-        if (hand.index == 10 || hand.index == 11) {
-            nodeType = Model.getMetaTypes().getUseCase();
-        } else {
-            nodeType = Model.getMetaTypes().getActor();
-        }
-
-        int bx = mX, by = mY;
-        boolean reverse = false;
-        switch (hand.index) {
-	case 10 : //add superclass
-	    edgeType = Model.getMetaTypes().getGeneralization();
-	    by = cy;
-	    bx = cx + cw / 2;
-	    break;
-	case 11 : //add subclass
-	    edgeType = Model.getMetaTypes().getGeneralization();
-	    reverse = true;
-	    by = cy + ch;
-	    bx = cx + cw / 2;
-	    break;
-	case 12 : //add assoc
-	    edgeType = Model.getMetaTypes().getAssociation();
-	    by = cy + ch / 2;
-	    bx = cx + cw;
-	    break;
-	case 13 : // add assoc
-	    edgeType = Model.getMetaTypes().getAssociation();
-	    reverse = true;
-	    by = cy + ch / 2;
-	    bx = cx;
-	    break;
-	default :
-	    LOG.warn("invalid handle number");
-	    break;
-        }
-        code = hand.index;
-        if (edgeType != null && nodeType != null) {
-            Editor ce = Globals.curEditor();
-            ModeCreateEdgeAndNode m =
-                new ModeCreateEdgeAndNode(ce, edgeType, false, this);
-            m.setup((FigNode) getContent(), getContent().getOwner(),
-                    bx, by, reverse);
-            ce.pushMode(m);
-        }
-
+    @Override
+    protected Icon[] getIcons() {
+        return icons;
     }
 
-
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#createEdgeAbove(
-     *         org.tigris.gef.graph.MutableGraphModel, java.lang.Object)
-     */
-    protected Object createEdgeAbove(MutableGraphModel gm, Object newNode) {
-        return gm.connect(getContent().getOwner(), newNode,
-                // TODO: Remove when GEF with this fixed and incorporated
-                // http://gef.tigris.org/issues/show_bug.cgi?id=203
-               (Class) Model.getMetaTypes().getGeneralization());
+    @Override
+    protected String getInstructions(int index) {
+        return instructions[index - 10];
     }
 
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#createEdgeLeft(
-     *         org.tigris.gef.graph.MutableGraphModel, java.lang.Object)
-     */
-    protected Object createEdgeLeft(MutableGraphModel gm, Object newNode) {
-        return gm.connect(newNode, getContent().getOwner(),
-            // TODO: Remove (Class) when GEF with this fixed and incorporated
-            // http://gef.tigris.org/issues/show_bug.cgi?id=203
-            (Class) Model.getMetaTypes().getAssociation());
+    @Override
+    protected Object getNewEdgeType(int index) {
+        return edgeType[index - 10];
     }
 
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#createEdgeRight(
-     *         org.tigris.gef.graph.MutableGraphModel, java.lang.Object)
-     */
-    protected Object createEdgeRight(MutableGraphModel gm, Object newNode) {
-        return gm.connect(getContent().getOwner(), newNode,
-            // TODO: Remove when GEF with this fixed and incorporated
-            // http://gef.tigris.org/issues/show_bug.cgi?id=203
-			  (Class) Model.getMetaTypes().getAssociation());
+    @Override
+    protected Object getNewNode(int index) {
+        if (index == 0) {
+            index = getButton();
+        }
+        if (index == 10 || index == 11) {
+            return Model.getUseCasesFactory().createUseCase();
+        } 
+        return Model.getUseCasesFactory().createActor();
     }
-
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#createEdgeUnder(
-     *         org.tigris.gef.graph.MutableGraphModel, java.lang.Object)
-     */
-    protected Object createEdgeUnder(MutableGraphModel gm, Object newNode) {
-        return gm.connect(newNode, getContent().getOwner(),
-            // TODO: Remove when GEF with this fixed and incorporated
-            // http://gef.tigris.org/issues/show_bug.cgi?id=203
-			  (Class) Model.getMetaTypes().getGeneralization());
+    
+    @Override
+    protected Object getNewNodeType(int index) {
+        if (index == 10 || index == 11) {
+            return Model.getMetaTypes().getUseCase();
+        } 
+        return Model.getMetaTypes().getActor();
     }
 
-    /*
-     * @see org.tigris.gef.base.SelectionButtons#getNewNode(int)
-     */
-    protected Object getNewNode(int buttonCode) {
-        Object newNode = null;
-        if (buttonCode < 10) {
-            buttonCode = code;
-        }
-        if (buttonCode == 10 || buttonCode == 11) {
-            newNode = Model.getUseCasesFactory().createUseCase();
-        } else {
-            newNode = Model.getUseCasesFactory().createActor();
-        }
-        return newNode;
+    @Override
+    protected boolean isDragEdgeReverse(int index) {
+        if (index == 11) {
+            return true;
+        } 
+        return false;
     }
 
-} /* end class SelectionUseCase */
+}
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.