I would like to create an image of an Eclipse GEF diagram on the server side without having to load the entire editor environment.
The diagram is designed using eclipse bpmn2-modeler which is based on eclipse graphiti which is based on GEF.
The idea would be:
- load BPMN model
- generate diagram information
- export diagram as image
This snippet should do step 1, load the BPMN model:
URI modelUri = URI.createFileURI("D:/temp/data.bpmn");
ResourceSet resourceSet = new Bpmn2ModelerResourceSetImpl();
resourceSet.setURIConverter(new ProxyURIConverterImplExtension(modelUri));
Bpmn2ResourceImpl resource = (Bpmn2ResourceImpl) resourceSet.createResource(modelUri, Bpmn2ModelerResourceImpl.BPMN2_CONTENT_TYPE_ID);
ModelHandler modelHandler = ModelHandlerLocator.createModelHandler(modelUri, resource);
to generate the diagram information I found
org.eclipse.bpmn2.modeler.core.di.DIImport
.
The problem here is that the constructor requires aorg.eclipse.graphiti.ui.editor.DiagramEditor
and on the server I don't have one, no running UI environment.
Is there some other util or handler that can generate the diagram for me?I took a look at the
org.eclipse.graphiti.ui.features.DefaultSaveImageFeature
andorg.eclipse.graphiti.ui.internal.util.ui.print.AbstractFigureSelectionDialog (initScaledImage())
.
But I need to first get passed the step 2 issue, before digging deeper into this.
Maybe I'm on the wrong way and there is a much easier approach?