Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » how to get list of editparts
how to get list of editparts [message #224876] Wed, 08 April 2009 11:41 Go to next message
Eclipse UserFriend
Originally posted by: taus.proceedinnovation.com

Hallo,

I have a Diagram d and want to get the list of EditParts contained in
this diagram. How can I accomplish this?

Thanks ini advance
Walter
Re: how to get list of editparts [message #224885 is a reply to message #224876] Wed, 08 April 2009 11:51 Go to previous messageGo to next message
Javier is currently offline JavierFriend
Messages: 57
Registered: July 2009
Member
Hi Walter,

You can do that using the viewer and getting the EditPartRegistry: a map
with all the EditParts created.

EditPart.getViewer().getEditPartRegistry()

Hope this helps,
Javier
Re: how to get list of editparts [message #224946 is a reply to message #224885] Wed, 08 April 2009 12:25 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: taus.proceedinnovation.com

Javier schrieb:
> Hi Walter,
>
> You can do that using the viewer and getting the EditPartRegistry: a map
> with all the EditParts created.
>
> EditPart.getViewer().getEditPartRegistry()
>
> Hope this helps,
> Javier
>
>
Hi Javier,

I have only got a Diagram d. I have not got an EditPart Object. So I
can't use your code template. And for a diagram object I have not found
a way to get to the viewer.

Thanks,
Walter
Re: how to get list of editparts [message #225007 is a reply to message #224946] Wed, 08 April 2009 15:17 Go to previous message
Eclipse UserFriend
Originally posted by: cayla_sha.gmx.net

Walter Taus schrieb:
> Javier schrieb:
>> Hi Walter,
>>
>> You can do that using the viewer and getting the EditPartRegistry: a
>> map with all the EditParts created.
>>
>> EditPart.getViewer().getEditPartRegistry()
>>
>> Hope this helps,
>> Javier
>>
>>
> Hi Javier,
>
> I have only got a Diagram d. I have not got an EditPart Object. So I
> can't use your code template. And for a diagram object I have not found
> a way to get to the viewer.
>
> Thanks,
> Walter

Hi Walter,

I found a way around this. It works, but I think it's not the best
programming style.

I put some code into the class ....diagram.part.XxxDiagramEditor:
/**
* @generated NOT
*/
private static XxxDiagramEditor instance;

/**
* @generated NOT
*/
public XxxDiagramEditor() {
super(true);
instance = this;
}

/**
* @generated NOT
*/
public static XxxDiagramEditor getInstance() {
return instance;
}

This works, because the constructor is only called once at the opening
of the diagram.

Now I can get the EditPartRegistry from everywhere in the code like this:
DiagramGraphicalViewer dgv = (DiagramGraphicalViewer)
XxxDiagramEditor.getInstance().getDiagramGraphicalViewer();
Map<?, ?> editPartRegistry = dgv.getEditPartRegistry();


If anyone finds a better method, I would appreciate to hear about.
Best wishes
Julia
Previous Topic:Customizing generated code
Next Topic:Convenient way to interrupt element creation after dialog cancellation
Goto Forum:
  


Current Time: Thu Apr 25 19:45:04 GMT 2024

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

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

Back to the top