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