use of org.eclipse.sapphire.ui.swt.gef.SapphireDiagramEditor in project liferay-ide by liferay.
the class WorkflowDefinitionEditor method createDiagramPages.
@Override
protected void createDiagramPages() throws PartInitException {
_diagramEditor = new SapphireDiagramEditor(this, getModelElement(), DefinitionLoader.sdef(WorkflowDefinitionEditor.class).page("DiagramPage"));
addEditorPage(0, _diagramEditor);
}
use of org.eclipse.sapphire.ui.swt.gef.SapphireDiagramEditor in project liferay-ide by liferay.
the class StartTransitionActionHandler method run.
@Override
protected Object run(Presentation context) {
WorkflowDefinitionEditor editor = context.part().adapt(WorkflowDefinitionEditor.class);
SapphireDiagramEditor diagramEditor = editor.getDiagramEditor();
ISapphirePart part = context.part();
DiagramNodePart diagramPart = part.nearest(DiagramNodePart.class);
SapphireDiagramEditorPagePart editorPart = part.nearest(SapphireDiagramEditorPagePart.class);
ConnectionPalette connectionPalette = editorPart.getConnectionPalettes().get(0);
CreationFactory factory = new ConnectionCreationFactory(connectionPalette.getConnectionDef());
ConnectionCreationTool tool = new ConnectionCreationTool(factory);
diagramEditor.getEditDomain().setActiveTool(tool);
Event e = new Event();
e.x = diagramPart.getNodeBounds().getX();
e.y = diagramPart.getNodeBounds().getY();
e.widget = diagramEditor.getGraphicalViewer().getControl();
e.button = 1;
MouseEvent me = new MouseEvent(e);
tool.mouseDown(me, diagramEditor.getGraphicalViewer());
return null;
}
use of org.eclipse.sapphire.ui.swt.gef.SapphireDiagramEditor in project liferay-ide by liferay.
the class ShowDiagramPartActionHandler method run.
@Override
protected Object run(Presentation context) {
SapphireDiagramEditorPagePart diagramPart = context.part().nearest(SapphireDiagramEditorPagePart.class);
if (diagramPart != null) {
LabelProvider labelProvider = new LabelProvider() {
@Override
public Image getImage(Object element) {
if (element instanceof DiagramNodePart) {
DiagramNodePart diagramNodePart = (DiagramNodePart) element;
Element modelElement = diagramNodePart.getLocalModelElement();
return diagramPart.getSwtResourceCache().image(modelElement.type().image());
} else if (element instanceof DiagramConnectionPart) {
return diagramPart.getSwtResourceCache().image(Transition.TYPE.image());
} else {
return diagramPart.getSwtResourceCache().image(WorkflowNode.TYPE.image());
}
}
@Override
public String getText(Object element) {
if (element instanceof DiagramNodePart) {
return ((DiagramNodePart) element).getId();
} else if (element instanceof DiagramConnectionPart) {
return ((DiagramConnectionPart) element).getLabel();
} else {
if (element != null) {
return element.toString();
}
return "";
}
}
};
ElementListSelectionDialog dialog = new ElementListSelectionDialog(((SwtPresentation) context).shell(), labelProvider);
List<SapphirePart> parts = new ArrayList<>();
parts.addAll(diagramPart.getNodes());
parts.addAll(diagramPart.getConnections());
dialog.setElements(parts.toArray());
dialog.setMultipleSelection(false);
dialog.setHelpAvailable(false);
dialog.setTitle("Find Part");
dialog.setMessage("Select part:");
dialog.open();
Object[] result = dialog.getResult();
if ((result != null) && (result.length == 1)) {
// select node in diagram
ISapphirePart part = (ISapphirePart) result[0];
if (part instanceof DiagramConnectionPart || part instanceof DiagramNodePart) {
/*
* diagramPart.setSelections( ReadOnlyListFactory.create(
* part ) );
*/
SapphireDiagramEditor diagramEditor = diagramPart.adapt(SapphireDiagramEditor.class);
GraphicalViewer viewer = diagramEditor.getGraphicalViewer();
GraphicalEditPart editpart = diagramEditor.getGraphicalEditPart(part);
if (editpart != null) {
// Force a layout first.
viewer.flush();
viewer.select(editpart);
viewer.reveal(editpart);
}
}
}
}
return null;
}
Aggregations