Skip to main content



      Home
Home » Modeling » GMF (Graphical Modeling Framework) » Adding children to a compartment programmatically
Adding children to a compartment programmatically [message #87726] Tue, 26 December 2006 14:51 Go to next message
Eclipse UserFriend
Originally posted by: mricardo.ef.pt

Hello,

Can anyone give me a hint, in how to add compartment children to a node
programmatically?
I want to be able to create a Node, with an popup action, and additionally
one child in its compartment.
The node creation, I've got, but I dont know how to create compartment
children.
The code for the Node creation is the following (inspired by mindmap):
private void getCreatePageCommand() {


CreateViewRequest pageRequest =
CreateViewRequestFactory.getCreateShapeRequest(WebviewElemen tTypes.Page_1001,

selectedElement.getDiagramPreferencesHint());


Point p = selectedElement.getFigure().getBounds().getTopRight().getCop y();

selectedElement.getFigure().translateToAbsolute(p);

int edgeCount = selectedElement.getNotationView().getSourceEdges().size();

int offset = (edgeCount * 50) - 100;

pageRequest.setLocation(p.translate(100, offset));


ViewEditPart viewEditPart = (ViewEditPart) selectedElement;

Command createPageCmd = viewEditPart.getCommand(pageRequest);


selectedElement.getDiagramEditDomain().getDiagramCommandStac k().execute(createPageCmd);


Collection newObjects = DiagramCommandStack.getReturnValues(createPageCmd);

Iterator i = newObjects.iterator();

if (i.hasNext()) {


Object obj = i.next();

Page page = (Page) ((IAdaptable) obj).getAdapter(Page.class);

final PageEditPart editPart = (PageEditPart)
selectedElement.findEditPart(selectedElement, (EObject) page);

final EditPartViewer v = editPart.getViewer();

Display.getCurrent().asyncExec(new Runnable() {


public void run() {

v.setSelection(new StructuredSelection(editPart));

Request der = new Request(RequestConstants.REQ_DIRECT_EDIT);

editPart.performRequest(der);

} });

}

}

Thanks,
--
Miguel Ricardo

EF - Tecnologias de Informa
Re: Adding children to a compartment programmatically [message #87870 is a reply to message #87726] Wed, 27 December 2006 06:32 Go to previous message
Eclipse UserFriend
Hello Miguel,

AFAIK compartments should be created automatically on creating the node itself.
See decorateView() method for ???ViewFactory generated for node.

-----------------
Alex Shatalin
Previous Topic:Realize the MOF-concept
Next Topic:Detaching Palette from the Editor?
Goto Forum:
  


Current Time: Sun Jul 20 14:52:06 EDT 2025

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

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

Back to the top