Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Need programmatic access to ArrangeAction
Need programmatic access to ArrangeAction [message #76335] Thu, 09 November 2006 20:03 Go to next message
Eclipse UserFriend
Originally posted by: awm_abu.yahoo.com

Hi all,

I want to force my diagram to lay itself out when the zoom level changes as
I rearrange them based on this.
It will work if I choosed the Arrange All action on the GUI.
So I was thinking if I could invoke this action programmatically then it
would work.
So anyone know how I can get a handle on the action ?
Re: Need programmatic access to ArrangeAction [message #76351 is a reply to message #76335] Thu, 09 November 2006 20:16 Go to previous messageGo to next message
Mohammed Mostafa is currently offline Mohammed MostafaFriend
Messages: 143
Registered: July 2009
Senior Member
Alan;
You can do something like this
ArrangeRequest arrangeRequest =
new ArrangeRequest(RequestConstants.REQ_ARRANGE_DEFERRED);
request.setPartsToArrange(editParts);
Command arrangeCmd = containerEP.getCommand(request);

then you can compose this arrange command with your zoom command



Alan wrote:
> Hi all,
>
> I want to force my diagram to lay itself out when the zoom level changes as
> I rearrange them based on this.
> It will work if I choosed the Arrange All action on the GUI.
> So I was thinking if I could invoke this action programmatically then it
> would work.
> So anyone know how I can get a handle on the action ?
>
>
>
>
Re: Need programmatic access to ArrangeAction [message #76887 is a reply to message #76351] Sat, 11 November 2006 16:14 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: awm_abu.yahoo.com

This is a multi-part message in MIME format.

------=_NextPart_000_002A_01C705AC.6FF094E0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Thanks for the reply.

Ok so here's how I got on.
I added a ZoomListener to the ZoomManager I get from the =
RenderedDiagramRootEditPart which is the parent of my DiagramEditPart.

When I receive a zoomChanged event I run the following code:

public void zoomChanged(double zoom) {try{ArrangeRequest arrangeRequest =
=3Dnew ArrangeRequest(RequestConstants.REQ_ARRANGE_DEFERRED);List l =3D =
getChildren();arrangeRequest.setPartsToArrange(l);Command arrangeCmd =3D =
getCommand(arrangeRequest);arrangeCmd.execute();}catch(Excep tion =
e){e.printStackTrace();}}When I run this I get a NullPointer exception =
like the below :java.lang.NullPointerExceptionat =
org.eclipse.gmf.runtime.diagram.ui.commands.DeferredLayoutCo mmand$1.run(D=
eferredLayoutCommand.java:151)at =
org.eclipse.gmf.runtime.diagram.ui.util.EditPartUtil.synchro nizeRunnableT=
oMainThread(EditPartUtil.java:72)at =
org.eclipse.gmf.runtime.diagram.ui.commands.DeferredLayoutCo mmand.doExecu=
teWithResult(DeferredLayoutCommand.java:185)at =
org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTr ansactionalCo=
mmand.doExecute(AbstractTransactionalCommand.java:245)at =
org.eclipse.emf.workspace.AbstractEMFOperation.execute(Abstr actEMFOperati=
on.java:127)at =
org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy.ex ecute(IComman=
dProxy.java:64)The line in question is List editParts =3D new =
ArrayList(viewAdapters.size());My viewAdapters are null...any idea why =
?Thanks again.


"Mohammed Mostafa" <mmostafa@ca.ibm.com> wrote in message =
news:ej02cs$oj2$1@utils.eclipse.org...
> Alan;
> You can do something like this
> ArrangeRequest arrangeRequest =3D
> new ArrangeRequest(RequestConstants.REQ_ARRANGE_DEFERRED);
> request.setPartsToArrange(editParts);
> Command arrangeCmd =3D containerEP.getCommand(request);
>=20
> then you can compose this arrange command with your zoom command
>=20
>=20
>=20
> Alan wrote:
>> Hi all,
>>=20
>> I want to force my diagram to lay itself out when the zoom level =
changes as=20
>> I rearrange them based on this.
>> It will work if I choosed the Arrange All action on the GUI.
>> So I was thinking if I could invoke this action programmatically then =
it=20
>> would work.
>> So anyone know how I can get a handle on the action ?
>>=20
>>=20
>>=20
>>
------=_NextPart_000_002A_01C705AC.6FF094E0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2900.2963" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=3DArial size=3D2>Thanks for the reply.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Ok so here's how I got on.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>I added a ZoomListener to the =
ZoomManager I get=20
from the RenderedDiagramRootEditPart which is the parent of my=20
DiagramEditPart.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>When I receive a zoomChanged event I =
run the=20
following code:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV><PRE><FONT =
size=3D2>public void zoomChanged(double zoom) {</FONT></PRE><PRE><FONT =
size=3D2>try</FONT></PRE><PRE><FONT size=3D2>{</FONT></PRE><PRE><FONT =
size=3D2>ArrangeRequest arrangeRequest =3D</FONT></PRE><PRE><FONT =
size=3D2>new =
ArrangeRequest(RequestConstants.REQ_ARRANGE_DEFERRED);</FONT ></PRE><PRE><=
FONT size=3D2>List l =3D getChildren();</FONT></PRE><PRE><FONT =
size=3D2>arrangeRequest.setPartsToArrange(l);</FONT></PRE ><PRE><FONT =
size=3D2>Command arrangeCmd =3D =
getCommand(arrangeRequest);</FONT></PRE><PRE><FONT =
size=3D2>arrangeCmd.execute();</FONT></PRE><PRE><FONT =
size=3D2>}</FONT></PRE><PRE><FONT size=3D2>catch(Exception =
e)</FONT></PRE><PRE><FONT size=3D2>{</FONT></PRE><PRE><FONT =
size=3D2>e.printStackTrace();</FONT></PRE><PRE><FONT =
size=3D2>}</FONT></PRE><PRE><FONT size=3D2>}</FONT></PRE><PRE><FONT =
size=3D2></FONT>&nbsp;</PRE><PRE><FONT size=3D2>When I run this I get a =
NullPointer exception like the below :</FONT></PRE><PRE><U><FONT =
color=3D#000080 size=3D2><P =
align=3Dleft>java.lang.NullPointerException</P></U></FONT ><FONT =
color=3D#ff0000 size=3D2><P align=3Dleft>at =
org.eclipse.gmf.runtime.diagram.ui.commands.DeferredLayoutCo mmand$1.run( <=
/FONT><U><FONT color=3D#000080 =
size=3D2>DeferredLayoutCommand.java:151</U></FONT><FONT color=3D#ff0000 =
size=3D2>)</P><P align=3Dleft>at =
org.eclipse.gmf.runtime.diagram.ui.util.EditPartUtil.synchro nizeRunnableT=
oMainThread(</FONT><U><FONT color=3D#000080 =
size=3D2>EditPartUtil.java:72</U></FONT><FONT color=3D#ff0000 =
size=3D2>)</P><P align=3Dleft>at =
org.eclipse.gmf.runtime.diagram.ui.commands.DeferredLayoutCo mmand.doExecu=
teWithResult(</FONT><U><FONT color=3D#000080 =
size=3D2>DeferredLayoutCommand.java:185</U></FONT><FONT color=3D#ff0000 =
size=3D2>)</P><P align=3Dleft>at =
org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTr ansactionalCo=
mmand.doExecute(</FONT><U><FONT color=3D#000080 =
size=3D2>AbstractTransactionalCommand.java:245</U></FONT> <FONT =
color=3D#ff0000 size=3D2>)</P><P align=3Dleft>at =
org.eclipse.emf.workspace.AbstractEMFOperation.execute(</FONT ><U><FONT =
color=3D#000080 size=3D2>AbstractEMFOperation.java:127</U></FONT><FONT =
color=3D#ff0000 size=3D2>)</P><P align=3Dleft>at =
org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy.ex ecute( </FONT>=
<U><FONT color=3D#000080 size=3D2>ICommandProxy.java:64</U></FONT><FONT =
color=3D#ff0000 size=3D2>)</P><P><FONT face=3DArial =
color=3D#000000></FONT>&nbsp;</P><P><FONT face=3DArial =
color=3D#000000></FONT>&nbsp;</P><P><FONT face=3DArial =
color=3D#000000>The line in question is </FONT></P><P><FONT face=3DArial =
color=3D#000000></FONT>&nbsp;</P><U><FONT color=3D#0000ff =
size=3D2><P>List</U></FONT><FONT color=3D#000000 size=3D2> editParts =3D =
</FONT><B><FONT color=3D#7f0055 size=3D2>new</B></FONT><FONT =
color=3D#000000 size=3D2> ArrayList(</FONT><FONT color=3D#0000c0 =
size=3D2>viewAdapters</FONT><FONT size=3D2><FONT =
color=3D#000000>.size());</FONT></FONT></P><P><FONT size=3D2><FONT =
color=3D#000000></FONT></FONT>&nbsp;</P><P><FONT size=3D2><FONT =
color=3D#000000>My viewAdapters are null...any idea why =
?</FONT></FONT></P><P><FONT size=3D2><FONT =
color=3D#000000></FONT></FONT>&nbsp;</P><P><FONT size=3D2><FONT =
color=3D#000000></FONT></FONT>&nbsp;</P><P><FONT size=3D2><FONT =
color=3D#000000>Thanks again.</FONT></P></FONT></FONT></PRE><PRE><FONT =
size=3D2></FONT>&nbsp;</PRE><PRE><FONT size=3D2></FONT>&nbsp;</PRE>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>"Mohammed Mostafa" &lt;</FONT><A=20
href=3D"mailto:mmostafa@ca.ibm.com"><FONT face=3DArial=20
size=3D2>mmostafa@ca.ibm.com</FONT></A><FONT face=3DArial size=3D2>&gt; =
wrote in=20
message </FONT><A href=3D"news:ej02cs$oj2$1@utils.eclipse.org"><FONT =
face=3DArial=20
size=3D2>news:ej02cs$oj2$1@utils.eclipse.org</FONT></A><FONT =
face=3DArial=20
size=3D2>...</FONT></DIV><FONT face=3DArial size=3D2>&gt;=20
Alan;<BR>&gt;&nbsp;&nbsp;&nbsp; You can do something like=20
this<BR> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&a mp;nbsp; ArrangeRequest =
arrangeRequest=20
=3D<BR>&gt; new=20
ArrangeRequest(RequestConstants.REQ_ARRANGE_DEFERRED);<BR>&gt;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;=20
request.setPartsToArrange(editParts);<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;=20
Command arrangeCmd =3D containerEP.getCommand(request);<BR>&gt; <BR>&gt; =
then you=20
can compose this arrange command with your zoom command<BR>&gt; <BR>&gt; =

<BR>&gt; <BR>&gt; Alan wrote:<BR>&gt;&gt; Hi all,<BR>&gt;&gt; =
<BR>&gt;&gt; I=20
want to force my diagram to lay itself out when the zoom level changes =
as=20
<BR>&gt;&gt; I rearrange them based on this.<BR>&gt;&gt; It will work if =
I=20
choosed the Arrange All action on the GUI.<BR>&gt;&gt; So I was thinking =
if I=20
could invoke this action programmatically then it <BR>&gt;&gt; would=20
work.<BR>&gt;&gt; So anyone know how I can get a handle on the action=20
?<BR>&gt;&gt; <BR>&gt;&gt; <BR>&gt;&gt; =
<BR>&gt;&gt;</FONT></BODY></HTML>

------=_NextPart_000_002A_01C705AC.6FF094E0--
Re: Need programmatic access to ArrangeAction [message #77213 is a reply to message #76887] Mon, 13 November 2006 16:20 Go to previous message
Mohammed Mostafa is currently offline Mohammed MostafaFriend
Messages: 143
Registered: July 2009
Senior Member
Hi Alan;

The DeferredLayoutCommand, assumes that ViewAdapters had been set on
the Arrange Request that is why you get the NULL pointer exception, try
to use ActionIds.ACTION_ARRANGE_ALL instead of
RequestConstants.REQ_ARRANGE_DEFERRED this should avoid the pass that
cause the NULL pointer exception.




Alan wrote:
> Thanks for the reply.
>
> Ok so here's how I got on.
> I added a ZoomListener to the ZoomManager I get from the
> RenderedDiagramRootEditPart which is the parent of my DiagramEditPart.
>
> When I receive a zoomChanged event I run the following code:
>
>
> public void zoomChanged(double zoom) {
>
> try
>
> {
>
> ArrangeRequest arrangeRequest =
>
> new ArrangeRequest(RequestConstants.REQ_ARRANGE_DEFERRED);
>
> List l = getChildren();
>
> arrangeRequest.setPartsToArrange(l);
>
> Command arrangeCmd = getCommand(arrangeRequest);
>
> arrangeCmd.execute();
>
> }
>
> catch(Exception e)
>
> {
>
> e.printStackTrace();
>
> }
>
> }
>
>
>
> When I run this I get a NullPointer exception like the below :
>
> __
>
> _java.lang.NullPointerException_
>
> at
> org.eclipse.gmf.runtime.diagram.ui.commands.DeferredLayoutCo mmand$1.run(_DeferredLayoutCommand.java:151_)
>
> at
> org.eclipse.gmf.runtime.diagram.ui.util.EditPartUtil.synchro nizeRunnableToMainThread(_EditPartUtil.java:72_)
>
> at
> org.eclipse.gmf.runtime.diagram.ui.commands.DeferredLayoutCo mmand.doExecuteWithResult(_DeferredLayoutCommand.java:185_)
>
> at
> org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTr ansactionalCommand.doExecute(_AbstractTransactionalCommand.j ava:245_)
>
> at
> org.eclipse.emf.workspace.AbstractEMFOperation.execute(_Abst ractEMFOperation.java:127_)
>
> at
> org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy.ex ecute(_ICommandProxy.java:64_)
>
>
>
>
>
> The line in question is
>
>
>
> __
>
> _List_ editParts = *new* ArrayList(viewAdapters.size());
>
>
>
> My viewAdapters are null...any idea why ?
>
>
>
>
>
> Thanks again.
>
>
>
>
>
>
>
>
> "Mohammed Mostafa" <mmostafa@ca.ibm.com <mailto:mmostafa@ca.ibm.com>>
> wrote in message news:ej02cs$oj2$1@utils.eclipse.org...
> > Alan;
> > You can do something like this
> > ArrangeRequest arrangeRequest =
> > new ArrangeRequest(RequestConstants.REQ_ARRANGE_DEFERRED);
> > request.setPartsToArrange(editParts);
> > Command arrangeCmd = containerEP.getCommand(request);
> >
> > then you can compose this arrange command with your zoom command
> >
> >
> >
> > Alan wrote:
> >> Hi all,
> >>
> >> I want to force my diagram to lay itself out when the zoom level
> changes as
> >> I rearrange them based on this.
> >> It will work if I choosed the Arrange All action on the GUI.
> >> So I was thinking if I could invoke this action programmatically
> then it
> >> would work.
> >> So anyone know how I can get a handle on the action ?
> >>
> >>
> >>
> >>
Previous Topic:Copy/Paste
Next Topic:fixing copy & paste issues
Goto Forum:
  


Current Time: Wed Jun 26 19:57:29 GMT 2024

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

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

Back to the top