Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Get EditParts of GraphicalEditor
Get EditParts of GraphicalEditor [message #245196] Wed, 27 August 2008 13:19 Go to next message
Hauke Fuhrmann is currently offline Hauke FuhrmannFriend
Messages: 333
Registered: July 2009
Senior Member
Hi there,

I need to obtain all EditParts of a generic GraphicalEditor in GEF. How
can I do that?

GraphicalEditor has a method getGraphicalViewer() and the viewer could
return the RootEditPart. Unfortunately the getGraphicalViewer() method
is protected and hence cannot be called from outside.

So I need a more specific Editor, that extends the GraphicalEditor and
exposes the getGraphicalViewer method to the public, as for example a
GMF editor. But I do not want to be limited to specialized editors...

Any hints for that?

Cheers,
Hauke
Re: Get EditParts of GraphicalEditor [message #245218 is a reply to message #245196] Thu, 28 August 2008 01:43 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: lifesting.gmail.com

Hauke Fuhrmann wrote:
> Hi there,
>
> I need to obtain all EditParts of a generic GraphicalEditor in GEF. How
> can I do that?
>
> GraphicalEditor has a method getGraphicalViewer() and the viewer could
> return the RootEditPart. Unfortunately the getGraphicalViewer() method
> is protected and hence cannot be called from outside.
>
> So I need a more specific Editor, that extends the GraphicalEditor and
> exposes the getGraphicalViewer method to the public, as for example a
> GMF editor. But I do not want to be limited to specialized editors...
>
> Any hints for that?
>
> Cheers,
> Hauke
1 you can obtain GrpahicalViewer from outside by Adapter, e.g:

GraphicalViewer gv =
((GraphicalEditor)part).getAdapter(GraphicalViewer.class);

2 Iterate all EditPart of GraphicalViewer:

for (Iterator ite = gv.getEditPartRegistry().keySet().iterator();
ite.hasNext();)
{
EditPart ep = ite.next();
//Some operations against to EditPart here.
}
Re: Get EditParts of GraphicalEditor [message #245223 is a reply to message #245218] Thu, 28 August 2008 01:48 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: lifesting.gmail.com

David BY Chan wrote:
> Hauke Fuhrmann wrote:
>> Hi there,
>>
>> I need to obtain all EditParts of a generic GraphicalEditor in GEF. How
>> can I do that?
>>
>> GraphicalEditor has a method getGraphicalViewer() and the viewer could
>> return the RootEditPart. Unfortunately the getGraphicalViewer() method
>> is protected and hence cannot be called from outside.
>>
>> So I need a more specific Editor, that extends the GraphicalEditor and
>> exposes the getGraphicalViewer method to the public, as for example a
>> GMF editor. But I do not want to be limited to specialized editors...
>>
>> Any hints for that?
>>
>> Cheers,
>> Hauke
> 1 you can obtain GrpahicalViewer from outside by Adapter, e.g:
>
> GraphicalViewer gv =
> ((GraphicalEditor)part).getAdapter(GraphicalViewer.class);
>
> 2 Iterate all EditPart of GraphicalViewer:
>
> for (Iterator ite = gv.getEditPartRegistry().keySet().iterator();
> ite.hasNext();)
> {
> EditPart ep = ite.next();
> //Some operations against to EditPart here.
> }
Sorry, you need chage "gv.getEditPartRegistry().keySet().iterator()" to
"gv.getEditPartRegistry().values().iterator()" in the above statements.
Re: Get EditParts of GraphicalEditor [message #245236 is a reply to message #245218] Thu, 28 August 2008 10:31 Go to previous message
Hauke Fuhrmann is currently offline Hauke FuhrmannFriend
Messages: 333
Registered: July 2009
Senior Member
David BY Chan wrote:
> 1 you can obtain GrpahicalViewer from outside by Adapter, e.g:
>
> GraphicalViewer gv =
> ((GraphicalEditor)part).getAdapter(GraphicalViewer.class);

Oh, thanks! That's easy :-)
Is there a common way how to find out such things? How to know in
general what adapters are available for a class? This is usually not
documented in the APIs, is it?

Cheers,
Hauke
Previous Topic:Populate Wizard from a CreationTool
Next Topic:Refreshing a Custom View
Goto Forum:
  


Current Time: Thu Apr 25 10:26:47 GMT 2024

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

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

Back to the top