Author: bobtarling
Date: 2011-05-09 12:39:31-0700
New Revision: 19384
Modified:
trunk/src/argouml-core-model-euml/src/org/argouml/model/euml/MetaTypesEUMLImpl.java
trunk/src/argouml-core-model-euml/src/org/argouml/model/euml/StateMachinesFactoryEUMLImpl.java
trunk/src/argouml-core-model-euml/src/org/argouml/model/euml/StateMachinesHelperEUMLImpl.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:
Model implementations for UML2 Regions
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=19384&r1=19383&r2=19384
==============================================================================
--- 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 2011-05-09 12:39:31-0700
@@ -13,6 +13,8 @@
package org.argouml.model.euml;
+import javax.swing.plaf.synth.Region;
+
import org.argouml.model.MetaTypes;
import org.argouml.model.NotImplementedException;
import org.eclipse.uml2.uml.Abstraction;
@@ -490,6 +492,10 @@
return Reception.class;
}
+ public Object getRegion() {
+ return Region.class;
+ }
+
public Object getReturnAction() {
// TODO: Auto-generated method stub
throw new NotYetImplementedException();
Modified: trunk/src/argouml-core-model-euml/src/org/argouml/model/euml/StateMachinesFactoryEUMLImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-model-euml/src/org/argouml/model/euml/StateMachinesFactoryEUMLImpl.java?view=diff&pathrev=19384&r1=19383&r2=19384
==============================================================================
--- trunk/src/argouml-core-model-euml/src/org/argouml/model/euml/StateMachinesFactoryEUMLImpl.java (original)
+++ trunk/src/argouml-core-model-euml/src/org/argouml/model/euml/StateMachinesFactoryEUMLImpl.java 2011-05-09 12:39:31-0700
@@ -11,9 +11,14 @@
*******************************************************************************/
package org.argouml.model.euml;
+import java.util.List;
+
import org.argouml.model.AbstractModelFactory;
+import org.argouml.model.Model;
import org.argouml.model.StateMachinesFactory;
import org.eclipse.uml2.uml.BehavioredClassifier;
+import org.eclipse.uml2.uml.Region;
+import org.eclipse.uml2.uml.State;
import org.eclipse.uml2.uml.StateMachine;
import org.eclipse.uml2.uml.Transition;
import org.eclipse.uml2.uml.UMLFactory;
@@ -156,20 +161,49 @@
}
- public Object buildTransition(Object owningState, Object source, Object dest) {
- // TODO: Auto-generated method stub
- throw new NotYetImplementedException();
-
+ public Object buildTransition(
+ Object owningState, Object source, Object dest) {
+
+ if (!(source instanceof Vertex) || !(dest instanceof Vertex)) {
+ throw new IllegalArgumentException(
+ "The source and dest must both be vertices. Source=" //$NON-NLS-1$
+ + source + " dest=" + dest); //$NON-NLS-1$
+ }
+
+ if (!(owningState instanceof StateMachine)
+ && !(owningState instanceof State)
+ && !(owningState instanceof Region)) {
+ throw new IllegalArgumentException(
+ "Did not expect a " + owningState); //$NON-NLS-1$
+ }
+
+ final Object region;
+ if (owningState instanceof StateMachine || owningState instanceof State) {
+ List regions = Model.getStateMachinesHelper().getRegions(owningState);
+ if (regions.isEmpty()) {
+ region = Model.getUmlFactory().buildNode(
+ Model.getMetaTypes().getRegion(), owningState);
+ } else {
+ region = regions.get(0);
+ }
+ } else {
+ region = (Region) owningState;
+ }
+
+ Transition transition = createTransition();
+ transition.setSource((Vertex) source);
+ transition.setTarget((Vertex) dest);
+ transition.setContainer((Region) region);
+ return transition;
}
public Object buildTransition(Object source, Object target) {
- if (source instanceof Vertex && target instanceof Vertex) {
- Transition trans = createTransition();
- trans.setSource((Vertex) source);
- trans.setTarget((Vertex) target);
- return trans;
+ if (!(source instanceof Vertex) || !(target instanceof Vertex)) {
+ throw new IllegalArgumentException();
}
- throw new IllegalArgumentException();
+
+ Region region = ((Vertex) source).getContainer();
+ return buildTransition(region, source, target);
}
public Object createCallEvent() {
Modified: trunk/src/argouml-core-model-euml/src/org/argouml/model/euml/StateMachinesHelperEUMLImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-model-euml/src/org/argouml/model/euml/StateMachinesHelperEUMLImpl.java?view=diff&pathrev=19384&r1=19383&r2=19384
==============================================================================
--- trunk/src/argouml-core-model-euml/src/org/argouml/model/euml/StateMachinesHelperEUMLImpl.java (original)
+++ trunk/src/argouml-core-model-euml/src/org/argouml/model/euml/StateMachinesHelperEUMLImpl.java 2011-05-09 12:39:31-0700
@@ -112,11 +112,12 @@
public List getRegions(Object handle) {
if (handle instanceof StateMachine) {
- ((StateMachine) handle).getRegions();
+ return ((StateMachine) handle).getRegions();
} else if (handle instanceof State) {
- ((State) handle).getRegions();
+ return ((State) handle).getRegions();
}
- throw new IllegalArgumentException();
+ throw new IllegalArgumentException(
+ "getRegions call not valid for a " + handle); //$NON-NLS-1$
}
public Object getSource(Object trans) {
@@ -198,10 +199,29 @@
}
- public void setContainer(Object handle, Object compositeState) {
- // TODO: Auto-generated method stub
- throw new NotYetImplementedException();
-
+ public void setContainer(Object handle, Object region) {
+ if (!(handle instanceof Vertex)) {
+ throw new IllegalArgumentException(
+ "Expected a vertext, got a " + handle); //$NON-NLS-1$
+ }
+
+ if (region instanceof State) {
+ List<Region> regions = ((State) region).getRegions();
+ if (regions.isEmpty()) {
+ region = Model.getUmlFactory().buildNode(
+ Model.getMetaTypes().getRegion(), region);
+ } else {
+ region = regions.get(0);
+ }
+ }
+
+ if (region == null || region instanceof Region) {
+ ((Vertex) handle).setContainer((Region) region);
+ return;
+ }
+
+ throw new IllegalArgumentException(
+ "Expected a State or Region, got a " + handle); //$NON-NLS-1$
}
public void setContext(Object statemachine, Object modelElement) {
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=19384&r1=19383&r2=19384
==============================================================================
--- 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 2011-05-09 12:39:31-0700
@@ -67,9 +67,12 @@
import org.eclipse.uml2.uml.Pin;
import org.eclipse.uml2.uml.Profile;
import org.eclipse.uml2.uml.Property;
+import org.eclipse.uml2.uml.Pseudostate;
import org.eclipse.uml2.uml.Reception;
+import org.eclipse.uml2.uml.Region;
import org.eclipse.uml2.uml.Signal;
import org.eclipse.uml2.uml.State;
+import org.eclipse.uml2.uml.StateMachine;
import org.eclipse.uml2.uml.Stereotype;
import org.eclipse.uml2.uml.TemplateParameter;
import org.eclipse.uml2.uml.Transition;
@@ -77,6 +80,7 @@
import org.eclipse.uml2.uml.UMLFactory;
import org.eclipse.uml2.uml.Usage;
import org.eclipse.uml2.uml.UseCase;
+import org.eclipse.uml2.uml.Vertex;
/**
* The implementation of the UmlFactory for EUML2.
@@ -353,6 +357,8 @@
o = UMLFactory.eINSTANCE.createState();
} else if (elementType == metaTypes.getFinalState()) {
o = UMLFactory.eINSTANCE.createFinalState();
+ } else if (elementType == metaTypes.getRegion()) {
+ o = UMLFactory.eINSTANCE.createRegion();
} else if (elementType == metaTypes.getPseudostate()) {
o = modelImpl.getStateMachinesFactory().createPseudostate();
} else if (elementType == metaTypes.getActionState()) {
@@ -599,6 +605,29 @@
validContainmentMap.put(Element.class,
new Class<?>[] {
});
+
+ // specifies valid elements for a Region to contain
+ validContainmentMap.put(Region.class,
+ new Class<?>[] {
+ State.class, Pseudostate.class
+ });
+
+ // specifies valid elements for a Region to contain
+ validContainmentMap.put(StateMachine.class,
+ new Class<?>[] {
+ Region.class
+ });
+
+ // specifies valid elements for a Package to contain
+ validContainmentMap.put(Package.class,
+ new Class<?>[] {
+ Package.class, Actor.class,
+ UseCase.class, org.eclipse.uml2.uml.Class.class,
+ Interface.class, Component.class,
+ Node.class, Enumeration.class, DataType.class,
+ Signal.class
+ });
+
// specifies valid elements for a Package to contain
validContainmentMap.put(Package.class,
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=19384&r1=19383&r2=19384
==============================================================================
--- 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 2011-05-09 12:39:31-0700
@@ -528,6 +528,10 @@
return Reception.class;
}
+ public Object getRegion() {
+ throw new NotImplementedException("Not a UML 1.4 element");
+ }
+
public Object getReturnAction() {
return ReturnAction.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=19384&r1=19383&r2=19384
==============================================================================
--- trunk/src/argouml-core-model/src/org/argouml/model/MetaTypes.java (original)
+++ trunk/src/argouml-core-model/src/org/argouml/model/MetaTypes.java 2011-05-09 12:39:31-0700
@@ -475,6 +475,11 @@
Object getReception();
/**
+ * @return Returns the Region.
+ */
+ Object getRegion();
+
+ /**
* @return Returns the ReturnAction.
*/
Object getReturnAction();
------------------------------------------------------
http://argouml.tigris.org/ds/viewMessage.do?dsForumId=5905&dsMessageId=2733446
To unsubscribe from this discussion, e-mail: [[email protected]].
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.