use of org.knime.core.node.property.hilite.HiLiteHandler in project knime-core by knime.
the class BinModelNodeView method modelChanged.
/**
* {@inheritDoc}
*/
@Override
protected void modelChanged() {
CAIMDiscretizationNodeModel model = getNodeModel();
if (model == null) {
return;
}
HiLiteHandler hiliteHandler = model.getInHiLiteHandler(0);
for (AbstractPlotter plotter : m_plotters) {
plotter.reset();
plotter.setHiLiteHandler(hiliteHandler);
((BinModelPlotter) plotter).setDiscretizationModel((model).getDiscretizationModel());
plotter.updatePaintModel();
plotter.getDrawingPane().repaint();
}
}
use of org.knime.core.node.property.hilite.HiLiteHandler in project knime-core by knime.
the class InteractiveHiLiteCollectorNodeModel method appendAnnotation.
/**
* Appends new annotation.
* @param anno the annotation to append to the current hilit keys
* @param newColumn true, a new column is created at the end of the table
* holding the current annotation
*/
final void appendAnnotation(final String anno, final boolean newColumn) {
HiLiteHandler hdl = getInHiLiteHandler(0);
if (hdl == null || hdl.getHiLitKeys().isEmpty()) {
return;
}
if (m_lastIndex == null) {
m_lastIndex = 0;
} else if (newColumn) {
m_lastIndex++;
}
for (RowKey key : hdl.getHiLitKeys()) {
Map<Integer, String> list = m_annotationMap.get(key);
if (list == null) {
list = new LinkedHashMap<Integer, String>();
list.put(m_lastIndex, anno);
} else {
String str = list.get(m_lastIndex);
if (str == null) {
list.put(m_lastIndex, anno);
} else if (!str.contains(anno)) {
list.put(m_lastIndex, str + "," + anno);
}
}
m_annotationMap.put(key, list);
}
notifyViews(null);
}
use of org.knime.core.node.property.hilite.HiLiteHandler in project knime-core by knime.
the class WorkflowManager method configureSingleNodeContainer.
/**
* Configure a SingleNodeContainer.
*
* @param snc node to be configured
* @param keepNodeMessage Whether to keep previously set node messages (important during load sometimes)
* @return true if the configuration did change something.
*/
private boolean configureSingleNodeContainer(final SingleNodeContainer snc, final boolean keepNodeMessage) {
boolean configurationChanged = false;
try (WorkflowLock lock = lock()) {
NodeMessage oldMessage = keepNodeMessage ? snc.getNodeMessage() : NodeMessage.NONE;
final int inCount = snc.getNrInPorts();
NodeID sncID = snc.getID();
NodeOutPort[] predPorts = assemblePredecessorOutPorts(sncID);
final PortObjectSpec[] inSpecs = new PortObjectSpec[inCount];
final FlowObjectStack[] sos = new FlowObjectStack[inCount];
final HiLiteHandler[] hiliteHdls = new HiLiteHandler[inCount];
// check for presence of input specs and collects inport
// TableSpecs, FlowObjectStacks and HiLiteHandlers
boolean allSpecsExists = true;
for (int i = 0; i < predPorts.length; i++) {
if (predPorts[i] != null) {
inSpecs[i] = predPorts[i].getPortObjectSpec();
sos[i] = predPorts[i].getFlowObjectStack();
hiliteHdls[i] = predPorts[i].getHiLiteHandler();
allSpecsExists &= inSpecs[i] != null;
} else if (snc.getInPort(i).getPortType().isOptional()) {
// optional input, which is not connected ... ignore
} else {
allSpecsExists = false;
}
}
if (!allSpecsExists) {
// (NodeMessage did not change -- can exit here)
return false;
}
if (!canConfigureNodes()) {
snc.setNodeMessage(NodeMessage.merge(oldMessage, NodeMessage.newWarning("Outer workflow does not have input data, execute it first")));
return false;
}
// which might attempt to configure an already queued node again
switch(snc.getInternalState()) {
case IDLE:
case CONFIGURED:
case UNCONFIGURED_MARKEDFOREXEC:
case CONFIGURED_MARKEDFOREXEC:
// grid/server) -- also these nodes will be configured() on load
case EXECUTINGREMOTELY:
// the stack that previously would have been propagated,
// used to track changes
FlowObjectStack oldFOS = snc.createOutFlowObjectStack();
// create new FlowObjectStack
boolean flowStackConflict = false;
FlowObjectStack scsc;
try {
scsc = createAndSetFlowObjectStackFor(snc, sos);
} catch (IllegalFlowObjectStackException e) {
LOGGER.warn("Unable to merge flow object stacks: " + e.getMessage(), e);
scsc = new FlowObjectStack(sncID);
flowStackConflict = true;
}
snc.setCredentialsStore(m_credentialsStore);
// update backwards reference for loops
if (snc.isModelCompatibleTo(LoopEndNode.class)) {
// if this is an END to a loop, make sure it knows its head
// (for both: active and inactive loops)
Node sncNode = ((NativeNodeContainer) snc).getNode();
FlowLoopContext slc = scsc.peek(FlowLoopContext.class);
if (slc == null) {
// no head found - ignore during configure!
sncNode.setLoopStartNode(null);
} else {
// loop seems to be correctly wired - set head
NodeContainer headNode = m_workflow.getNode(slc.getOwner());
if (headNode == null) {
// odd: head is not in the same workflow,
// ignore as well during configure
sncNode.setLoopStartNode(null);
} else {
// head found, let the end node know about it:
sncNode.setLoopStartNode(((NativeNodeContainer) headNode).getNode());
}
}
}
// TODO think about it... happens magically
for (int i = 0; i < inCount; i++) {
snc.setInHiLiteHandler(i, hiliteHdls[i]);
}
// remember HiLiteHandler on OUTPORTS of all nodes!
HiLiteHandler[] oldHdl = new HiLiteHandler[snc.getNrOutPorts()];
for (int i = 0; i < oldHdl.length; i++) {
oldHdl[i] = snc.getOutPort(i).getHiLiteHandler();
}
// configure node itself
boolean outputSpecsChanged = false;
if (flowStackConflict) {
// can't be configured due to stack clash.
// make sure execution from here on is canceled
disableNodeForExecution(sncID);
// (ought to be red with this type of error!)
if (!snc.getInternalState().equals(IDLE)) {
// if not already idle make sure it is!
invokeResetOnSingleNodeContainer(snc);
}
// report the problem
snc.setNodeMessage(NodeMessage.merge(oldMessage, NodeMessage.newError("Can't merge FlowVariable Stacks! (likely a loop problem.)")));
// different outputs - empty ports!
outputSpecsChanged = true;
} else {
outputSpecsChanged = snc.configure(inSpecs, keepNodeMessage);
}
// NOTE:
// no need to clean stacks of LoopEnd nodes - done automagically
// inside the getFlowObjectStack of the ports of LoopEnd
// Nodes.
// check if FlowObjectStacks have changed
boolean stackChanged = false;
FlowObjectStack newFOS = snc.createOutFlowObjectStack();
stackChanged = !newFOS.equals(oldFOS);
// check if HiLiteHandlers have changed
boolean hiLiteHdlsChanged = false;
for (int i = 0; i < oldHdl.length; i++) {
HiLiteHandler hdl = snc.getOutPort(i).getHiLiteHandler();
hiLiteHdlsChanged |= (hdl != oldHdl[i]);
}
configurationChanged = (outputSpecsChanged || stackChanged || hiLiteHdlsChanged);
// and finally check if we can queue this node!
if (snc.getInternalState().equals(UNCONFIGURED_MARKEDFOREXEC) || snc.getInternalState().equals(CONFIGURED_MARKEDFOREXEC)) {
queueIfQueuable(snc);
}
break;
case EXECUTED:
case EXECUTED_MARKEDFOREXEC:
// should not happen but could if reset has worked on slightly
// different nodes than configure, for instance.
// FIXME: report errors again, once configure follows only ports, not nodes.
LOGGER.debug("configure found " + snc.getInternalState() + " node: " + snc.getNameWithID());
break;
case PREEXECUTE:
case POSTEXECUTE:
case EXECUTING:
// should not happen but could if reset has worked on slightly
// different nodes than configure, for instance.
LOGGER.debug("configure found " + snc.getInternalState() + " node: " + snc.getNameWithID());
break;
case CONFIGURED_QUEUED:
case EXECUTED_QUEUED:
// should not happen but could if reset has worked on slightly
// different nodes than configure, for instance.
LOGGER.debug("configure found " + snc.getInternalState() + " node: " + snc.getNameWithID());
break;
default:
LOGGER.error("configure found weird state (" + snc.getInternalState() + "): " + snc.getNameWithID());
}
}
return configurationChanged;
// we have a problem here. Subsequent metanodes with through connections
// need to be configured no matter what - they can change their state
// because 3 nodes before in the pipeline the execute state changed...
// return configurationChanged == configurationChanged;
}
use of org.knime.core.node.property.hilite.HiLiteHandler in project knime-core by knime.
the class HiLiteCollectorNodeView method modelChanged.
/**
* {@inheritDoc}
*/
@Override
public void modelChanged() {
DataTable data = super.getNodeModel().getHiLiteAnnotationsTable();
m_table.setDataTable(data);
HiLiteHandler hdl = super.getNodeModel().getInHiLiteHandler(0);
m_table.setHiLiteHandler(hdl);
m_table.setColumnWidth(50);
}
use of org.knime.core.node.property.hilite.HiLiteHandler in project knime-core by knime.
the class JoinerNodeModel method reset.
/**
* Removes all registered <code>HiLiteHandlers</code> and adds only the
* ones at the connected inports.
*
* @see org.knime.core.node.NodeModel#reset()
*/
@Override
protected void reset() {
m_leftIt = null;
m_rightIt = null;
m_exec = null;
m_firstMapHelper = null;
m_hiliteManager.removeAllToHiliteHandlers();
for (int i = 0; i < getNrInPorts(); i++) {
HiLiteHandler hdl = getInHiLiteHandler(i);
m_hiliteManager.addToHiLiteHandler(hdl);
}
}
Aggregations