Search in sources :

Example 6 with WorkflowRootEditPart

use of org.knime.workbench.editor2.editparts.WorkflowRootEditPart in project knime-core by knime.

the class WorkflowEditor method createGraphicalViewer.

/**
 * Creates the graphical viewer that is hosted in this editor and hooks
 * keyhandler and edit domain.
 *
 * @see org.eclipse.gef.ui.parts.GraphicalEditor
 *      #createGraphicalViewer(org.eclipse.swt.widgets.Composite)
 * @param parent The parent
 */
@Override
protected void createGraphicalViewer(final Composite parent) {
    IEditorSite editorSite = getEditorSite();
    GraphicalViewer viewer = new WorkflowGraphicalViewerCreator(editorSite, this.getActionRegistry()).createViewer(parent);
    // Add a listener to the static node provider
    NodeProvider.INSTANCE.addListener(this);
    // Configure the key handler
    GraphicalViewerKeyHandler keyHandler = new GraphicalViewerKeyHandler(viewer);
    KeyHandler parentKeyHandler = keyHandler.setParent(getCommonKeyHandler());
    viewer.setKeyHandler(parentKeyHandler);
    // hook the viewer into the EditDomain
    getEditDomain().addViewer(viewer);
    // activate the viewer as selection provider for Eclipse
    getSite().setSelectionProvider(viewer);
    // remember this viewer
    m_graphicalViewer = viewer;
    // load properties like grid- or node-connections settings (e.g. width, curved)
    // needs to be called before getGraphicalViewer().setContents(m_manager), since
    // the node connections are repainted on that setContents-call and the properties need
    // to be set by then
    loadProperties();
    // We already have the model - set it into the viewer
    getGraphicalViewer().setContents(m_manager);
    // add Help context
    WorkbenchHelpSystem.getInstance().setHelp(m_graphicalViewer.getControl(), "org.knime.workbench.help.flow_editor_context");
    updateEditorBackgroundColor();
    updateJobManagerDisplay();
    updateTempRemoteWorkflowMessage();
    RootEditPart rep = getGraphicalViewer().getRootEditPart();
    ((WorkflowRootEditPart) rep.getChildren().get(0)).createToolTipHelper(getSite().getShell());
    ZoomManager zm = this.getZoomManager();
    zm.setZoomLevels(ZOOM_LEVELS);
    m_zoomWheelListener = new ZoomWheelListener(zm, (FigureCanvas) getViewer().getControl());
}
Also used : FigureCanvas(org.eclipse.draw2d.FigureCanvas) GraphicalViewer(org.eclipse.gef.GraphicalViewer) WorkflowRootEditPart(org.knime.workbench.editor2.editparts.WorkflowRootEditPart) ZoomManager(org.eclipse.gef.editparts.ZoomManager) GraphicalViewerKeyHandler(org.eclipse.gef.ui.parts.GraphicalViewerKeyHandler) KeyHandler(org.eclipse.gef.KeyHandler) GraphicalViewerKeyHandler(org.eclipse.gef.ui.parts.GraphicalViewerKeyHandler) IEditorSite(org.eclipse.ui.IEditorSite) WorkflowRootEditPart(org.knime.workbench.editor2.editparts.WorkflowRootEditPart) RootEditPart(org.eclipse.gef.RootEditPart) ScalableFreeformRootEditPart(org.eclipse.gef.editparts.ScalableFreeformRootEditPart)

Example 7 with WorkflowRootEditPart

use of org.knime.workbench.editor2.editparts.WorkflowRootEditPart in project knime-core by knime.

the class WorkflowEditor method updateJobManagerDisplay.

private void updateJobManagerDisplay() {
    NodeExecutionJobManager jobManager = m_manager.findJobManager();
    URL url;
    if (jobManager instanceof AbstractNodeExecutionJobManager) {
        url = ((AbstractNodeExecutionJobManager) jobManager).getIconForWorkflow();
    } else {
        url = null;
    }
    Image image;
    if (url != null) {
        image = ImageRepository.getUnscaledImage(url);
    } else {
        image = null;
    }
    WorkflowFigure workflowFigure = ((WorkflowRootEditPart) getViewer().getRootEditPart().getContents()).getFigure();
    workflowFigure.setJobManagerFigure(image);
}
Also used : WorkflowFigure(org.knime.workbench.editor2.figures.WorkflowFigure) WorkflowRootEditPart(org.knime.workbench.editor2.editparts.WorkflowRootEditPart) AbstractNodeExecutionJobManager(org.knime.core.node.workflow.AbstractNodeExecutionJobManager) Image(org.eclipse.swt.graphics.Image) URL(java.net.URL) AbstractNodeExecutionJobManager(org.knime.core.node.workflow.AbstractNodeExecutionJobManager) NodeExecutionJobManager(org.knime.core.node.workflow.NodeExecutionJobManager)

