Author: bobtarling Date: 2011-05-07 04:43:37-0700 New Revision: 19358 Modified: trunk/src/argouml-core-model-euml/src/org/argouml/model/euml/FacadeEUMLImpl.java trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/FacadeMDRImpl.java trunk/src/argouml-core-model/src/org/argouml/model/Facade.java
Log: Implement some UML2 methods for state diagram. Introduce getTriggers method (UML2 has a List not just a single item) 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=19358&r1=19357&r2=19358 ============================================================================== --- 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-07 04:43:37-0700 @@ -789,8 +789,10 @@ } public Object getGuard(Object handle) { - throw new NotYetImplementedException(); - + if (isATransition(handle)) { + return ((Transition) handle).getGuard(); + } + throw new IllegalArgumentException(); } public Object getIcon(Object handle) { @@ -849,8 +851,26 @@ return ((UseCase) handle).getIncludes(); } - public Collection getIncomings(Object handle) { - throw new NotYetImplementedException(); + public List getIncomings(Object handle) { + if (isAGuard(handle) || isAAction(handle)) { + return getIncomings(getTransition(handle)); + } + if (isAEvent(handle)) { + Iterator trans = getTransitions(handle).iterator(); + List incomings = new ArrayList(); + while (trans.hasNext()) { + incomings.addAll(getIncomings(trans.next())); + } + return incomings; + } + if (isAStateVertex(handle)) { + return ((Vertex) handle).getIncomings(); + } + // For a Transition use indirection through source StateVertex + if (isATransition(handle)) { + return ((Transition) handle).getSource().getIncomings(); + } + throw new IllegalArgumentException(); } public Object getInitialValue(Object handle) { @@ -1150,8 +1170,26 @@ throw new NotYetImplementedException(); } - public Collection getOutgoings(Object handle) { - throw new NotYetImplementedException(); + public List getOutgoings(Object handle) { + if (isAGuard(handle) || isAAction(handle)) { + return getOutgoings(getTransition(handle)); + } + if (isAEvent(handle)) { + Iterator trans = getTransitions(handle).iterator(); + List outgoings = new ArrayList(); + while (trans.hasNext()) { + outgoings.addAll(getOutgoings(trans.next())); + } + return outgoings; + } + if (isAStateVertex(handle)) { + return ((Vertex) handle).getOutgoings(); + } + // For a Transition use indirection through source StateVertex + if (isATransition(handle)) { + return ((Transition) handle).getSource().getOutgoings(); + } + throw new IllegalArgumentException(); } public Collection<Element> getOwnedElements(Object handle) { @@ -1600,6 +1638,13 @@ return ((Transition) handle).getTriggers().get(0); } + public List<Trigger> getTriggers(Object handle) { + if (!(handle instanceof Transition)) { + throw new IllegalArgumentException(); + } + return ((Transition) handle).getTriggers(); + } + public Object getType(Object handle) { if (!(handle instanceof TypedElement)) { throw new IllegalArgumentException(); Modified: trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/FacadeMDRImpl.java Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/FacadeMDRImpl.java?view=diff&pathrev=19358&r1=19357&r2=19358 ============================================================================== --- trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/FacadeMDRImpl.java (original) +++ trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/FacadeMDRImpl.java 2011-05-07 04:43:37-0700 @@ -3457,6 +3457,22 @@ } } + public List getTriggers(Object handle) { + try { + if (handle instanceof Transition) { + ArrayList l = new ArrayList(); + Event trig = ((Transition) handle).getTrigger(); + if (trig != null) { + l.add(trig); + } + return l; + } + return illegalArgumentList(handle); + } catch (InvalidObjectException e) { + throw new InvalidElementException(e); + } + } + public Object getType(Object handle) { 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=19358&r1=19357&r2=19358 ============================================================================== --- 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-07 04:43:37-0700 @@ -2864,10 +2864,19 @@ * * @param handle the transition * @return the trigger + * @deprecated use getTriggers */ Object getTrigger(Object handle); /** + * Get the triggers of a transition. + * + * @param handle the transition + * @return the trigger + */ + List getTriggers(Object handle); + + /** * The type of a StructuralFeature, AssociationEnd, Parameter, * ObjectFlowState, TagDefinition, TaggedValue or ClassifierInState. * ------------------------------------------------------ http://argouml.tigris.org/ds/viewMessage.do?dsForumId=5905&dsMessageId=2732327 To unsubscribe from this discussion, e-mail: [[email protected]].
