Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » State Machine - UML Editor & Programmatic
State Machine - UML Editor & Programmatic [message #468754] Mon, 22 January 2007 19:03 Go to next message
Eclipse User
Originally posted by: psentosa.yahoo.com

Hi,

I'd like to create a state machine both programmaticaly and by using the UML
editor, but I'm still confused on how to use them.

1. What are the differences between the usage of Packaged Element -,
Classifier Behaviour -, Nested Behaviour -, Owned Type-, and Do Actions
(Protocol) State Machine?
2. Can "State" exist only within "Region"? I read about "Region" only in the
context of concurrent region (thus, concurrent sub-state). But what about in
the non-concurrent environtment? Do we still need a region?
3. Is this the correct order to define a state charts:
- create (Owned Type/Packaged Element) State Machine
- Create Region
- Create State(s)
- ...??
4. Is there any way to define the beginning state/black circle? (Just like
we can define "Final State"/bordered circle)
5. To define sub states of, say, state A, do I have to create a region as a
child of State A, and then create some states within the newly created
region?

Programmaticaly, how can I create a state machine? If I use the factory
method UMLFactory.eInstance.createStateMachine and I'd like to put this
under the Model element, how can this be done?

Thanks and would appreciate any hints


Paul
Re: State Machine - UML Editor & Programmatic [message #468760 is a reply to message #468754] Tue, 23 January 2007 09:30 Go to previous messageGo to next message
james bruck is currently offline james bruck
Messages: 1724
Registered: July 2009
Senior Member
Hi Paul,

UML can be a complicated puzzle ;) ... This is where a graphical tool comes
in handy.

Your best starting point is to look at the superstructure spec ..

http://www.omg.org/docs/ptc/06-04-02.pdf

some answers inline below ...

- James.


"Paul Sentosa" <psentosa@yahoo.com> wrote in message
news:ep3jd3$ilc$1@utils.eclipse.org...
> Hi,
>
> I'd like to create a state machine both programmaticaly and by using the
> UML
> editor, but I'm still confused on how to use them.
>
> 1. What are the differences between the usage of Packaged Element -,
> Classifier Behaviour -, Nested Behaviour -, Owned Type-, and Do Actions
> (Protocol) State Machine?

A packageable element indicates a named element that may be owned directly
by a package.
Interfaces and classes can own nested classifiers ( ie nested classes ).
Packages can own "Types" ( ie. a class is a Type). Types are
PackageableElements.

Have a look at the UML superstructure spec for detailed explanations of all
these items ( I would simply be cutting and pasting definitions for these
items from the spec )

> 2. Can "State" exist only within "Region"? I read about "Region" only in
> the
> context of concurrent region (thus, concurrent sub-state). But what about
> in
> the non-concurrent environtment? Do we still need a region?

Yes in a non-concurent environment a statemachine would still own a region
in which you would have states.

> 3. Is this the correct order to define a state charts:
> - create (Owned Type/Packaged Element) State Machine
> - Create Region
> - Create State(s)
> - ...??

Yes. ... a StateMachine is a Class. Packages own classess... The order
you have indicated is right.


> 4. Is there any way to define the beginning state/black circle? (Just like
> we can define "Final State"/bordered circle)

Have a look at Pseudostates and the PseudostateKind enumeration. The
Pseudostate entry point is what you are interested in I believe.


> 5. To define sub states of, say, state A, do I have to create a region as
> a
> child of State A, and then create some states within the newly created
> region?

Yes.

>
> Programmaticaly, how can I create a state machine? If I use the factory
> method UMLFactory.eInstance.createStateMachine and I'd like to put this
> under the Model element, how can this be done?

BehavioredClassifiers own behaviors ... StateMachine's are Behaviors.
You can use the BehavioredClassifier.createOwnedBehavior() or
myBehavioredClassifier.getOwnedBehaviors().add(UMLFactory.eI nstance.createStateMachine());

>
> Thanks and would appreciate any hints
>
>
> Paul
>
>
>
Re: State Machine - UML Editor & Programmatic [message #468907 is a reply to message #468760] Tue, 23 January 2007 10:52 Go to previous messageGo to next message
Paul is currently offline Paul
Messages: 55
Registered: July 2009
Member
Hi James,

many thanks for your kind explanation.
To my last question....I'm sorry if I'm missing something, but somehow I
still can't relate my Model element to a BehavioredClassifier.
Is using myModel.createOwnedType() also an alternative? (By casting Type
into StateMachine). What kind of EClass argument should then be used?
Could you please explain a bit more?

Thanks again.

Paul

"James Bruck" <jbruck@ca.ibm.com> schrieb im Newsbeitrag
news:ep5611$sft$1@utils.eclipse.org...
> Hi Paul,
>
> UML can be a complicated puzzle ;) ... This is where a graphical tool
comes
> in handy.
>
> Your best starting point is to look at the superstructure spec ..
>
> http://www.omg.org/docs/ptc/06-04-02.pdf
>
> some answers inline below ...
>
> - James.
>
>
> "Paul Sentosa" <psentosa@yahoo.com> wrote in message
> news:ep3jd3$ilc$1@utils.eclipse.org...
> > Hi,
> >
> > I'd like to create a state machine both programmaticaly and by using the
> > UML
> > editor, but I'm still confused on how to use them.
> >
> > 1. What are the differences between the usage of Packaged Element -,
> > Classifier Behaviour -, Nested Behaviour -, Owned Type-, and Do Actions
> > (Protocol) State Machine?
>
> A packageable element indicates a named element that may be owned directly
> by a package.
> Interfaces and classes can own nested classifiers ( ie nested classes ).
> Packages can own "Types" ( ie. a class is a Type). Types are
> PackageableElements.
>
> Have a look at the UML superstructure spec for detailed explanations of
all
> these items ( I would simply be cutting and pasting definitions for these
> items from the spec )
>
> > 2. Can "State" exist only within "Region"? I read about "Region" only in
> > the
> > context of concurrent region (thus, concurrent sub-state). But what
about
> > in
> > the non-concurrent environtment? Do we still need a region?
>
> Yes in a non-concurent environment a statemachine would still own a region
> in which you would have states.
>
> > 3. Is this the correct order to define a state charts:
> > - create (Owned Type/Packaged Element) State Machine
> > - Create Region
> > - Create State(s)
> > - ...??
>
> Yes. ... a StateMachine is a Class. Packages own classess... The order
> you have indicated is right.
>
>
> > 4. Is there any way to define the beginning state/black circle? (Just
like
> > we can define "Final State"/bordered circle)
>
> Have a look at Pseudostates and the PseudostateKind enumeration. The
> Pseudostate entry point is what you are interested in I believe.
>
>
> > 5. To define sub states of, say, state A, do I have to create a region
as
> > a
> > child of State A, and then create some states within the newly created
> > region?
>
> Yes.
>
> >
> > Programmaticaly, how can I create a state machine? If I use the factory
> > method UMLFactory.eInstance.createStateMachine and I'd like to put this
> > under the Model element, how can this be done?
>
> BehavioredClassifiers own behaviors ... StateMachine's are Behaviors.
> You can use the BehavioredClassifier.createOwnedBehavior() or
>
myBehavioredClassifier.getOwnedBehaviors().add(UMLFactory.eI nstance.createSt
ateMachine());
>
> >
> > Thanks and would appreciate any hints
> >
> >
> > Paul
> >
> >
> >
>
>
Re: State Machine - UML Editor & Programmatic [message #468909 is a reply to message #468907] Tue, 23 January 2007 11:09 Go to previous messageGo to next message
james bruck is currently offline james bruck
Messages: 1724
Registered: July 2009
Senior Member
Hi Paul,

Ok ... let me back up a bit. Firstly, although Statemachines can be owned
direcly by a Package, by convention, they apply to a particular class.
So one would typically ( although not necessarily ) create a statemachine
under a class ( creating it directly under a Package is not wrong ).

So from your package you could do something like...


org.eclipse.uml2.uml.Class myClass =
(org.eclipse.uml2.uml.Class)myPackage.createOwnedType("myClass ",
ULPackage.Literals.CLASS);
// Note: Classes are Types
StateMachine myStateMachine =
(StateMachine)myClass.createOwnedBehavior("myStatemachine",
UMLPackage.Literals.STATE_MACHINE);
// Note: StateMachines are Behaviors, Behaviors are Classes.

Continue in this way to add a region and then a state etc.

The alternative is to manufacture these classes using the factory ie..
UMLFactory.eINSTANCE.createXXXX();
Then get the owning collection and add it in directly ( as mentioned
previously ).

Have a look at the "Getting started with UML" articles by Kenn Hussey for
better explanations.

Regards,

- James.


"Paul" <psentosa@yahoo.com> wrote in message
news:ep5b0c$mpm$1@utils.eclipse.org...
> Hi James,
>
> many thanks for your kind explanation.
> To my last question....I'm sorry if I'm missing something, but somehow I
> still can't relate my Model element to a BehavioredClassifier.
> Is using myModel.createOwnedType() also an alternative? (By casting Type
> into StateMachine). What kind of EClass argument should then be used?
> Could you please explain a bit more?
>
> Thanks again.
>
> Paul
>
> "James Bruck" <jbruck@ca.ibm.com> schrieb im Newsbeitrag
> news:ep5611$sft$1@utils.eclipse.org...
> > Hi Paul,
> >
> > UML can be a complicated puzzle ;) ... This is where a graphical tool
> comes
> > in handy.
> >
> > Your best starting point is to look at the superstructure spec ..
> >
> > http://www.omg.org/docs/ptc/06-04-02.pdf
> >
> > some answers inline below ...
> >
> > - James.
> >
> >
> > "Paul Sentosa" <psentosa@yahoo.com> wrote in message
> > news:ep3jd3$ilc$1@utils.eclipse.org...
> > > Hi,
> > >
> > > I'd like to create a state machine both programmaticaly and by using
the
> > > UML
> > > editor, but I'm still confused on how to use them.
> > >
> > > 1. What are the differences between the usage of Packaged Element -,
> > > Classifier Behaviour -, Nested Behaviour -, Owned Type-, and Do
Actions
> > > (Protocol) State Machine?
> >
> > A packageable element indicates a named element that may be owned
directly
> > by a package.
> > Interfaces and classes can own nested classifiers ( ie nested classes ).
> > Packages can own "Types" ( ie. a class is a Type). Types are
> > PackageableElements.
> >
> > Have a look at the UML superstructure spec for detailed explanations of
> all
> > these items ( I would simply be cutting and pasting definitions for
these
> > items from the spec )
> >
> > > 2. Can "State" exist only within "Region"? I read about "Region" only
in
> > > the
> > > context of concurrent region (thus, concurrent sub-state). But what
> about
> > > in
> > > the non-concurrent environtment? Do we still need a region?
> >
> > Yes in a non-concurent environment a statemachine would still own a
region
> > in which you would have states.
> >
> > > 3. Is this the correct order to define a state charts:
> > > - create (Owned Type/Packaged Element) State Machine
> > > - Create Region
> > > - Create State(s)
> > > - ...??
> >
> > Yes. ... a StateMachine is a Class. Packages own classess... The
order
> > you have indicated is right.
> >
> >
> > > 4. Is there any way to define the beginning state/black circle? (Just
> like
> > > we can define "Final State"/bordered circle)
> >
> > Have a look at Pseudostates and the PseudostateKind enumeration. The
> > Pseudostate entry point is what you are interested in I believe.
> >
> >
> > > 5. To define sub states of, say, state A, do I have to create a region
> as
> > > a
> > > child of State A, and then create some states within the newly created
> > > region?
> >
> > Yes.
> >
> > >
> > > Programmaticaly, how can I create a state machine? If I use the
factory
> > > method UMLFactory.eInstance.createStateMachine and I'd like to put
this
> > > under the Model element, how can this be done?
> >
> > BehavioredClassifiers own behaviors ... StateMachine's are Behaviors.
> > You can use the BehavioredClassifier.createOwnedBehavior() or
> >
>
myBehavioredClassifier.getOwnedBehaviors().add(UMLFactory.eI nstance.createSt
> ateMachine());
> >
> > >
> > > Thanks and would appreciate any hints
> > >
> > >
> > > Paul
> > >
> > >
> > >
> >
> >
>
>
Re: State Machine - UML Editor & Programmatic [message #468912 is a reply to message #468909] Tue, 23 January 2007 12:18 Go to previous messageGo to next message
Paul is currently offline Paul
Messages: 55
Registered: July 2009
Member
Thank you very much, James!

Best Regards
Paul

ps: Is it possible to have some more articles giving examples on how to use
the other APIs?

"James Bruck" <jbruck@ca.ibm.com> schrieb im Newsbeitrag
news:ep5bvn$p66$2@utils.eclipse.org...
> Hi Paul,
>
> Ok ... let me back up a bit. Firstly, although Statemachines can be
owned
> direcly by a Package, by convention, they apply to a particular class.
> So one would typically ( although not necessarily ) create a statemachine
> under a class ( creating it directly under a Package is not wrong ).
>
> So from your package you could do something like...
>
>
> org.eclipse.uml2.uml.Class myClass =
> (org.eclipse.uml2.uml.Class)myPackage.createOwnedType("myClass ",
> ULPackage.Literals.CLASS);
> // Note: Classes are Types
> StateMachine myStateMachine =
> (StateMachine)myClass.createOwnedBehavior("myStatemachine",
> UMLPackage.Literals.STATE_MACHINE);
> // Note: StateMachines are Behaviors, Behaviors are Classes.
>
> Continue in this way to add a region and then a state etc.
>
> The alternative is to manufacture these classes using the factory ie..
> UMLFactory.eINSTANCE.createXXXX();
> Then get the owning collection and add it in directly ( as mentioned
> previously ).
>
> Have a look at the "Getting started with UML" articles by Kenn Hussey for
> better explanations.
>
> Regards,
>
> - James.
>
>
> "Paul" <psentosa@yahoo.com> wrote in message
> news:ep5b0c$mpm$1@utils.eclipse.org...
> > Hi James,
> >
> > many thanks for your kind explanation.
> > To my last question....I'm sorry if I'm missing something, but somehow I
> > still can't relate my Model element to a BehavioredClassifier.
> > Is using myModel.createOwnedType() also an alternative? (By casting Type
> > into StateMachine). What kind of EClass argument should then be used?
> > Could you please explain a bit more?
> >
> > Thanks again.
> >
> > Paul
> >
> > "James Bruck" <jbruck@ca.ibm.com> schrieb im Newsbeitrag
> > news:ep5611$sft$1@utils.eclipse.org...
> > > Hi Paul,
> > >
> > > UML can be a complicated puzzle ;) ... This is where a graphical tool
> > comes
> > > in handy.
> > >
> > > Your best starting point is to look at the superstructure spec ..
> > >
> > > http://www.omg.org/docs/ptc/06-04-02.pdf
> > >
> > > some answers inline below ...
> > >
> > > - James.
> > >
> > >
> > > "Paul Sentosa" <psentosa@yahoo.com> wrote in message
> > > news:ep3jd3$ilc$1@utils.eclipse.org...
> > > > Hi,
> > > >
> > > > I'd like to create a state machine both programmaticaly and by using
> the
> > > > UML
> > > > editor, but I'm still confused on how to use them.
> > > >
> > > > 1. What are the differences between the usage of Packaged Element -,
> > > > Classifier Behaviour -, Nested Behaviour -, Owned Type-, and Do
> Actions
> > > > (Protocol) State Machine?
> > >
> > > A packageable element indicates a named element that may be owned
> directly
> > > by a package.
> > > Interfaces and classes can own nested classifiers ( ie nested
classes ).
> > > Packages can own "Types" ( ie. a class is a Type). Types are
> > > PackageableElements.
> > >
> > > Have a look at the UML superstructure spec for detailed explanations
of
> > all
> > > these items ( I would simply be cutting and pasting definitions for
> these
> > > items from the spec )
> > >
> > > > 2. Can "State" exist only within "Region"? I read about "Region"
only
> in
> > > > the
> > > > context of concurrent region (thus, concurrent sub-state). But what
> > about
> > > > in
> > > > the non-concurrent environtment? Do we still need a region?
> > >
> > > Yes in a non-concurent environment a statemachine would still own a
> region
> > > in which you would have states.
> > >
> > > > 3. Is this the correct order to define a state charts:
> > > > - create (Owned Type/Packaged Element) State Machine
> > > > - Create Region
> > > > - Create State(s)
> > > > - ...??
> > >
> > > Yes. ... a StateMachine is a Class. Packages own classess... The
> order
> > > you have indicated is right.
> > >
> > >
> > > > 4. Is there any way to define the beginning state/black circle?
(Just
> > like
> > > > we can define "Final State"/bordered circle)
> > >
> > > Have a look at Pseudostates and the PseudostateKind enumeration. The
> > > Pseudostate entry point is what you are interested in I believe.
> > >
> > >
> > > > 5. To define sub states of, say, state A, do I have to create a
region
> > as
> > > > a
> > > > child of State A, and then create some states within the newly
created
> > > > region?
> > >
> > > Yes.
> > >
> > > >
> > > > Programmaticaly, how can I create a state machine? If I use the
> factory
> > > > method UMLFactory.eInstance.createStateMachine and I'd like to put
> this
> > > > under the Model element, how can this be done?
> > >
> > > BehavioredClassifiers own behaviors ... StateMachine's are Behaviors.
> > > You can use the BehavioredClassifier.createOwnedBehavior() or
> > >
> >
>
myBehavioredClassifier.getOwnedBehaviors().add(UMLFactory.eI nstance.createSt
> > ateMachine());
> > >
> > > >
> > > > Thanks and would appreciate any hints
> > > >
> > > >
> > > > Paul
> > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>
Re: State Machine - UML Editor & Programmatic [message #469704 is a reply to message #468912] Sat, 27 January 2007 23:02 Go to previous messageGo to next message
james bruck is currently offline james bruck
Messages: 1724
Registered: July 2009
Senior Member
Hi Paul,

The migration document points out some of the new API's.
http://www.eclipse.org/modeling/mdt/uml2/docs/guides/UML2_2. 0_Migration_Guide/guide.html

You can add yourself to the notification list of this bugzilla to be the
first to get your hands on new articles.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=77413

Feel free to contribute articles yourself :)

Regards,

- James.


"Paul" <psentosa@yahoo.com> wrote in message
news:ep5g1r$k6r$1@utils.eclipse.org...
> Thank you very much, James!
>
> Best Regards
> Paul
>
> ps: Is it possible to have some more articles giving examples on how to
> use
> the other APIs?
>
> "James Bruck" <jbruck@ca.ibm.com> schrieb im Newsbeitrag
> news:ep5bvn$p66$2@utils.eclipse.org...
>> Hi Paul,
>>
>> Ok ... let me back up a bit. Firstly, although Statemachines can be
> owned
>> direcly by a Package, by convention, they apply to a particular class.
>> So one would typically ( although not necessarily ) create a statemachine
>> under a class ( creating it directly under a Package is not wrong ).
>>
>> So from your package you could do something like...
>>
>>
>> org.eclipse.uml2.uml.Class myClass =
>> (org.eclipse.uml2.uml.Class)myPackage.createOwnedType("myClass ",
>> ULPackage.Literals.CLASS);
>> // Note: Classes are Types
>> StateMachine myStateMachine =
>> (StateMachine)myClass.createOwnedBehavior("myStatemachine",
>> UMLPackage.Literals.STATE_MACHINE);
>> // Note: StateMachines are Behaviors, Behaviors are Classes.
>>
>> Continue in this way to add a region and then a state etc.
>>
>> The alternative is to manufacture these classes using the factory ie..
>> UMLFactory.eINSTANCE.createXXXX();
>> Then get the owning collection and add it in directly ( as mentioned
>> previously ).
>>
>> Have a look at the "Getting started with UML" articles by Kenn Hussey for
>> better explanations.
>>
>> Regards,
>>
>> - James.
>>
>>
>> "Paul" <psentosa@yahoo.com> wrote in message
>> news:ep5b0c$mpm$1@utils.eclipse.org...
>> > Hi James,
>> >
>> > many thanks for your kind explanation.
>> > To my last question....I'm sorry if I'm missing something, but somehow
>> > I
>> > still can't relate my Model element to a BehavioredClassifier.
>> > Is using myModel.createOwnedType() also an alternative? (By casting
>> > Type
>> > into StateMachine). What kind of EClass argument should then be used?
>> > Could you please explain a bit more?
>> >
>> > Thanks again.
>> >
>> > Paul
>> >
>> > "James Bruck" <jbruck@ca.ibm.com> schrieb im Newsbeitrag
>> > news:ep5611$sft$1@utils.eclipse.org...
>> > > Hi Paul,
>> > >
>> > > UML can be a complicated puzzle ;) ... This is where a graphical
>> > > tool
>> > comes
>> > > in handy.
>> > >
>> > > Your best starting point is to look at the superstructure spec ..
>> > >
>> > > http://www.omg.org/docs/ptc/06-04-02.pdf
>> > >
>> > > some answers inline below ...
>> > >
>> > > - James.
>> > >
>> > >
>> > > "Paul Sentosa" <psentosa@yahoo.com> wrote in message
>> > > news:ep3jd3$ilc$1@utils.eclipse.org...
>> > > > Hi,
>> > > >
>> > > > I'd like to create a state machine both programmaticaly and by
>> > > > using
>> the
>> > > > UML
>> > > > editor, but I'm still confused on how to use them.
>> > > >
>> > > > 1. What are the differences between the usage of Packaged
>> > > > Element -,
>> > > > Classifier Behaviour -, Nested Behaviour -, Owned Type-, and Do
>> Actions
>> > > > (Protocol) State Machine?
>> > >
>> > > A packageable element indicates a named element that may be owned
>> directly
>> > > by a package.
>> > > Interfaces and classes can own nested classifiers ( ie nested
> classes ).
>> > > Packages can own "Types" ( ie. a class is a Type). Types are
>> > > PackageableElements.
>> > >
>> > > Have a look at the UML superstructure spec for detailed explanations
> of
>> > all
>> > > these items ( I would simply be cutting and pasting definitions for
>> these
>> > > items from the spec )
>> > >
>> > > > 2. Can "State" exist only within "Region"? I read about "Region"
> only
>> in
>> > > > the
>> > > > context of concurrent region (thus, concurrent sub-state). But what
>> > about
>> > > > in
>> > > > the non-concurrent environtment? Do we still need a region?
>> > >
>> > > Yes in a non-concurent environment a statemachine would still own a
>> region
>> > > in which you would have states.
>> > >
>> > > > 3. Is this the correct order to define a state charts:
>> > > > - create (Owned Type/Packaged Element) State Machine
>> > > > - Create Region
>> > > > - Create State(s)
>> > > > - ...??
>> > >
>> > > Yes. ... a StateMachine is a Class. Packages own classess... The
>> order
>> > > you have indicated is right.
>> > >
>> > >
>> > > > 4. Is there any way to define the beginning state/black circle?
> (Just
>> > like
>> > > > we can define "Final State"/bordered circle)
>> > >
>> > > Have a look at Pseudostates and the PseudostateKind enumeration.
>> > > The
>> > > Pseudostate entry point is what you are interested in I believe.
>> > >
>> > >
>> > > > 5. To define sub states of, say, state A, do I have to create a
> region
>> > as
>> > > > a
>> > > > child of State A, and then create some states within the newly
> created
>> > > > region?
>> > >
>> > > Yes.
>> > >
>> > > >
>> > > > Programmaticaly, how can I create a state machine? If I use the
>> factory
>> > > > method UMLFactory.eInstance.createStateMachine and I'd like to put
>> this
>> > > > under the Model element, how can this be done?
>> > >
>> > > BehavioredClassifiers own behaviors ... StateMachine's are Behaviors.
>> > > You can use the BehavioredClassifier.createOwnedBehavior() or
>> > >
>> >
>>
> myBehavioredClassifier.getOwnedBehaviors().add(UMLFactory.eI nstance.createSt
>> > ateMachine());
>> > >
>> > > >
>> > > > Thanks and would appreciate any hints
>> > > >
>> > > >
>> > > > Paul
>> > > >
>> > > >
>> > > >
>> > >
>> > >
>> >
>> >
>>
>>
>
>
Re: State Machine - UML Editor & Programmatic [message #573351 is a reply to message #468754] Tue, 23 January 2007 09:30 Go to previous messageGo to next message
james bruck is currently offline james bruck
Messages: 1724
Registered: July 2009
Senior Member
Hi Paul,

UML can be a complicated puzzle ;) ... This is where a graphical tool comes
in handy.

