Search in sources :

Example 31 with SettingsModelBoolean

use of org.knime.core.node.defaultnodesettings.SettingsModelBoolean in project knime-core by knime.

the class RowKeyNodeModel method validateSettings.

/**
 * {@inheritDoc}
 */
@Override
protected void validateSettings(final NodeSettingsRO settings) throws InvalidSettingsException {
    assert (settings != null);
    final SettingsModelBoolean replaceRowKeyModel = m_replaceKey.createCloneWithValidatedValue(settings);
    final SettingsModelBoolean appendRowKeyModel = m_appendRowKey.createCloneWithValidatedValue(settings);
    final SettingsModelString newRowKeyModel = m_newRowKeyColumn.createCloneWithValidatedValue(settings);
    final SettingsModelString newColNameModel = m_newColumnName.createCloneWithValidatedValue(settings);
    validateInput(null, appendRowKeyModel.getBooleanValue(), newColNameModel.getStringValue(), replaceRowKeyModel.getBooleanValue(), newRowKeyModel.getStringValue(), appendRowKeyModel.getBooleanValue());
}
Also used : SettingsModelBoolean(org.knime.core.node.defaultnodesettings.SettingsModelBoolean) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString)

Example 32 with SettingsModelBoolean

use of org.knime.core.node.defaultnodesettings.SettingsModelBoolean in project knime-core by knime.

the class DBGroupByNodeModel2 method validateSettings.

/**
 * {@inheritDoc}
 */
@Override
protected void validateSettings(final NodeSettingsRO settings) throws InvalidSettingsException {
    super.validateSettings(settings);
    m_groupByCols.validateSettings(settings);
    final boolean addCountStar = ((SettingsModelBoolean) m_addCountStar.createCloneWithValidatedValue(settings)).getBooleanValue();
    final String colName = ((SettingsModelString) m_countStarColName.createCloneWithValidatedValue(settings)).getStringValue();
    if (addCountStar && (colName == null || colName.isEmpty())) {
        throw new IllegalArgumentException("Please specify the count(*) column name");
    }
    if (ColumnNamePolicy.getPolicy4Label(((SettingsModelString) m_columnNamePolicy.createCloneWithValidatedValue(settings)).getStringValue()) == null) {
        throw new InvalidSettingsException("Invalid column name policy");
    }
}
Also used : SettingsModelBoolean(org.knime.core.node.defaultnodesettings.SettingsModelBoolean) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) SettingsModelFilterString(org.knime.core.node.defaultnodesettings.SettingsModelFilterString) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString)

Example 33 with SettingsModelBoolean

use of org.knime.core.node.defaultnodesettings.SettingsModelBoolean 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
        }
    };
}
Also used : DataTableSpec(org.knime.core.data.DataTableSpec) HiLiteHandler(org.knime.core.node.property.hilite.HiLiteHandler) RowKey(org.knime.core.data.RowKey) NodeSettingsWO(org.knime.core.node.NodeSettingsWO) DataRow(org.knime.core.data.DataRow) SettingsModelBoolean(org.knime.core.node.defaultnodesettings.SettingsModelBoolean) NodeModel(org.knime.core.node.NodeModel) ExecutionContext(org.knime.core.node.ExecutionContext) BufferedDataTable(org.knime.core.node.BufferedDataTable) NodeSettingsRO(org.knime.core.node.NodeSettingsRO) ExecutionMonitor(org.knime.core.node.ExecutionMonitor) File(java.io.File) HashSet(java.util.HashSet)

Example 34 with SettingsModelBoolean

use of org.knime.core.node.defaultnodesettings.SettingsModelBoolean in project knime-core by knime.

the class DecisionTreeLearnerNodeDialog2 method createSettingsSkipNominalColumnsWithoutDomain.

/**
 * @return binary nominal split mode
 */
static SettingsModelBoolean createSettingsSkipNominalColumnsWithoutDomain() {
    SettingsModelBoolean setting = new SettingsModelBoolean(DecisionTreeLearnerNodeModel2.KEY_SKIP_COLUMNS, DecisionTreeLearnerNodeModel2.DEFAULT_BINARY_NOMINAL_SPLIT_MODE);
    setting.setBooleanValue(true);
    return setting;
}
Also used : SettingsModelBoolean(org.knime.core.node.defaultnodesettings.SettingsModelBoolean)

Example 35 with SettingsModelBoolean

use of org.knime.core.node.defaultnodesettings.SettingsModelBoolean in project knime-core by knime.

the class DecisionTreeLearnerNodeDialog2 method createSettingsFirstSplitColumn.

/**
 * @return name of column to perform first split on
 */
static SettingsModelString createSettingsFirstSplitColumn(final SettingsModelBoolean useFirstSplitCol) {
    SettingsModelString firstSplitCol = new SettingsModelString(DecisionTreeLearnerNodeModel2.KEY_FIRST_SPLIT_COL, null);
    useFirstSplitCol.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(final ChangeEvent e) {
            firstSplitCol.setEnabled(((SettingsModelBoolean) e.getSource()).getBooleanValue());
        }
    });
    firstSplitCol.setEnabled(useFirstSplitCol.getBooleanValue());
    return firstSplitCol;
}
Also used : SettingsModelBoolean(org.knime.core.node.defaultnodesettings.SettingsModelBoolean) ChangeEvent(javax.swing.event.ChangeEvent) ChangeListener(javax.swing.event.ChangeListener) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString)

Aggregations

SettingsModelBoolean (org.knime.core.node.defaultnodesettings.SettingsModelBoolean)36 SettingsModelString (org.knime.core.node.defaultnodesettings.SettingsModelString)15 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)13 ChangeEvent (javax.swing.event.ChangeEvent)5 ChangeListener (javax.swing.event.ChangeListener)5 IOException (java.io.IOException)4 CanceledExecutionException (org.knime.core.node.CanceledExecutionException)4 DialogComponentBoolean (org.knime.core.node.defaultnodesettings.DialogComponentBoolean)4 DialogComponentString (org.knime.core.node.defaultnodesettings.DialogComponentString)4 File (java.io.File)3 DataTableSpec (org.knime.core.data.DataTableSpec)3 RowKey (org.knime.core.data.RowKey)3 BufferedDataTable (org.knime.core.node.BufferedDataTable)3 ExecutionContext (org.knime.core.node.ExecutionContext)3 ExecutionMonitor (org.knime.core.node.ExecutionMonitor)3 NodeModel (org.knime.core.node.NodeModel)3 NodeSettingsRO (org.knime.core.node.NodeSettingsRO)3 NodeSettingsWO (org.knime.core.node.NodeSettingsWO)3 DateTimeException (java.time.DateTimeException)2 Duration (java.time.Duration)2