Search in sources :

Example 1 with HiLiteTranslator

use of org.knime.core.node.property.hilite.HiLiteTranslator in project knime-core by knime.

the class Unpivot2NodeModel method setInHiLiteHandler.

/**
 * {@inheritDoc}
 */
@Override
protected void setInHiLiteHandler(final int inIndex, final HiLiteHandler hiLiteHdl) {
    if (m_trans != null && m_trans.getFromHiLiteHandler() != hiLiteHdl) {
        m_trans.dispose();
        m_trans = null;
    }
    if (hiLiteHdl != null) {
        m_trans = new HiLiteTranslator(hiLiteHdl);
        m_trans.addToHiLiteHandler(m_hilite);
    }
}
Also used : HiLiteTranslator(org.knime.core.node.property.hilite.HiLiteTranslator)

Example 2 with HiLiteTranslator

use of org.knime.core.node.property.hilite.HiLiteTranslator in project knime-core by knime.

the class UnpivotNodeModel method setInHiLiteHandler.

/**
 * {@inheritDoc}
 */
@Override
protected void setInHiLiteHandler(final int inIndex, final HiLiteHandler hiLiteHdl) {
    if (m_trans == null) {
        m_trans = new HiLiteTranslator(hiLiteHdl);
        m_trans.addToHiLiteHandler(m_hilite);
    } else if (m_trans.getFromHiLiteHandler() != hiLiteHdl) {
        m_trans.removeAllToHiliteHandlers();
        m_trans.setMapper(null);
        m_trans.addToHiLiteHandler(m_hilite);
    }
}
Also used : HiLiteTranslator(org.knime.core.node.property.hilite.HiLiteTranslator)

Example 3 with HiLiteTranslator

use of org.knime.core.node.property.hilite.HiLiteTranslator in project knime-core by knime.

the class WebResourceController method getHiLiteTranslators.

private void getHiLiteTranslators(final HiLiteHandler handler, final Set<HiLiteHandler> knownHiLiteHandlers, final Set<HiLiteTranslator> knownTranslators, final Set<HiLiteManager> knownManagers) {
    if (handler == null || !knownHiLiteHandlers.add(handler)) {
        return;
    }
    Set<HiLiteTranslator> translators = handler.getHiLiteTranslators();
    for (HiLiteTranslator translator : translators) {
        if (translator != null && knownTranslators.add(translator)) {
            followHiLiteTranslator(translator, knownHiLiteHandlers, knownTranslators, knownManagers);
        }
    }
    Set<HiLiteManager> managers = handler.getHiLiteManagers();
    for (HiLiteManager manager : managers) {
        if (manager != null && knownManagers.add(manager)) {
            followHiLiteManager(manager, knownHiLiteHandlers, knownTranslators, knownManagers);
        }
    }
}
Also used : HiLiteTranslator(org.knime.core.node.property.hilite.HiLiteTranslator) HiLiteManager(org.knime.core.node.property.hilite.HiLiteManager)

Example 4 with HiLiteTranslator

use of org.knime.core.node.property.hilite.HiLiteTranslator in project knime-core by knime.

the class WizardPageUtil method createWizardPage.

/**
 * Creates the wizard page for a given node id. Throws exception if no wizard page available.
 *
 * Note: the workflow manager must be locked!
 *
 * @param manager the workflow that contains the component to create the wizard page for
 * @param subnodeID the node id for the subnode to create the wizard page for
 * @return The wizard page for the given node id
 * @throws IllegalArgumentException if there is no component for the given id
 */
