Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Specifying Location of Element during Configuration
Specifying Location of Element during Configuration [message #159454] Sat, 10 November 2007 18:04 Go to next message
Eclipse UserFriend
Originally posted by: thomas_reiter.gmx.at

I am developing an editor and got pretty far with studying the tutorials,
newsgroup articles and especially the logic
example.
However, I have on problem which I need your help to solve:

When I create an element in my diagram, I want it to be configured to
already
contain several child elements.
Analogous to the Logic example, I implemented the respective "XXXEditHelper"
and used a new "ConfigureXXXCommand"
to set up the newly created container element. (In the logic example, these
classes closely follow the CircuitEditHelper and the
ConfigureLogicElementCommand.)
Everything works like a charm, ... But additonally I would also like to
specify in the "ConfigureXXXCommand" the location
of the new object inside the container. AFAIU the problem is that only the
semantic element is created during configuration,
and the view and editpart are later on instantiated through the
CanonicalPolicy.
Simply spoken, I dont know how to get a hold of the view and set its bounds
during configuration...

Essentially, this is how the logic example creates the contained elements
during configuration, and i do it the same way:

CreateElementRequest createRequest = new
CreateElementRequest(getEditingDomain(), container, type,
containmentFeature);

IElementType elementType =
ElementTypeRegistry.getInstance().getElementType(createReque st.getEditHelperContext());


ICommand createCommand = elementType.getEditCommand(createRequest);



So, my question is: How can I specify where the view for the semantic
element should be positioned?

Can I create view and element at this place in the code with
CreateViewAndElement Request?
(But then i don't know how to retrieve the command, since I have no editpart
to get the command from, only
the element type...)

It is important for me to specify the location in this place in the code (or
also possibly in an advice or advicehelper of a specialization type,
as I would like to allow contributions of specializations that define the
location of contained elements. Hence, using a custom layout is
not suitable for me...)

Thanks for your help!
Thomas
Re: Specifying Location of Element during Configuration [message #159734 is a reply to message #159454] Mon, 12 November 2007 16:38 Go to previous messageGo to next message
Cherie Revells is currently offline Cherie RevellsFriend
Messages: 299
Registered: July 2009
Senior Member
Thomas,

Is the location of the children inside the container dependent on how
the user gesture was done or are you trying to change the default
locations so it looks nicer? If the location is not dependent on the
user gesture, then the CanonicalEditPolicy should be capable of
arranging the children in better default locations. There are two ways
that this could be handled in GMF:

1) The TerminalCanonicalEditPolicy.getCreateViewCommand() uses a
SetBoundsCommand to explicitly set the locations of the terminals on a
circuit in the logic diagram. The location is dependent on which
terminal is being created (they all have a set location).

2) The CanonicalConnectionEditPolicy.refreshSemantic() method performs
a layout call after the children have been created. This should do the
same thing as if you clicked inside your compartment and did "Arrange
All". Are you extending this canonical editpolicy? I am not sure why
this code is not in the base CanonicalEditPolicy. Does the "Arrange
All" in the compartment work for you?

- Cherie

Thomas Reiter wrote:
> I am developing an editor and got pretty far with studying the tutorials,
> newsgroup articles and especially the logic
> example.
> However, I have on problem which I need your help to solve:
>
> When I create an element in my diagram, I want it to be configured to
> already
> contain several child elements.
> Analogous to the Logic example, I implemented the respective "XXXEditHelper"
> and used a new "ConfigureXXXCommand"
> to set up the newly created container element. (In the logic example, these
> classes closely follow the CircuitEditHelper and the
> ConfigureLogicElementCommand.)
> Everything works like a charm, ... But additonally I would also like to
> specify in the "ConfigureXXXCommand" the location
> of the new object inside the container. AFAIU the problem is that only the
> semantic element is created during configuration,
> and the view and editpart are later on instantiated through the
> CanonicalPolicy.
> Simply spoken, I dont know how to get a hold of the view and set its bounds
> during configuration...
>
> Essentially, this is how the logic example creates the contained elements
> during configuration, and i do it the same way:
>
> CreateElementRequest createRequest = new
> CreateElementRequest(getEditingDomain(), container, type,
> containmentFeature);
>
> IElementType elementType =
> ElementTypeRegistry.getInstance().getElementType(createReque st.getEditHelperContext());
>
>
> ICommand createCommand = elementType.getEditCommand(createRequest);
>
>
>
> So, my question is: How can I specify where the view for the semantic
> element should be positioned?
>
> Can I create view and element at this place in the code with
> CreateViewAndElement Request?
> (But then i don't know how to retrieve the command, since I have no editpart
> to get the command from, only
> the element type...)
>
> It is important for me to specify the location in this place in the code (or
> also possibly in an advice or advicehelper of a specialization type,
> as I would like to allow contributions of specializations that define the
> location of contained elements. Hence, using a custom layout is
> not suitable for me...)
>
> Thanks for your help!
> Thomas
>
>
Re: Specifying Location of Element during Configuration [message #159978 is a reply to message #159734] Tue, 13 November 2007 13:42 Go to previous message
Eclipse UserFriend
Originally posted by: thomas_reiter.gmx.at

Thanks for the hint!

In the meantime I was able to solve my problem, actually in pretty much the
same way as you are suggesting...
(My case is slightly different, because not all of my "children" have an id
by which I can later on access them
to lay them out...)

Thx again for directions, I don't know how I could miss those code pieces in
the example in the frst place... ;-)