Example 8 with WorkflowRootEditPart

use of org.knime.workbench.editor2.editparts.WorkflowRootEditPart in project knime-core by knime.

the class WorkflowEditor method updateTempRemoteWorkflowMessage.

/**
 * Places the message at the top of the editor - above all other contents.
 */
private void updateTempRemoteWorkflowMessage() {
    WorkflowFigure workflowFigure = ((WorkflowRootEditPart) getViewer().getRootEditPart().getContents()).getFigure();
    if (isTempRemoteWorkflowEditor()) {
        URI origRemoteLocation = m_origRemoteLocation;
        WorkflowEditor parentEditor = m_parentEditor;
        while (origRemoteLocation == null && parentEditor != null) {
            origRemoteLocation = parentEditor.m_origRemoteLocation;
            parentEditor = parentEditor.m_parentEditor;
        }
        workflowFigure.setMessage("  This is a temporary copy of \"" + URIUtil.toDecodedString(origRemoteLocation) + "\".\n  Use \"Save\" to upload it back to its original location on the server or \"Save As...\" to " + "store it in a different location.");
    } else if (!getWorkflowManager().isPresent()) {
        workflowFigure.setMessage("This is a remotely opened job workflow. It can neither be stored locally nor edited." + " It also just represents a static snapshot of the job workflow and won't get" + " updated automatically (use context menu to refresh).");
    } else {
        workflowFigure.setMessage(null);
    }
    List<IEditorPart> subEditors = getSubEditors();
    for (IEditorPart ep : subEditors) {
        if (ep instanceof WorkflowEditor) {
            ((WorkflowEditor) ep).updateTempRemoteWorkflowMessage();
        }
    }
}
Also used : WorkflowFigure(org.knime.workbench.editor2.figures.WorkflowFigure) WorkflowRootEditPart(org.knime.workbench.editor2.editparts.WorkflowRootEditPart) IEditorPart(org.eclipse.ui.IEditorPart) URI(java.net.URI)

Example 9 with WorkflowRootEditPart

use of org.knime.workbench.editor2.editparts.WorkflowRootEditPart in project knime-core by knime.

the class WorkflowEditorDropTargetListener method dragOver.

/**
 * {@inheritDoc}
 *
 * Marks nodes or edges if a new node should replace an old node or should be inserted on an edge.
 */
