Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » How to get the RootEditPart from Editor
How to get the RootEditPart from Editor [message #218115] Mon, 19 June 2006 20:51 Go to next message
Eclipse UserFriend
Originally posted by: mliu.technicacorp.com

I am a newbie so please bear with me.

I created an Eclipse Plugin that has a graphical editor using Draw2D
figures. I would like to add a button on the toolbar which, once clicked,
will perform some actions in the editor's view.

For example, I have some graphical objects on the editor view and I would
like to redo the layout for these graphical objects when a button on the
toolbar is clicked.

So for this, I created a class something like this:

public class RedoLayout implements IEditorActoinDelegate {

private IEditorPart targetPart;

public void run(IAction arg0)
{
targetPart =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage().getActiveEditor();

MyGraphicalEditor editor = (MyGraphicalEditor)targetPart;
}

}

I can get a handle to the editor which by casting the targetPart in the code
above.

But now in order for me to redraw the layout, I need to be able to access
the RootEditPart of what's on the editor view. From the editor instance, how
do I get a hold of the RootEditPart of the GraphicalViewer so that I can
manuplate the properties of the graphical objects in the editor view?

Thanks for any help.
Re: How to get the RootEditPart from Editor [message #218199 is a reply to message #218115] Tue, 20 June 2006 17:47 Go to previous messageGo to next message
Mohammed Mostafa is currently offline Mohammed MostafaFriend
Messages: 143
Registered: July 2009
Senior Member
This is a multipart message in MIME format.
--=_alternative 0061F98185257193_=
Content-Type: text/plain; charset="US-ASCII"

You can call getGraphicalViewer().getRootEditPart() on your Graphical
Editor
--=_alternative 0061F98185257193_=
Content-Type: text/html; charset="US-ASCII"


<br><font size=2 face="sans-serif">You can call </font><font size=2 face="Courier New">getGraphicalViewer().getRootEditPart()</font><font size=2 face="sans-serif">
on your Graphical Editor</font>
--=_alternative 0061F98185257193_=--
Re: How to get the RootEditPart from Editor [message #218228 is a reply to message #218199] Tue, 20 June 2006 18:49 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mliu.technicacorp.com

This is a multi-part message in MIME format.

------=_NextPart_000_003B_01C69478.BA8088D0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

getGraphicalViewer() is a protected method and can only be called from a =
subclass. However in my case, I have the implementation of a =
IEditorActionDelegate class.
<mmostafa@ca.ibm.com> wrote in message =
news:e79cc1$vsj$1@utils.eclipse.org...

You can call getGraphicalViewer().getRootEditPart() on your Graphical =
Editor
------=_NextPart_000_003B_01C69478.BA8088D0
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.2873" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>getGraphicalViewer() is a protected =
method and can=20
only be called from a subclass. However in my case, I have the =
implementation of=20
a IEditorActionDelegate class.</FONT></DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>&lt;<A =
href=3D"mailto:mmostafa@ca.ibm.com">mmostafa@ca.ibm.com</A>&gt;=20
wrote in message <A=20
=
href=3D"news:e79cc1$vsj$1@utils.eclipse.org">news:e79cc1$vsj$1@utils.ecli=
pse.org</A>...</DIV><BR><FONT=20
face=3Dsans-serif size=3D2>You can call </FONT><FONT face=3D"Courier =
New"=20
size=3D2>getGraphicalViewer().getRootEditPart()</FONT><FONT =
face=3Dsans-serif=20
size=3D2> on your Graphical Editor</FONT></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_003B_01C69478.BA8088D0--
Re: How to get the RootEditPart from Editor [message #218327 is a reply to message #218228] Thu, 22 June 2006 17:02 Go to previous message
Mohammed Mostafa is currently offline Mohammed MostafaFriend
Messages: 143
Registered: July 2009
Senior Member
This is a multipart message in MIME format.
--=_alternative 005DDB1085257195_=
Content-Type: text/plain; charset="US-ASCII"

if you can not use the getGraphicalViewer method because of the
visibility, try using getAdapter(GraphicalViewer.class)
--=_alternative 005DDB1085257195_=
Content-Type: text/html; charset="US-ASCII"


<br><font size=2 face="sans-serif">if you can not use the getGraphicalViewer
method because of the visibility, try using </font><font size=2 face="Courier New">getAdapter(GraphicalViewer.</font><font size=2 color=#820040 face="Courier New"><b>class</b></font><font size=2 face="Courier New">)</font>
--=_alternative 005DDB1085257195_=--
Previous Topic:Wrong location from BendpointRequest
Next Topic:Trouble with labels and child editparts.
Goto Forum:
  


Current Time: Fri Mar 29 05:28:49 GMT 2024

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

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

Back to the top