Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Diagram partitionning(how open a new diagram for a property)
icon5.gif  Diagram partitionning [message #699379] Thu, 21 July 2011 13:14 Go to next message
Valerian Merkling is currently offline Valerian MerklingFriend
Messages: 71
Registered: May 2011
Member
Hi everyone !

I followed this tutorial http://www.jevon.org/wiki/GMF_Diagram_Partitioning and i'm now able to open a new editor for a node.

I would like to know if it's possible to configure it for this case :
a subEditor for a class FOO

a class BAR with a FOO property, and a double clic on the BAR node opening the diagram for the FOO element.


Thanks in advance !

Valerian
Re: Diagram partitionning [message #699684 is a reply to message #699379] Fri, 22 July 2011 05:01 Go to previous messageGo to next message
Stu Plu is currently offline Stu PluFriend
Messages: 44
Registered: July 2009
Member
Hi I did this by adding a OpenEditPolicy on the node (BAR in your case) and then extrated Foo the variable and build the string to represent the diagram name and then opened. Here is some code pasted together that might help (my code my spread over a number of class so I have done a quick copy / paste into one method for you):-

public class BAREditPart extends ShapeNodeEditPart {
/**
* @generated NOT
*/
private OpenEditPolicy createOpenEditPolicy() {
OpenEditPolicy policy = new OpenEditPolicy() {
protected Command getOpenCommand(Request request) {
Shell shell = new Shell();
// GET Attribute to that represents Diagram name to open
String aDiagramName = ((BARActionImpl)((NodeImpl)this.getHost().getModel()).getElement()).getFOOVariable().trim();
// Now build full path so diagram from the FOOVariable can be opened.
if (aDiagramName.length()!=0) {
XMIResourceImpl resource = (XMIResourceImpl)((ShapeNodeEditPart)this.getHost()).getEditingDomain().getResourceSet().getResources().get(1);
String pathString = ""+resource.getURI().toString().replaceAll("platform:/resource", "");
String tempString = pathString.replaceAll(resource.getURI().segment(resource.getURI().segmentCount()-1),"")+aDiagramName;
String fileString = tempString+".extention";
URI diagramModelFilename = URI.createPlatformResourceURI(fileString,false);
GMFResource myGMFDiagram = new GMFResource(diagramModelFilename);
try {
myGMFDiagram.load(Collections.EMPTY_MAP);
if (myGMFDiagram.isLoaded()) {
DiagramEditorUtil.openDiagram(myGMFDiagram);
}
} catch (IOException e1) {
} catch (PartInitException e) {
}
}
}
};
return policy;
}


Hope that helps a little
Re: Diagram partitionning [message #699691 is a reply to message #699684] Fri, 22 July 2011 05:22 Go to previous message
Stu Plu is currently offline Stu PluFriend
Messages: 44
Registered: July 2009
Member
Dont forget to edit the createDefaultEditPolicies() Smile
e.g. My code was
installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE,
new BARItemSemanticEditPolicy());
installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
installEditPolicy(EditPolicyRoles.OPEN_ROLE, createOpenEditPolicy());
// remove the ability to add connections to node << This was for me you might not want this
removeEditPolicy(EditPolicyRoles.CONNECTION_HANDLES_ROLE);
}
Previous Topic:how to create popup for the properties of the nodes?
Next Topic:Refactoring in GMF editor
Goto Forum:
  


Current Time: Wed Mar 03 07:03:34 GMT 2021

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

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

Back to the top