use of org.knime.core.node.property.hilite.HiLiteHandler in project knime-core by knime.
the class TableNodeModel method setInternalTables.
/**
* {@inheritDoc}
*/
@Override
public void setInternalTables(final BufferedDataTable[] tables) {
m_table = tables[0];
HiLiteHandler inProp = getInHiLiteHandler(INPORT);
updateView(new UpdateObject(m_table, inProp));
}
use of org.knime.core.node.property.hilite.HiLiteHandler in project knime-core by knime.
the class TableNodeModel method execute.
/**
* Called when new data is available. Accesses the input data table and the
* property handler, sets them in the {@link TableContentModel} and starts
* event firing to inform listeners. Do not call this method separately, it
* is invoked by this model's node.
*
* @param data the data table at the (single) input port, wrapped in a
* one-dimensional array
* @param exec the execution monitor
* @return an empty table
*
* @see NodeModel#execute(BufferedDataTable[],ExecutionContext)
*/
@Override
protected BufferedDataTable[] execute(final BufferedDataTable[] data, final ExecutionContext exec) {
m_table = data[0];
HiLiteHandler inProp = getInHiLiteHandler(INPORT);
updateView(new UpdateObject(m_table, inProp));
return new BufferedDataTable[0];
}
use of org.knime.core.node.property.hilite.HiLiteHandler in project knime-core by knime.
the class DefaultVisualizationNodeView method modelChanged.
/**
* {@inheritDoc}
*/
@Override
protected void modelChanged() {
NodeModel model = getNodeModel();
if (model == null) {
return;
}
if (!(model instanceof DataProvider)) {
throw new IllegalArgumentException("Model must implement the DataProvider " + "interface!");
}
DataProvider provider = (DataProvider) model;
HiLiteHandler hiliteHandler = model.getInHiLiteHandler(0);
// do not care about antialias
for (AbstractPlotter plotter : m_plotters) {
plotter.reset();
plotter.setHiLiteHandler(hiliteHandler);
plotter.setDataProvider(provider);
plotter.updatePaintModel();
}
}
use of org.knime.core.node.property.hilite.HiLiteHandler in project knime-core by knime.
the class AutoHiLiteNodeFactory method createNodeModel.
/**
* {@inheritDoc}
*/
@Override
public NodeModel createNodeModel() {
return new NodeModel(1, 1) {
private SettingsModelBoolean m_smClearHiLites = createClearHilitesModel();
/**
* {@inheritDoc}
*/
@Override
protected DataTableSpec[] configure(final DataTableSpec[] inSpecs) throws InvalidSettingsException {
return inSpecs;
}
/**
* {@inheritDoc}
*/
@Override
protected BufferedDataTable[] execute(final BufferedDataTable[] inData, final ExecutionContext exec) throws Exception {
if (m_smClearHiLites.getBooleanValue()) {
getInHiLiteHandler(0).fireClearHiLiteEvent();
}
final Set<RowKey> keys = new HashSet<RowKey>();
final HiLiteHandler hlh = getInHiLiteHandler(0);
long counter = 0;
long numOfRows = inData[0].size();
for (final DataRow row : inData[0]) {
keys.add(row.getKey());
if (keys.size() == NUMBER_OF_ROWS_HILITED_AT_ONCE) {
exec.setProgress(++counter * NUMBER_OF_ROWS_HILITED_AT_ONCE / (double) numOfRows, "HiLiting all rows...");
hlh.fireHiLiteEvent(keys);
keys.clear();
}
}
hlh.fireHiLiteEvent(keys);
// wait for hilite to propagate
ViewUtils.invokeAndWaitInEDT(() -> {
});
return inData;
}
@Override
protected void loadInternals(final File nodeInternDir, final ExecutionMonitor exec) throws IOException, CanceledExecutionException {
}
@Override
protected void saveInternals(final File nodeInternDir, final ExecutionMonitor exec) throws IOException, CanceledExecutionException {
}
@Override
protected void saveSettingsTo(final NodeSettingsWO settings) {
m_smClearHiLites.saveSettingsTo(settings);
}
@Override
protected void validateSettings(final NodeSettingsRO settings) throws InvalidSettingsException {
m_smClearHiLites.validateSettings(settings);
}
@Override
protected void loadValidatedSettingsFrom(final NodeSettingsRO settings) throws InvalidSettingsException {
m_smClearHiLites.loadSettingsFrom(settings);
}
@Override
protected void reset() {
// no op
}
};
}
use of org.knime.core.node.property.hilite.HiLiteHandler in project knime-core by knime.
the class WebResourceController method getWizardPageInternal.
/**
* Crates the wizard page for a given node id. Throws exception if no wizard page available.
*
* @param subnodeID the node id for the subnode to retrieve the wizard page for
* @return The wizard page for the given node id
*/
@SuppressWarnings("rawtypes")
protected WizardPageContent getWizardPageInternal(final NodeID subnodeID) {
if (subnodeID == null) {
LOGGER.error("No node ID supplied for creating wizard page");
return null;
}
final WorkflowManager manager = m_manager;
assert manager.isLockedByCurrentThread();
// int currentSubnodeIDSuffix = m_promptedSubnodeIDSuffixes.peek();
// final NodeID subNodeID = toNodeID(currentSubnodeIDSuffix);
SubNodeContainer subNC = manager.getNodeContainer(subnodeID, SubNodeContainer.class, true);
WorkflowManager subWFM = subNC.getWorkflowManager();
Map<NodeID, WizardNode> wizardNodeMap = subWFM.findNodes(WizardNode.class, NOT_HIDDEN_FILTER, false);
LinkedHashMap<NodeIDSuffix, WizardNode> resultMap = new LinkedHashMap<NodeIDSuffix, WizardNode>();
// LinkedHashMap<NodeIDSuffix, WizardNode> errorMap = new LinkedHashMap<NodeIDSuffix, WizardNode>();
LinkedHashMap<NodeIDSuffix, WizardPageNodeInfo> infoMap = new LinkedHashMap<NodeIDSuffix, WizardPageNodeInfo>();
Set<HiLiteHandler> initialHiliteHandlerSet = new HashSet<HiLiteHandler>();
for (Map.Entry<NodeID, WizardNode> entry : wizardNodeMap.entrySet()) {
NodeContainer nc = subWFM.getNodeContainer(entry.getKey());
if ((nc instanceof SingleNodeContainer) && ((SingleNodeContainer) nc).isInactive()) {
// skip nodes in inactive branches
continue;
}
NodeID.NodeIDSuffix idSuffix = NodeID.NodeIDSuffix.create(manager.getID(), entry.getKey());
WizardPageNodeInfo nodeInfo = new WizardPageNodeInfo();
nodeInfo.setNodeName(nc.getName());
nodeInfo.setNodeAnnotation(nc.getNodeAnnotation().toString());
nodeInfo.setNodeState(nc.getInternalState());
nodeInfo.setNodeMessage(nc.getNodeMessage());
infoMap.put(idSuffix, nodeInfo);
if (EXECUTED.equals(nc.getInternalState())) {
// regular viewable nodes need to be executed
resultMap.put(idSuffix, entry.getValue());
}
for (int i = 0; i < nc.getNrInPorts() - 1; i++) {
HiLiteHandler hiLiteHandler = ((NodeModel) entry.getValue()).getInHiLiteHandler(i);
if (hiLiteHandler != null) {
initialHiliteHandlerSet.add(hiLiteHandler);
}
}
}
NodeID.NodeIDSuffix pageID = NodeID.NodeIDSuffix.create(manager.getID(), subWFM.getID());
String pageLayout = subNC.getLayoutJSONString();
if (StringUtils.isEmpty(pageLayout)) {
try {
pageLayout = LayoutUtil.createDefaultLayout(resultMap);
} catch (IOException ex) {
LOGGER.error("Default page layout could not be created: " + ex.getMessage(), ex);
}
}
Set<HiLiteHandler> knownHiLiteHandlers = new HashSet<HiLiteHandler>();
Set<HiLiteTranslator> knownTranslators = new HashSet<HiLiteTranslator>();
Set<HiLiteManager> knownManagers = new HashSet<HiLiteManager>();
for (HiLiteHandler initialHandler : initialHiliteHandlerSet) {
getHiLiteTranslators(initialHandler, knownHiLiteHandlers, knownTranslators, knownManagers);
}
List<HiLiteTranslator> translatorList = knownTranslators.size() > 0 ? new ArrayList<HiLiteTranslator>(knownTranslators) : null;
List<HiLiteManager> managerList = knownManagers.size() > 0 ? new ArrayList<HiLiteManager>(knownManagers) : null;
WizardPageContent page = new WizardPageContent(pageID, resultMap, pageLayout, translatorList, managerList);
page.setInfoMap(infoMap);
return page;
}
Aggregations