Search in sources :

Example 1 with SingleNodeContainer

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

the class NodeMonitorView method updateDataTable.

/*
     *  Put (static and simple) content of one output port table into table.
     */
private void updateDataTable(final NodeContainer nc, final int port) {
    assert Display.getCurrent().getThread() == Thread.currentThread();
    m_info.setText("Port Output");
    m_table.removeAll();
    for (TableColumn tc : m_table.getColumns()) {
        tc.dispose();
    }
    // check if we can display something at all:
    int index = port;
    if (nc instanceof SingleNodeContainer) {
        // we don't care about (hidden) variable OutPort
        index++;
    }
    if (nc.getNrOutPorts() <= index) {
        // no (real) port available
        TableItem item = new TableItem(m_table, SWT.NONE);
        item.setText(0, "No output ports");
        return;
    }
    NodeOutPort nop = nc.getOutPort(index);
    PortObject po = nop.getPortObject();
    if ((po == null) || !(po instanceof BufferedDataTable)) {
        // no table in port - ignore.
        TableItem item = new TableItem(m_table, SWT.NONE);
        item.setText(0, "Unknown or no PortObject");
        return;
    }
    // retrieve table
    BufferedDataTable bdt = (BufferedDataTable) po;
    TableColumn column = new TableColumn(m_table, SWT.NONE);
    column.setText("ID");
    for (int i = 0; i < bdt.getDataTableSpec().getNumColumns(); i++) {
        column = new TableColumn(m_table, SWT.NONE);
        column.setText(bdt.getDataTableSpec().getColumnSpec(i).getName());
    }
    int rowIndex = 0;
    Iterator<DataRow> rowIt = bdt.iteratorFailProve();
    while (rowIndex < 42 && rowIt.hasNext()) {
        DataRow thisRow = rowIt.next();
        TableItem item = new TableItem(m_table, SWT.NONE);
        item.setText(0, thisRow.getKey().getString());
        for (int i = 0; i < thisRow.getNumCells(); i++) {
            DataCell c = thisRow.getCell(i);
            String s = c.toString().replaceAll("\\p{Cntrl}", "_");
            item.setText(i + 1, s);
        }
        rowIndex++;
    }
    for (int i = 0; i < m_table.getColumnCount(); i++) {
        m_table.getColumn(i).pack();
    }
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) BufferedDataTable(org.knime.core.node.BufferedDataTable) NodeOutPort(org.knime.core.node.workflow.NodeOutPort) DataCell(org.knime.core.data.DataCell) TableColumn(org.eclipse.swt.widgets.TableColumn) PortObject(org.knime.core.node.port.PortObject) DataRow(org.knime.core.data.DataRow) SingleNodeContainer(org.knime.core.node.workflow.SingleNodeContainer)

Example 2 with SingleNodeContainer

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

the class NodeOutputView method updateVariableTable.

/*
     *  Put info about workflow variables into table.
     */
