Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 Tools » Using command/request on umltools diagrams
Using command/request on umltools diagrams [message #470344] Wed, 09 May 2007 07:34 Go to next message
Philippe is currently offline PhilippeFriend
Messages: 100
Registered: July 2009
Senior Member
Hi again,

I'm stuck in finding how I can programmatically modify the diagram and
the semantic model (add a class in a class diagram for instance).

is it possible using command and request as other gmf generated tools or
not ?

Thanks for any help.
Philippe
Re: Using command/request on umltools diagrams [message #470345 is a reply to message #470344] Wed, 09 May 2007 11:52 Go to previous messageGo to next message
Michael Golubev is currently offline Michael GolubevFriend
Messages: 383
Registered: July 2009
Senior Member
Hello Philippe,

You may also take a look, e.g, at the org.eclipse.uml2.diagram.clazz.action.CreateAssociationFromP roperties
class
(src-custom root of ClassD plugin).

It makes the following:
1. Creates new association for given property end that is owned by classifier.
(semantic change)
2. Creates opposite association end owned by association (semantic change)
3. Adds Edge for association to diagram (notation)
4. Remove the property view from classifier view (notation).

Please note that for creation of single elements you can use the same requests
that are used by diagram tools.
Basically, the following code should get you the complete (semantic + notation)
command to create a class:

List types = Arrays.asList(new IElementType[] {
UMLElementTypes.Class_3007,
UMLElementTypes.Class_2001, //you can use only this one for top level
classes
UMLElementTypes.Class_3003,
UMLElementTypes.Class_3030,
});
CreateUnspecifiedTypeRequest request = new CreateUnspecifiedTypeRequest(elementTypes,
UMLDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT);
Command result = getDiagramEditPart().getCommand(request);

Hope it helps,
Michael

> Hi again,
>
> I'm stuck in finding how I can programmatically modify the diagram and
> the semantic model (add a class in a class diagram for instance).
>
> is it possible using command and request as other gmf generated tools
> or not ?
>
> Thanks for any help.
> Philippe
Re: Using command/request on umltools diagrams [message #470721 is a reply to message #470345] Fri, 11 May 2007 08:16 Go to previous message
Philippe is currently offline PhilippeFriend
Messages: 100
Registered: July 2009
Senior Member
Hello Michael,

thanks for your explanations,
I have now a better understanding of all of it and I'd like to go further.

If i'm right the semantic, view and editpart are considered as 3
"layers" for working on in GMF and the editpart can act by the use of
commands on the semantic or the view but are only created when opening
the diagram editor.

My work for now is to try to implements model/diagram transformations
programmatically.
For instance I tried to directly make minor changes using UML2 API
(changing class name) and they were correctly reported in the diagram,
but as it get more complex, as creating classes (using
createOwnedClass() or the UML editor) the diagram is not updated anymore.
And i don't know how to work on diagrams...
As the diagram isn't opened in a editor, I believe that I cannot use
editparts, so is working on the view "layer" the best way (and how?) or
forcing the opening in a editor to use editparts would offer a stronger
edition possibilities ?

Many thanks for your help.
Philippe

Michael Golubev wrote:
> Hello Philippe,
>
> You may also take a look, e.g, at the
> org.eclipse.uml2.diagram.clazz.action.CreateAssociationFromP roperties
> class (src-custom root of ClassD plugin).
>
> It makes the following:
> 1. Creates new association for given property end that is owned by
> classifier. (semantic change)
> 2. Creates opposite association end owned by association (semantic change)
> 3. Adds Edge for association to diagram (notation)
> 4. Remove the property view from classifier view (notation).
>
> Please note that for creation of single elements you can use the same
> requests that are used by diagram tools.
> Basically, the following code should get you the complete (semantic +
> notation) command to create a class:
> List types = Arrays.asList(new IElementType[] {
> UMLElementTypes.Class_3007, UMLElementTypes.Class_2001, //you can
> use only this one for top level classes
> UMLElementTypes.Class_3003, UMLElementTypes.Class_3030, });
> CreateUnspecifiedTypeRequest request = new
> CreateUnspecifiedTypeRequest(elementTypes,
> UMLDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT);
> Command result = getDiagramEditPart().getCommand(request);
>
> Hope it helps, Michael
>
>> Hi again,
>>
>> I'm stuck in finding how I can programmatically modify the diagram and
>> the semantic model (add a class in a class diagram for instance).
>>
>> is it possible using command and request as other gmf generated tools
>> or not ?
>>
>> Thanks for any help.
>> Philippe
>
>
Re: Using command/request on umltools diagrams [message #592843 is a reply to message #470344] Wed, 09 May 2007 11:52 Go to previous message
Michael Golubev is currently offline Michael GolubevFriend
Messages: 383
Registered: July 2009
Senior Member
Hello Philippe,

You may also take a look, e.g, at the org.eclipse.uml2.diagram.clazz.action.CreateAssociationFromP roperties
class
(src-custom root of ClassD plugin).

It makes the following:
1. Creates new association for given property end that is owned by classifier.
(semantic change)
2. Creates opposite association end owned by association (semantic change)
3. Adds Edge for association to diagram (notation)
4. Remove the property view from classifier view (notation).

Please note that for creation of single elements you can use the same requests
that are used by diagram tools.
Basically, the following code should get you the complete (semantic + notation)
command to create a class:

List types = Arrays.asList(new IElementType[] {
UMLElementTypes.Class_3007,
UMLElementTypes.Class_2001, //you can use only this one for top level
classes
UMLElementTypes.Class_3003,
UMLElementTypes.Class_3030,
});
CreateUnspecifiedTypeRequest request = new CreateUnspecifiedTypeRequest(elementTypes,
UMLDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT);
Command result = getDiagramEditPart().getCommand(request);

Hope it helps,
Michael

> Hi again,
>
> I'm stuck in finding how I can programmatically modify the diagram and
> the semantic model (add a class in a class diagram for instance).
>
> is it possible using command and request as other gmf generated tools
> or not ?
>
> Thanks for any help.
> Philippe
Re: Using command/request on umltools diagrams [message #592990 is a reply to message #470345] Fri, 11 May 2007 08:16 Go to previous message
Philippe is currently offline PhilippeFriend
Messages: 100
Registered: July 2009
Senior Member
Hello Michael,

thanks for your explanations,
I have now a better understanding of all of it and I'd like to go further.

If i'm right the semantic, view and editpart are considered as 3
"layers" for working on in GMF and the editpart can act by the use of
commands on the semantic or the view but are only created when opening
the diagram editor.

My work for now is to try to implements model/diagram transformations
programmatically.
For instance I tried to directly make minor changes using UML2 API
(changing class name) and they were correctly reported in the diagram,
but as it get more complex, as creating classes (using
createOwnedClass() or the UML editor) the diagram is not updated anymore.
And i don't know how to work on diagrams...
As the diagram isn't opened in a editor, I believe that I cannot use
editparts, so is working on the view "layer" the best way (and how?) or
forcing the opening in a editor to use editparts would offer a stronger
edition possibilities ?

Many thanks for your help.
Philippe

Michael Golubev wrote:
> Hello Philippe,
>
> You may also take a look, e.g, at the
> org.eclipse.uml2.diagram.clazz.action.CreateAssociationFromP roperties
> class (src-custom root of ClassD plugin).
>
> It makes the following:
> 1. Creates new association for given property end that is owned by
> classifier. (semantic change)
> 2. Creates opposite association end owned by association (semantic change)
> 3. Adds Edge for association to diagram (notation)
> 4. Remove the property view from classifier view (notation).
>
> Please note that for creation of single elements you can use the same
> requests that are used by diagram tools.
> Basically, the following code should get you the complete (semantic +
> notation) command to create a class:
> List types = Arrays.asList(new IElementType[] {
> UMLElementTypes.Class_3007, UMLElementTypes.Class_2001, //you can
> use only this one for top level classes
> UMLElementTypes.Class_3003, UMLElementTypes.Class_3030, });
> CreateUnspecifiedTypeRequest request = new
> CreateUnspecifiedTypeRequest(elementTypes,
> UMLDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT);
> Command result = getDiagramEditPart().getCommand(request);
>
> Hope it helps, Michael
>
>> Hi again,
>>
>> I'm stuck in finding how I can programmatically modify the diagram and
>> the semantic model (add a class in a class diagram for instance).
>>
>> is it possible using command and request as other gmf generated tools
>> or not ?
>>
>> Thanks for any help.
>> Philippe
>
>
Previous Topic:models inside another model
Next Topic:Modeling of uml model created with uml2
Goto Forum:
  


Current Time: Thu Apr 25 06:28:13 GMT 2024

Powered by FUDForum. Page generated in 0.02407 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top