Search in sources :

Example 6 with WorkflowAnnotation

use of org.knime.core.node.workflow.WorkflowAnnotation in project knime-core by knime.

the class AddAnnotationCommand method execute.

/**
 * {@inheritDoc}
 */
@Override
public void execute() {
    // adapt location to the viewport location and the zoom factor
    // this seems to be a workaround for a bug in the framework
    ZoomManager zoomManager = (ZoomManager) m_viewer.getProperty(ZoomManager.class.toString());
    // adjust the location according to the viewport position
    // seems to be a workaround for a bug in the framework
    // (should imediately deliver the correct view position and not
    // the position of the viewport)
    PrecisionPoint location = new PrecisionPoint(m_location.x, m_location.y);
    WorkflowEditor.adaptZoom(zoomManager, location, true);
    m_anno = new WorkflowAnnotation();
    AnnotationData data = new AnnotationData();
    // it is a workflow annotation
    data.setBgColor(INITIAL_FLOWANNO_COLOR);
    data.setDimension((int) location.preciseX, (int) location.preciseY, DEFAULT_WIDTH, DEFAULT_HEIGHT);
    data.setBorderSize(AnnotationEditPart.getAnnotationDefaultBorderSizePrefValue());
    data.setBorderColor(INITAL_FLOWBORDER_COLOR);
    data.setText(INITIAL_FLOWANNO_TEXT);
    data.setStyleRanges(new AnnotationData.StyleRange[0]);
    m_anno.copyFrom(data, true);
    WorkflowManager hostWFM = getHostWFM();
    hostWFM.addWorkflowAnnotation(m_anno);
    m_viewer.deselectAll();
    // select the new ones....
    if (m_viewer.getRootEditPart().getContents() != null && m_viewer.getRootEditPart().getContents() instanceof WorkflowRootEditPart) {
        ((WorkflowRootEditPart) m_viewer.getRootEditPart().getContents()).setFutureAnnotationSelection(Collections.singleton(m_anno));
    }
}
Also used : ZoomManager(org.eclipse.gef.editparts.ZoomManager) AnnotationData(org.knime.core.node.workflow.AnnotationData) WorkflowRootEditPart(org.knime.workbench.editor2.editparts.WorkflowRootEditPart) WorkflowManager(org.knime.core.node.workflow.WorkflowManager) PrecisionPoint(org.eclipse.draw2d.geometry.PrecisionPoint) WorkflowAnnotation(org.knime.core.node.workflow.WorkflowAnnotation)

Example 7 with WorkflowAnnotation

use of org.knime.core.node.workflow.WorkflowAnnotation in project knime-core by knime.

the class CreateMetaNodeCommand method undo.

/**
 * {@inheritDoc}
 */
@Override
public void undo() {
    NodeID[] ids = m_copyContent.getNodeIDs();
    if (LOGGER.isDebugEnabled()) {
        String debug = "Removing node";
        if (ids.length == 1) {
            debug = debug + " " + ids[0];
        } else {
            debug = debug + "s " + Arrays.asList(ids);
        }
        LOGGER.debug(debug);
    }
    WorkflowManager wm = getHostWFM();
    if (canUndo()) {
        for (NodeID id : ids) {
            wm.removeNode(id);
        }
        for (WorkflowAnnotation anno : m_copyContent.getAnnotations()) {
            wm.removeAnnotation(anno);
        }
    } else {
        MessageDialog.openInformation(Display.getDefault().getActiveShell(), "Operation no allowed", "The node(s) " + Arrays.asList(ids) + " can currently not be removed");
    }
}
Also used : WorkflowManager(org.knime.core.node.workflow.WorkflowManager) NodeID(org.knime.core.node.workflow.NodeID) WorkflowAnnotation(org.knime.core.node.workflow.WorkflowAnnotation)

Example 8 with WorkflowAnnotation

use of org.knime.core.node.workflow.WorkflowAnnotation in project knime-core by knime.

the class ExpandSubNodeCommand method execute.

/**
 * {@inheritDoc}
 */
@Override
public void execute() {
    try {
        WorkflowManager hostWFM = getHostWFM();
        // close editor of subnode and children
        NodeID wfmID = ((SubNodeContainer) hostWFM.getNodeContainer(m_id)).getWorkflowManager().getID();
        for (IEditorPart child : m_editor.getSubEditors(m_id)) {
            child.getEditorSite().getPage().closeEditor(child, false);
        }
        m_expandResult = hostWFM.expandSubWorkflow(m_id);
        WorkflowAnnotation[] annotations = m_expandResult.getExpandedCopyContent().getAnnotations();
        NodeID[] nodeIDs = m_expandResult.getExpandedCopyContent().getNodeIDs();
        EditPartViewer partViewer = m_editor.getViewer();
        partViewer.deselectAll();
        // select the new ones....
        if (partViewer.getRootEditPart().getContents() != null && partViewer.getRootEditPart().getContents() instanceof WorkflowRootEditPart) {
            WorkflowRootEditPart rootEditPart = (WorkflowRootEditPart) partViewer.getRootEditPart().getContents();
            rootEditPart.setFutureSelection(nodeIDs);
            rootEditPart.setFutureAnnotationSelection(Arrays.asList(annotations));
        }
    } catch (Exception e) {
        String error = "Expanding Wrapped Metanode failed: " + e.getMessage();
        LOGGER.error(error, e);
        MessageDialog.openError(Display.getCurrent().getActiveShell(), "Expand failed", error);
    }
}
Also used : WorkflowRootEditPart(org.knime.workbench.editor2.editparts.WorkflowRootEditPart) WorkflowManager(org.knime.core.node.workflow.WorkflowManager) NodeID(org.knime.core.node.workflow.NodeID) EditPartViewer(org.eclipse.gef.EditPartViewer) IEditorPart(org.eclipse.ui.IEditorPart) WorkflowAnnotation(org.knime.core.node.workflow.WorkflowAnnotation)

