Need programmatic access to ArrangeAction [message #76335] |
Thu, 09 November 2006 20:03 |
Eclipse User |
|
|
|
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 #76887 is a reply to message #76351] |
Sat, 11 November 2006 16:14 |
Eclipse User |
|
|
|
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> </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> </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> </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> </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> </P><P><FONT face=3DArial =
color=3D#000000></FONT> </P><P><FONT face=3DArial =
color=3D#000000>The line in question is </FONT></P><P><FONT face=3DArial =
color=3D#000000></FONT> </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> </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> </P><P><FONT size=3D2><FONT =
color=3D#000000></FONT></FONT> </P><P><FONT size=3D2><FONT =
color=3D#000000>Thanks again.</FONT></P></FONT></FONT></PRE><PRE><FONT =
size=3D2></FONT> </PRE><PRE><FONT size=3D2></FONT> </PRE>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>"Mohammed Mostafa" <</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>> =
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>>=20
Alan;<BR>> You can do something like=20
this<BR> > &a mp;nbsp; ArrangeRequest =
arrangeRequest=20
=3D<BR>> new=20
ArrangeRequest(RequestConstants.REQ_ARRANGE_DEFERRED);<BR>>  =
; =20
request.setPartsToArrange(editParts);<BR>> &nbs=
p; =20
Command arrangeCmd =3D containerEP.getCommand(request);<BR>> <BR>> =
then you=20
can compose this arrange command with your zoom command<BR>> <BR>> =
<BR>> <BR>> Alan wrote:<BR>>> Hi all,<BR>>> =
<BR>>> I=20
want to force my diagram to lay itself out when the zoom level changes =
as=20
<BR>>> I rearrange them based on this.<BR>>> It will work if =
I=20
choosed the Arrange All action on the GUI.<BR>>> So I was thinking =
if I=20
could invoke this action programmatically then it <BR>>> would=20
work.<BR>>> So anyone know how I can get a handle on the action=20
?<BR>>> <BR>>> <BR>>> =
<BR>>></FONT></BODY></HTML>
------=_NextPart_000_002A_01C705AC.6FF094E0--
|
|
|
|
Powered by
FUDForum. Page generated in 0.03422 seconds