public static WizardPage createWizardPage(final WorkflowManager manager, final NodeID subnodeID) {
    if (subnodeID == null) {
        LOGGER.error("No node ID supplied for creating wizard page");
        return null;
    }
    // NOSONAR
    assert manager.isLockedByCurrentThread();
    LinkedHashMap<NodeIDSuffix, NativeNodeContainer> resultMap = new LinkedHashMap<>();
    Set<HiLiteHandler> initialHiliteHandlerSet = new HashSet<>();
    SubNodeContainer subNC = manager.getNodeContainer(subnodeID, SubNodeContainer.class, true);
    LinkedHashMap<NodeIDSuffix, SubNodeContainer> sncMap = new LinkedHashMap<>();
    findNestedViewNodes(subNC, resultMap, sncMap, initialHiliteHandlerSet);
    SubnodeContainerLayoutStringProvider layoutStringProvider = subNC.getSubnodeLayoutStringProvider();
    if (layoutStringProvider.isEmptyLayout() || layoutStringProvider.isPlaceholderLayout()) {
        try {
            var subWfm = subNC.getWorkflowManager();
            Map<NodeIDSuffix, SingleNodeContainer> viewMap = new LinkedHashMap<>();
            getWizardPageNodes(subWfm).stream().forEach(n -> viewMap.put(toNodeIDSuffix(manager, n.getID()), n));
            Map<NodeID, SubNodeContainer> nestedSubs = getSubPageNodes(subWfm);
            nestedSubs.entrySet().stream().forEach(e -> viewMap.put(toNodeIDSuffix(manager, e.getKey()), e.getValue()));
            layoutStringProvider.setLayoutString(LayoutUtil.createDefaultLayout(viewMap));
        } catch (IOException ex) {
            LOGGER.error("Default page layout could not be created: " + ex.getMessage(), ex);
        }
    }
    try {
        LayoutUtil.expandNestedLayout(layoutStringProvider, subNC.getWorkflowManager());
    } catch (IOException ex) {
        LOGGER.error("Nested layouts could not be expanded: " + ex.getMessage(), ex);
    }
    try {
        var containerID = NodeID.fromString(NodeIDSuffix.create(manager.getID(), subNC.getWorkflowManager().getID()).toString());
        LayoutUtil.addUnreferencedViews(layoutStringProvider, resultMap, sncMap, containerID);
    } catch (IOException ex) {
        LOGGER.error("Layout could not be amended by unreferenced views: " + ex.getMessage(), ex);
    }
    try {
        LayoutUtil.updateLayout(layoutStringProvider);
    } catch (Exception ex) {
        // NOSONAR
        LOGGER.error("Layout could not be updated: " + ex.getMessage(), ex);
    }
    Set<HiLiteHandler> knownHiLiteHandlers = new HashSet<>();
    Set<HiLiteTranslator> knownTranslators = new HashSet<>();
    Set<HiLiteManager> knownManagers = new HashSet<>();
    for (HiLiteHandler initialHandler : initialHiliteHandlerSet) {
        getHiLiteTranslators(initialHandler, knownHiLiteHandlers, knownTranslators, knownManagers);
    }
    List<HiLiteTranslator> translatorList = !knownTranslators.isEmpty() ? new ArrayList<>(knownTranslators) : null;
    List<HiLiteManager> managerList = !knownManagers.isEmpty() ? new ArrayList<>(knownManagers) : null;
    return new WizardPage(subnodeID, resultMap, layoutStringProvider.getLayoutString(), translatorList, managerList);
}
Also used : HiLiteHandler(org.knime.core.node.property.hilite.HiLiteHandler) LinkedHashMap(java.util.LinkedHashMap) NodeID(org.knime.core.node.workflow.NodeID) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) SingleNodeContainer(org.knime.core.node.workflow.SingleNodeContainer) HiLiteTranslator(org.knime.core.node.property.hilite.HiLiteTranslator) IOException(java.io.IOException) HiLiteManager(org.knime.core.node.property.hilite.HiLiteManager) IOException(java.io.IOException) SubNodeContainer(org.knime.core.node.workflow.SubNodeContainer) NodeIDSuffix(org.knime.core.node.workflow.NodeID.NodeIDSuffix) SubnodeContainerLayoutStringProvider(org.knime.core.node.workflow.SubnodeContainerLayoutStringProvider) NativeNodeContainer(org.knime.core.node.workflow.NativeNodeContainer)

Example 5 with HiLiteTranslator

use of org.knime.core.node.property.hilite.HiLiteTranslator in project knime-core by knime.

the class Joiner2NodeModel method setInHiLiteHandler.

/**
 * {@inheritDoc}
 */
@Override
protected void setInHiLiteHandler(final int inIndex, final HiLiteHandler hiLiteHdl) {
    if (0 == inIndex) {
        m_leftTranslator.removeAllToHiliteHandlers();
        m_leftTranslator = new HiLiteTranslator(hiLiteHdl, m_leftMapper);
        m_leftTranslator.addToHiLiteHandler(m_outHandler);
    } else {
        m_rightTranslator.removeAllToHiliteHandlers();
        m_rightTranslator = new HiLiteTranslator(hiLiteHdl, m_rightMapper);
        m_rightTranslator.addToHiLiteHandler(m_outHandler);
    }
}
Also used : HiLiteTranslator(org.knime.core.node.property.hilite.HiLiteTranslator)

Aggregations

HiLiteTranslator (org.knime.core.node.property.hilite.HiLiteTranslator)9 HiLiteManager (org.knime.core.node.property.hilite.HiLiteManager)5 IOException (java.io.IOException)3 LinkedHashSet (java.util.LinkedHashSet)3 NodeIDSuffix (org.knime.core.node.workflow.NodeID.NodeIDSuffix)3 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 LinkedHashMap (java.util.LinkedHashMap)2 Map (java.util.Map)2 HiLiteHandler (org.knime.core.node.property.hilite.HiLiteHandler)2 WizardPageNodeInfo (org.knime.core.node.workflow.WebResourceController.WizardPageContent.WizardPageNodeInfo)2 ArrayList (java.util.ArrayList)1 NodeModel (org.knime.core.node.NodeModel)1 WebResourceLocator (org.knime.core.node.web.WebResourceLocator)1 WebTemplate (org.knime.core.node.web.WebTemplate)1 WizardNode (org.knime.core.node.wizard.WizardNode)1 NativeNodeContainer (org.knime.core.node.workflow.NativeNodeContainer)1 NodeContainerState (org.knime.core.node.workflow.NodeContainerState)1 NodeID (org.knime.core.node.workflow.NodeID)1 NodeMessage (org.knime.core.node.workflow.NodeMessage)1