Search in sources :

Example 1 with ConnectionCreationTool

use of org.eclipse.gef.tools.ConnectionCreationTool 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;
}
Also used : SapphireDiagramEditorPagePart(org.eclipse.sapphire.ui.diagram.editor.SapphireDiagramEditorPagePart) MouseEvent(org.eclipse.swt.events.MouseEvent) ConnectionCreationTool(org.eclipse.gef.tools.ConnectionCreationTool) SapphireDiagramEditor(org.eclipse.sapphire.ui.swt.gef.SapphireDiagramEditor) ConnectionPalette(org.eclipse.sapphire.ui.diagram.editor.SapphireDiagramEditorPagePart.ConnectionPalette) ConnectionCreationFactory(org.eclipse.sapphire.ui.swt.gef.ConnectionCreationFactory) CreationFactory(org.eclipse.gef.requests.CreationFactory) Event(org.eclipse.swt.widgets.Event) MouseEvent(org.eclipse.swt.events.MouseEvent) ConnectionCreationFactory(org.eclipse.sapphire.ui.swt.gef.ConnectionCreationFactory) ISapphirePart(org.eclipse.sapphire.ui.ISapphirePart) DiagramNodePart(org.eclipse.sapphire.ui.diagram.editor.DiagramNodePart) WorkflowDefinitionEditor(com.liferay.ide.kaleo.ui.editor.WorkflowDefinitionEditor)

Aggregations

WorkflowDefinitionEditor (com.liferay.ide.kaleo.ui.editor.WorkflowDefinitionEditor)1 CreationFactory (org.eclipse.gef.requests.CreationFactory)1 ConnectionCreationTool (org.eclipse.gef.tools.ConnectionCreationTool)1 ISapphirePart (org.eclipse.sapphire.ui.ISapphirePart)1 DiagramNodePart (org.eclipse.sapphire.ui.diagram.editor.DiagramNodePart)1 SapphireDiagramEditorPagePart (org.eclipse.sapphire.ui.diagram.editor.SapphireDiagramEditorPagePart)1 ConnectionPalette (org.eclipse.sapphire.ui.diagram.editor.SapphireDiagramEditorPagePart.ConnectionPalette)1 ConnectionCreationFactory (org.eclipse.sapphire.ui.swt.gef.ConnectionCreationFactory)1 SapphireDiagramEditor (org.eclipse.sapphire.ui.swt.gef.SapphireDiagramEditor)1 MouseEvent (org.eclipse.swt.events.MouseEvent)1 Event (org.eclipse.swt.widgets.Event)1