@Override
public void dragOver(final DropTargetEvent event) {
    WorkflowManagerUI wfm = ((WorkflowRootEditPart) getViewer().getRootEditPart().getContents()).getWorkflowManager();
    m_node = null;
    m_edge = null;
    m_nodeCount = 0;
    m_edgeCount = 0;
    // edge-/nodedist
    double edgedist = Integer.MAX_VALUE;
    double nodedist = Integer.MAX_VALUE;
    Point dropLocation = getDropLocation(event);
    EditPart ep = getViewer().findObjectAt(dropLocation.getTranslated(0, 0));
    if (ep instanceof NodeContainerEditPart) {
        double temp = dropLocation.getDistance(dropLocation.getTranslated(0, 0));
        // choose nearest node to mouse position
        if (nodedist >= temp) {
            m_node = (NodeContainerEditPart) ep;
            nodedist = temp;
        }
        m_nodeCount++;
    } else if (ep instanceof ConnectionContainerEditPart) {
        double temp = dropLocation.getDistance(dropLocation.getTranslated(0, 0));
        // choose nearest edge to mouse-position
        if (edgedist >= temp) {
            m_edge = (ConnectionContainerEditPart) ep;
            edgedist = temp;
        }
        m_edgeCount++;
    }
    unmark(wfm);
    if (m_node != null && m_nodeCount >= m_edgeCount) {
        m_markedNode = m_node;
        m_markedNode.mark();
        // workaround for eclipse bug 393868 (https://bugs.eclipse.org/bugs/show_bug.cgi?id=393868)
        WindowsDNDHelper.hideDragImage();
    } else if (m_edge != null) {
        m_edgeColor = m_edge.getFigure().getForegroundColor();
        m_edgeWidth = ((ProgressPolylineConnection) m_edge.getFigure()).getLineWidth();
        m_markedEdge = m_edge;
        ((ProgressPolylineConnection) m_markedEdge.getFigure()).setLineWidth(m_edgeWidth + 3);
        m_markedEdge.getFigure().setForegroundColor(RED);
        // workaround for eclipse bug 393868 (https://bugs.eclipse.org/bugs/show_bug.cgi?id=393868)
        WindowsDNDHelper.hideDragImage();
    }
}
Also used : NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) ConnectionContainerEditPart(org.knime.workbench.editor2.editparts.ConnectionContainerEditPart) WorkflowRootEditPart(org.knime.workbench.editor2.editparts.WorkflowRootEditPart) WorkflowRootEditPart(org.knime.workbench.editor2.editparts.WorkflowRootEditPart) WorkflowInPortBarEditPart(org.knime.workbench.editor2.editparts.WorkflowInPortBarEditPart) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) ConnectionContainerEditPart(org.knime.workbench.editor2.editparts.ConnectionContainerEditPart) EditPart(org.eclipse.gef.EditPart) WorkflowOutPortBarEditPart(org.knime.workbench.editor2.editparts.WorkflowOutPortBarEditPart) WorkflowManagerUI(org.knime.core.ui.node.workflow.WorkflowManagerUI) ProgressPolylineConnection(org.knime.workbench.editor2.figures.ProgressPolylineConnection) Point(org.eclipse.draw2d.geometry.Point)

Example 10 with WorkflowRootEditPart

use of org.knime.workbench.editor2.editparts.WorkflowRootEditPart in project knime-core by knime.

the class AnnotationEditPart method performEdit.

/**
 * Opens the editor to directoy edit the annotation in place.
 */
public void performEdit() {
    final EditPart parent = getParent();
    if (parent instanceof WorkflowRootEditPart) {
        WorkflowRootEditPart wkfRootEdit = (WorkflowRootEditPart) parent;
        if (wkfRootEdit.getWorkflowManager().isWriteProtected()) {
            return;
        }
    }
    if (m_directEditManager == null) {
        m_directEditManager = new AnnotationEditManager(this, new StyledTextEditorLocator((NodeAnnotationFigure) getFigure()));
    }
    m_directEditManager.show();
}
Also used : EditPart(org.eclipse.gef.EditPart) AnnotationEditManager(org.knime.workbench.editor2.directannotationedit.AnnotationEditManager) StyledTextEditorLocator(org.knime.workbench.editor2.directannotationedit.StyledTextEditorLocator)

Aggregations

WorkflowRootEditPart (org.knime.workbench.editor2.editparts.WorkflowRootEditPart)18 WorkflowManager (org.knime.core.node.workflow.WorkflowManager)7 NodeContainerEditPart (org.knime.workbench.editor2.editparts.NodeContainerEditPart)6 NodeContainerFigure (org.knime.workbench.editor2.figures.NodeContainerFigure)5 Point (org.eclipse.draw2d.geometry.Point)4 EditPart (org.eclipse.gef.EditPart)4 WorkflowAnnotation (org.knime.core.node.workflow.WorkflowAnnotation)4 Rectangle (org.eclipse.draw2d.geometry.Rectangle)3 EditPartViewer (org.eclipse.gef.EditPartViewer)3 IEditorPart (org.eclipse.ui.IEditorPart)3 NodeAnnotation (org.knime.core.node.workflow.NodeAnnotation)3 WorkflowManagerUI (org.knime.core.ui.node.workflow.WorkflowManagerUI)3 NodeAnnotationEditPart (org.knime.workbench.editor2.editparts.NodeAnnotationEditPart)3 IFigure (org.eclipse.draw2d.IFigure)2 PrecisionPoint (org.eclipse.draw2d.geometry.PrecisionPoint)2 ZoomManager (org.eclipse.gef.editparts.ZoomManager)2 ScrollingGraphicalViewer (org.eclipse.gef.ui.parts.ScrollingGraphicalViewer)2 ConnectionContainer (org.knime.core.node.workflow.ConnectionContainer)2 NodeContainer (org.knime.core.node.workflow.NodeContainer)2 NodeUIInformation (org.knime.core.node.workflow.NodeUIInformation)2