Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » How to get the EditPart of a Node from its View object?
How to get the EditPart of a Node from its View object? [message #229121] Thu, 07 May 2009 09:48 Go to next message
TL is currently offline TLFriend
Messages: 22
Registered: July 2009
Junior Member
Hello,

how can I get the coresponding EditPart of the node, when I only have
the View object (notation model) of this node?

Thank you in advance.
Re: How to get the EditPart of a Node from its View object? [message #229264 is a reply to message #229121] Fri, 08 May 2009 04:16 Go to previous message
BG is currently offline BGFriend
Messages: 45
Registered: July 2009
Member
Hi,
Try this snippet to obtain editpart from view
IEditorPart editorPart = PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getActivePage().getActiveEditor( );

//DiagramEditor should be activated
Assert.isTrue(editorPart instanceof DiagramEditor);

DiagramEditor diagramEditor = (DiagramEditor) editorPart;

//activated DiagramEditor must be the one that corresponds to
//this view's diagram
Assert.isTrue(diagramEditor.getDiagram().equals(view.getDiag ram()));

//diagramEditor instanceof IDiagramWorkbenchPart
IDiagramGraphicalViewer viewer = diagramEditor
.getDiagramGraphicalViewer();
Assert.isNotNull(viewer);

//find the edit part
Object obj = viewer.getEditPartRegistry().get(view);

if (obj instanceof EditPart) {
Editpart editpart = (EditPart)obj
}
Regards
Byre
Previous Topic:Getting the source and target Node form an Edge
Next Topic:how to show List in a property view
Goto Forum:
  


Current Time: Thu Nov 23 15:17:24 GMT 2017

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

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