how to get list of editparts [message #224876] |
Wed, 08 April 2009 11:41 |
Eclipse User |
|
|
|
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 #224946 is a reply to message #224885] |
Wed, 08 April 2009 12:25 |
Eclipse User |
|
|
|
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 |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.02987 seconds