Search in sources :

Example 11 with FlowVariableFilterConfiguration

use of org.knime.core.node.util.filter.variable.FlowVariableFilterConfiguration in project knime-core by knime.

the class VariableLoopEndNodeModel method loadValidatedSettingsFrom.

/**
 * {@inheritDoc}
 */
@Override
protected void loadValidatedSettingsFrom(final NodeSettingsRO settings) throws InvalidSettingsException {
    try {
        FlowVariableFilterConfiguration config = new FlowVariableFilterConfiguration("selection");
        config.loadConfigurationInModel(settings);
        m_selection = config;
    } catch (InvalidSettingsException e) {
    // stay with defaults
    }
}
Also used : InvalidSettingsException(org.knime.core.node.InvalidSettingsException) FlowVariableFilterConfiguration(org.knime.core.node.util.filter.variable.FlowVariableFilterConfiguration)

Example 12 with FlowVariableFilterConfiguration

use of org.knime.core.node.util.filter.variable.FlowVariableFilterConfiguration in project knime-core by knime.

the class VirtualSubNodeInputNodeDialogPane method saveSettingsTo.

/**
 * {@inheritDoc}
 */
@Override
protected void saveSettingsTo(final NodeSettingsWO settings) throws InvalidSettingsException {
    String prefix;
    if (m_variablePrefixChecker.isSelected()) {
        String text = StringUtils.trimToEmpty(m_variablePrefixTextField.getText());
        if (text.isEmpty()) {
            throw new InvalidSettingsException("Prefix string must not be empty");
        }
        prefix = text;
    } else {
        prefix = null;
    }
    VirtualSubNodeInputConfiguration configuration = new VirtualSubNodeInputConfiguration(m_portDescriptionPanels.length);
    configuration.setFlowVariablePrefix(prefix);
    FlowVariableFilterConfiguration f = VirtualSubNodeInputConfiguration.createFilterConfiguration();
    m_variableFilterPanel.saveConfiguration(f);
    configuration.setFilterConfiguration(f);
    String[] portNames = new String[m_portDescriptionPanels.length];
    String[] portDescriptions = new String[m_portDescriptionPanels.length];
    for (int i = 0; i < m_portDescriptionPanels.length; i++) {
        portNames[i] = m_portDescriptionPanels[i].getPortName();
        portDescriptions[i] = m_portDescriptionPanels[i].getPortDescription();
    }
    configuration.setSubNodeDescription(m_subNodeDescription.getText());
    configuration.setPortNames(portNames);
    configuration.setPortDescriptions(portDescriptions);
    configuration.saveConfiguration(settings);
}
Also used : InvalidSettingsException(org.knime.core.node.InvalidSettingsException) FlowVariableFilterConfiguration(org.knime.core.node.util.filter.variable.FlowVariableFilterConfiguration)

Example 13 with FlowVariableFilterConfiguration

use of org.knime.core.node.util.filter.variable.FlowVariableFilterConfiguration in project knime-core by knime.

the class VirtualSubNodeInputNodeModel method pushFlowVariables.

/**
 * @throws Exception
 */
private void pushFlowVariables() throws InvalidSettingsException {
    String prefix = m_configuration.getFlowVariablePrefix() == null ? "" : m_configuration.getFlowVariablePrefix();
    FlowVariableFilterConfiguration filterConfiguration = m_configuration.getFilterConfiguration();
    Map<String, FlowVariable> availableVariables = getSubNodeContainerFlowObjectStack().getAvailableFlowVariables(Type.values());
    FilterResult filtered = filterConfiguration.applyTo(availableVariables);
    for (String include : filtered.getIncludes()) {
        FlowVariable f = availableVariables.get(include);
        switch(f.getScope()) {
            case Global:
                // ignore global flow vars
                continue;
            case Flow:
            case Local:
            default:
        }
        final String name = prefix + f.getName();
        Node.invokePushFlowVariable(this, f.withNewName(name));
    }
}
Also used : FilterResult(org.knime.core.node.util.filter.NameFilterConfiguration.FilterResult) FlowVariableFilterConfiguration(org.knime.core.node.util.filter.variable.FlowVariableFilterConfiguration) FlowVariable(org.knime.core.node.workflow.FlowVariable)

Example 14 with FlowVariableFilterConfiguration

use of org.knime.core.node.util.filter.variable.FlowVariableFilterConfiguration in project knime-core by knime.

the class VirtualSubNodeOutputNodeDialogPane method saveSettingsTo.

/**
 * {@inheritDoc}
 */
@Override
protected void saveSettingsTo(final NodeSettingsWO settings) throws InvalidSettingsException {
    String prefix;
    if (m_variablePrefixChecker.isSelected()) {
        String text = StringUtils.trimToEmpty(m_variablePrefixTextField.getText());
        if (text.isEmpty()) {
            throw new InvalidSettingsException("Prefix string must not be empty");
        }
        prefix = text;
    } else {
        prefix = null;
    }
    VirtualSubNodeInputConfiguration configuration = new VirtualSubNodeInputConfiguration(m_portDescriptionPanels.length);
    configuration.setFlowVariablePrefix(prefix);
    FlowVariableFilterConfiguration f = VirtualSubNodeInputConfiguration.createFilterConfiguration();
    m_variableFilterPanel.saveConfiguration(f);
    configuration.setFilterConfiguration(f);
    String[] portNames = new String[m_portDescriptionPanels.length];
    String[] portDescriptions = new String[m_portDescriptionPanels.length];
    for (int i = 0; i < m_portDescriptionPanels.length; i++) {
        portNames[i] = m_portDescriptionPanels[i].getPortName();
        portDescriptions[i] = m_portDescriptionPanels[i].getPortDescription();
    }
    configuration.setPortNames(portNames);
    configuration.setPortDescriptions(portDescriptions);
    configuration.saveConfiguration(settings);
}
Also used : InvalidSettingsException(org.knime.core.node.InvalidSettingsException) FlowVariableFilterConfiguration(org.knime.core.node.util.filter.variable.FlowVariableFilterConfiguration)

Aggregations

FlowVariableFilterConfiguration (org.knime.core.node.util.filter.variable.FlowVariableFilterConfiguration)14 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)3 FlowVariable (org.knime.core.node.workflow.FlowVariable)2 FilterResult (org.knime.core.node.util.filter.NameFilterConfiguration.FilterResult)1