Author: bobtarling Date: 2010-07-17 04:37:06-0700 New Revision: 18524 Added: trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigAction.java Modified: trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/UMLActivityDiagram.java trunk/src/argouml-core-model-euml/src/org/argouml/model/euml/MetaTypesEUMLImpl.java trunk/src/argouml-core-model-euml/src/org/argouml/model/euml/UmlFactoryEUMLImpl.java trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/MetaTypesMDRImpl.java trunk/src/argouml-core-model/src/org/argouml/model/MetaTypes.java
Log: Add a few action tool to activity diagram (currently the all look the same) Added: trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigAction.java Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigAction.java?view=markup&pathrev=18524 ============================================================================== --- (empty file) +++ trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigAction.java 2010-07-17 04:37:06-0700 @@ -0,0 +1,80 @@ +/* $Id: FigAction.java bobtarling $ + ***************************************************************************** + * Copyright (c) 2010 Contributors - see below + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Bob Tarling + ***************************************************************************** + */ + +package org.argouml.activity2.diagram; + +import java.awt.Dimension; +import java.awt.Rectangle; +import org.argouml.uml.diagram.DiagramSettings; +import org.argouml.uml.diagram.ui.FigNodeModelElement; +import org.tigris.gef.presentation.Fig; +import org.tigris.gef.presentation.FigRRect; + +public class FigAction extends FigNodeModelElement { + + private static final int PADDING = 8; + private static final int WIDTH = 90; + private static final int HEIGHT = 25; + + /** + * Constructor a new FigAction + * + * @param owner the owning UML element + * @param bounds rectangle describing bounds + * @param settings rendering settings + */ + public FigAction(final Object owner, final Rectangle bounds, + final DiagramSettings settings) { + super(owner, bounds, settings); + addFig(getBigPort()); + } + + @Override + protected Fig createBigPortFig() { + return new FigRRect(X0, Y0, WIDTH, HEIGHT, LINE_COLOR, FILL_COLOR); + } + + @Override + public Dimension getMinimumSize() { + Dimension stereoDim = getStereotypeFig().getMinimumSize(); + Dimension nameDim = getNameFig().getMinimumSize(); + + int w = Math.max(stereoDim.width, nameDim.width) + PADDING * 2; + /* The stereoDim has height=2, even if it is empty, + * hence the -2 below: */ + int h = stereoDim.height - 2 + nameDim.height + PADDING; + w = Math.max(w, h + 44); // the width needs to be > the height + return new Dimension(w, h); + } + + @Override + protected void setStandardBounds(int x, int y, int w, int h) { + if (getNameFig() == null) { + return; + } + Rectangle oldBounds = getBounds(); + + Dimension stereoDim = getStereotypeFig().getMinimumSize(); + Dimension nameDim = getNameFig().getMinimumSize(); + getNameFig().setBounds(x + PADDING, y + stereoDim.height, + w - PADDING * 2, nameDim.height); + getStereotypeFig().setBounds(x + PADDING, y, + w - PADDING * 2, stereoDim.height); + getBigPort().setBounds(x, y, w, h); + ((FigRRect) getBigPort()).setCornerRadius(h); + + calcBounds(); + updateEdges(); + firePropChange("bounds", oldBounds, getBounds()); + } +} Modified: trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/UMLActivityDiagram.java Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/UMLActivityDiagram.java?view=diff&pathrev=18524&r1=18523&r2=18524 ============================================================================== --- trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/UMLActivityDiagram.java (original) +++ trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/UMLActivityDiagram.java 2010-07-17 04:37:06-0700 @@ -18,14 +18,18 @@ import java.util.Collection; import java.util.Collections; +import javax.swing.Action; + import org.apache.log4j.Logger; import org.argouml.i18n.Translator; import org.argouml.model.ActivityDiagram; 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.static_structure.ui.FigComment; import org.argouml.uml.diagram.ui.FigNodeModelElement; +import org.argouml.uml.diagram.ui.RadioAction; import org.argouml.uml.diagram.ui.UMLDiagram; import org.tigris.gef.base.LayerPerspective; import org.tigris.gef.base.LayerPerspectiveMutable; @@ -34,8 +38,6 @@ public class UMLActivityDiagram extends UMLDiagram implements ActivityDiagram { - private Object[] actions; - private static final Logger LOG = Logger .getLogger(UMLActivityDiagram.class); @@ -77,11 +79,22 @@ @Override protected Object[] getUmlActions() { - if (actions == null) { - actions = new Object[0]; - } + Object[] actions = + { + createAction(Model.getMetaTypes().getCallBehaviorAction(), "button.new-callbehavioraction"), + createAction(Model.getMetaTypes().getCreateObjectAction(), "button.new-createobjectaction"), + createAction(Model.getMetaTypes().getDestroyObjectAction(), "button.new-destroyobjectaction"), + }; return actions; } + + /** + * @return Returns a diagram tool creation action. + */ + private Action createAction(Object metaType, String label) { + return new RadioAction( + new CmdCreateNode(metaType, label)); + } @Override public String getLabelName() { @@ -96,7 +109,7 @@ @Override public boolean doesAccept(Object objectToAccept) { - if (Model.getFacade().isAComment(objectToAccept)) { + if (Model.getFacade().isAComment(objectToAccept) || Model.getFacade().isAAction(objectToAccept)) { return true; } return false; @@ -131,7 +144,9 @@ DiagramSettings settings = getDiagramSettings(); - if (Model.getFacade().isAComment(modelElement)) { + if (Model.getFacade().isAAction(modelElement)) { + figNode = new FigAction(modelElement, bounds, settings); + } else if (Model.getFacade().isAComment(modelElement)) { figNode = new FigComment(modelElement, bounds, settings); } Modified: trunk/src/argouml-core-model-euml/src/org/argouml/model/euml/MetaTypesEUMLImpl.java Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-model-euml/src/org/argouml/model/euml/MetaTypesEUMLImpl.java?view=diff&pathrev=18524&r1=18523&r2=18524 ============================================================================== --- trunk/src/argouml-core-model-euml/src/org/argouml/model/euml/MetaTypesEUMLImpl.java (original) +++ trunk/src/argouml-core-model-euml/src/org/argouml/model/euml/MetaTypesEUMLImpl.java 2010-07-17 04:37:06-0700 @@ -26,6 +26,7 @@ import org.eclipse.uml2.uml.AssociationClass; import org.eclipse.uml2.uml.BehavioralFeature; import org.eclipse.uml2.uml.CallAction; +import org.eclipse.uml2.uml.CallBehaviorAction; import org.eclipse.uml2.uml.CallConcurrencyKind; import org.eclipse.uml2.uml.CallEvent; import org.eclipse.uml2.uml.ChangeEvent; @@ -34,8 +35,10 @@ import org.eclipse.uml2.uml.Comment; import org.eclipse.uml2.uml.Component; import org.eclipse.uml2.uml.Constraint; +import org.eclipse.uml2.uml.CreateObjectAction; import org.eclipse.uml2.uml.DataType; import org.eclipse.uml2.uml.Dependency; +import org.eclipse.uml2.uml.DestroyObjectAction; import org.eclipse.uml2.uml.Element; import org.eclipse.uml2.uml.ElementImport; import org.eclipse.uml2.uml.Enumeration; @@ -188,6 +191,10 @@ return CallAction.class; } + public Object getCallBehaviorAction() { + return CallBehaviorAction.class; + } + public Object getCallConcurrencyKind() { return CallConcurrencyKind.class; } @@ -237,8 +244,11 @@ } public Object getCreateAction() { - // TODO: Auto-generated method stub - throw new NotYetImplementedException(); + throw new NotImplementedException("This is not a UML2 element"); + } + + public Object getCreateObjectAction() { + return CreateObjectAction.class; } public Object getDataType() { @@ -250,8 +260,11 @@ } public Object getDestroyAction() { - // TODO: Auto-generated method stub - throw new NotYetImplementedException(); + throw new NotImplementedException("This is not a UML2 class"); + } + + public Object getDestroyObjectAction() { + return DestroyObjectAction.class; } public Object getElementImport() { Modified: trunk/src/argouml-core-model-euml/src/org/argouml/model/euml/UmlFactoryEUMLImpl.java Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-model-euml/src/org/argouml/model/euml/UmlFactoryEUMLImpl.java?view=diff&pathrev=18524&r1=18523&r2=18524 ============================================================================== --- trunk/src/argouml-core-model-euml/src/org/argouml/model/euml/UmlFactoryEUMLImpl.java (original) +++ trunk/src/argouml-core-model-euml/src/org/argouml/model/euml/UmlFactoryEUMLImpl.java 2010-07-17 04:37:06-0700 @@ -64,6 +64,7 @@ import org.eclipse.uml2.uml.TemplateParameter; import org.eclipse.uml2.uml.Transition; import org.eclipse.uml2.uml.Type; +import org.eclipse.uml2.uml.UMLFactory; import org.eclipse.uml2.uml.Usage; import org.eclipse.uml2.uml.UseCase; @@ -270,8 +271,12 @@ "Attempt to instantiate abstract type"); //$NON-NLS-1$ } else if (elementType == metaTypes.getActivity()) { o = modelImpl.getActivityGraphsFactory().createActivityGraph(); - } else if (elementType == metaTypes.getCallState()) { - o = modelImpl.getActivityGraphsFactory().createCallState(); + } else if (elementType == metaTypes.getCallBehaviorAction()) { + o = UMLFactory.eINSTANCE.createCallBehaviorAction(); + } else if (elementType == metaTypes.getCreateObjectAction()) { + o = UMLFactory.eINSTANCE.createCreateObjectAction(); + } else if (elementType == metaTypes.getDestroyObjectAction()) { + o = UMLFactory.eINSTANCE.createDestroyObjectAction(); } else if (elementType == metaTypes.getSimpleState()) { o = modelImpl.getStateMachinesFactory().createSimpleState(); } else if (elementType == metaTypes.getFinalState()) { Modified: trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/MetaTypesMDRImpl.java Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/MetaTypesMDRImpl.java?view=diff&pathrev=18524&r1=18523&r2=18524 ============================================================================== --- trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/MetaTypesMDRImpl.java (original) +++ trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/MetaTypesMDRImpl.java 2010-07-17 04:37:06-0700 @@ -276,6 +276,10 @@ return CallAction.class; } + public Object getCallBehaviorAction() { + throw new NotImplementedException("This is not a UML1.4 class"); + } + public Object getCallConcurrencyKind() { return CallConcurrencyKind.class; } @@ -324,6 +328,10 @@ return CreateAction.class; } + public Object getCreateObjectAction() { + throw new NotImplementedException("This is not a UML1.4 class"); + } + public Object getDataType() { return DataType.class; } @@ -336,6 +344,10 @@ return DestroyAction.class; } + public Object getDestroyObjectAction() { + throw new NotImplementedException("This is not a UML1.4 class"); + } + public Object getEnumeration() { return Enumeration.class; } Modified: trunk/src/argouml-core-model/src/org/argouml/model/MetaTypes.java Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-model/src/org/argouml/model/MetaTypes.java?view=diff&pathrev=18524&r1=18523&r2=18524 ============================================================================== --- trunk/src/argouml-core-model/src/org/argouml/model/MetaTypes.java (original) +++ trunk/src/argouml-core-model/src/org/argouml/model/MetaTypes.java 2010-07-17 04:37:06-0700 @@ -152,6 +152,11 @@ Object getCallAction(); /** + * @return Returns the CreateObjectAction. + */ + Object getCallBehaviorAction(); + + /** * @return Returns the CallConcurrencyKind. */ Object getCallConcurrencyKind(); @@ -215,6 +220,11 @@ Object getCreateAction(); /** + * @return Returns the CreateObjectAction. + */ + Object getCreateObjectAction(); + + /** * @return Returns the Datatype. */ Object getDataType(); @@ -230,6 +240,11 @@ Object getDestroyAction(); /** + * @return Returns the DestroyObjectAction. + */ + Object getDestroyObjectAction(); + + /** * @return the ElementImport class. */ Object getElementImport(); ------------------------------------------------------ http://argouml.tigris.org/ds/viewMessage.do?dsForumId=5905&dsMessageId=2634423 To unsubscribe from this discussion, e-mail: [[email protected]].
