Create a diagram programmatically from another Spray project

7 views
Skip to first unread message

Simone Di Cola

unread,
Oct 6, 2014, 1:32:19 PM10/6/14
to spray...@googlegroups.com
Hi all,
 Can you please tell me how can I create a new diagram (this means a new file etc..) from inside another Spray project?

I've searched but I could not find a complete example. 

Thanks 
Simone

Simone Di Cola

unread,
Oct 6, 2014, 3:23:41 PM10/6/14
to spray...@googlegroups.com
I've created this method following the CreateWizardExample (it works :) )

private void openComponent(final String componentID) {
try {
final IProject project = EclipseIDEUtils.getCurrentProject();
final IFolder diagramFolder = (componentID.equalsIgnoreCase("AtomicDesign")) ? project.getFolder("components/atomic") : project.getFolder("components/composite");
String editorExtension = "diagram"; //$NON-NLS-1$
String editorID = DiagramEditor.DIAGRAM_EDITOR_ID;
String diagramName = "compTEST";
// Create the diagram
Diagram diagram = Graphiti.getPeCreateService().createDiagram(componentID, diagramName, true);
// Create the file
IFile diagramFile = diagramFolder.getFile(diagramName + "." + editorExtension); //$NON-NLS-1$
URI uri = URI.createPlatformResourceURI(diagramFile.getFullPath().toString(), true);
FileService.createEmfFileForDiagram(uri, diagram);
String providerId = GraphitiUi.getExtensionManager().getDiagramTypeProviderId(diagram.getDiagramTypeId());
DiagramEditorInput editorInput = new DiagramEditorInput(EcoreUtil.getURI(diagram), providerId);
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(editorInput, editorID);
} catch (PartInitException e) {
LOGGER.error("Error in opening the editor", e);
Reply all
Reply to author
Forward
0 new messages