Search in sources :

Example 6 with SingleNodeContainer

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

the class NodeOutputView method updateNodeContainerInfo.

/* Update all visuals with information regarding new NodeContainer.
     * Also de-register previous node and register with the new one if
     * the underlying NC changed.
     */
private void updateNodeContainerInfo(final NodeID nc) {
    if (m_portIndex.getCombo().isDisposed()) {
        return;
    }
    if (nc == null) {
        showErrorAndClear("");
        return;
    }
    m_portIndex.getCombo().setEnabled(false);
    assert Display.getCurrent().getThread() == Thread.currentThread();
    if ((m_lastNode != null) && (m_lastNode != nc)) {
        if (m_workflow.containsNodeContainer(m_lastNode)) {
            NodeContainer last = m_workflow.getNodeContainer(m_lastNode);
            last.removeNodeStateChangeListener(NodeOutputView.this);
        }
    }
    NodeContainer node = m_workflow.getNodeContainer(nc);
    if ((m_lastNode == null) || (m_lastNode != nc)) {
        m_lastNode = nc;
        node.addNodeStateChangeListener(NodeOutputView.this);
        setPartName(node.getNameWithID());
    }
    m_title.setText(node.getName() + "  (" + node.getID() + ")");
    switch(m_choice) {
        case VARS:
            updateVariableTable(node);
            break;
        case SETTINGS:
        case ALLSETTINGS:
            updateSettingsTable(node, DISPLAYOPTIONS.ALLSETTINGS.equals(m_choice));
            break;
        case TABLE:
            m_portIndex.getCombo().setEnabled(true);
            int nrPorts = node.getNrOutPorts();
            if (node instanceof SingleNodeContainer) {
                // correct for (default - mostly invisible) Variable Port
                nrPorts--;
            }
            String[] vals = new String[nrPorts];
            for (int i = 0; i < nrPorts; i++) {
                vals[i] = "Port " + i;
            }
            m_portIndex.getCombo().removeAll();
            m_portIndex.getCombo().setItems(vals);
            m_portIndex.getCombo().select(0);
            updateDataTable(node, 0);
            break;
        case GRAPHANNOTATIONS:
            updateGraphAnnotationTable(node);
            break;
        default:
            throw new AssertionError("Unhandled switch case: " + m_choice);
    }
}
Also used : NodeContainer(org.knime.core.node.workflow.NodeContainer) NativeNodeContainer(org.knime.core.node.workflow.NativeNodeContainer) SingleNodeContainer(org.knime.core.node.workflow.SingleNodeContainer) Point(org.eclipse.swt.graphics.Point) SingleNodeContainer(org.knime.core.node.workflow.SingleNodeContainer)

Example 7 with SingleNodeContainer

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

the class NodeMonitorView method updateVariableTable.

/*
     *  Put info about workflow variables into table.
     */
private void updateVariableTable(final NodeContainer nc) {
    assert Display.getCurrent().getThread() == Thread.currentThread();
    // Initialize table
    m_table.removeAll();
    for (TableColumn tc : m_table.getColumns()) {
        tc.dispose();
    }
    String[] titles = { "Variable", "Value" };
    for (int i = 0; i < titles.length; i++) {
        TableColumn column = new TableColumn(m_table, SWT.NONE);
        column.setText(titles[i]);
    }
    // retrieve variables
    Collection<FlowVariable> fvs;
    if ((nc instanceof SingleNodeContainer) || nc.getNrOutPorts() > 0) {
        // for normal nodes port 0 is available (hidden variable OutPort!)
        FlowObjectStack fos = nc.getOutPort(0).getFlowObjectStack();
        if (fos != null) {
            fvs = fos.getAvailableFlowVariables(Type.values()).values();
        } else {
            fvs = null;
        }
        m_info.setText("Node Variables");
    } else {
        // no output port on metanode - display workflow variables
        fvs = ((WorkflowManager) nc).getWorkflowVariables();
        m_info.setText("Metanode Variables");
    }
    if (fvs != null) {
        // update content
        for (FlowVariable fv : fvs) {
            TableItem item = new TableItem(m_table, SWT.NONE);
            item.setText(0, fv.getName());
            item.setText(1, fv.getValueAsString());
        }
    }
    for (int i = 0; i < m_table.getColumnCount(); i++) {
        m_table.getColumn(i).pack();
    }
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) FlowObjectStack(org.knime.core.node.workflow.FlowObjectStack) TableColumn(org.eclipse.swt.widgets.TableColumn) FlowVariable(org.knime.core.node.workflow.FlowVariable) SingleNodeContainer(org.knime.core.node.workflow.SingleNodeContainer)

