Search in sources :

Example 1 with AttrValueRowFilter

use of org.knime.base.node.preproc.filter.row.rowfilter.AttrValueRowFilter in project knime-core by knime.

the class ColumnRowFilterPanel method loadSettingsFromFilter.

/**
 * {@inheritDoc}
 */
@Override
public void loadSettingsFromFilter(final IRowFilter filter) throws InvalidSettingsException {
    // accept ColValFilterOldObsolete for backward compatibility
    if (filter instanceof ColValFilterOldObsolete) {
        loadSettingsFromColValFilter((ColValFilterOldObsolete) filter);
    } else {
        if (!(filter instanceof AttrValueRowFilter)) {
            throw new InvalidSettingsException("Column value row filter " + "panel can only load settings from a range filter, " + "an attribute value filter.");
        }
        AttrValueRowFilter avFilter = (AttrValueRowFilter) filter;
        String colName = avFilter.getColName();
        if (colName != null) {
            m_colCombo.setSelectedColumn(colName);
        }
        m_deepFiltering.setSelected(avFilter.getDeepFiltering());
        updateDeepFiltering();
        if (filter instanceof StringCompareRowFilter) {
            StringCompareRowFilter f = (StringCompareRowFilter) filter;
            m_useRegExpr.setSelected(true);
            m_regExpr.setSelectedItem(f.getPattern());
            m_isRegExpr.setSelected(f.getIsRegExpr());
            m_hasWildCards.setSelected(f.getHasWildcards());
            m_caseSensitive.setSelected(f.getCaseSensitive());
        } else if (filter instanceof RangeRowFilter) {
            RangeRowFilter f = (RangeRowFilter) filter;
            m_useRange.setSelected(true);
            String upper = "";
            String lower = "";
            if (f.getUpperBound() != null) {
                upper = f.getUpperBound().toString();
            }
            if (f.getLowerBound() != null) {
                lower = f.getLowerBound().toString();
            }
            m_upperBound.setText(upper);
            m_lowerBound.setText(lower);
        } else if (filter instanceof MissingValueRowFilter) {
            m_useMissValue.setSelected(true);
        } else {
            // attribute value filter.
            assert false;
        }
    }
}
Also used : InvalidSettingsException(org.knime.core.node.InvalidSettingsException) ColValFilterOldObsolete(org.knime.base.node.preproc.filter.row.rowfilter.ColValFilterOldObsolete) RangeRowFilter(org.knime.base.node.preproc.filter.row.rowfilter.RangeRowFilter) StringCompareRowFilter(org.knime.base.node.preproc.filter.row.rowfilter.StringCompareRowFilter) AttrValueRowFilter(org.knime.base.node.preproc.filter.row.rowfilter.AttrValueRowFilter) MissingValueRowFilter(org.knime.base.node.preproc.filter.row.rowfilter.MissingValueRowFilter)

Example 2 with AttrValueRowFilter

use of org.knime.base.node.preproc.filter.row.rowfilter.AttrValueRowFilter in project knime-core by knime.

the class RowFilterNodeDialogPane method loadSettingsFrom.

/**
 * {@inheritDoc}
 */