Thomas

"Cherie Revells" <crevells@ca.ibm.com> schrieb im Newsbeitrag
news:fh9vp4$119$1@build.eclipse.org...
> Thomas,
>
> Is the location of the children inside the container dependent on how the
> user gesture was done or are you trying to change the default locations so
> it looks nicer? If the location is not dependent on the user gesture,
> then the CanonicalEditPolicy should be capable of arranging the children
> in better default locations. There are two ways that this could be
> handled in GMF:
>
> 1) The TerminalCanonicalEditPolicy.getCreateViewCommand() uses a
> SetBoundsCommand to explicitly set the locations of the terminals on a
> circuit in the logic diagram. The location is dependent on which terminal
> is being created (they all have a set location).
>
> 2) The CanonicalConnectionEditPolicy.refreshSemantic() method performs a
> layout call after the children have been created. This should do the same
> thing as if you clicked inside your compartment and did "Arrange All".
> Are you extending this canonical editpolicy? I am not sure why this code
> is not in the base CanonicalEditPolicy. Does the "Arrange All" in the
> compartment work for you?
>
> - Cherie
>
> Thomas Reiter wrote:
>> I am developing an editor and got pretty far with studying the tutorials,
>> newsgroup articles and especially the logic
>> example.
>> However, I have on problem which I need your help to solve:
>>
>> When I create an element in my diagram, I want it to be configured to
>> already
>> contain several child elements.
>> Analogous to the Logic example, I implemented the respective
>> "XXXEditHelper" and used a new "ConfigureXXXCommand"
>> to set up the newly created container element. (In the logic example,
>> these classes closely follow the CircuitEditHelper and the
>> ConfigureLogicElementCommand.)
>> Everything works like a charm, ... But additonally I would also like to
>> specify in the "ConfigureXXXCommand" the location
>> of the new object inside the container. AFAIU the problem is that only
>> the semantic element is created during configuration,
>> and the view and editpart are later on instantiated through the
>> CanonicalPolicy.
>> Simply spoken, I dont know how to get a hold of the view and set its
>> bounds during configuration...
>>
>> Essentially, this is how the logic example creates the contained elements
>> during configuration, and i do it the same way:
>>
>> CreateElementRequest createRequest = new
>> CreateElementRequest(getEditingDomain(), container, type,
>> containmentFeature);
>>
>> IElementType elementType =
>> ElementTypeRegistry.getInstance().getElementType(createReque st.getEditHelperContext());
>>
>>
>> ICommand createCommand = elementType.getEditCommand(createRequest);
>>
>>
>>
>> So, my question is: How can I specify where the view for the semantic
>> element should be positioned?
>>
>> Can I create view and element at this place in the code with
>> CreateViewAndElement Request?
>> (But then i don't know how to retrieve the command, since I have no
>> editpart to get the command from, only
>> the element type...)
>>
>> It is important for me to specify the location in this place in the code
>> (or also possibly in an advice or advicehelper of a specialization type,
>> as I would like to allow contributions of specializations that define the
>> location of contained elements. Hence, using a custom layout is
>> not suitable for me...)
>>
>> Thanks for your help!
>> Thomas
>>
Previous Topic:Two editors seperated by tabs
Next Topic:ConcurrentModificationException
Goto Forum:
  


Current Time: Thu Apr 25 08:09:03 GMT 2024

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

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

Back to the top