Example 8 with SingleNodeContainer

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

the class WrappedNodeDialog method runOK.

private void runOK(final boolean execute, final boolean openView) {
    // send close action to underlying dialog pane
    NodeContext.pushContext(m_nodeContainer);
    try {
        m_dialogPane.callOnClose();
        buttonPressed(IDialogConstants.OK_ID);
        if (execute) {
            m_nodeContainer.getParent().executeUpToHere(m_nodeContainer.getID());
        }
        if (openView) {
            final Rectangle knimeWindowBounds = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().getBounds();
            ViewUtils.invokeLaterInEDT(new Runnable() {

                /**
                 * {inheritDoc}
                 */
                @Override
                public void run() {
                    // show out-port view for nodes with at least
                    // one out-port (whereby the first is used as flow
                    // variable port for SingleNodeContainer), otherwise
                    // handle meta node (without flow variable port)
                    final int pIndex;
                    if (m_nodeContainer instanceof SingleNodeContainer) {
                        pIndex = 1;
                    } else {
                        pIndex = 0;
                    }
                    if (m_nodeContainer.getNrOutPorts() > pIndex) {
                        NodeOutPort port = m_nodeContainer.getOutPort(pIndex);
                        java.awt.Rectangle bounds = new java.awt.Rectangle(knimeWindowBounds.x, knimeWindowBounds.y, knimeWindowBounds.width, knimeWindowBounds.height);
                        port.openPortView(port.getPortName(), bounds);
                    }
                }
            });
        }
    } finally {
        NodeContext.removeLastContext();
    }
}
Also used : Rectangle(org.eclipse.swt.graphics.Rectangle) NodeOutPort(org.knime.core.node.workflow.NodeOutPort) SingleNodeContainer(org.knime.core.node.workflow.SingleNodeContainer)

Example 9 with SingleNodeContainer

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

the class WorkflowMoveDragListener method isNode.

/*
     * Nodes are either SingleNodeContainers (in case the flow is opened in
     * an editor) or IFolders.
     */
private boolean isNode(final Object source) {
    if (source instanceof IFolder) {
        IFolder dir = (IFolder) source;
        IContainer p = dir.getParent();
        if (p == null) {
            return false;
        }
        return p.exists(new Path(WorkflowPersistor.WORKFLOW_FILE));
    }
    return (source instanceof SingleNodeContainer);
}
Also used : Path(org.eclipse.core.runtime.Path) IContainer(org.eclipse.core.resources.IContainer) IFolder(org.eclipse.core.resources.IFolder) SingleNodeContainer(org.knime.core.node.workflow.SingleNodeContainer)

Aggregations

SingleNodeContainer (org.knime.core.node.workflow.SingleNodeContainer)9 Point (org.eclipse.swt.graphics.Point)3 TableColumn (org.eclipse.swt.widgets.TableColumn)3 TableItem (org.eclipse.swt.widgets.TableItem)3 NodeOutPort (org.knime.core.node.workflow.NodeOutPort)3 BufferedDataTable (org.knime.core.node.BufferedDataTable)2 PortObject (org.knime.core.node.port.PortObject)2 FlowObjectStack (org.knime.core.node.workflow.FlowObjectStack)2 FlowVariable (org.knime.core.node.workflow.FlowVariable)2 IContainer (org.eclipse.core.resources.IContainer)1 IFolder (org.eclipse.core.resources.IFolder)1 Path (org.eclipse.core.runtime.Path)1 Rectangle (org.eclipse.swt.graphics.Rectangle)1 MessageBox (org.eclipse.swt.widgets.MessageBox)1 DataCell (org.knime.core.data.DataCell)1 DataRow (org.knime.core.data.DataRow)1 NativeNodeContainer (org.knime.core.node.workflow.NativeNodeContainer)1 NodeContainer (org.knime.core.node.workflow.NodeContainer)1 NodeID (org.knime.core.node.workflow.NodeID)1 NodeUIInformation (org.knime.core.node.workflow.NodeUIInformation)1