updateDirtyState();
}
private void marshallImage(Bpmn2MemoryModel model, String modelFileName) {
try {
final GraphicalViewer graphicalViewer = (GraphicalViewer) ((DiagramEditor) model.getFeatureProvider()
.getDiagramTypeProvider().getDiagramEditor()).getAdapter(GraphicalViewer.class);
if (graphicalViewer == null || graphicalViewer.getEditPartRegistry() == null) {
return;
}
final ScalableFreeformRootEditPart rootEditPart = (ScalableFreeformRootEditPart) graphicalViewer.getEditPartRegistry().get(LayerManager.ID);
final IFigure rootFigure = ((LayerManager) rootEditPart).getLayer(LayerConstants.PRINTABLE_LAYERS);
final IFigure gridFigure = ((LayerManager) rootEditPart).getLayer(LayerConstants.GRID_LAYER);
final Rectangle rootFigureBounds = rootFigure.getBounds();
final boolean toggleRequired = gridFigure.isShowing();
final Display display = Display.getDefault();
final Image img = new Image(display, rootFigureBounds.width, rootFigureBounds.height);
final GC imageGC = new GC(img);
final SWTGraphics grap = new SWTGraphics(imageGC);
// Access UI thread from runnable to print the canvas to the image
display.syncExec(new Runnable() {
@Override
public void run() {
if (toggleRequired) {
// Disable any grids temporarily
gridFigure.setVisible(false);
}
// Deselect any selections
graphicalViewer.deselectAll();
rootFigure.paint(grap);
}
});
ImageLoader imgLoader = new ImageLoader();