Your best starting point is to look at the superstructure spec ..

http://www.omg.org/docs/ptc/06-04-02.pdf

some answers inline below ...

- James.


"Paul Sentosa" <psentosa@yahoo.com> wrote in message
news:ep3jd3$ilc$1@utils.eclipse.org...
> Hi,
>
> I'd like to create a state machine both programmaticaly and by using the
> UML
> editor, but I'm still confused on how to use them.
>
> 1. What are the differences between the usage of Packaged Element -,
> Classifier Behaviour -, Nested Behaviour -, Owned Type-, and Do Actions
> (Protocol) State Machine?

A packageable element indicates a named element that may be owned directly
by a package.
Interfaces and classes can own nested classifiers ( ie nested classes ).
Packages can own "Types" ( ie. a class is a Type). Types are
PackageableElements.

Have a look at the UML superstructure spec for detailed explanations of all
these items ( I would simply be cutting and pasting definitions for these
items from the spec )

> 2. Can "State" exist only within "Region"? I read about "Region" only in
> the
> context of concurrent region (thus, concurrent sub-state). But what about
> in
> the non-concurrent environtment? Do we still need a region?

Yes in a non-concurent environment a statemachine would still own a region
in which you would have states.

> 3. Is this the correct order to define a state charts:
> - create (Owned Type/Packaged Element) State Machine
> - Create Region
> - Create State(s)
> - ...??