private void updateVariableTable(final NodeContainer nc) {
    assert Display.getCurrent().getThread() == Thread.currentThread();
    // display swt table
    ((StackLayout) m_stackPanel.getLayout()).topControl = m_table;
    m_stackPanel.layout();
    // 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(org.knime.core.node.workflow.FlowVariable.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) Point(org.eclipse.swt.graphics.Point) FlowVariable(org.knime.core.node.workflow.FlowVariable) SingleNodeContainer(org.knime.core.node.workflow.SingleNodeContainer)

Example 3 with SingleNodeContainer

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

the class NodeOutputView method updateDataTable.

/*
     *  Put (static and simple) content of one output port table into table.
     */
private void updateDataTable(final NodeContainer nc, final int port) {
    assert Display.getCurrent().getThread() == Thread.currentThread();
    // display data table
    ((StackLayout) m_stackPanel.getLayout()).topControl = m_tableViewPanel;
    m_stackPanel.layout();
    m_info.setText("Port Output");
    m_tableView.setDataTable(null);
    // check if we can display something at all:
    int index = port;
    if (nc instanceof SingleNodeContainer) {
        // we don't care about (hidden) variable OutPort
        index++;
    }
    if (nc.getNrOutPorts() <= index) {
        // no (real) port available
        m_errorLabel.setText("No output ports");
        ((StackLayout) m_stackPanel.getLayout()).topControl = m_errorLabel;
        m_stackPanel.layout();
        return;
    }
    NodeOutPort nop = nc.getOutPort(index);
    PortObject po = nop.getPortObject();
    if ((po == null) || !(po instanceof BufferedDataTable)) {
        // no table in port - ignore.
        m_errorLabel.setText("Unknown or no PortObject");
        ((StackLayout) m_stackPanel.getLayout()).topControl = m_errorLabel;
        m_stackPanel.layout();
        return;
    }
    // retrieve table
    m_tableView.setDataTable((DataTable) po);
    m_tableView.repaint();
}
Also used : BufferedDataTable(org.knime.core.node.BufferedDataTable) NodeOutPort(org.knime.core.node.workflow.NodeOutPort) PortObject(org.knime.core.node.port.PortObject) Point(org.eclipse.swt.graphics.Point) SingleNodeContainer(org.knime.core.node.workflow.SingleNodeContainer)

Example 4 with SingleNodeContainer

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

the class PauseLoopExecutionAction method internalCalculateEnabled.

/**
 * @return <code>true</code>, if just one loop end node part is selected
 *         which is executing.
 *
 * @see org.eclipse.gef.ui.actions.WorkbenchPartAction#calculateEnabled()
 */
@Override
protected boolean internalCalculateEnabled() {
    NodeContainerEditPart[] parts = getSelectedParts(NodeContainerEditPart.class);
    if (parts.length != 1) {
        return false;
    }
    // enabled if the one selected node is an executing LoopEndNode
    NodeContainerUI nc = parts[0].getNodeContainer();
    if (Wrapper.wraps(nc, SingleNodeContainer.class)) {
        SingleNodeContainer snc = Wrapper.unwrap(nc, SingleNodeContainer.class);
        if ((snc.isModelCompatibleTo(LoopEndNode.class)) && (nc.getNodeContainerState().isExecutionInProgress())) {
            return true;
        }
    }
    return false;
}
Also used : NodeContainerUI(org.knime.core.ui.node.workflow.NodeContainerUI) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) SingleNodeContainer(org.knime.core.node.workflow.SingleNodeContainer)

Example 5 with SingleNodeContainer

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

the class DropNodeCommand method execute.

/**
 * {@inheritDoc}
 */
@Override
public void execute() {
    // Add node to workflow and get the container
    WorkflowManager hostWFM = getHostWFM();
    try {
        NodeID id = hostWFM.addNodeAndApplyContext(m_factory, m_dropContext);
        m_container = hostWFM.getNodeContainer(id);
        // create extra info and set it
        NodeUIInformation info = NodeUIInformation.builder().setNodeLocation(m_location.x, m_location.y, -1, -1).setHasAbsoluteCoordinates(false).setSnapToGrid(m_snapToGrid).setIsDropLocation(true).build();
        m_container.setUIInformation(info);
        // Open the dialog. Some times.
        if (m_container instanceof SingleNodeContainer && m_container.getNodeContainerState().isIdle() && m_container.hasDialog() && // and has only a variable in port
        m_container.getNrInPorts() == 1) {
            // if not executable and has a dialog and is fully connected
            // This is embedded in a special JFace wrapper dialog
            // 
            Display.getDefault().asyncExec(new Runnable() {

                @Override
                public void run() {
                    try {
                        WrappedNodeDialog dlg = new WrappedNodeDialog(Display.getCurrent().getActiveShell(), m_container);
                        dlg.open();
                    } catch (Exception e) {
                    // they need to open it manually then
                    }
                }
            });
        }
    } catch (Throwable t) {
        // if fails notify the user
        LOGGER.debug("Node cannot be created.", t);
        MessageBox mb = new MessageBox(Display.getDefault().getActiveShell(), SWT.ICON_WARNING | SWT.OK);
        mb.setText("Node cannot be created.");
        mb.setMessage("The selected node could not be created " + "due to the following reason:\n" + t.getMessage());
        mb.open();
        return;
    }
}
Also used : NodeUIInformation(org.knime.core.node.workflow.NodeUIInformation) WorkflowManager(org.knime.core.node.workflow.WorkflowManager) NodeID(org.knime.core.node.workflow.NodeID) SingleNodeContainer(org.knime.core.node.workflow.SingleNodeContainer) WrappedNodeDialog(org.knime.workbench.ui.wrapper.WrappedNodeDialog) MessageBox(org.eclipse.swt.widgets.MessageBox)

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