Author: bszanto
Date: 2008-07-06 04:06:49-0700
New Revision: 15172
Modified:
branches/gsoc2008/feature1_5138_bszanto/argouml-app/src/org/argouml/uml/diagram/ui/ActionAddExistingNodes.java
branches/gsoc2008/feature1_5138_bszanto/argouml-app/src/org/argouml/uml/diagram/ui/AddExistingNodeCommand.java
branches/gsoc2008/feature1_5138_bszanto/argouml-app/src/org/argouml/uml/diagram/ui/DnDJGraph.java
branches/gsoc2008/feature1_5138_bszanto/argouml-app/src/org/argouml/uml/diagram/ui/UMLDiagram.java
branches/gsoc2008/feature1_5138_bszanto/argouml-core-diagrams-sequence2/src/org/argouml/uml/diagram/sequence2/ui/SequenceDiagramRenderer.java
branches/gsoc2008/feature1_5138_bszanto/argouml-core-diagrams-sequence2/src/org/argouml/uml/diagram/sequence2/ui/UMLSequenceDiagram.java
Log:
Fixes several bugs: [1] messages can now be created between CR added via DnD or "Add to diagram", [2] all CRs are now positioned properly, [3] attibutes and operations are now ignored. Also refactored some code to avoid redundancies.
Modified: branches/gsoc2008/feature1_5138_bszanto/argouml-app/src/org/argouml/uml/diagram/ui/ActionAddExistingNodes.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/feature1_5138_bszanto/argouml-app/src/org/argouml/uml/diagram/ui/ActionAddExistingNodes.java?view=diff&rev=15172&p1=branches/gsoc2008/feature1_5138_bszanto/argouml-app/src/org/argouml/uml/diagram/ui/ActionAddExistingNodes.java&p2=branches/gsoc2008/feature1_5138_bszanto/argouml-app/src/org/argouml/uml/diagram/ui/ActionAddExistingNodes.java&r1=15171&r2=15172
==============================================================================
--- branches/gsoc2008/feature1_5138_bszanto/argouml-app/src/org/argouml/uml/diagram/ui/ActionAddExistingNodes.java (original)
+++ branches/gsoc2008/feature1_5138_bszanto/argouml-app/src/org/argouml/uml/diagram/ui/ActionAddExistingNodes.java 2008-07-06 04:06:49-0700
@@ -101,7 +101,10 @@
Collection oldTargets = TargetManager.getInstance().getTargets();
int count = 0;
for (Object me : modelElements) {
- if (Model.getFacade().isANaryAssociation(me)) {
+ if (diagram instanceof UMLDiagram
+ && ((UMLDiagram) diagram).doesAccept(me)) {
+ ((UMLDiagram) diagram).drop(me, location);
+ } else if (Model.getFacade().isANaryAssociation(me)) {
AddExistingNodeCommand cmd =
new AddExistingNodeCommand(me, location,
count++);
Modified: branches/gsoc2008/feature1_5138_bszanto/argouml-app/src/org/argouml/uml/diagram/ui/AddExistingNodeCommand.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/feature1_5138_bszanto/argouml-app/src/org/argouml/uml/diagram/ui/AddExistingNodeCommand.java?view=diff&rev=15172&p1=branches/gsoc2008/feature1_5138_bszanto/argouml-app/src/org/argouml/uml/diagram/ui/AddExistingNodeCommand.java&p2=branches/gsoc2008/feature1_5138_bszanto/argouml-app/src/org/argouml/uml/diagram/ui/AddExistingNodeCommand.java&r1=15171&r2=15172
==============================================================================
--- branches/gsoc2008/feature1_5138_bszanto/argouml-app/src/org/argouml/uml/diagram/ui/AddExistingNodeCommand.java (original)
+++ branches/gsoc2008/feature1_5138_bszanto/argouml-app/src/org/argouml/uml/diagram/ui/AddExistingNodeCommand.java 2008-07-06 04:06:49-0700
@@ -121,21 +121,22 @@
if (activeDiagram instanceof UMLDiagram &&
((UMLDiagram) activeDiagram).doesAccept(object)) {
- //TODO: i18n
- instructions = "Click on diagram to add as a new Classifier Role";
+ instructions = ((UMLDiagram) activeDiagram).
+ getInstructions(object);
+ placeMode = ((UMLDiagram) activeDiagram).
+ getModePlace(this, instructions);
+ placeMode.setAddRelatedEdges(true);
} else {
instructions =
Translator.localize(
"misc.message.click-on-diagram-to-add",
new Object[] {Model.getFacade().toString(object),});
-
+ placeMode = new ModePlace(this, instructions);
+ placeMode.setAddRelatedEdges(true);
}
Globals.showStatus(instructions);
}
- placeMode = new ModePlace(this, instructions);
- placeMode.setAddRelatedEdges(true);
-
if (location == null) {
Globals.mode(placeMode, false);
} else {
Modified: branches/gsoc2008/feature1_5138_bszanto/argouml-app/src/org/argouml/uml/diagram/ui/DnDJGraph.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/feature1_5138_bszanto/argouml-app/src/org/argouml/uml/diagram/ui/DnDJGraph.java?view=diff&rev=15172&p1=branches/gsoc2008/feature1_5138_bszanto/argouml-app/src/org/argouml/uml/diagram/ui/DnDJGraph.java&p2=branches/gsoc2008/feature1_5138_bszanto/argouml-app/src/org/argouml/uml/diagram/ui/DnDJGraph.java&r1=15171&r2=15172
==============================================================================
--- branches/gsoc2008/feature1_5138_bszanto/argouml-app/src/org/argouml/uml/diagram/ui/DnDJGraph.java (original)
+++ branches/gsoc2008/feature1_5138_bszanto/argouml-app/src/org/argouml/uml/diagram/ui/DnDJGraph.java 2008-07-06 04:06:49-0700
@@ -135,7 +135,6 @@
* java.awt.dnd.DropTargetDragEvent)
*/
public void dragOver(DropTargetDragEvent dtde) {
- System.out.println("Drag Over");
try {
ArgoDiagram dia = ProjectManager.getManager().
getCurrentProject().getActiveDiagram();
@@ -176,8 +175,6 @@
* java.awt.dnd.DropTargetDropEvent)
*/
public void drop(DropTargetDropEvent dropTargetDropEvent) {
- System.out.println("Droped");
-
Transferable tr = dropTargetDropEvent.getTransferable();
//if the flavor is not supported, then reject the drop:
if (!tr.isDataFlavorSupported(
@@ -202,8 +199,8 @@
dropTargetDropEvent.getLocation());
}
- ActionAddExistingNodes.addNodes(modelElements,
- dropTargetDropEvent.getLocation(), diagram);
+// ActionAddExistingNodes.addNodes(modelElements,
+// dropTargetDropEvent.getLocation(), diagram);
dropTargetDropEvent.getDropTargetContext().dropComplete(true);
} catch (UnsupportedFlavorException e) {
Modified: branches/gsoc2008/feature1_5138_bszanto/argouml-app/src/org/argouml/uml/diagram/ui/UMLDiagram.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/feature1_5138_bszanto/argouml-app/src/org/argouml/uml/diagram/ui/UMLDiagram.java?view=diff&rev=15172&p1=branches/gsoc2008/feature1_5138_bszanto/argouml-app/src/org/argouml/uml/diagram/ui/UMLDiagram.java&p2=branches/gsoc2008/feature1_5138_bszanto/argouml-app/src/org/argouml/uml/diagram/ui/UMLDiagram.java&r1=15171&r2=15172
==============================================================================
--- branches/gsoc2008/feature1_5138_bszanto/argouml-app/src/org/argouml/uml/diagram/ui/UMLDiagram.java (original)
+++ branches/gsoc2008/feature1_5138_bszanto/argouml-app/src/org/argouml/uml/diagram/ui/UMLDiagram.java 2008-07-06 04:06:49-0700
@@ -56,6 +56,7 @@
import org.tigris.gef.base.ModePlace;
import org.tigris.gef.base.ModeSelect;
import org.tigris.gef.graph.GraphFactory;
+import org.tigris.gef.presentation.FigNode;
import org.tigris.toolbar.ToolBarFactory;
import org.tigris.toolbar.ToolBarManager;
import org.tigris.toolbar.toolbutton.ToolButton;
@@ -580,24 +581,35 @@
* Handles elements dropped over.
* @param droppedObject
* @param location
+ * @return The object that has been added to the diagram.
*/
- public void drop(Object droppedObject, Point location) {
+ public FigNode drop(Object droppedObject, Point location) {
+ return null;
}
-// /**
-// * Creates a diagram specific @see org.tigris.gef.base.ModePlace that
-// * alowes the diagram to place an accepted type of object
-// * [ @see #doesAccept(Object) ] as it should. This is required 1. since a
-// * diagram may receive an object that can't be placed as is, but needs some
-// * tranformation and 2. diagrams in modules should be independent from the
-// * main app, and should use their own implementation of ModePlace if it's
-// * required.
-// * @param gf
-// * @param instructions
-// * @return The created ModePlace.
-// */
-// public ModePlace getModePlace(GraphFactory gf, String instructions) {
-// return new ModePlace(gf, instructions);
-// }
+ /**
+ * Gets the instructions to be displayed on the status bar.
+ * @param droppedObject
+ * @return The instructions.
+ */
+ public String getInstructions(Object droppedObject) {
+ return "";
+ }
+
+ /**
+ * Creates a diagram specific @see org.tigris.gef.base.ModePlace that
+ * alowes the diagram to place an accepted type of object
+ * [ @see #doesAccept(Object) ] as it should. This is required 1. since a
+ * diagram may receive an object that can't be placed as is, but needs some
+ * tranformation and 2. diagrams in modules should be independent from the
+ * main app, and should use their own implementation of ModePlace if it's
+ * required.
+ * @param gf
+ * @param instructions
+ * @return The created ModePlace.
+ */
+ public ModePlace getModePlace(GraphFactory gf, String instructions) {
+ return new ModePlace(gf, instructions);
+ }
}
Modified: branches/gsoc2008/feature1_5138_bszanto/argouml-core-diagrams-sequence2/src/org/argouml/uml/diagram/sequence2/ui/SequenceDiagramRenderer.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/feature1_5138_bszanto/argouml-core-diagrams-sequence2/src/org/argouml/uml/diagram/sequence2/ui/SequenceDiagramRenderer.java?view=diff&rev=15172&p1=branches/gsoc2008/feature1_5138_bszanto/argouml-core-diagrams-sequence2/src/org/argouml/uml/diagram/sequence2/ui/SequenceDiagramRenderer.java&p2=branches/gsoc2008/feature1_5138_bszanto/argouml-core-diagrams-sequence2/src/org/argouml/uml/diagram/sequence2/ui/SequenceDiagramRenderer.java&r1=15171&r2=15172
==============================================================================
--- branches/gsoc2008/feature1_5138_bszanto/argouml-core-diagrams-sequence2/src/org/argouml/uml/diagram/sequence2/ui/SequenceDiagramRenderer.java (original)
+++ branches/gsoc2008/feature1_5138_bszanto/argouml-core-diagrams-sequence2/src/org/argouml/uml/diagram/sequence2/ui/SequenceDiagramRenderer.java 2008-07-06 04:06:49-0700
@@ -24,21 +24,29 @@
package org.argouml.uml.diagram.sequence2.ui;
+import java.awt.Point;
+import java.util.List;
import java.util.Map;
import org.apache.log4j.Logger;
+import org.argouml.kernel.ProjectManager;
import org.argouml.model.Model;
import org.argouml.uml.CommentEdge;
+import org.argouml.uml.diagram.ArgoDiagram;
import org.argouml.uml.diagram.UmlDiagramRenderer;
import org.argouml.uml.diagram.sequence2.SequenceDiagramGraphModel;
import org.argouml.uml.diagram.static_structure.ui.FigComment;
import org.argouml.uml.diagram.static_structure.ui.FigEdgeNote;
+import org.argouml.uml.diagram.ui.UMLDiagram;
import org.tigris.gef.base.Editor;
import org.tigris.gef.base.Globals;
import org.tigris.gef.base.Layer;
+import org.tigris.gef.base.Mode;
import org.tigris.gef.graph.GraphModel;
+import org.tigris.gef.presentation.Fig;
import org.tigris.gef.presentation.FigEdge;
import org.tigris.gef.presentation.FigNode;
+import org.tigris.swidgets.DropDownIcon;
/**
*
@@ -51,26 +59,6 @@
*/
private static final Logger LOG =
Logger.getLogger(SequenceDiagramRenderer.class);
-
- /**
- * Creates a new Classifier Role with a specified base.
- * @param base
- * @return The new CR
- */
- private Object makeNewCR(Object base) {
- Object node = null;
- Editor ce = Globals.curEditor();
- GraphModel gm = ce.getGraphModel();
- if (gm instanceof SequenceDiagramGraphModel) {
- Object collaboration =
- ((SequenceDiagramGraphModel) gm).getCollaboration();
- node =
- Model.getCollaborationsFactory().buildClassifierRole(
- collaboration);
- }
- Model.getCollaborationsHelper().addBase(node, base);
- return node;
- }
/*
* @see org.tigris.gef.graph.GraphNodeRenderer#getFigNodeFor(
@@ -80,25 +68,26 @@
public FigNode getFigNodeFor(GraphModel gm, Layer lay, Object node,
Map styleAttributes) {
FigNode result = null;
- if (Model.getFacade().isAClassifierRole(node)) {
- result = new FigClassifierRole(node);
- } else if (Model.getFacade().isAComment(node)) {
- result = new FigComment(gm, node);
- } else if (Model.getFacade().isAClass(node)
- || Model.getFacade().isAActor(node)) {
- /*
- * if the user tries to add a Class or an Actor, a new CR should be
- * created with the Class or the Actor as a Base.
- */
- result = new FigClassifierRole(makeNewCR(node));
+ ArgoDiagram diag = ProjectManager.getManager().getCurrentProject()
+ .getActiveDiagram();
+ if (diag instanceof UMLDiagram
+ && ((UMLDiagram) diag).doesAccept(node)) {
+ // if the user tries to add a Class or an Actor, a new CR should be
+ // created with the Class or the Actor as a Base. This is done by
+ // the diagram via the drop method.
+ result = ((UMLDiagram) diag).drop(node, null);
+ } else {
+ if (Model.getFacade().isAClassifierRole(node)) {
+ result = new FigClassifierRole(node);
+ } else if (Model.getFacade().isAComment(node)) {
+ result = new FigComment(gm, node);
+ }
+ LOG.debug("SequenceDiagramRenderer getFigNodeFor " + result);
+ lay.add(result);
}
- LOG.debug("SequenceDiagramRenderer getFigNodeFor " + result);
- lay.add(result);
- return result;
+ return result;
}
-
-
/*
* @see org.tigris.gef.graph.GraphEdgeRenderer#getFigEdgeFor(
* org.tigris.gef.graph.GraphModel, org.tigris.gef.base.Layer,
Modified: branches/gsoc2008/feature1_5138_bszanto/argouml-core-diagrams-sequence2/src/org/argouml/uml/diagram/sequence2/ui/UMLSequenceDiagram.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/feature1_5138_bszanto/argouml-core-diagrams-sequence2/src/org/argouml/uml/diagram/sequence2/ui/UMLSequenceDiagram.java?view=diff&rev=15172&p1=branches/gsoc2008/feature1_5138_bszanto/argouml-core-diagrams-sequence2/src/org/argouml/uml/diagram/sequence2/ui/UMLSequenceDiagram.java&p2=branches/gsoc2008/feature1_5138_bszanto/argouml-core-diagrams-sequence2/src/org/argouml/uml/diagram/sequence2/ui/UMLSequenceDiagram.java&r1=15171&r2=15172
==============================================================================
--- branches/gsoc2008/feature1_5138_bszanto/argouml-core-diagrams-sequence2/src/org/argouml/uml/diagram/sequence2/ui/UMLSequenceDiagram.java (original)
+++ branches/gsoc2008/feature1_5138_bszanto/argouml-core-diagrams-sequence2/src/org/argouml/uml/diagram/sequence2/ui/UMLSequenceDiagram.java 2008-07-06 04:06:49-0700
@@ -42,6 +42,8 @@
import org.tigris.gef.base.Globals;
import org.tigris.gef.base.LayerPerspective;
import org.tigris.gef.base.LayerPerspectiveMutable;
+import org.tigris.gef.base.ModePlace;
+import org.tigris.gef.graph.GraphFactory;
import org.tigris.gef.graph.GraphModel;
import org.tigris.gef.graph.MutableGraphModel;
import org.tigris.gef.presentation.Fig;
@@ -200,7 +202,7 @@
* @param base
* @return The new CR
*/
- private FigClassifierRole makeNewCR(Object base) {
+ private Object makeNewCR(Object base) {
Object node = null;
Editor ce = Globals.curEditor();
GraphModel gm = ce.getGraphModel();
@@ -211,10 +213,23 @@
Model.getCollaborationsFactory().buildClassifierRole(
collaboration);
}
-
+ getGraphModel().getNodes().add(node);
Model.getCollaborationsHelper().addBase(node, base);
- FigClassifierRole newCR = new FigClassifierRole(node);
+ return node;
+ }
+
+ /**
+ * Creates the Fig for the CR. Y position will be adjusted to match other
+ * the other CRs.
+ * @param classifierRole
+ * @param location The position where to put the new fig.
+ * @return
+ */
+ private FigClassifierRole makeNewFigCR(Object classifierRole,
+ Point location) {
+
+ FigClassifierRole newCR = new FigClassifierRole(classifierRole);
// Y position of the new CR should match existing CRs Y position
List nodes = getLayer().getContentsNoEdges();
@@ -232,17 +247,45 @@
}
i++;
}
-
+ if (location != null) {
+ if (newCR.getY() == 0) {
+ newCR.setY(location.y);
+ }
+ newCR.setX(location.x);
+ }
return newCR;
}
+ @Override
+ public FigNode drop(Object droppedObject, Point location) {
+ FigClassifierRole newCR = null;
+ if (Model.getFacade().isAClassifierRole(droppedObject)) {
+ newCR = makeNewFigCR(droppedObject, location);
+ } else if (Model.getFacade().isAClass(droppedObject)
+ || Model.getFacade().isAActor(droppedObject)){
+ newCR = makeNewFigCR(makeNewCR(droppedObject), location);
+ }
+ if (newCR != null) {
+ add(newCR);
+ LOG.debug("Dropped object " + droppedObject + " converted to "
+ + newCR);
+ } else {
+ LOG.debug("Dropped object NOT added " + droppedObject);
+ }
+ return newCR;
+ }
@Override
- public void drop(Object droppedObject, Point location) {
- FigClassifierRole newCR = makeNewCR(droppedObject);
- if (location != null) {
- newCR.setX(location.x);
+ public String getInstructions(Object droppedObject) {
+ if (Model.getFacade().isAClassifierRole(droppedObject)) {
+ //TODO: i18n
+ return "Click on diagram to add as a new Classifier Role";
}
- add(newCR);
+ return super.getInstructions(droppedObject);
+ }
+
+ @Override
+ public ModePlace getModePlace(GraphFactory gf, String instructions) {
+ return new ModePlaceClassifierRole(gf, instructions);
}
}
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.