Yes. ... a StateMachine is a Class. Packages own classess... The order
you have indicated is right.


> 4. Is there any way to define the beginning state/black circle? (Just like
> we can define "Final State"/bordered circle)

Have a look at Pseudostates and the PseudostateKind enumeration. The
Pseudostate entry point is what you are interested in I believe.


> 5. To define sub states of, say, state A, do I have to create a region as
> a
> child of State A, and then create some states within the newly created
> region?

Yes.

>
> Programmaticaly, how can I create a state machine? If I use the factory
> method UMLFactory.eInstance.createStateMachine and I'd like to put this
> under the Model element, how can this be done?

BehavioredClassifiers own behaviors ... StateMachine's are Behaviors.
You can use the BehavioredClassifier.createOwnedBehavior() or
myBehavioredClassifier.getOwnedBehaviors().add(UMLFactory.eI nstance.createStateMachine());

>
> Thanks and would appreciate any hints
>
>
> Paul
>
>
>
Re: State Machine - UML Editor & Programmatic [message #573625 is a reply to message #468760] Tue, 23 January 2007 10:52 Go to previous messageGo to next message
Paul is currently offline Paul
Messages: 55
Registered: July 2009
Member
Hi James,

many thanks for your kind explanation.
To my last question....I'm sorry if I'm missing something, but somehow I
still can't relate my Model element to a BehavioredClassifier.
Is using myModel.createOwnedType() also an alternative? (By casting Type
into StateMachine). What kind of EClass argument should then be used?
Could you please explain a bit more?

Thanks again.

Paul

"James Bruck" <jbruck@ca.ibm.com> schrieb im Newsbeitrag
news:ep5611$sft$1@utils.eclipse.org...
> Hi Paul,
>
> UML can be a complicated puzzle ;) ... This is where a graphical tool
comes
> in handy.
>
> Your best starting point is to look at the superstructure spec ..
>
> http://www.omg.org/docs/ptc/06-04-02.pdf
>
> some answers inline below ...
>
> - James.
>
>
> "Paul Sentosa" <psentosa@yahoo.com> wrote in message
> news:ep3jd3$ilc$1@utils.eclipse.org...
> > Hi,
> >
> > I'd like to create a state machine both programmaticaly and by using the
> > UML
> > editor, but I'm still confused on how to use them.
> >
> > 1. What are the differences between the usage of Packaged Element -,
> > Classifier Behaviour -, Nested Behaviour -, Owned Type-, and Do Actions
> > (Protocol) State Machine?
>
> A packageable element indicates a named element that may be owned directly
> by a package.
> Interfaces and classes can own nested classifiers ( ie nested classes ).
> Packages can own "Types" ( ie. a class is a Type). Types are
> PackageableElements.
>
> Have a look at the UML superstructure spec for detailed explanations of
all
> these items ( I would simply be cutting and pasting definitions for these
> items from the spec )
>
> > 2. Can "State" exist only within "Region"? I read about "Region" only in
> > the
> > context of concurrent region (thus, concurrent sub-state). But what
about
> > in
> > the non-concurrent environtment? Do we still need a region?
>
> Yes in a non-concurent environment a statemachine would still own a region
> in which you would have states.
>
> > 3. Is this the correct order to define a state charts:
> > - create (Owned Type/Packaged Element) State Machine
> > - Create Region
> > - Create State(s)
> > - ...??
>
> Yes. ... a StateMachine is a Class. Packages own classess... The order
> you have indicated is right.
>
>
> > 4. Is there any way to define the beginning state/black circle? (Just
like
> > we can define "Final State"/bordered circle)
>
> Have a look at Pseudostates and the PseudostateKind enumeration. The
> Pseudostate entry point is what you are interested in I believe.
>
>
> > 5. To define sub states of, say, state A, do I have to create a region
as
> > a
> > child of State A, and then create some states within the newly created
> > region?
>
> Yes.
>
> >
> > Programmaticaly, how can I create a state machine? If I use the factory
> > method UMLFactory.eInstance.createStateMachine and I'd like to put this
> > under the Model element, how can this be done?
>
> BehavioredClassifiers own behaviors ... StateMachine's are Behaviors.
> You can use the BehavioredClassifier.createOwnedBehavior() or
>
myBehavioredClassifier.getOwnedBehaviors().add(UMLFactory.eI nstance.createSt
ateMachine());
>
> >
> > Thanks and would appreciate any hints
> >
> >
> > Paul
> >
> >
> >
>
>
Re: State Machine - UML Editor & Programmatic [message #573641 is a reply to message #468907] Tue, 23 January 2007 11:09 Go to previous messageGo to next message
james bruck is currently offline james bruck
Messages: 1724
Registered: July 2009
Senior Member
Hi Paul,

Ok ... let me back up a bit. Firstly, although Statemachines can be owned
direcly by a Package, by convention, they apply to a particular class.
So one would typically ( although not necessarily ) create a statemachine
under a class ( creating it directly under a Package is not wrong ).

So from your package you could do something like...


org.eclipse.uml2.uml.Class myClass =
(org.eclipse.uml2.uml.Class)myPackage.createOwnedType("myClass ",
ULPackage.Literals.CLASS);
// Note: Classes are Types
StateMachine myStateMachine =
(StateMachine)myClass.createOwnedBehavior("myStatemachine",
UMLPackage.Literals.STATE_MACHINE);
// Note: StateMachines are Behaviors, Behaviors are Classes.

Continue in this way to add a region and then a state etc.

The alternative is to manufacture these classes using the factory ie..
UMLFactory.eINSTANCE.createXXXX();
Then get the owning collection and add it in directly ( as mentioned
previously ).

Have a look at the "Getting started with UML" articles by Kenn Hussey for
better explanations.

Regards,

- James.


"Paul" <psentosa@yahoo.com> wrote in message
news:ep5b0c$mpm$1@utils.eclipse.org...
> Hi James,
>
> many thanks for your kind explanation.
> To my last question....I'm sorry if I'm missing something, but somehow I
> still can't relate my Model element to a BehavioredClassifier.
> Is using myModel.createOwnedType() also an alternative? (By casting Type
> into StateMachine). What kind of EClass argument should then be used?
> Could you please explain a bit more?
>
> Thanks again.
>
> Paul
>
> "James Bruck" <jbruck@ca.ibm.com> schrieb im Newsbeitrag
> news:ep5611$sft$1@utils.eclipse.org...
> > Hi Paul,
> >
> > UML can be a complicated puzzle ;) ... This is where a graphical tool
> comes
> > in handy.
> >
> > Your best starting point is to look at the superstructure spec ..
> >
> > http://www.omg.org/docs/ptc/06-04-02.pdf
> >
> > some answers inline below ...
> >
> > - James.
> >
> >
> > "Paul Sentosa" <psentosa@yahoo.com> wrote in message
> > news:ep3jd3$ilc$1@utils.eclipse.org...
> > > Hi,
> > >
> > > I'd like to create a state machine both programmaticaly and by using
the
> > > UML
> > > editor, but I'm still confused on how to use them.
> > >
> > > 1. What are the differences between the usage of Packaged Element -,
> > > Classifier Behaviour -, Nested Behaviour -, Owned Type-, and Do
Actions
> > > (Protocol) State Machine?
> >
> > A packageable element indicates a named element that may be owned
directly
> > by a package.
> > Interfaces and classes can own nested classifiers ( ie nested classes ).
> > Packages can own "Types" ( ie. a class is a Type). Types are
> > PackageableElements.
> >
> > Have a look at the UML superstructure spec for detailed explanations of
> all
> > these items ( I would simply be cutting and pasting definitions for
these
> > items from the spec )
> >
> > > 2. Can "State" exist only within "Region"? I read about "Region" only
in
> > > the
> > > context of concurrent region (thus, concurrent sub-state). But what
> about
> > > in
> > > the non-concurrent environtment? Do we still need a region?
> >
> > Yes in a non-concurent environment a statemachine would still own a
region
> > in which you would have states.
> >
> > > 3. Is this the correct order to define a state charts:
> > > - create (Owned Type/Packaged Element) State Machine
> > > - Create Region
> > > - Create State(s)
> > > - ...??
> >
> > Yes. ... a StateMachine is a Class. Packages own classess... The
order
> > you have indicated is right.
> >
> >
> > > 4. Is there any way to define the beginning state/black circle? (Just
> like
> > > we can define "Final State"/bordered circle)
> >
> > Have a look at Pseudostates and the PseudostateKind enumeration. The
> > Pseudostate entry point is what you are interested in I believe.
> >
> >
> > > 5. To define sub states of, say, state A, do I have to create a region
> as
> > > a
> > > child of State A, and then create some states within the newly created
> > > region?
> >
> > Yes.
> >
> > >
> > > Programmaticaly, how can I create a state machine? If I use the
factory
> > > method UMLFactory.eInstance.createStateMachine and I'd like to put
this
> > > under the Model element, how can this be done?
> >
> > BehavioredClassifiers own behaviors ... StateMachine's are Behaviors.
> > You can use the BehavioredClassifier.createOwnedBehavior() or
> >
>
myBehavioredClassifier.getOwnedBehaviors().add(UMLFactory.eI nstance.createSt
> ateMachine());
> >
> > >
> > > Thanks and would appreciate any hints
> > >
> > >
> > > Paul
> > >
> > >
> > >
> >
> >
>
>
Re: State Machine - UML Editor & Programmatic [message #573666 is a reply to message #468909] Tue, 23 January 2007 12:18 Go to previous messageGo to next message
Paul is currently offline Paul
Messages: 55
Registered: July 2009
Member
Thank you very much, James!

Best Regards
Paul

ps: Is it possible to have some more articles giving examples on how to use
the other APIs?

"James Bruck" <jbruck@ca.ibm.com> schrieb im Newsbeitrag
news:ep5bvn$p66$2@utils.eclipse.org...
> Hi Paul,
>
> Ok ... let me back up a bit. Firstly, although Statemachines can be
owned
> direcly by a Package, by convention, they apply to a particular class.
> So one would typically ( although not necessarily ) create a statemachine
> under a class ( creating it directly under a Package is not wrong ).
>
> So from your package you could do something like...
>
>
> org.eclipse.uml2.uml.Class myClass =
> (org.eclipse.uml2.uml.Class)myPackage.createOwnedType("myClass ",
> ULPackage.Literals.CLASS);
> // Note: Classes are Types
> StateMachine myStateMachine =
> (StateMachine)myClass.createOwnedBehavior("myStatemachine",
> UMLPackage.Literals.STATE_MACHINE);
> // Note: StateMachines are Behaviors, Behaviors are Classes.
>
> Continue in this way to add a region and then a state etc.
>
> The alternative is to manufacture these classes using the factory ie..
> UMLFactory.eINSTANCE.createXXXX();
> Then get the owning collection and add it in directly ( as mentioned
> previously ).
>
> Have a look at the "Getting started with UML" articles by Kenn Hussey for
> better explanations.
>
> Regards,
>
> - James.
>
>
> "Paul" <psentosa@yahoo.com> wrote in message
> news:ep5b0c$mpm$1@utils.eclipse.org...
> > Hi James,
> >
> > many thanks for your kind explanation.
> > To my last question....I'm sorry if I'm missing something, but somehow I
> > still can't relate my Model element to a BehavioredClassifier.
> > Is using myModel.createOwnedType() also an alternative? (By casting Type
> > into StateMachine). What kind of EClass argument should then be used?
> > Could you please explain a bit more?
> >
> > Thanks again.
> >
> > Paul
> >
> > "James Bruck" <jbruck@ca.ibm.com> schrieb im Newsbeitrag
> > news:ep5611$sft$1@utils.eclipse.org...
> > > Hi Paul,
> > >
> > > UML can be a complicated puzzle ;) ... This is where a graphical tool
> > comes
> > > in handy.
> > >
> > > Your best starting point is to look at the superstructure spec ..
> > >
> > > http://www.omg.org/docs/ptc/06-04-02.pdf
> > >
> > > some answers inline below ...
> > >
> > > - James.
> > >
> > >
> > > "Paul Sentosa" <psentosa@yahoo.com> wrote in message
> > > news:ep3jd3$ilc$1@utils.eclipse.org...
> > > > Hi,
> > > >
> > > > I'd like to create a state machine both programmaticaly and by using
> the
> > > > UML
> > > > editor, but I'm still confused on how to use them.
> > > >
> > > > 1. What are the differences between the usage of Packaged Element -,
> > > > Classifier Behaviour -, Nested Behaviour -, Owned Type-, and Do
> Actions
> > > > (Protocol) State Machine?
> > >
> > > A packageable element indicates a named element that may be owned
> directly
> > > by a package.
> > > Interfaces and classes can own nested classifiers ( ie nested
classes ).
> > > Packages can own "Types" ( ie. a class is a Type). Types are
> > > PackageableElements.
> > >
> > > Have a look at the UML superstructure spec for detailed explanations
of
> > all
> > > these items ( I would simply be cutting and pasting definitions for
> these
> > > items from the spec )
> > >
> > > > 2. Can "State" exist only within "Region"? I read about "Region"
only
> in
> > > > the
> > > > context of concurrent region (thus, concurrent sub-state). But what
> > about
> > > > in
> > > > the non-concurrent environtment? Do we still need a region?
> > >
> > > Yes in a non-concurent environment a statemachine would still own a
> region
> > > in which you would have states.
> > >
> > > > 3. Is this the correct order to define a state charts:
> > > > - create (Owned Type/Packaged Element) State Machine
> > > > - Create Region
> > > > - Create State(s)
> > > > - ...??
> > >
> > > Yes. ... a StateMachine is a Class. Packages own classess... The
> order
> > > you have indicated is right.
> > >
> > >
> > > > 4. Is there any way to define the beginning state/black circle?
(Just
> > like
> > > > we can define "Final State"/bordered circle)
> > >
> > > Have a look at Pseudostates and the PseudostateKind enumeration. The
> > > Pseudostate entry point is what you are interested in I believe.
> > >
> > >
> > > > 5. To define sub states of, say, state A, do I have to create a
region
> > as
> > > > a
> > > > child of State A, and then create some states within the newly
created
> > > > region?
> > >
> > > Yes.
> > >
> > > >
> > > > Programmaticaly, how can I create a state machine? If I use the
> factory
> > > > method UMLFactory.eInstance.createStateMachine and I'd like to put
> this
> > > > under the Model element, how can this be done?
> > >
> > > BehavioredClassifiers own behaviors ... StateMachine's are Behaviors.
> > > You can use the BehavioredClassifier.createOwnedBehavior() or
> > >
> >
>
myBehavioredClassifier.getOwnedBehaviors().add(UMLFactory.eI nstance.createSt
> > ateMachine());
> > >
> > > >
> > > > Thanks and would appreciate any hints
> > > >
> > > >
> > > > Paul
> > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>
Re: State Machine - UML Editor & Programmatic [message #576357 is a reply to message #468912] Sat, 27 January 2007 23:02 Go to previous messageGo to next message
james bruck is currently offline james bruck
Messages: 1724
Registered: July 2009
Senior Member
Hi Paul,

The migration document points out some of the new API's.
http://www.eclipse.org/modeling/mdt/uml2/docs/guides/UML2_2. 0_Migration_Guide/guide.html

You can add yourself to the notification list of this bugzilla to be the
first to get your hands on new articles.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=77413

Feel free to contribute articles yourself :)

