use of org.knime.core.node.util.ColumnSelectionComboxBox in project knime-core by knime.
the class ColumnRowFilterPanel method instantiateComponents.
@SuppressWarnings("unchecked")
private void instantiateComponents(final RowFilterNodeDialogPane parentPane, final DataTableSpec tSpec) throws NotConfigurableException {
/* instantiate the col idx selector, depending on the table spec */
assert ((tSpec != null) && (tSpec.getNumColumns() > 0));
Vector<String> colNames = new Vector<String>();
for (int c = 0; c < tSpec.getNumColumns(); c++) {
colNames.add(tSpec.getColumnSpec(c).getName());
}
m_colCombo = new ColumnSelectionComboxBox((Border) null, DataValue.class);
m_colCombo.update(tSpec, null);
m_colCombo.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(final ItemEvent e) {
selectedColChanged();
}
});
m_deepFiltering = new JCheckBox("filter based on collection elements");
/* the selectors for what kind of checking will be done */
m_useRange = new JRadioButton("use range checking");
m_useRegExpr = new JRadioButton("use pattern matching");
m_useMissValue = new JRadioButton("only missing values match");
m_useRange.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(final ItemEvent e) {
radiosChanged();
}
});
m_useRegExpr.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(final ItemEvent e) {
radiosChanged();
}
});
m_useMissValue.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(final ItemEvent e) {
radiosChanged();
}
});
m_radios = new ButtonGroup();
m_radios.add(m_useRange);
m_radios.add(m_useRegExpr);
m_radios.add(m_useMissValue);
/* the bound edit fields */
m_lowerLabel = new JLabel("lower bound:");
m_lowerLabel.setToolTipText("Smallest value of the range to be filtered.");
m_lowerBound = new JTextField();
m_upperLabel = new JLabel("upper bound:");
m_upperLabel.setToolTipText("Largest value of the range to be filtered.");
m_upperBound = new JTextField();
m_lowerBound.getDocument().addDocumentListener(new DocumentListener() {
@Override
public void insertUpdate(final DocumentEvent e) {
boundsChanged();
}
@Override
public void removeUpdate(final DocumentEvent e) {
boundsChanged();
}
@Override
public void changedUpdate(final DocumentEvent e) {
boundsChanged();
}
});
m_upperBound.getDocument().addDocumentListener(new DocumentListener() {
@Override
public void insertUpdate(final DocumentEvent e) {
boundsChanged();
}
@Override
public void removeUpdate(final DocumentEvent e) {
boundsChanged();
}
@Override
public void changedUpdate(final DocumentEvent e) {
boundsChanged();
}
});
/* the regular expression stuff */
m_regLabel = new JLabel("pattern:");
// it's important that the column selection is created before!
m_regExpr = new JComboBox(getPossibleValuesOfSelectedColumn());
m_regExpr.setEditable(true);
m_regExpr.setSelectedItem("");
m_regExpr.setMinimumSize(new Dimension(50, m_regExpr.getPreferredSize().height));
// m_regExpr.setPreferredSize(new Dimension(200, 50));
m_regExpr.setMaximumSize(new Dimension(300, 50));
JTextField ed = (JTextField) m_regExpr.getEditor().getEditorComponent();
ed.getDocument().addDocumentListener(new DocumentListener() {
@Override
public void insertUpdate(final DocumentEvent e) {
regExprChanged();
}
@Override
public void removeUpdate(final DocumentEvent e) {
regExprChanged();
}
@Override
public void changedUpdate(final DocumentEvent e) {
regExprChanged();
}
});
m_regExpr.addItemListener(this);
/* add flow variable button for the pattern/regexpr */
FlowVariableModel fvm = parentPane.createFlowVariableModel(new String[] { RowFilterNodeModel.CFGFILTER, StringCompareRowFilter.CFGKEY_PATTERN }, FlowVariable.Type.STRING);
fvm.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(final ChangeEvent evt) {
FlowVariableModel fvm = (FlowVariableModel) (evt.getSource());
m_regExpr.setEnabled(!fvm.isVariableReplacementEnabled());
if (fvm.isVariableReplacementEnabled() && m_regExpr.getSelectedItem().equals("")) {
// TODO: replace with more meaningful default - empty
// pattern are rejected by dialog.
m_regExpr.setSelectedItem(fvm.getInputVariableName());
}
}
});
m_regExprVarButton = new FlowVariableModelButton(fvm);
m_caseSensitive = new JCheckBox("case sensitive match");
m_isRegExpr = new JCheckBox("regular expression");
m_hasWildCards = new JCheckBox("contains wild cards");
m_hasWildCards.setToolTipText("insert '?' or '*' to match any one " + "character or any sequence (including none) of characters.");
m_isRegExpr.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(final ItemEvent e) {
wildRegExprChanged(e);
// also trigger regular expression recompile
regExprChanged();
}
});
m_hasWildCards.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(final ItemEvent e) {
wildRegExprChanged(e);
// also trigger regular expression recompile
regExprChanged();
}
});
/* and a label to display errors/warnings */
m_errText = new JTextArea();
m_errText.setEditable(false);
m_errText.setLineWrap(true);
m_errText.setWrapStyleWord(true);
m_errText.setBackground(getBackground());
m_errText.setFont(new Font(m_errText.getFont().getName(), Font.BOLD, m_errText.getFont().getSize()));
m_errText.setMinimumSize(new Dimension(350, 50));
m_errText.setMaximumSize(new Dimension(350, 100));
m_errText.setForeground(Color.RED);
/* set the default values */
m_useRegExpr.setSelected(true);
}
use of org.knime.core.node.util.ColumnSelectionComboxBox in project knime-core by knime.
the class CrosstabNodeDialog method createSettingsPanel.
@SuppressWarnings("unchecked")
private JPanel createSettingsPanel() {
JPanel p = new JPanel(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.BOTH;
c.anchor = GridBagConstraints.WEST;
c.insets = new Insets(8, 3, 3, 3);
c.gridx = 0;
c.gridy = 0;
c.gridwidth = 1;
c.weightx = 0;
c.weighty = 0;
c.fill = GridBagConstraints.BOTH;
p.add(new JLabel("Row variable:"), c);
c.gridx++;
c.weightx = 1;
m_rowVarColumn = new ColumnSelectionComboxBox(StringValue.class, DoubleValue.class);
m_rowVarColumn.setBorder(null);
p.add(m_rowVarColumn, c);
c.insets = new Insets(3, 3, 3, 3);
c.gridx = 0;
c.gridy++;
c.weightx = 0;
p.add(new JLabel("Column variable:"), c);
c.gridx++;
c.weightx = 1;
m_colVarColumn = new ColumnSelectionComboxBox(StringValue.class, DoubleValue.class);
m_colVarColumn.setBorder(null);
p.add(m_colVarColumn, c);
c.gridx = 0;
c.gridy++;
c.weightx = 0;
p.add(new JLabel("Weight column:"), c);
c.gridx++;
c.weightx = 1;
m_weightColumn = new ColumnSelectionPanel((Border) null, new DataValueColumnFilter(DoubleValue.class), true);
m_weightColumn.setBorder(null);
p.add(m_weightColumn, c);
c.gridx = 0;
c.gridy++;
c.gridwidth = 2;
m_enableHiliting = new JCheckBox("Enable hiliting");
p.add(m_enableHiliting, c);
c.gridy++;
c.gridx = 0;
c.weighty = 1;
p.add(new JPanel(), c);
return p;
}
Aggregations