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);
}
}
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();
}
}
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();
}
}
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);
}
Aggregations