Regards,

- James.


"Paul" <psentosa@yahoo.com> wrote in message
news:ep5g1r$k6r$1@utils.eclipse.org...
> Thank you very much, James!
>
> Best Regards
> Paul
>
> ps: Is it possible to have some more articles giving examples on how to
> use
> the other APIs?
>
> "James Bruck" <jbruck@ca.ibm.com> schrieb im Newsbeitrag
> news:ep5bvn$p66$2@utils.eclipse.org...
>> Hi Paul,
>>
>> Ok ... let me back up a bit. Firstly, although Statemachines can be
> owned
>> direcly by a Package, by convention, they apply to a particular class.
>> So one would typically ( although not necessarily ) create a statemachine
>> under a class ( creating it directly under a Package is not wrong ).
>>
>> So from your package you could do something like...
>>
>>
>> org.eclipse.uml2.uml.Class myClass =
>> (org.eclipse.uml2.uml.Class)myPackage.createOwnedType("myClass ",
>> ULPackage.Literals.CLASS);
>> // Note: Classes are Types
>> StateMachine myStateMachine =
>> (StateMachine)myClass.createOwnedBehavior("myStatemachine",
>> UMLPackage.Literals.STATE_MACHINE);
>> // Note: StateMachines are Behaviors, Behaviors are Classes.
>>
>> Continue in this way to add a region and then a state etc.
>>
>> The alternative is to manufacture these classes using the factory ie..
>> UMLFactory.eINSTANCE.createXXXX();
>> Then get the owning collection and add it in directly ( as mentioned
>> previously ).
>>
>> Have a look at the "Getting started with UML" articles by Kenn Hussey for
>> better explanations.
>>
>> Regards,
>>
>> - James.
>>
>>
>> "Paul" <psentosa@yahoo.com> wrote in message
>> news:ep5b0c$mpm$1@utils.eclipse.org...
>> > Hi James,
>> >
>> > many thanks for your kind explanation.
>> > To my last question....I'm sorry if I'm missing something, but somehow
>> > I
>> > still can't relate my Model element to a BehavioredClassifier.
>> > Is using myModel.createOwnedType() also an alternative? (By casting
>> > Type
>> > into StateMachine). What kind of EClass argument should then be used?
>> > Could you please explain a bit more?
>> >
>> > Thanks again.
>> >
>> > Paul
>> >
>> > "James Bruck" <jbruck@ca.ibm.com> schrieb im Newsbeitrag
>> > news:ep5611$sft$1@utils.eclipse.org...
>> > > Hi Paul,
>> > >
>> > > UML can be a complicated puzzle ;) ... This is where a graphical
>> > > tool
>> > comes
>> > > in handy.
>> > >
>> > > Your best starting point is to look at the superstructure spec ..
>> > >
>> > > http://www.omg.org/docs/ptc/06-04-02.pdf
>> > >
>> > > some answers inline below ...
>> > >
>> > > - James.
>> > >
>> > >
>> > > "Paul Sentosa" <psentosa@yahoo.com> wrote in message
>> > > news:ep3jd3$ilc$1@utils.eclipse.org...
>> > > > Hi,
>> > > >
>> > > > I'd like to create a state machine both programmaticaly and by
>> > > > using
>> the
>> > > > UML
>> > > > editor, but I'm still confused on how to use them.
>> > > >
>> > > > 1. What are the differences between the usage of Packaged
>> > > > Element -,
>> > > > Classifier Behaviour -, Nested Behaviour -, Owned Type-, and Do
>> Actions
>> > > > (Protocol) State Machine?
>> > >
>> > > A packageable element indicates a named element that may be owned
>> directly
>> > > by a package.
>> > > Interfaces and classes can own nested classifiers ( ie nested
> classes ).
>> > > Packages can own "Types" ( ie. a class is a Type). Types are
>> > > PackageableElements.
>> > >
>> > > Have a look at the UML superstructure spec for detailed explanations
> of
>> > all
>> > > these items ( I would simply be cutting and pasting definitions for
>> these
>> > > items from the spec )
>> > >
>> > > > 2. Can "State" exist only within "Region"? I read about "Region"
> only
>> in
>> > > > the
>> > > > context of concurrent region (thus, concurrent sub-state). But what
>> > about
>> > > > in
>> > > > the non-concurrent environtment? Do we still need a region?
>> > >
>> > > Yes in a non-concurent environment a statemachine would still own a
>> region
>> > > in which you would have states.
>> > >
>> > > > 3. Is this the correct order to define a state charts:
>> > > > - create (Owned Type/Packaged Element) State Machine
>> > > > - Create Region
>> > > > - Create State(s)
>> > > > - ...??
>> > >
>> > > Yes. ... a StateMachine is a Class. Packages own classess... The
>> order
>> > > you have indicated is right.
>> > >
>> > >
>> > > > 4. Is there any way to define the beginning state/black circle?
> (Just
>> > like
>> > > > we can define "Final State"/bordered circle)
>> > >
>> > > Have a look at Pseudostates and the PseudostateKind enumeration.
>> > > The
>> > > Pseudostate entry point is what you are interested in I believe.
>> > >
>> > >
>> > > > 5. To define sub states of, say, state A, do I have to create a
> region
>> > as
>> > > > a
>> > > > child of State A, and then create some states within the newly
> created
>> > > > region?
>> > >
>> > > Yes.
>> > >
>> > > >
>> > > > Programmaticaly, how can I create a state machine? If I use the
>> factory
>> > > > method UMLFactory.eInstance.createStateMachine and I'd like to put
>> this
>> > > > under the Model element, how can this be done?
>> > >
>> > > BehavioredClassifiers own behaviors ... StateMachine's are Behaviors.
>> > > You can use the BehavioredClassifier.createOwnedBehavior() or
>> > >
>> >
>>
> myBehavioredClassifier.getOwnedBehaviors().add(UMLFactory.eI nstance.createSt
>> > ateMachine());
>> > >
>> > > >
>> > > > Thanks and would appreciate any hints
>> > > >
>> > > >
>> > > > Paul
>> > > >
>> > > >
>> > > >
>> > >
>> > >
>> >
>> >
>>
>>
>
>
Re: State Machine - UML Editor & Programmatic [message #992045 is a reply to message #576357] Thu, 20 December 2012 13:54 Go to previous message
Federico Toledo is currently offline Federico Toledo
Messages: 97
Registered: April 2012
Location: Ciudad Real, Spain
Member
I am doing what you were asking, and here is my code

StateMachine sm = UMLFactory.eINSTANCE.createStateMachine();
sm.setName(name);
sm.setPackage(behaviorModelPackage);
Previous Topic:API way to determine the subset(s) of a given EReference
Next Topic:UML Statechart Flattening
Goto Forum:
  


Current Time: Fri Aug 29 20:28:36 EDT 2014

Powered by FUDForum. Page generated in 0.09206 seconds