Author: mvw
Date: 2007-09-02 06:53:08-0700
New Revision: 13477
Modified:
trunk/src_new/org/argouml/uml/diagram/UmlDiagramRenderer.java
trunk/src_new/org/argouml/uml/diagram/static_structure/ClassDiagramGraphModel.java
trunk/src_new/org/argouml/uml/diagram/static_structure/ui/ClassDiagramRenderer.java
trunk/src_new/org/argouml/uml/diagram/static_structure/ui/FigInstance.java
trunk/src_new/org/argouml/uml/diagram/ui/ActionAddExistingNodes.java
trunk/src_new/org/argouml/uml/diagram/ui/AddExistingNodeCommand.java
trunk/src_new/org/argouml/uml/diagram/ui/DnDJGraph.java
Log:
Fix for issue 3930: Add to Diagram for multiple selection.
Various improvements for "Add to diagram".
Modified: trunk/src_new/org/argouml/uml/diagram/UmlDiagramRenderer.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/diagram/UmlDiagramRenderer.java?view=diff&rev=13477&p1=trunk/src_new/org/argouml/uml/diagram/UmlDiagramRenderer.java&p2=trunk/src_new/org/argouml/uml/diagram/UmlDiagramRenderer.java&r1=13476&r2=13477
==============================================================================
--- trunk/src_new/org/argouml/uml/diagram/UmlDiagramRenderer.java (original)
+++ trunk/src_new/org/argouml/uml/diagram/UmlDiagramRenderer.java 2007-09-02 06:53:08-0700
@@ -63,7 +63,6 @@
import org.argouml.uml.diagram.static_structure.ui.FigDataType;
import org.argouml.uml.diagram.static_structure.ui.FigEdgeNote;
import org.argouml.uml.diagram.static_structure.ui.FigEnumeration;
-import org.argouml.uml.diagram.static_structure.ui.FigInstance;
import org.argouml.uml.diagram.static_structure.ui.FigInterface;
import org.argouml.uml.diagram.static_structure.ui.FigLink;
import org.argouml.uml.diagram.static_structure.ui.FigModel;
@@ -166,8 +165,6 @@
figNode = new FigComponent();
} else if (Model.getFacade().isAComponentInstance(node)) {
figNode = new FigComponentInstance();
- } else if (Model.getFacade().isAInstance(node)) {
- figNode = new FigInstance();
} else if (Model.getFacade().isAObject(node)) {
figNode = new FigObject();
} else if (Model.getFacade().isAComment(node)) {
Modified: trunk/src_new/org/argouml/uml/diagram/static_structure/ClassDiagramGraphModel.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/diagram/static_structure/ClassDiagramGraphModel.java?view=diff&rev=13477&p1=trunk/src_new/org/argouml/uml/diagram/static_structure/ClassDiagramGraphModel.java&p2=trunk/src_new/org/argouml/uml/diagram/static_structure/ClassDiagramGraphModel.java&r1=13476&r2=13477
==============================================================================
--- trunk/src_new/org/argouml/uml/diagram/static_structure/ClassDiagramGraphModel.java (original)
+++ trunk/src_new/org/argouml/uml/diagram/static_structure/ClassDiagramGraphModel.java 2007-09-02 06:53:08-0700
@@ -226,6 +226,9 @@
if (Model.getFacade().isAModel(node)) {
return false; // issue 3774
}
+ if (Model.getFacade().isAClassifierRole(node)) {
+ return false;
+ }
return Model.getFacade().isAClassifier(node)
|| Model.getFacade().isAPackage(node)
|| Model.getFacade().isAStereotype(node)
Modified: trunk/src_new/org/argouml/uml/diagram/static_structure/ui/ClassDiagramRenderer.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/diagram/static_structure/ui/ClassDiagramRenderer.java?view=diff&rev=13477&p1=trunk/src_new/org/argouml/uml/diagram/static_structure/ui/ClassDiagramRenderer.java&p2=trunk/src_new/org/argouml/uml/diagram/static_structure/ui/ClassDiagramRenderer.java&r1=13476&r2=13477
==============================================================================
--- trunk/src_new/org/argouml/uml/diagram/static_structure/ui/ClassDiagramRenderer.java (original)
+++ trunk/src_new/org/argouml/uml/diagram/static_structure/ui/ClassDiagramRenderer.java 2007-09-02 06:53:08-0700
@@ -34,7 +34,9 @@
import org.argouml.uml.CommentEdge;
import org.argouml.uml.diagram.GraphChangeAdapter;
import org.argouml.uml.diagram.UmlDiagramRenderer;
+import org.argouml.uml.diagram.deployment.ui.FigComponent;
import org.argouml.uml.diagram.deployment.ui.FigComponentInstance;
+import org.argouml.uml.diagram.deployment.ui.FigMNode;
import org.argouml.uml.diagram.deployment.ui.FigNodeInstance;
import org.argouml.uml.diagram.deployment.ui.FigObject;
import org.argouml.uml.diagram.ui.FigAssociation;
@@ -116,8 +118,6 @@
figNode = new FigClass(gm, node);
} else if (Model.getFacade().isAInterface(node)) {
figNode = new FigInterface(gm, node);
- } else if (Model.getFacade().isAInstance(node)) {
- figNode = new FigInstance(gm, node);
} else if (Model.getFacade().isAModel(node)) {
figNode = new FigModel(gm, node);
} else if (Model.getFacade().isASubsystem(node)) {
@@ -148,6 +148,10 @@
figNode = new FigNodeInstance(gm, node);
} else if (Model.getFacade().isAComponentInstance(node)) {
figNode = new FigComponentInstance(gm, node);
+ } else if (Model.getFacade().isANode(node)) {
+ figNode = new FigMNode(gm, node);
+ } else if (Model.getFacade().isAComponent(node)) {
+ figNode = new FigComponent(gm, node);
} else {
LOG.error("TODO: ClassDiagramRenderer getFigNodeFor " + node);
throw new IllegalArgumentException(
Modified: trunk/src_new/org/argouml/uml/diagram/static_structure/ui/FigInstance.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/diagram/static_structure/ui/FigInstance.java?view=diff&rev=13477&p1=trunk/src_new/org/argouml/uml/diagram/static_structure/ui/FigInstance.java&p2=trunk/src_new/org/argouml/uml/diagram/static_structure/ui/FigInstance.java&r1=13476&r2=13477
==============================================================================
--- trunk/src_new/org/argouml/uml/diagram/static_structure/ui/FigInstance.java (original)
+++ trunk/src_new/org/argouml/uml/diagram/static_structure/ui/FigInstance.java 2007-09-02 06:53:08-0700
@@ -35,15 +35,15 @@
import org.tigris.gef.presentation.FigText;
/**
- * Class to display graphics for a UML MInstance in a diagram.
+ * Class to display graphics for a UML MInstance in a diagram.<p>
*
- * TODO: The UML element 'Instance' is abstract. Shouldn't this
- * figure be too? If not, it should only be used as a last resort
- * fallback if no more specialized type can be found. - tfm - 20070508
+ * The UML element 'Instance' is abstract. <p>
+ *
+ * TODO: This Fig is not used - can we remove it?
*
* @author agauthie
*/
-public class FigInstance extends FigNodeModelElement {
+public abstract class FigInstance extends FigNodeModelElement {
/** UML does not really use ports, so just define one big one so
* that users can drag edges to or from any point in the icon. */
Modified: trunk/src_new/org/argouml/uml/diagram/ui/ActionAddExistingNodes.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/diagram/ui/ActionAddExistingNodes.java?view=diff&rev=13477&p1=trunk/src_new/org/argouml/uml/diagram/ui/ActionAddExistingNodes.java&p2=trunk/src_new/org/argouml/uml/diagram/ui/ActionAddExistingNodes.java&r1=13476&r2=13477
==============================================================================
--- trunk/src_new/org/argouml/uml/diagram/ui/ActionAddExistingNodes.java (original)
+++ trunk/src_new/org/argouml/uml/diagram/ui/ActionAddExistingNodes.java 2007-09-02 06:53:08-0700
@@ -1,5 +1,5 @@
// $Id$
-// Copyright (c) 2006 The Regents of the University of California. All
+// Copyright (c) 2006-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
@@ -25,14 +25,14 @@
package org.argouml.uml.diagram.ui;
+import java.awt.Point;
import java.awt.event.ActionEvent;
import java.util.Collection;
-import java.util.Iterator;
import org.argouml.kernel.ProjectManager;
import org.argouml.model.Model;
+import org.argouml.ui.targetmanager.TargetManager;
import org.argouml.uml.diagram.ArgoDiagram;
-import org.argouml.uml.reveng.DiagramInterface;
import org.tigris.gef.base.Globals;
import org.tigris.gef.graph.MutableGraphModel;
import org.tigris.gef.undo.UndoableAction;
@@ -79,28 +79,53 @@
return false;
}
- /*
- * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
- */
@Override
public void actionPerformed(ActionEvent ae) {
super.actionPerformed(ae);
if (!objects.isEmpty()) {
- // Use DiagramInterface to add classes to diagram
ArgoDiagram dia = ProjectManager.getManager().getCurrentProject()
.getActiveDiagram();
- if (dia != null) {
- DiagramInterface diagram =
- new DiagramInterface(Globals.curEditor());
- diagram.setCurrentDiagram(dia);
- for (Object o : objects) {
- if (Model.getFacade().isAClass(o)) {
- diagram.addClass(o, false);
- } else if (Model.getFacade().isAInterface(o)) {
- diagram.addInterface(o, false);
+ addNodes(objects, null, dia);
+ }
+ }
+
+ /**
+ * @param modelElements the modelelements to add Nodes for
+ * @param location the point where to drop the node.
+ * Also <code>null</code> is acceptable.
+ * @param diagram the diagram to add the nodes to
+ */
+ public static void addNodes(Collection modelElements,
+ Point location, ArgoDiagram diagram) {
+ MutableGraphModel gm = (MutableGraphModel) diagram.getGraphModel();
+ Collection oldTargets = TargetManager.getInstance().getTargets();
+ int count = 0;
+ for (Object me : modelElements) {
+ if (Model.getFacade().isANaryAssociation(me)) {
+ AddExistingNodeCommand cmd =
+ new AddExistingNodeCommand(me, location,
+ count++);
+ cmd.execute();
+ } else if (Model.getFacade().isAUMLElement(me)) {
+ if (gm.canAddEdge(me)) {
+ gm.addEdge(me);
+ // TODO: An AssociationClass should be possible to add
+ // as a side effect of adding a node and its related
+ // edges, but that doesn't work as things are currently
+ // structured. - tfm 20061208
+ if (Model.getFacade().isAAssociationClass(me)) {
+ ModeCreateAssociationClass.buildInActiveLayer(
+ Globals.curEditor(),
+ me);
}
+ } else if (gm.canAddNode(me)) {
+ AddExistingNodeCommand cmd =
+ new AddExistingNodeCommand(me, location,
+ count++);
+ cmd.execute();
}
}
}
+ TargetManager.getInstance().setTargets(oldTargets);
}
}
Modified: trunk/src_new/org/argouml/uml/diagram/ui/AddExistingNodeCommand.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/diagram/ui/AddExistingNodeCommand.java?view=diff&rev=13477&p1=trunk/src_new/org/argouml/uml/diagram/ui/AddExistingNodeCommand.java&p2=trunk/src_new/org/argouml/uml/diagram/ui/AddExistingNodeCommand.java&r1=13476&r2=13477
==============================================================================
--- trunk/src_new/org/argouml/uml/diagram/ui/AddExistingNodeCommand.java (original)
+++ trunk/src_new/org/argouml/uml/diagram/ui/AddExistingNodeCommand.java 2007-09-02 06:53:08-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
@@ -54,9 +54,9 @@
private Object object;
/**
- * the DropTargetDropEvent that caused this action.
+ * the location to drop the node.
*/
- private DropTargetDropEvent dropEvent;
+ private Point location;
/**
* 0 if this is the 1st element dropped here,
@@ -85,7 +85,21 @@
public AddExistingNodeCommand(Object o, DropTargetDropEvent event,
int cnt) {
object = o;
- dropEvent = event;
+ location = event.getLocation();
+ count = cnt;
+ }
+
+ /**
+ * @param o the UML modelelement to be added
+ * @param dropLocation the point where to drop the node.
+ * Also <code>null</code> is acceptable.
+ * @param cnt 0 if this is the 1st element dropped here,
+ * n if this is the (n+1)-th element dropped here.
+ */
+ public AddExistingNodeCommand(Object o, Point dropLocation,
+ int cnt) {
+ object = o;
+ location = dropLocation;
count = cnt;
}
@@ -112,7 +126,7 @@
ModePlace placeMode = new ModePlace(this, instructions);
placeMode.setAddRelatedEdges(true);
- if (dropEvent == null) {
+ if (location == null) {
Globals.mode(placeMode, false);
} else {
/* Calculate the drop location, and place every n-th element
@@ -120,8 +134,8 @@
*/
Point p =
new Point(
- dropEvent.getLocation().x + (count * 100),
- dropEvent.getLocation().y);
+ location.x + (count * 100),
+ location.y);
/* Take canvas scrolling into account.
* The implementation below does place the element correctly
* when the canvas has been scrolled.
Modified: trunk/src_new/org/argouml/uml/diagram/ui/DnDJGraph.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/diagram/ui/DnDJGraph.java?view=diff&rev=13477&p1=trunk/src_new/org/argouml/uml/diagram/ui/DnDJGraph.java&p2=trunk/src_new/org/argouml/uml/diagram/ui/DnDJGraph.java&r1=13476&r2=13477
==============================================================================
--- trunk/src_new/org/argouml/uml/diagram/ui/DnDJGraph.java (original)
+++ trunk/src_new/org/argouml/uml/diagram/ui/DnDJGraph.java 2007-09-02 06:53:08-0700
@@ -34,18 +34,15 @@
import java.awt.dnd.DropTargetListener;
import java.io.IOException;
import java.util.Collection;
-import java.util.Iterator;
import org.apache.log4j.Logger;
import org.argouml.kernel.ProjectManager;
-import org.argouml.model.Model;
import org.argouml.ui.TransferableModelElements;
-import org.argouml.ui.targetmanager.TargetManager;
+import org.argouml.uml.diagram.ArgoDiagram;
import org.tigris.gef.base.Diagram;
import org.tigris.gef.base.Editor;
import org.tigris.gef.graph.ConnectionConstrainer;
import org.tigris.gef.graph.GraphModel;
-import org.tigris.gef.graph.MutableGraphModel;
import org.tigris.gef.graph.presentation.JGraph;
/**
@@ -180,44 +177,16 @@
dropTargetDropEvent.acceptDrop(dropTargetDropEvent.getDropAction());
//get the model elements that are being transfered.
Collection modelElements;
- MutableGraphModel gm =
- (MutableGraphModel) ProjectManager.getManager().
- getCurrentProject().getActiveDiagram().getGraphModel();
try {
- Collection oldTargets = TargetManager.getInstance().getTargets();
+ ArgoDiagram diagram = ProjectManager.getManager()
+ .getCurrentProject().getActiveDiagram();
modelElements =
(Collection) tr.getTransferData(
TransferableModelElements.UML_COLLECTION_FLAVOR);
- int count = 0;
- Iterator i = modelElements.iterator();
- while (i.hasNext()) {
- Object me = i.next();
- if (Model.getFacade().isANaryAssociation(me)) {
- AddExistingNodeCommand cmd =
- new AddExistingNodeCommand(me, dropTargetDropEvent,
- count++);
- cmd.execute();
- } else if (Model.getFacade().isAUMLElement(me)) {
- if (gm.canAddEdge(me)) {
- gm.addEdge(me);
- // TODO: An AssociationClass should be possible to add
- // as a side effect of adding a node and its related
- // edges, but that doesn't work as things are currently
- // structured. - tfm 20061208
- if (Model.getFacade().isAAssociationClass(me)) {
- ModeCreateAssociationClass.buildInActiveLayer(
- getEditor(),
- me);
- }
- } else if (gm.canAddNode(me)) {
- AddExistingNodeCommand cmd =
- new AddExistingNodeCommand(me, dropTargetDropEvent,
- count++);
- cmd.execute();
- }
- }
- }
- TargetManager.getInstance().setTargets(oldTargets);
+
+ ActionAddExistingNodes.addNodes(modelElements,
+ dropTargetDropEvent.getLocation(), diagram);
+
dropTargetDropEvent.getDropTargetContext().dropComplete(true);
} catch (UnsupportedFlavorException e) {
LOG.debug(e);
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.