Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » i need help setting a node's child editpart as contents for the RootEditPart
i need help setting a node's child editpart as contents for the RootEditPart [message #500098] Tue, 24 November 2009 23:24 Go to next message
spyro  is currently offline spyro Friend
Messages: 18
Registered: July 2009
Junior Member
Hello,
i need to add the following functionality to my editor:
node A has another node B as a child, and node B has a child C.
Node B should have DiagramImpl as View because
when i double click on node A, node B should open up (basically a new Canvas should open where i can create nodes from type C).

the problem is how can i set the view of B to DiagramImpl? after this is done i can do
MyDiagramEditor.getDiagramEditPart().getViewer().getRootEdit Part().setContents(B);
and it should work i guess.

i tried the following :

EditorViewFactory f=new EditorViewFactory();
IElementType type1 = XXXElementTypes.Editor_1000;
View view= f.createDiagram(new CreateElementRequestAdapter(new CreateElementRequest(type1)), XXX.diagram.part.XXXVisualIDRegistry
.getType(XXX.diagram.edit.parts.EditorEditPart.VISUAL_ID), rootEP.getDiagramPreferencesHint());


EditorEditPart g=new EditorEditPart(view);

and "view" is created as DiagramImpl but it has nothing on it and when i call
MyDiagramEditor.getDiagramEditPart().getViewer().getRootEdit Part().setContents(g);

i get NullPointerException.


i hope i could explain my issue in a clear way so some of you can help me. Is what i want doable and how?

thanks and regards,
spyro
Re: i need help setting a node's child editpart as contents for the RootEditPart [message #500833 is a reply to message #500098] Sun, 29 November 2009 12:35 Go to previous message
Alex Shatalin is currently offline Alex ShatalinFriend
Messages: 141
Registered: July 2009
Senior Member
Hello spyro,

Try following:
1. Create separate .gmfmap file for element B.
2. in .gmfmap with element A select NodeMapping for element A and set "Related
Diagram" property to point to CanvasMapping created on step 1. (you have
to load .gmfmap from step 1. into the editor of current .gmfmap fie by using
popup menu action "Load Resource.." in order to have corresponding CanvasMapping
available in chooser dialog for "Related Diagram" property)
3. generate both diagrams.
4. Browse generated code for diagram with element A and compare it with prev.
versino to see what was added.
5. Modify generated OpenDiagramEditPolicy (getDiagramDomainElement() method)
to get proper element to be used as a root one for diagram, from step 1.
(As I understand, you have to double-click on diagram element "A" and open
diagram for it's child one "B", so getDiagramDomainElement() have to to something
like: "((A) ((View) diagramFacet.eContainer()).getElement()).getB()")

-----------------
Alex Shatalin
Previous Topic:Extending the diagram from another plugin project?
Next Topic:synchronize Outline/Overview with MultiPageEditor
Goto Forum:
  


Current Time: Sun Apr 18 07:31:44 GMT 2021

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

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

Back to the top