Example 9 with WorkflowAnnotation

use of org.knime.core.node.workflow.WorkflowAnnotation in project knime-core by knime.

the class DeleteCommand method execute.

/**
 * {@inheritDoc}
 */
@Override
public void execute() {
    WorkflowManager hostWFM = getHostWFM();
    // removed.
    if (m_nodeIDs.length > 0 || m_annotations.length > 0) {
        WorkflowCopyContent.Builder content = WorkflowCopyContent.builder();
        content.setNodeIDs(m_nodeIDs);
        content.setAnnotation(m_annotations);
        m_undoPersitor = hostWFM.copy(true, content.build());
    }
    for (WorkflowAnnotation anno : m_annotations) {
        hostWFM.removeAnnotation(anno);
    }
    for (NodeID id : m_nodeIDs) {
        hostWFM.removeNode(id);
    }
    for (ConnectionContainer cc : m_connections) {
        hostWFM.removeConnection(cc);
    }
}
Also used : WorkflowCopyContent(org.knime.core.node.workflow.WorkflowCopyContent) ConnectionContainer(org.knime.core.node.workflow.ConnectionContainer) WorkflowManager(org.knime.core.node.workflow.WorkflowManager) NodeID(org.knime.core.node.workflow.NodeID) WorkflowAnnotation(org.knime.core.node.workflow.WorkflowAnnotation)

Example 10 with WorkflowAnnotation

use of org.knime.core.node.workflow.WorkflowAnnotation in project knime-core by knime.

the class AnnotationEditPart method createFigure.

/**
 * {@inheritDoc}
 */
@Override
protected IFigure createFigure() {
    Annotation anno = getModel();
    NodeAnnotationFigure f = new WorkflowAnnotationFigure(anno);
    if (anno instanceof WorkflowAnnotation) {
        f.setBounds(new Rectangle(anno.getX(), anno.getY(), anno.getWidth(), anno.getHeight()));
    }
    return f;
}
Also used : WorkflowAnnotationFigure(org.knime.workbench.editor2.figures.WorkflowAnnotationFigure) Rectangle(org.eclipse.draw2d.geometry.Rectangle) NodeAnnotationFigure(org.knime.workbench.editor2.figures.NodeAnnotationFigure) WorkflowAnnotation(org.knime.core.node.workflow.WorkflowAnnotation) NodeAnnotation(org.knime.core.node.workflow.NodeAnnotation) Annotation(org.knime.core.node.workflow.Annotation) WorkflowAnnotation(org.knime.core.node.workflow.WorkflowAnnotation)

Aggregations

WorkflowAnnotation (org.knime.core.node.workflow.WorkflowAnnotation)11 NodeID (org.knime.core.node.workflow.NodeID)8 WorkflowManager (org.knime.core.node.workflow.WorkflowManager)7 WorkflowRootEditPart (org.knime.workbench.editor2.editparts.WorkflowRootEditPart)3 ArrayList (java.util.ArrayList)2 EditPartViewer (org.eclipse.gef.EditPartViewer)2 ConnectionContainer (org.knime.core.node.workflow.ConnectionContainer)2 ConnectionUIInformation (org.knime.core.node.workflow.ConnectionUIInformation)2 NodeAnnotation (org.knime.core.node.workflow.NodeAnnotation)2 NodeUIInformation (org.knime.core.node.workflow.NodeUIInformation)2 WorkflowCopyContent (org.knime.core.node.workflow.WorkflowCopyContent)2 WorkflowPersistor (org.knime.core.node.workflow.WorkflowPersistor)2 HashSet (java.util.HashSet)1 PrecisionPoint (org.eclipse.draw2d.geometry.PrecisionPoint)1 Rectangle (org.eclipse.draw2d.geometry.Rectangle)1 ZoomManager (org.eclipse.gef.editparts.ZoomManager)1 InputDialog (org.eclipse.jface.dialogs.InputDialog)1 MessageBox (org.eclipse.swt.widgets.MessageBox)1 IEditorPart (org.eclipse.ui.IEditorPart)1 Annotation (org.knime.core.node.workflow.Annotation)1