@Override
protected void loadSettingsFrom(final NodeSettingsRO settings, final DataTableSpec[] specs) throws NotConfigurableException {
    if ((specs[0] == null) || (specs[0].getNumColumns() < 1)) {
        throw new NotConfigurableException("Cannot be configured without" + " input table");
    }
    // remove the old filter panels, if any
    if (m_rangePanel != null) {
        m_filterPanel.remove(m_rangePanel);
    }
    if (m_rowIDPanel != null) {
        m_filterPanel.remove(m_rowIDPanel);
    }
    if (m_colValPanel != null) {
        m_filterPanel.remove(m_colValPanel);
    }
    // now create new filter panels
    m_rangePanel = new RowNoRowFilterPanel();
    m_rowIDPanel = new RowIDRowFilterPanel();
    m_colValPanel = new ColumnRowFilterPanel(this, specs[0]);
    /*
         * now read the filters. We support three different filters:
         * RowIDFilter, AttrValfilter, and RowNumberFilter. But only one at a
         * time.
         */
    IRowFilter filter = null;
    try {
        // get the filter
        filter = RowFilterFactory.createRowFilter(settings.getNodeSettings(RowFilterNodeModel.CFGFILTER));
    } catch (InvalidSettingsException ise) {
    // silently ignore invalid filters.
    }
    String actionCommand = "colval";
    if (filter == null) {
        // set the default
        m_colValInclRadio.setSelected(true);
        filterSelectionChanged("colval");
        return;
    }
    if (filter instanceof ColValFilterOldObsolete) {
        // support the obsolete filter for backward compatibility
        ColValFilterOldObsolete f = (ColValFilterOldObsolete) filter;
        actionCommand = "colval";
        // activate the corresponding radio button
        if (f.includeMatchingLines()) {
            m_colValInclRadio.setSelected(true);
        } else {
            m_colValExclRadio.setSelected(true);
        }
        try {
            m_colValPanel.loadSettingsFromFilter(f);
        } catch (InvalidSettingsException ise) {
        // ignore failure
        }
    } else if (filter instanceof AttrValueRowFilter) {
        // this covers all the attribute value filters:
        // range, string compare, missing value filter
        AttrValueRowFilter f = (AttrValueRowFilter) filter;
        actionCommand = "colval";
        // activate the corresponding radio button
        if (f.getInclude()) {
            m_colValInclRadio.setSelected(true);
        } else {
            m_colValExclRadio.setSelected(true);
        }
        try {
            m_colValPanel.loadSettingsFromFilter(f);
        } catch (InvalidSettingsException ise) {
        // ignore failure
        }
    } else if (filter instanceof RowIDRowFilter) {
        RowIDRowFilter f = (RowIDRowFilter) filter;
        actionCommand = "id";
        // activate the corresponding radio button
        if (f.getInclude()) {
            m_rowIDInclRadio.setSelected(true);
        } else {
            m_rowIDExclRadio.setSelected(true);
        }
        try {
            m_rowIDPanel.loadSettingsFromFilter(f);
        } catch (InvalidSettingsException ise) {
        // ignore failure
        }
    } else if (filter instanceof RowNoRowFilter) {
        RowNoRowFilter f = (RowNoRowFilter) filter;
        actionCommand = "range";
        // activate the corresponding radio button
        if (f.getInclude()) {
            m_rangeInclRadio.setSelected(true);
        } else {
            m_rangeExclRadio.setSelected(true);
        }
        try {
            m_rangePanel.loadSettingsFromFilter(f);
        } catch (InvalidSettingsException ise) {
        // ignore failure
        }
    } else {
    // we silently ignore unsupported filter and leave default settings.
    }
    filterSelectionChanged(actionCommand);
}
Also used : NotConfigurableException(org.knime.core.node.NotConfigurableException) RowNoRowFilter(org.knime.base.node.preproc.filter.row.rowfilter.RowNoRowFilter) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) RowIDRowFilter(org.knime.base.node.preproc.filter.row.rowfilter.RowIDRowFilter) ColValFilterOldObsolete(org.knime.base.node.preproc.filter.row.rowfilter.ColValFilterOldObsolete) AttrValueRowFilter(org.knime.base.node.preproc.filter.row.rowfilter.AttrValueRowFilter) IRowFilter(org.knime.base.node.preproc.filter.row.rowfilter.IRowFilter)

Aggregations

AttrValueRowFilter (org.knime.base.node.preproc.filter.row.rowfilter.AttrValueRowFilter)2 ColValFilterOldObsolete (org.knime.base.node.preproc.filter.row.rowfilter.ColValFilterOldObsolete)2 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)2 IRowFilter (org.knime.base.node.preproc.filter.row.rowfilter.IRowFilter)1 MissingValueRowFilter (org.knime.base.node.preproc.filter.row.rowfilter.MissingValueRowFilter)1 RangeRowFilter (org.knime.base.node.preproc.filter.row.rowfilter.RangeRowFilter)1 RowIDRowFilter (org.knime.base.node.preproc.filter.row.rowfilter.RowIDRowFilter)1 RowNoRowFilter (org.knime.base.node.preproc.filter.row.rowfilter.RowNoRowFilter)1 StringCompareRowFilter (org.knime.base.node.preproc.filter.row.rowfilter.StringCompareRowFilter)1 NotConfigurableException (org.knime.core.node.NotConfigurableException)1