Author: mvw
Date: 2011-05-12 23:12:11-0700
New Revision: 19413
Modified:
trunk/src/argouml-core-model-euml/src/org/argouml/model/euml/FacadeEUMLImpl.java
trunk/src/argouml-core-model-euml/src/org/argouml/model/euml/StateMachinesHelperEUMLImpl.java
trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/StateMachinesHelperMDRImpl.java
trunk/src/argouml-core-model/src/org/argouml/model/Facade.java
trunk/src/argouml-core-model/src/org/argouml/model/StateMachinesHelper.java
trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLStateMachineTransitionListModel.java
Log:
Some model code to cope with the way internal transitions are defined in UML2.
Modified: trunk/src/argouml-core-model-euml/src/org/argouml/model/euml/FacadeEUMLImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-model-euml/src/org/argouml/model/euml/FacadeEUMLImpl.java?view=diff&pathrev=19413&r1=19412&r2=19413
==============================================================================
--- trunk/src/argouml-core-model-euml/src/org/argouml/model/euml/FacadeEUMLImpl.java (original)
+++ trunk/src/argouml-core-model-euml/src/org/argouml/model/euml/FacadeEUMLImpl.java 2011-05-12 23:12:11-0700
@@ -1,6 +1,6 @@
// $Id$
/*******************************************************************************
- * Copyright (c) 2007,2011 Tom Morris and other contributors
+ * Copyright (c) 2007-2011 Tom Morris and other contributors
* 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
@@ -912,7 +912,23 @@
}
public Collection getInternalTransitions(Object handle) {
- throw new NotYetImplementedException();
+ if (isAVertex(handle)) {
+ Region region = ((Vertex) handle).getContainer();
+ if (region == null) {
+ return null;
+ }
+ List<Transition> result = new ArrayList<Transition>();
+ List<Transition> transitions = region.getTransitions();
+ for (Transition transition : transitions) {
+ if ((transition.getSource() == handle) &&
+ (transition.getTarget() == handle) &&
+ transition.getKind() == TransitionKind.INTERNAL_LITERAL) {
+ result.add(transition);
+ }
+ }
+ return result;
+ }
+ throw new IllegalArgumentException();
}
public Object getKind(Object handle) {
@@ -1630,7 +1646,26 @@
}
public Collection getTransitions(Object handle) {
- throw new NotYetImplementedException();
+ if (isAStateMachine(handle)) {
+ List<Region> regions = ((StateMachine) handle).getRegions();
+ List<Transition> result = new ArrayList<Transition>();
+ for (Region region : regions) {
+ result.addAll(region.getTransitions());
+ }
+ return result;
+ } else if (isAVertex(handle)) {
+ return getInternalTransitions(handle);
+ } else if (isARegion(handle)) {
+ return ((Region) handle).getTransitions();
+ } else if (isATrigger(handle)) {
+ List<Transition> result = new ArrayList<Transition>();
+ // TODO: not complete - how to retrieve the transitions?
+ } else if (isAEvent(handle)) {
+ // TODO: not complete
+ throw new NotYetImplementedException();
+ }
+ throw new IllegalArgumentException(
+ "handle must be instance of StateMachine, Vertex, Region, Trigger or Event"); //$NON-NLS-1$
}
public Trigger getTrigger(Object handle) {
@@ -2202,6 +2237,10 @@
return handle instanceof Reception;
}
+ public boolean isARegion(Object handle) {
+ return handle instanceof Region;
+ }
+
public boolean isARelationship(Object handle) {
return handle instanceof Relationship;
}
@@ -2250,6 +2289,10 @@
return handle instanceof Vertex;
}
+ public boolean isAVertex(Object handle) {
+ return handle instanceof Vertex;
+ }
+
public boolean isAStereotype(Object handle) {
return handle instanceof Stereotype;
}
@@ -2326,6 +2369,10 @@
public boolean isATransition(Object handle) {
return handle instanceof Transition;
}
+
+ public boolean isATrigger(Object handle) {
+ return handle instanceof Trigger;
+ }
public boolean isAUMLElement(Object handle) {
return handle instanceof Element;
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=19413&r1=19412&r2=19413
==============================================================================
--- 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-12 23:12:11-0700
@@ -9,9 +9,11 @@
* Contributors:
* Tom Morris - initial framework
* Bob Tarling
+ * Michiel van der Wulp
*******************************************************************************/
package org.argouml.model.euml;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@@ -22,6 +24,7 @@
import org.eclipse.uml2.uml.State;
import org.eclipse.uml2.uml.StateMachine;
import org.eclipse.uml2.uml.Transition;
+import org.eclipse.uml2.uml.TransitionKind;
import org.eclipse.uml2.uml.Vertex;
/**
@@ -98,6 +101,29 @@
throw new IllegalArgumentException();
}
+ public Collection getTransitions(Object handle,
+ boolean includeInternals) {
+ if (handle instanceof StateMachine) {
+ Collection<Transition> result = new ArrayList<Transition>();
+ List<Region> regions = ((StateMachine) handle).getRegions();
+ for (Region region : regions) {
+ List<Transition> transitions =region.getTransitions();
+ if (includeInternals) {
+ result.addAll(transitions);
+ } else {
+ for (Transition transition : transitions) {
+ if (!transition.getKind().equals(TransitionKind.INTERNAL_LITERAL)) {
+ result.add(transition);
+ }
+ }
+ }
+ }
+ return result;
+ }
+ throw new IllegalArgumentException(
+ "Argument is not a statemachine");
+ }
+
public Collection getOutgoingStates(Object ostatevertex) {
// TODO: Auto-generated method stub
throw new NotYetImplementedException();
Modified: trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/StateMachinesHelperMDRImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/StateMachinesHelperMDRImpl.java?view=diff&pathrev=19413&r1=19412&r2=19413
==============================================================================
--- trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/StateMachinesHelperMDRImpl.java (original)
+++ trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/StateMachinesHelperMDRImpl.java 2011-05-12 23:12:11-0700
@@ -1,6 +1,6 @@
/* $Id$
*****************************************************************************
- * Copyright (c) 2009-2010 Contributors - see below
+ * Copyright (c) 2009-2011 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
@@ -8,7 +8,7 @@
*
* Contributors:
* tfmorris
- * mvw
+ * Michiel van der Wulp
*****************************************************************************
*
* Some portions of this file was previously release using the BSD License:
@@ -356,6 +356,27 @@
"Argument is not a composite state");
}
+ public Collection<Transition> getTransitions(Object handle,
+ boolean includeInternals) {
+ if (handle instanceof StateMachine) {
+ Collection<Transition> result = new ArrayList<Transition>();
+ result.addAll(((StateMachine) handle).getTransitions());
+ if (includeInternals) {
+ State top = ((StateMachine) handle).getTop();
+ if (top != null && top instanceof CompositeState) {
+ Collection<StateVertex> subs = getAllSubStates(top);
+ for (StateVertex sub : subs) {
+ if (sub instanceof State) {
+ result.addAll(((State) sub).getInternalTransition());
+ }
+ }
+ }
+ }
+ return result;
+ }
+ throw new IllegalArgumentException(
+ "Argument is not a statemachine");
+ }
public void removeSubvertex(Object handle, Object subvertex) {
try {
Modified: trunk/src/argouml-core-model/src/org/argouml/model/Facade.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-model/src/org/argouml/model/Facade.java?view=diff&pathrev=19413&r1=19412&r2=19413
==============================================================================
--- trunk/src/argouml-core-model/src/org/argouml/model/Facade.java (original)
+++ trunk/src/argouml-core-model/src/org/argouml/model/Facade.java 2011-05-12 23:12:11-0700
@@ -1934,13 +1934,14 @@
Collection getIncluders(Object handle);
/**
- * Return the incoming Transitions for some StateVertex, Transition, Action,
- * or Guard. For a Transition, the incomings of its source StateVertex are
+ * Return the incoming Transitions for some StateVertex, Event,
+ * Transition, Action, or Guard.
+ * For a Transition, the incomings of its source StateVertex are
* used. For an Action or Guard, the owning Transition is found and then
* the algorithm for Transitions is applied.
*
* @param handle
- * a StateVertex, Transition, Action, or Guard
+ * a StateVertex, Guard, Action, Event or Transition
* @return Collection of Transitions
*/
Collection getIncomings(Object handle);
@@ -1994,9 +1995,9 @@
Collection getInteractions(Object handle);
/**
- * Return the internalTransitions belonging to a State.
+ * Return the internalTransitions belonging to a State (UML1&2) or Vertex (UML2).
*
- * @param handle the State
+ * @param handle the State (UML1&2) or Vertex (UML2)
* @return Collection
*/
Collection getInternalTransitions(Object handle);
@@ -2492,9 +2493,9 @@
/**
* Return the collection of Transitions outgoing from the given
- * stateVertex.
+ * stateVertex, Guard, Action, Event or Transition.
*
- * @param handle statevertex
+ * @param handle stateVertex, Guard, Action, Event or Transition
* @return Collection
*/
Collection getOutgoings(Object handle);
@@ -3017,14 +3018,22 @@
/**
* Return the transitions belonging to the given handle. The handle can be
- * a StateMachine, CompositeState, or Event. For a StateMachine, the
- * Transitions transitions belonging to StateMachine are returned. For a
- * CompositeState, its internalTransitions are returned. For an Event, all
- * transitions triggered by this event will be given back.
+ * a StateMachine, State (UML1), Region (UML2), Vertex (UML2) or Event.
+ * For a StateMachine, the Transitions belonging to the StateMachine
+ * are returned.
+ * For a State, its internalTransitions are returned.
+ * For an Event, all transitions triggered by this event will be given back. <p>
+ *
+ * When the handle is a StateMachine: In UML1 the returned list
+ * excludes all internal transitions. In UML2 internal transitions are included.
+ * Hence this use is deprecated - use
+ * {@link StateMachinesHelper#getTransitions(Object, boolean)} instead,
+ * which clearly specifies whether or not to include the internal transitions.
*
* @param handle
* a StateMachine, CompositeState, or Event
* @return Collection of Transitions
+ * @deprecated by mvw - for a StateMachine
*/
Collection getTransitions(Object handle);
Modified: trunk/src/argouml-core-model/src/org/argouml/model/StateMachinesHelper.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-model/src/org/argouml/model/StateMachinesHelper.java?view=diff&pathrev=19413&r1=19412&r2=19413
==============================================================================
--- trunk/src/argouml-core-model/src/org/argouml/model/StateMachinesHelper.java (original)
+++ trunk/src/argouml-core-model/src/org/argouml/model/StateMachinesHelper.java 2011-05-12 23:12:11-0700
@@ -1,6 +1,6 @@
/* $Id$
*******************************************************************************
- * Copyright (c) 2009-2010 Contributors - see below
+ * Copyright (c) 2009-2011 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
@@ -8,7 +8,7 @@
*
* Contributors:
* tfmorris
- * mvw
+ * Michiel van der Wulp
*******************************************************************************
*
* Some portions of this file was previously release using the BSD License:
@@ -212,6 +212,18 @@
* @return all substates
*/
Collection getAllSubStates(Object compState);
+
+ /**
+ * Return the transitions belonging to the given StateMachine.
+ * The boolean parameter determines the kinds of Transitions returned.
+ * Never returns null.
+ *
+ * @param handle a StateMachine
+ * @param includeInternals include all internal transitions
+ * @return Collection of Transitions
+ */
+ Collection getTransitions(Object handle,
+ boolean includeInternals);
/**
* Remove a given subvertex from a given composite state.
Modified: trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLStateMachineTransitionListModel.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLStateMachineTransitionListModel.java?view=diff&pathrev=19413&r1=19412&r2=19413
==============================================================================
--- trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLStateMachineTransitionListModel.java (original)
+++ trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLStateMachineTransitionListModel.java 2011-05-12 23:12:11-0700
@@ -1,6 +1,6 @@
/* $Id$
*****************************************************************************
- * Copyright (c) 2009 Contributors - see below
+ * Copyright (c) 2009-2011 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
@@ -8,6 +8,7 @@
*
* Contributors:
* bobtarling
+ * Michiel van der Wulp
*****************************************************************************
*
* Some portions of this file was previously release using the BSD License:
@@ -39,7 +40,6 @@
package org.argouml.core.propertypanels.ui;
import org.argouml.model.Model;
-import org.argouml.uml.ui.UMLModelElementListModel2;
/**
* @since Dec 6, 2002
@@ -62,14 +62,14 @@
* @see org.argouml.uml.ui.UMLModelElementListModel2#buildModelList()
*/
protected void buildModelList() {
- setAllElements(Model.getFacade().getTransitions(getTarget()));
+ setAllElements(Model.getStateMachinesHelper().getTransitions(getTarget(), true));
}
/*
* @see org.argouml.uml.ui.UMLModelElementListModel2#isValidElement(Object)
*/
protected boolean isValidElement(Object element) {
- return Model.getFacade().getTransitions(getTarget()).contains(element);
+ return Model.getStateMachinesHelper().getTransitions(getTarget(), true).contains(element);
}
}
------------------------------------------------------
http://argouml.tigris.org/ds/viewMessage.do?dsForumId=5905&dsMessageId=2735263
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.