Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » arrangeAll by code
arrangeAll by code [message #85401] Thu, 14 December 2006 12:12 Go to next message
Eclipse UserFriend
Originally posted by: pqueralt.yahoo.es

Hi all,

Well I would like to call the arrangeAll action by code.
Re: arrangeAll by code [message #85416 is a reply to message #85401] Thu, 14 December 2006 12:36 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: pqueralt.yahoo.es

Well, I am trying this code


but it always falls in the getCommand(arrangeRequest) instruction because of
it don't understand the request.
try

{

ArrangeRequest arrangeRequest = new
ArrangeRequest(ActionIds.ACTION_ARRANGE_ALL);

List l = getDiagram().getChildren();

arrangeRequest.setPartsToArrange(l);

Command arrangeCmd = getCommand(arrangeRequest);

arrangeCmd.execute();

System.out.println("He hecho el ARRANGEAll");

}catch(Exception e){

e.printStackTrace();

}



Any idea?
Many thanks.
Pascual

but It alwa




"P" <pqueralt@yahoo.es> escribi
Re: arrangeAll by code [message #85431 is a reply to message #85416] Thu, 14 December 2006 13:05 Go to previous messageGo to next message
Cherie Revells is currently offline Cherie RevellsFriend
Messages: 299
Registered: July 2009
Senior Member
Hi Pascual,

Where are you sending the request? The request should go to the
DiagramEditPart or the ShapeCompartmentEditpart for which you want to
arrange all the shapes.

By the way, if you are doing an arrange all then you do not need to set
the parts to arrange. An arrange all will layout all the children of
the container to which the request is being sent.

Regards,
Cherie

P wrote:
> Well, I am trying this code
>
>
> but it always falls in the getCommand(arrangeRequest) instruction because of
> it don't understand the request.
> try
>
> {
>
> ArrangeRequest arrangeRequest = new
> ArrangeRequest(ActionIds.ACTION_ARRANGE_ALL);
>
> List l = getDiagram().getChildren();
>
> arrangeRequest.setPartsToArrange(l);
>
> Command arrangeCmd = getCommand(arrangeRequest);
>
> arrangeCmd.execute();
>
> System.out.println("He hecho el ARRANGEAll");
>
> }catch(Exception e){
>
> e.printStackTrace();
>
> }
>
>
>
> Any idea?
> Many thanks.
> Pascual
>
> but It alwa
>
>
>
>
> "P" <pqueralt@yahoo.es> escribió en el mensaje
> news:elrf2r$fik$1@utils.eclipse.org...
>> Hi all,
>>
>> Well I would like to call the arrangeAll action by code.ç
>> I have imported the library
>>
>> import org.eclipse.gmf.runtime.diagram.ui.actions.internal.ArrangeA ction;
>>
>>
>> but it is not visible as a restriction of these plugin. The same is
>> happening with DiagramAction class.
>>
>> Does anybody know how I can succed?
>>
>> Many thanks in advance.
>>
>> Pascual
>>
>
>
Re: arrangeAll by code [message #85527 is a reply to message #85431] Thu, 14 December 2006 15:23 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: pqueralt.yahoo.es

Hi Cherie,

Many thanks for your answer, it has been very helpful. However I appreciate
that the effect is totally different if I do arrangeAll automatically all
the boxes and edges appear together in the center of the diagram, while if i
do it manually it places everything o.k. It is always like that or am I
doing something wrong??

I have put the code at the end of the method "where " in the module
DiagramCanonicalEditPolicy where it seems to finish the process, with the
instruction "getHost().getCommand(arrangeRequest)" just like you said
Cheers.

Pascual




"Cherie Revells" <crevells@ca.ibm.com> escribi
Re: arrangeAll by code [message #85572 is a reply to message #85527] Thu, 14 December 2006 16:32 Go to previous message
Mohammed Mostafa is currently offline Mohammed MostafaFriend
Messages: 143
Registered: July 2009
Senior Member
Hi ;
The arrange result will vary depending on the context, if the context
is the same the result should be the same regardless how did you invoke
it. Make sure that you invoke the arrange request on the correct Parent
(the one you want to arrange its children, like the diagram edit part)
at the correct time, for example if you execute the arrange command
before the children edit parts are created then nothing will be arranged.

One way to debug it is to put a break point in the
DefaultProvider#build_graph and check the editparts passed in both
cases, if it is not the same then this will explain the different
results you get.

One more point, if your the edit part had a ContainerEditPolicy
installed on it it should be able to understand the ACTION_ARRANGE_ALL



P wrote:
> Hi Cherie,
>
> Many thanks for your answer, it has been very helpful. However I appreciate
> that the effect is totally different if I do arrangeAll automatically all
> the boxes and edges appear together in the center of the diagram, while if i
> do it manually it places everything o.k. It is always like that or am I
> doing something wrong??
>
> I have put the code at the end of the method "where " in the module
> DiagramCanonicalEditPolicy where it seems to finish the process, with the
> instruction "getHost().getCommand(arrangeRequest)" just like you said
> Cheers.
>
> Pascual
>
>
>
>
> "Cherie Revells" <crevells@ca.ibm.com> escribió en el mensaje
> news:elri7n$500$1@utils.eclipse.org...
>> Hi Pascual,
>>
>> Where are you sending the request? The request should go to the
>> DiagramEditPart or the ShapeCompartmentEditpart for which you want to
>> arrange all the shapes.
>>
>> By the way, if you are doing an arrange all then you do not need to set
>> the parts to arrange. An arrange all will layout all the children of the
>> container to which the request is being sent.
>>
>> Regards,
>> Cherie
>>
>> P wrote:
>>> Well, I am trying this code
>>>
>>>
>>> but it always falls in the getCommand(arrangeRequest) instruction because
>>> of it don't understand the request.
>>> try
>>>
>>> {
>>>
>>> ArrangeRequest arrangeRequest = new
>>> ArrangeRequest(ActionIds.ACTION_ARRANGE_ALL);
>>>
>>> List l = getDiagram().getChildren();
>>>
>>> arrangeRequest.setPartsToArrange(l);
>>>
>>> Command arrangeCmd = getCommand(arrangeRequest);
>>>
>>> arrangeCmd.execute();
>>>
>>> System.out.println("He hecho el ARRANGEAll");
>>>
>>> }catch(Exception e){
>>>
>>> e.printStackTrace();
>>>
>>> }
>>>
>>>
>>>
>>> Any idea?
>>> Many thanks.
>>> Pascual
>>>
>>> but It alwa
>>>
>>>
>>>
>>>
>>> "P" <pqueralt@yahoo.es> escribió en el mensaje
>>> news:elrf2r$fik$1@utils.eclipse.org...
>>>> Hi all,
>>>>
>>>> Well I would like to call the arrangeAll action by code.ç
>>>> I have imported the library
>>>>
>>>> import
>>>> org.eclipse.gmf.runtime.diagram.ui.actions.internal.ArrangeA ction;
>>>>
>>>>
>>>> but it is not visible as a restriction of these plugin. The same is
>>>> happening with DiagramAction class.
>>>>
>>>> Does anybody know how I can succed?
>>>>
>>>> Many thanks in advance.
>>>>
>>>> Pascual
>>>>
>
Previous Topic:"GenPropertySheet" available in GMF 1.0 ??
Next Topic:Cannot find some specific classes (problems removing components)
Goto Forum:
  


Current Time: Sat Dec 21 15:51:52 GMT 2024

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

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

Back to the top