svn commit: r17258 - trunk/src/argouml-core-diagrams-uml2/src/org/argouml/diagram/uml2
Bob Tarling <[email protected]>
| Newsgroups | gmane.comp.lang.uml.argouml.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: bobtarling
Date: 2009-08-10 15:43:29-0700
New Revision: 17258
Added:
trunk/src/argouml-core-diagrams-uml2/src/org/argouml/diagram/uml2/FigExtend2.java
trunk/src/argouml-core-diagrams-uml2/src/org/argouml/diagram/uml2/FigInclude2.java
trunk/src/argouml-core-diagrams-uml2/src/org/argouml/diagram/uml2/UMLUseCaseDiagram2.java
trunk/src/argouml-core-diagrams-uml2/src/org/argouml/diagram/uml2/UseCaseDiagram2Factory.java
trunk/src/argouml-core-diagrams-uml2/src/org/argouml/diagram/uml2/UseCaseDiagramRenderer2.java
Modified:
trunk/src/argouml-core-diagrams-uml2/src/org/argouml/diagram/uml2/Uml2DiagramModule.java
Log:
Provide diagram extensions for use cases
Added: trunk/src/argouml-core-diagrams-uml2/src/org/argouml/diagram/uml2/FigExtend2.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-diagrams-uml2/src/org/argouml/diagram/uml2/FigExtend2.java?view=markup&pathrev=17258
==============================================================================
--- (empty file)
+++ trunk/src/argouml-core-diagrams-uml2/src/org/argouml/diagram/uml2/FigExtend2.java 2009-08-10 15:43:29-0700
@@ -0,0 +1,47 @@
+// $Id: FigExtend.java 17045 2009-04-05 16:52:52Z mvw $
+// Copyright (c) 1996-2009 The Regents of the University of California. All
+// Rights Reserved. Permission to use, copy, modify, and distribute this
+// software and its documentation without fee, and without a written
+// agreement is hereby granted, provided that the above copyright notice
+// and this paragraph appear in all copies. This software program and
+// documentation are copyrighted by The Regents of the University of
+// California. The software program and documentation are supplied "AS
+// IS", without any accompanying services from The Regents. The Regents
+// does not warrant that the operation of the program will be
+// uninterrupted or error-free. The end-user understands that the program
+// was developed for research purposes and is advised not to rely
+// exclusively on the program for any reason. IN NO EVENT SHALL THE
+// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
+// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+package org.argouml.diagram.uml2;
+
+import org.argouml.uml.diagram.DiagramSettings;
+import org.argouml.uml.diagram.use_case.ui.FigExtend;
+
+/**
+ * A fig for use with extend relationships on use case diagrams.<p>
+ *
+ * Realised as a dotted line with an open arrow head and the label
+ * «extend» together with any condition alongside.<p>
+ */
+public class FigExtend2 extends FigExtend {
+
+ /**
+ * Construct an Extend fig.
+ *
+ * @param owner uml element
+ * @param settings rendering settings
+ */
+ public FigExtend2(Object owner, DiagramSettings settings) {
+ super(owner, settings);
+ }
+}
Added: trunk/src/argouml-core-diagrams-uml2/src/org/argouml/diagram/uml2/FigInclude2.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-diagrams-uml2/src/org/argouml/diagram/uml2/FigInclude2.java?view=markup&pathrev=17258
==============================================================================
--- (empty file)
+++ trunk/src/argouml-core-diagrams-uml2/src/org/argouml/diagram/uml2/FigInclude2.java 2009-08-10 15:43:29-0700
@@ -0,0 +1,134 @@
+// $Id: FigInclude.java 17045 2009-04-05 16:52:52Z mvw $
+// Copyright (c) 1996-2009 The Regents of the University of California. All
+// Rights Reserved. Permission to use, copy, modify, and distribute this
+// software and its documentation without fee, and without a written
+// agreement is hereby granted, provided that the above copyright notice
+// and this paragraph appear in all copies. This software program and
+// documentation are copyrighted by The Regents of the University of
+// California. The software program and documentation are supplied "AS
+// IS", without any accompanying services from The Regents. The Regents
+// does not warrant that the operation of the program will be
+// uninterrupted or error-free. The end-user understands that the program
+// was developed for research purposes and is advised not to rely
+// exclusively on the program for any reason. IN NO EVENT SHALL THE
+// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
+// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+package org.argouml.diagram.uml2;
+
+import java.awt.Graphics;
+import java.awt.Rectangle;
+
+import org.argouml.uml.diagram.DiagramSettings;
+import org.argouml.uml.diagram.ui.FigEdgeModelElement;
+import org.argouml.uml.diagram.ui.FigSingleLineText;
+import org.argouml.uml.diagram.ui.PathItemPlacement;
+import org.tigris.gef.presentation.ArrowHeadGreater;
+import org.tigris.gef.presentation.Fig;
+
+
+/**
+ * A fig for use with include relationships on use case diagrams.<p>
+ *
+ * Realised as a dotted line with an open arrow head and the label
+ * <<include>> alongside a la stereotype.<p>
+ *
+ * @author Jeremy Bennett
+ */
+public class FigInclude2 extends FigEdgeModelElement {
+
+ /**
+ * Serial version - generated by Eclipse for rev. 1.14
+ */
+ private static final long serialVersionUID = 6199364390483239154L;
+
+ /*
+ * Text fig to hold the <<include>> label
+ */
+ private FigSingleLineText label;
+
+ private ArrowHeadGreater endArrow = new ArrowHeadGreater();
+
+ private void initialize() {
+ // The <<include>> label.
+ // It's not a true stereotype, so don't use the stereotype support
+ label.setTextColor(TEXT_COLOR);
+ label.setTextFilled(false);
+ label.setFilled(false);
+ label.setLineWidth(0);
+ label.setEditable(false);
+ label.setText("<<include>>");
+
+ addPathItem(label, new PathItemPlacement(this, label, 50, 10));
+
+ // Make the line dashed
+
+ setDashed(true);
+
+ // Add an arrow with an open arrow head
+
+ setDestArrowHead(endArrow);
+
+ // Make the edge go between nearest points
+
+ setBetweenNearestPoints(true);
+ }
+
+ /**
+ * Construct a fig owned by the given UML element with the provided render
+ * settings.
+ * @param edge owning UML element
+ * @param settings rendering settings
+ */
+ public FigInclude2(Object edge, DiagramSettings settings) {
+ super(edge, settings);
+ label = new FigSingleLineText(edge, new Rectangle(X0, Y0 + 20, 90, 20),
+ settings, false);
+ initialize();
+ }
+
+ /**
+ * <p>Set a new fig to represent this edge.</p>
+ *
+ * <p>We invoke the superclass accessor. Then change aspects of the
+ * new fig that are not as we want. In this case to use dashed lines.</p>
+ *
+ * @param f The fig to use.
+ */
+ @Override
+ public void setFig(Fig f) {
+ super.setFig(f);
+ setDashed(true);
+ }
+
+ /**
+ * <p>Define whether the given fig can be edited (it can't).</p>
+ *
+ * @param f The fig about which the enquiry is being made. Ignored in this
+ * implementation.
+ *
+ * @return <code>false</code> under all circumstances.
+ */
+ @Override
+ protected boolean canEdit(Fig f) {
+ return false;
+ }
+
+ /*
+ * @see org.tigris.gef.presentation.Fig#paint(java.awt.Graphics)
+ */
+ @Override
+ public void paint(Graphics g) {
+ endArrow.setLineColor(getLineColor());
+ super.paint(g);
+ }
+}
+
Added: trunk/src/argouml-core-diagrams-uml2/src/org/argouml/diagram/uml2/UMLUseCaseDiagram2.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-diagrams-uml2/src/org/argouml/diagram/uml2/UMLUseCaseDiagram2.java?view=markup&pathrev=17258
==============================================================================
--- (empty file)
+++ trunk/src/argouml-core-diagrams-uml2/src/org/argouml/diagram/uml2/UMLUseCaseDiagram2.java 2009-08-10 15:43:29-0700
@@ -0,0 +1,499 @@
+// $Id: UMLUseCaseDiagram.java 17255 2009-08-10 21:33:00Z bobtarling $
+// Copyright (c) 1996-2008 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
+// and this paragraph appear in all copies. This software program and
+// documentation are copyrighted by The Regents of the University of
+// California. The software program and documentation are supplied "AS
+// IS", without any accompanying services from The Regents. The Regents
+// does not warrant that the operation of the program will be
+// uninterrupted or error-free. The end-user understands that the program
+// was developed for research purposes and is advised not to rely
+// exclusively on the program for any reason. IN NO EVENT SHALL THE
+// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
+// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+package org.argouml.diagram.uml2;
+
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.beans.PropertyVetoException;
+import java.util.Collection;
+import java.util.HashSet;
+
+import javax.swing.Action;
+
+import org.apache.log4j.Logger;
+import org.argouml.i18n.Translator;
+import org.argouml.model.Model;
+import org.argouml.ui.CmdCreateNode;
+import org.argouml.uml.diagram.DiagramElement;
+import org.argouml.uml.diagram.DiagramSettings;
+import org.argouml.uml.diagram.ui.ActionAddExtensionPoint;
+import org.argouml.uml.diagram.ui.ActionSetAddAssociationMode;
+import org.argouml.uml.diagram.ui.ActionSetMode;
+import org.argouml.uml.diagram.ui.FigNodeModelElement;
+import org.argouml.uml.diagram.ui.RadioAction;
+import org.argouml.uml.diagram.ui.UMLDiagram;
+import org.argouml.uml.diagram.use_case.UseCaseDiagramGraphModel;
+import org.argouml.util.ToolBarUtility;
+import org.tigris.gef.base.LayerPerspective;
+import org.tigris.gef.base.LayerPerspectiveMutable;
+import org.tigris.gef.base.ModeCreatePolyEdge;
+import org.tigris.gef.presentation.FigNode;
+
+/**
+ * The base class of the use case diagram.<p>
+ *
+ * Defines the toolbar, provides for its initialization and provides
+ * constructors for a top level diagram and one within a defined
+ * namespace.<p>
+ *
+ * A use case diagram has as owner either a package or a classifier.
+ */
+public class UMLUseCaseDiagram2 extends UMLDiagram {
+
+ private static final Logger LOG = Logger.getLogger(UMLUseCaseDiagram2.class);
+
+ // Actions specific to the use case diagram toolbar
+
+ /**
+ * Tool to add an actor node.<p>
+ */
+ private Action actionActor;
+
+ /**
+ * Tool to add a use case node.<p>
+ */
+ private Action actionUseCase;
+
+ /**
+ * Tool to create an association between UML artifacts using a
+ * polyedge.<p>
+ */
+ private Action actionAssociation;
+ private Action actionAggregation;
+ private Action actionComposition;
+ private Action actionUniAssociation;
+ private Action actionUniAggregation;
+ private Action actionUniComposition;
+
+ /**
+ * Tool to create a generalization between UML artifacts using a
+ * polyedge.<p>
+ */
+ private Action actionGeneralize;
+
+ /**
+ * Tool to create an extend relationship between UML use cases
+ * using a polyedge.<p>
+ */
+ private Action actionExtend;
+
+ /**
+ * Tool to create an include relationship between UML use cases
+ * using a polyedge.<p>
+ */
+ private Action actionInclude;
+
+ /**
+ * Tool to create a dependency between UML artifacts using a
+ * polyedge.<p>
+ */
+ private Action actionDependency;
+
+ private Action actionExtensionPoint;
+
+ /**
+ * Construct a new use case diagram with no defined namespace.<p>
+ *
+ * Note we must never call this directly, since defining the
+ * namespace is what makes everything work. However GEF will call
+ * it directly when loading a new diagram, so it must remain
+ * public.<p>
+ *
+ * A unique name is constructed by using the serial index.
+ * We allow for the possibility
+ * that setting this may fail, in which case no name is set.<p>
+ * @deprecated ony for use by PGML parser.
+ */
+ @Deprecated
+ public UMLUseCaseDiagram2() {
+ super(new UseCaseDiagramGraphModel());
+ try {
+ setName(getNewDiagramName());
+ } catch (PropertyVetoException pve) { }
+ }
+
+ /**
+ * Construct a new use case diagram with in a defined namespace.<p>
+ *
+ * Invokes the generic constructor {@link #UMLUseCaseDiagram()},
+ * then intialises the namespace (which initializes all the
+ * graphics).<p>
+ *
+ * This is the constructor which should always be used.<p>
+ *
+ * @param m the desired namespace for this diagram.
+ */
+ public UMLUseCaseDiagram2(Object m) {
+ this();
+ if (!Model.getFacade().isANamespace(m)) {
+ throw new IllegalArgumentException();
+ }
+ setNamespace(m);
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param name the name for the diagram
+ * @param namespace the namespace for the diagram
+ */
+ public UMLUseCaseDiagram2(String name, Object namespace) {
+ this(namespace);
+ if (!Model.getFacade().isANamespace(namespace)) {
+ throw new IllegalArgumentException();
+ }
+ try {
+ setName(name);
+ } catch (PropertyVetoException v) { }
+ }
+
+ /**
+ * Perform a number of important initializations of a <em>Use Case
+ * Diagram</em>.<p>
+ *
+ * Creates a new graph model for the diagram, settings its
+ * namespace to that supplied.<p>
+ *
+ * Changed <em>lay</em> from <em>LayerPerspective</em> to
+ * <em>LayerPerspectiveMutable</em>. This class is a child of
+ * <em>LayerPerspective</em> and was implemented to correct some
+ * difficulties in changing the model. <em>lay</em> is used mainly
+ * in <em>LayerManager</em>(GEF) to control the adding, changing
+ * and deleting of items in a layer of the diagram.<p>
+ *
+ * Set a renderer suitable for the use case diagram.<p>
+ *
+ * <em>Note</em>. This is declared as public. Not clear that other
+ * classes should be allowed to invoke this method.<p>
+ *
+ * @param handle Namespace to be used for this diagram.
+ *
+ * @author [email protected] Jan 24, 2002
+ */
+ @Override
+ public void setNamespace(Object handle) {
+ if (!Model.getFacade().isANamespace(handle)) {
+ LOG.error(
+ "Illegal argument. Object " + handle + " is not a namespace");
+ throw new IllegalArgumentException(
+ "Illegal argument. Object " + handle + " is not a namespace");
+ }
+ Object m = handle;
+ super.setNamespace(m);
+
+ UseCaseDiagramGraphModel gm =
+ (UseCaseDiagramGraphModel) getGraphModel();
+ gm.setHomeModel(m);
+ LayerPerspective lay =
+ new LayerPerspectiveMutable(Model.getFacade().getName(m), gm);
+ UseCaseDiagramRenderer2 rend = new UseCaseDiagramRenderer2();
+ lay.setGraphNodeRenderer(rend);
+ lay.setGraphEdgeRenderer(rend);
+ setLayer(lay);
+
+ // The renderer should be a singleton
+
+ }
+
+ /*
+ * @see org.argouml.uml.diagram.ui.UMLDiagram#getUmlActions()
+ */
+ protected Object[] getUmlActions() {
+ Object[] actions =
+ {
+ getActionActor(),
+ getActionUseCase(),
+ null,
+ getAssociationActions(),
+ getActionDependency(),
+ getActionGeneralize(),
+ getActionExtend(),
+ getActionInclude(),
+ null,
+ getActionExtensionPoint(),
+ };
+ return actions;
+ }
+
+ private Object[] getAssociationActions() {
+ Object[][] actions = {
+ {getActionAssociation(), getActionUniAssociation() },
+ {getActionAggregation(), getActionUniAggregation() },
+ {getActionComposition(), getActionUniComposition() },
+ };
+ ToolBarUtility.manageDefault(actions, "diagram.usecase.association");
+ return actions;
+ }
+
+ /*
+ * @see org.argouml.uml.diagram.ui.UMLDiagram#getLabelName()
+ */
+ public String getLabelName() {
+ return Translator.localize("label.usecase-diagram");
+ }
+
+ /**
+ * @return Returns the actionActor.
+ */
+ protected Action getActionActor() {
+ if (actionActor == null) {
+ actionActor = new RadioAction(new CmdCreateNode(
+ Model.getMetaTypes().getActor(), "button.new-actor"));
+ }
+ return actionActor;
+ }
+ /**
+ * @return Returns the actionAggregation.
+ */
+ protected Action getActionAggregation() {
+ if (actionAggregation == null) {
+ actionAggregation = new RadioAction(
+ new ActionSetAddAssociationMode(
+ Model.getAggregationKind().getAggregate(),
+ false,
+ "button.new-aggregation"));
+ }
+ return actionAggregation;
+ }
+ /**
+ * @return Returns the actionAssociation.
+ */
+ protected Action getActionAssociation() {
+ if (actionAssociation == null) {
+ actionAssociation = new RadioAction(
+ new ActionSetAddAssociationMode(
+ Model.getAggregationKind().getNone(),
+ false,
+ "button.new-association"));
+ }
+ return actionAssociation;
+ }
+ /**
+ * @return Returns the actionComposition.
+ */
+ protected Action getActionComposition() {
+ if (actionComposition == null) {
+ actionComposition = new RadioAction(
+ new ActionSetAddAssociationMode(
+ Model.getAggregationKind().getComposite(),
+ false,
+ "button.new-composition"));
+ }
+ return actionComposition;
+ }
+ /**
+ * @return Returns the actionDependency.
+ */
+ protected Action getActionDependency() {
+ if (actionDependency == null) {
+ actionDependency = new RadioAction(
+ new ActionSetMode(
+ ModeCreatePolyEdge.class,
+ "edgeClass",
+ Model.getMetaTypes().getDependency(),
+ "button.new-dependency"));
+ }
+ return actionDependency;
+ }
+ /**
+ * @return Returns the actionExtend.
+ */
+ protected Action getActionExtend() {
+ if (actionExtend == null) {
+ actionExtend = new RadioAction(
+ new ActionSetMode(
+ ModeCreatePolyEdge.class,
+ "edgeClass",
+ Model.getMetaTypes().getExtend(),
+ "button.new-extend"));
+ }
+ return actionExtend;
+ }
+ /**
+ * @return Returns the actionGeneralize.
+ */
+ protected Action getActionGeneralize() {
+ if (actionGeneralize == null) {
+ actionGeneralize = new RadioAction(
+ new ActionSetMode(
+ ModeCreatePolyEdge.class,
+ "edgeClass",
+ Model.getMetaTypes().getGeneralization(),
+ "button.new-generalization"));
+ }
+ return actionGeneralize;
+ }
+ /**
+ * @return Returns the actionInclude.
+ */
+ protected Action getActionInclude() {
+ if (actionInclude == null) {
+ actionInclude = new RadioAction(
+ new ActionSetMode(
+ ModeCreatePolyEdge.class,
+ "edgeClass",
+ Model.getMetaTypes().getInclude(),
+ "button.new-include"));
+ }
+ return actionInclude;
+ }
+ /**
+ * @return Returns the actionUniAggregation.
+ */
+ protected Action getActionUniAggregation() {
+ if (actionUniAggregation == null) {
+ actionUniAggregation = new RadioAction(
+ new ActionSetAddAssociationMode(
+ Model.getAggregationKind().getAggregate(),
+ true,
+ "button.new-uniaggregation"));
+ }
+ return actionUniAggregation;
+ }
+ /**
+ * @return Returns the actionUniAssociation.
+ */
+ protected Action getActionUniAssociation() {
+ if (actionUniAssociation == null) {
+ actionUniAssociation = new RadioAction(
+ new ActionSetAddAssociationMode(
+ Model.getAggregationKind().getNone(),
+ true,
+ "button.new-uniassociation"));
+ }
+ return actionUniAssociation;
+ }
+ /**
+ * @return Returns the actionUniComposition.
+ */
+ protected Action getActionUniComposition() {
+ if (actionUniComposition == null) {
+ actionUniComposition = new RadioAction(
+ new ActionSetAddAssociationMode(
+ Model.getAggregationKind().getComposite(),
+ true,
+ "button.new-unicomposition"));
+ }
+ return actionUniComposition;
+ }
+ /**
+ * @return Returns the actionUseCase.
+ */
+ protected Action getActionUseCase() {
+ if (actionUseCase == null) {
+ actionUseCase = new RadioAction(new CmdCreateNode(
+ Model.getMetaTypes().getUseCase(), "button.new-usecase"));
+ }
+ return actionUseCase;
+ }
+
+ /**
+ * @return the action to create an extension point
+ */
+ protected Action getActionExtensionPoint() {
+ if (actionExtensionPoint == null) {
+ actionExtensionPoint = ActionAddExtensionPoint.singleton();
+ }
+ return actionExtensionPoint;
+ }
+
+ /*
+ * @see org.argouml.uml.diagram.ui.UMLDiagram#isRelocationAllowed(java.lang.Object)
+ */
+ public boolean isRelocationAllowed(Object base) {
+ return Model.getFacade().isAPackage(base)
+ || Model.getFacade().isAClassifier(base);
+ }
+
+ /*
+ * @see org.argouml.uml.diagram.ui.UMLDiagram#relocate(java.lang.Object)
+ */
+ public boolean relocate(Object base) {
+ setNamespace(base);
+ damage();
+ return true;
+ }
+
+ /*
+ * Allow all Packages and Classifiers..
+ */
+ @SuppressWarnings("unchecked")
+ public Collection getRelocationCandidates(Object root) {
+ Collection c = new HashSet();
+ c.add(Model.getModelManagementHelper()
+ .getAllModelElementsOfKindWithModel(root,
+ Model.getMetaTypes().getPackage()));
+ c.add(Model.getModelManagementHelper()
+ .getAllModelElementsOfKindWithModel(root,
+ Model.getMetaTypes().getClassifier()));
+ return c;
+ }
+
+ public void encloserChanged(FigNode enclosed,
+ FigNode oldEncloser, FigNode newEncloser) {
+ // Do nothing.
+ }
+
+ @Override
+ public boolean doesAccept(Object objectToAccept) {
+ if (Model.getFacade().isAActor(objectToAccept)) {
+ return true;
+ } else if (Model.getFacade().isAUseCase(objectToAccept)) {
+ return true;
+ } else if (Model.getFacade().isAComment(objectToAccept)) {
+ return true;
+ } else if (Model.getFacade().isAPackage(objectToAccept)) {
+ return true;
+ }
+ return false;
+
+ }
+
+ public DiagramElement createDiagramElement(
+ final Object modelElement,
+ final Rectangle bounds) {
+
+ FigNodeModelElement figNode = null;
+
+ DiagramSettings settings = getDiagramSettings();
+
+ if (Model.getFacade().isAActor(modelElement)) {
+ figNode = new FigActor2(modelElement, bounds, settings);
+ } else if (Model.getFacade().isAUseCase(modelElement)) {
+ figNode = new FigUseCase2(modelElement, bounds, settings);
+ } else if (Model.getFacade().isAComment(modelElement)) {
+ figNode = new FigComment2(modelElement, bounds, settings);
+ } else if (Model.getFacade().isAPackage(modelElement)) {
+ figNode = new FigPackage2(modelElement, bounds, settings);
+ }
+ if (figNode != null) {
+ LOG.debug("Model element " + modelElement + " converted to "
+ + figNode);
+ } else {
+ LOG.debug("Dropped object NOT added " + figNode);
+ }
+ return figNode;
+ }
+}
Modified: trunk/src/argouml-core-diagrams-uml2/src/org/argouml/diagram/uml2/Uml2DiagramModule.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-diagrams-uml2/src/org/argouml/diagram/uml2/Uml2DiagramModule.java?view=diff&pathrev=17258&r1=17257&r2=17258
==============================================================================
--- trunk/src/argouml-core-diagrams-uml2/src/org/argouml/diagram/uml2/Uml2DiagramModule.java (original)
+++ trunk/src/argouml-core-diagrams-uml2/src/org/argouml/diagram/uml2/Uml2DiagramModule.java 2009-08-10 15:43:29-0700
@@ -53,6 +53,9 @@
DiagramFactory.getInstance().registerDiagramFactory(
DiagramType.Class,
(DiagramFactoryInterface2) new ClassDiagram2Factory());
+ DiagramFactory.getInstance().registerDiagramFactory(
+ DiagramType.UseCase,
+ (DiagramFactoryInterface2) new UseCaseDiagram2Factory());
LOG.info("ClassDiagram Module enabled.");
return true;
Added: trunk/src/argouml-core-diagrams-uml2/src/org/argouml/diagram/uml2/UseCaseDiagram2Factory.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-diagrams-uml2/src/org/argouml/diagram/uml2/UseCaseDiagram2Factory.java?view=markup&pathrev=17258
==============================================================================
--- (empty file)
+++ trunk/src/argouml-core-diagrams-uml2/src/org/argouml/diagram/uml2/UseCaseDiagram2Factory.java 2009-08-10 15:43:29-0700
@@ -0,0 +1,70 @@
+// $Id: SequenceDiagramFactory.java 16381 2008-12-19 15:37:46Z bobtarling $
+// Copyright (c) 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
+// and this paragraph appear in all copies. This software program and
+// documentation are copyrighted by The Regents of the University of
+// California. The software program and documentation are supplied "AS
+// IS", without any accompanying services from The Regents. The Regents
+// does not warrant that the operation of the program will be
+// uninterrupted or error-free. The end-user understands that the program
+// was developed for research purposes and is advised not to rely
+// exclusively on the program for any reason. IN NO EVENT SHALL THE
+// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
+// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+package org.argouml.diagram.uml2;
+
+import java.beans.PropertyVetoException;
+
+import org.apache.log4j.Logger;
+import org.argouml.uml.diagram.ArgoDiagram;
+import org.argouml.uml.diagram.DiagramFactoryInterface2;
+import org.argouml.uml.diagram.DiagramSettings;
+
+/**
+ * This factory creates a Use Case Diagram.
+ * @see org.argouml.uml.diagram.DiagramFactory
+ */
+class UseCaseDiagram2Factory implements DiagramFactoryInterface2 {
+
+ /**
+ * Logger.
+ */
+ private static final Logger LOG =
+ Logger.getLogger(UseCaseDiagram2Factory.class);
+
+ /**
+ * Factory method to create a new instance of an ArgoDiagram.
+ *
+ * @param owner the owning element. This can be the owning namespace for a
+ * Class diagram or an owning Statemachine for a State Diagram or
+ * any other interpretation that the diagram type wants to apply.
+ * @param name the name of the diagram. This may be null if the caller would
+ * like the factory to provide a default name.
+ * @param settings default rendering settings for the diagram
+ * @return the newly instantiated diagram
+ */
+ public ArgoDiagram createDiagram(Object owner, String name,
+ DiagramSettings settings) {
+ final ArgoDiagram diagram = new UMLUseCaseDiagram2(owner);
+ if (name != null) {
+ try {
+ diagram.setName(name);
+ } catch (PropertyVetoException e) {
+ LOG.error("Cannot set the name " + name +
+ " to the diagram just created: "+ diagram.getName(), e);
+ }
+ }
+ return diagram;
+ }
+}
Added: trunk/src/argouml-core-diagrams-uml2/src/org/argouml/diagram/uml2/UseCaseDiagramRenderer2.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-diagrams-uml2/src/org/argouml/diagram/uml2/UseCaseDiagramRenderer2.java?view=markup&pathrev=17258
==============================================================================
--- (empty file)
+++ trunk/src/argouml-core-diagrams-uml2/src/org/argouml/diagram/uml2/UseCaseDiagramRenderer2.java 2009-08-10 15:43:29-0700
@@ -0,0 +1,244 @@
+// $Id: UseCaseDiagramRenderer.java 16640 2009-01-17 22:06:52Z tfmorris $
+// Copyright (c) 1996-2008 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
+// and this paragraph appear in all copies. This software program and
+// documentation are copyrighted by The Regents of the University of
+// California. The software program and documentation are supplied "AS
+// IS", without any accompanying services from The Regents. The Regents
+// does not warrant that the operation of the program will be
+// uninterrupted or error-free. The end-user understands that the program
+// was developed for research purposes and is advised not to rely
+// exclusively on the program for any reason. IN NO EVENT SHALL THE
+// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
+// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+package org.argouml.diagram.uml2;
+
+import java.util.Map;
+
+import org.apache.log4j.Logger;
+import org.argouml.model.Model;
+import org.argouml.uml.CommentEdge;
+import org.argouml.uml.diagram.ArgoDiagram;
+import org.argouml.uml.diagram.DiagramSettings;
+import org.argouml.uml.diagram.DiagramUtils;
+import org.argouml.uml.diagram.GraphChangeAdapter;
+import org.argouml.uml.diagram.UmlDiagramRenderer;
+import org.argouml.uml.diagram.ui.FigNodeModelElement;
+import org.argouml.uml.diagram.ui.UMLDiagram;
+import org.tigris.gef.base.Layer;
+import org.tigris.gef.base.LayerPerspective;
+import org.tigris.gef.graph.GraphModel;
+import org.tigris.gef.presentation.FigEdge;
+import org.tigris.gef.presentation.FigNode;
+
+// could be singleton
+
+/**
+ * This class defines a renderer object for UML Use Case Diagrams. In a
+ * Class Diagram the following UML objects are displayed with the
+ * following Figs:<p>
+ *
+ * <pre>
+ * UML Object --- Fig
+ * ---------------------------------------
+ * MActor --- FigActor
+ * MUseCase --- FigUseCase
+ * </pre>
+ *
+ * Provides {@link #getFigNodeFor} to implement the
+ * {@link org.tigris.gef.graph.GraphNodeRenderer} interface and
+ * {@link #getFigEdgeFor} to implement the
+ * {@link org.tigris.gef.graph.GraphEdgeRenderer} interface.<p>
+ *
+ * <em>Note</em>. Should be implemented as a singleton - we don't really
+ * need a separate instance for each use case diagram.<p>
+ *
+ * @author abonner
+ */
+public class UseCaseDiagramRenderer2 extends UmlDiagramRenderer {
+
+ static final long serialVersionUID = 2217410137377934879L;
+
+ /**
+ * Logger.
+ */
+ private static final Logger LOG =
+ Logger.getLogger(UseCaseDiagramRenderer2.class);
+
+
+ /**
+ * Return a Fig that can be used to represent the given node.<p>
+ *
+ * @param gm The graph model for which we are rendering.
+ *
+ * @param lay The layer in the graph on which we want this figure.
+ *
+ * @param node The node to be rendered (an model element object)
+ *
+ * @param styleAttributes an optional map of attributes to style the fig
+ *
+ * @return The fig to be used, or <code>null</code> if we can't create
+ * one.
+ */
+ public FigNode getFigNodeFor(GraphModel gm, Layer lay, Object node,
+ Map styleAttributes) {
+
+ FigNodeModelElement figNode = null;
+
+ // Create a new version of the relevant fig
+
+ ArgoDiagram diag = DiagramUtils.getActiveDiagram();
+ if (diag instanceof UMLDiagram
+ && ((UMLDiagram) diag).doesAccept(node)) {
+ figNode =
+ (FigNodeModelElement) ((UMLDiagram) diag).drop(node, null);
+
+ } else {
+ LOG.debug(this.getClass().toString()
+ + ": getFigNodeFor(" + gm.toString() + ", "
+ + lay.toString() + ", " + node.toString()
+ + ") - cannot create this sort of node.");
+ return null;
+ // TODO: Shouldn't we throw an exception here?!?!
+ }
+
+ lay.add(figNode);
+ figNode.setDiElement(
+ GraphChangeAdapter.getInstance().createElement(gm, node));
+
+ return figNode;
+ }
+
+
+ /**
+ * Return a Fig that can be used to represent the given edge.<p>
+ *
+ * Generally the same code as for the ClassDiagram, since it's very
+ * related to it. Deal with each of the edge types in turn.<p>
+ *
+ * @param gm The graph model for which we are rendering.
+ *
+ * @param lay The layer in the graph on which we want this figure.
+ *
+ * @param edge The edge to be rendered (an model element object)
+ *
+ * @param styleAttributes an optional map of attributes to style the fig
+ *
+ * @return The fig to be used, or <code>null</code> if we can't create
+ * one.
+ *
+ * @see org.tigris.gef.graph.GraphEdgeRenderer#getFigEdgeFor(
+ * org.tigris.gef.graph.GraphModel, org.tigris.gef.base.Layer,
+ * java.lang.Object, java.util.Map)
+ */
+ public FigEdge getFigEdgeFor(GraphModel gm, Layer lay, Object edge,
+ Map styleAttributes) {
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("making figedge for " + edge);
+ }
+
+ if (edge == null) {
+ throw new IllegalArgumentException("A model edge must be supplied");
+ }
+
+ DiagramSettings settings = ((ArgoDiagram) ((LayerPerspective) lay)
+ .getDiagram()).getDiagramSettings();
+
+ FigEdge newEdge = null;
+
+ if (Model.getFacade().isAAssociation(edge)) {
+ newEdge = new FigAssociation2(edge, settings);
+ } else if (Model.getFacade().isAGeneralization(edge)) {
+ newEdge = new FigGeneralization2(edge, settings);
+ } else if (Model.getFacade().isAExtend(edge)) {
+ newEdge = new FigExtend2(edge, settings);
+
+ // The nodes at the two ends
+ Object base = Model.getFacade().getBase(edge);
+ Object extension = Model.getFacade().getExtension(edge);
+
+ // The figs for the two end nodes
+ FigNode baseFN = (FigNode) lay.presentationFor(base);
+ FigNode extensionFN = (FigNode) lay.presentationFor(extension);
+
+ // Link the new extend relationship in to the ends. Remember we
+ // draw from the extension use case to the base use case.
+ newEdge.setSourcePortFig(extensionFN);
+ newEdge.setSourceFigNode(extensionFN);
+
+ newEdge.setDestPortFig(baseFN);
+ newEdge.setDestFigNode(baseFN);
+
+ } else if (Model.getFacade().isAInclude(edge)) {
+ newEdge = new FigInclude2(edge, settings);
+
+ Object base = Model.getFacade().getBase(edge);
+ Object addition = Model.getFacade().getAddition(edge);
+
+ // The figs for the two end nodes
+ FigNode baseFN = (FigNode) lay.presentationFor(base);
+ FigNode additionFN = (FigNode) lay.presentationFor(addition);
+
+ // Link the new include relationship in to the ends
+ newEdge.setSourcePortFig(baseFN);
+ newEdge.setSourceFigNode(baseFN);
+
+ newEdge.setDestPortFig(additionFN);
+ newEdge.setDestFigNode(additionFN);
+ } else if (Model.getFacade().isADependency(edge)) {
+ newEdge = new FigDependency2(edge, settings);
+
+ // Where there is more than one supplier or client, take the first
+ // element in each case. There really ought to be a check that
+ // there are some here for safety.
+
+ Object supplier =
+ ((Model.getFacade().getSuppliers(edge).toArray())[0]);
+ Object client =
+ ((Model.getFacade().getClients(edge).toArray())[0]);
+
+ // The figs for the two end nodes
+ FigNode supplierFN = (FigNode) lay.presentationFor(supplier);
+ FigNode clientFN = (FigNode) lay.presentationFor(client);
+
+ // Link the new dependency in to the ends
+ newEdge.setSourcePortFig(clientFN);
+ newEdge.setSourceFigNode(clientFN);
+
+ newEdge.setDestPortFig(supplierFN);
+ newEdge.setDestFigNode(supplierFN);
+
+ } else if (edge instanceof CommentEdge) {
+ newEdge = new FigEdgeNote2(edge, settings);
+ }
+
+ if (newEdge == null) {
+ throw new IllegalArgumentException(
+ "Don't know how to create FigEdge for model type "
+ + edge.getClass().getName());
+ } else {
+ setPorts(lay, newEdge);
+ }
+
+ lay.add(newEdge);
+ newEdge.setLayer(lay);
+
+// newEdge.setDiElement(
+// GraphChangeAdapter.getInstance().createElement(gm, edge));
+
+ return newEdge;
+ }
+
+}
------------------------------------------------------
http://argouml.tigris.org/ds/viewMessage.do?dsForumId=5905&dsMessageId=2382238
To unsubscribe from this discussion, e-mail: [[email protected]].