Search in sources :

Example 86 with ButtonGroup

use of javax.swing.ButtonGroup in project knime-core by knime.

the class DomainNodeDialogPane method createMinMaxTab.

private JPanel createMinMaxTab() {
    JPanel minMaxPanel = new JPanel(new BorderLayout());
    minMaxPanel.add(m_filterPanelMinMax, BorderLayout.CENTER);
    JPanel retainMinMaxPanel = new JPanel(new GridLayout(0, 1));
    retainMinMaxPanel.setBorder(BorderFactory.createTitledBorder(UNSELECTED_LABEL));
    ButtonGroup group = new ButtonGroup();
    group.add(m_minMaxUnselectedRetainButton);
    group.add(m_minMaxUnselectedDropButton);
    m_minMaxUnselectedRetainButton.doClick();
    retainMinMaxPanel.add(m_minMaxUnselectedRetainButton);
    retainMinMaxPanel.add(m_minMaxUnselectedDropButton);
    JPanel southPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    southPanel.add(retainMinMaxPanel);
    minMaxPanel.add(southPanel, BorderLayout.SOUTH);
    return minMaxPanel;
}
Also used : JPanel(javax.swing.JPanel) GridLayout(java.awt.GridLayout) FlowLayout(java.awt.FlowLayout) BorderLayout(java.awt.BorderLayout) ButtonGroup(javax.swing.ButtonGroup)

Example 87 with ButtonGroup

use of javax.swing.ButtonGroup in project knime-core by knime.

the class DomainNodeDialogPane method createPossValueTab.

private JPanel createPossValueTab() {
    JPanel possValPanel = new JPanel(new BorderLayout());
    possValPanel.add(m_filterPanelPossValues, BorderLayout.CENTER);
    JPanel southPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    JPanel retainPossValPanel = new JPanel(new GridLayout(0, 1));
    retainPossValPanel.setBorder(BorderFactory.createTitledBorder(UNSELECTED_LABEL));
    ButtonGroup group = new ButtonGroup();
    group.add(m_possValUnselectedRetainButton);
    group.add(m_possValUnselectedDropButton);
    m_possValUnselectedRetainButton.doClick();
    retainPossValPanel.add(m_possValUnselectedRetainButton);
    retainPossValPanel.add(m_possValUnselectedDropButton);
    southPanel.add(retainPossValPanel);
    southPanel.add(new JLabel("   "));
    southPanel.add(m_maxValuesChecker);
    southPanel.add(m_maxValuesSpinner);
    possValPanel.add(southPanel, BorderLayout.SOUTH);
    return possValPanel;
}
Also used : JPanel(javax.swing.JPanel) GridLayout(java.awt.GridLayout) FlowLayout(java.awt.FlowLayout) BorderLayout(java.awt.BorderLayout) ButtonGroup(javax.swing.ButtonGroup) JLabel(javax.swing.JLabel)

Example 88 with ButtonGroup

use of javax.swing.ButtonGroup 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);
}
Also used : DocumentListener(javax.swing.event.DocumentListener) ItemEvent(java.awt.event.ItemEvent) JRadioButton(javax.swing.JRadioButton) JTextArea(javax.swing.JTextArea) DataValue(org.knime.core.data.DataValue) ColumnSelectionComboxBox(org.knime.core.node.util.ColumnSelectionComboxBox) JTextField(javax.swing.JTextField) Font(java.awt.Font) FlowVariableModel(org.knime.core.node.FlowVariableModel) ChangeListener(javax.swing.event.ChangeListener) Vector(java.util.Vector) JComboBox(javax.swing.JComboBox) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) DocumentEvent(javax.swing.event.DocumentEvent) JCheckBox(javax.swing.JCheckBox) ChangeEvent(javax.swing.event.ChangeEvent) ButtonGroup(javax.swing.ButtonGroup) FlowVariableModelButton(org.knime.core.node.FlowVariableModelButton) ItemListener(java.awt.event.ItemListener) Border(javax.swing.border.Border)

Example 89 with ButtonGroup

use of javax.swing.ButtonGroup in project knime-core by knime.

the class Joiner2NodeDialog method createDuplicateColumnHandlingUIConstrols.

/**
 * @return the duplicate column handling panel
 * @since 2.12
 * @noreference This method is not intended to be referenced by clients.
 */
protected JPanel createDuplicateColumnHandlingUIConstrols() {
    JPanel left = new JPanel(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.NORTHWEST;
    c.insets = new Insets(2, 2, 2, 2);
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 0;
    c.gridwidth = 1;
    left.add(m_filterDuplicates, c);
    c.gridy++;
    left.add(m_dontExecute, c);
    c.gridy++;
    left.add(m_appendSuffixAutomatic, c);
    c.gridy++;
    left.add(m_appendSuffix, c);
    c.gridx++;
    m_suffix.setPreferredSize(new Dimension(100, m_suffix.getPreferredSize().height));
    left.add(m_suffix, c);
    m_appendSuffix.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(final ChangeEvent e) {
            m_suffix.setEnabled(m_appendSuffix.isSelected());
        }
    });
    ButtonGroup duplicateColGroup = new ButtonGroup();
    duplicateColGroup.add(m_filterDuplicates);
    duplicateColGroup.add(m_dontExecute);
    duplicateColGroup.add(m_appendSuffixAutomatic);
    duplicateColGroup.add(m_appendSuffix);
    left.setBorder(BorderFactory.createTitledBorder("Duplicate Column Handling"));
    JPanel right = new JPanel(new GridBagLayout());
    c.gridx = 0;
    c.gridy = 0;
    right.add(m_removeLeftJoinCols, c);
    c.gridy++;
    right.add(m_removeRightJoinCols, c);
    right.setBorder(BorderFactory.createTitledBorder("Joining Columns Handling"));
    JPanel p = new JPanel(new GridLayout(1, 2));
    p.add(left);
    p.add(right);
    return p;
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) GridLayout(java.awt.GridLayout) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) ChangeEvent(javax.swing.event.ChangeEvent) ButtonGroup(javax.swing.ButtonGroup) ChangeListener(javax.swing.event.ChangeListener) Dimension(java.awt.Dimension)

Example 90 with ButtonGroup

use of javax.swing.ButtonGroup in project knime-core by knime.

the class Joiner2NodeDialog method createJoinPredicateUIControls.

/**
 * @param includeRowId <code>true</code> if the user can select the row id as a potential matching column
 * @param showMatchModes <code>true</code> if the AND and OR match mode option should available
 * @return the column pair panel
 * @since 2.12
 * @noreference This method is not intended to be referenced by clients.
 */
protected JPanel createJoinPredicateUIControls(final boolean includeRowId, final boolean showMatchModes) {
    JPanel p = new JPanel(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.NORTHWEST;
    c.insets = new Insets(2, 2, 2, 2);
    c.gridx = 0;
    c.gridy = 0;
    if (showMatchModes) {
        JPanel matchButtonPanel = new JPanel(new FlowLayout());
        matchButtonPanel.add(m_matchAllButton);
        matchButtonPanel.add(m_matchAnyButton);
        p.add(matchButtonPanel, c);
        ButtonGroup group = new ButtonGroup();
        group.add(m_matchAllButton);
        group.add(m_matchAnyButton);
        c.gridx = 0;
        c.gridy++;
    }
    c.gridwidth = 3;
    c.weightx = 1;
    c.weighty = 1;
    m_columnPairs = new ColumnPairsSelectionPanel(includeRowId) {

        private static final long serialVersionUID = 1L;

        /**
         * {@inheritDoc}
         */
        @Override
        protected void initComboBox(final DataTableSpec spec, final JComboBox comboBox, final String selected) {
            super.initComboBox(spec, comboBox, selected);
            // the first entry is the row id, set as default.
            if (selected == null) {
                comboBox.setSelectedIndex(0);
            }
        }
    };
    m_columnPairs.setRowKeyIdentifier(Joiner2Settings.ROW_KEY_IDENTIFIER);
    JScrollPane scrollPane = new JScrollPane(m_columnPairs);
    m_columnPairs.setBackground(Color.white);
    Component header = m_columnPairs.getHeaderView();
    header.setPreferredSize(new Dimension(300, 20));
    scrollPane.setColumnHeaderView(header);
    scrollPane.setPreferredSize(new Dimension(300, 200));
    scrollPane.setMinimumSize(new Dimension(300, 100));
    p.add(scrollPane, c);
    p.setBorder(BorderFactory.createTitledBorder("Joining Columns"));
    return p;
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) DataTableSpec(org.knime.core.data.DataTableSpec) Insets(java.awt.Insets) FlowLayout(java.awt.FlowLayout) GridBagLayout(java.awt.GridBagLayout) JComboBox(javax.swing.JComboBox) Dimension(java.awt.Dimension) ButtonGroup(javax.swing.ButtonGroup) JComponent(javax.swing.JComponent) Component(java.awt.Component) ColumnPairsSelectionPanel(org.knime.core.node.util.ColumnPairsSelectionPanel)

Aggregations

ButtonGroup (javax.swing.ButtonGroup)339 JPanel (javax.swing.JPanel)202 JRadioButton (javax.swing.JRadioButton)186 JLabel (javax.swing.JLabel)148 ActionEvent (java.awt.event.ActionEvent)134 ActionListener (java.awt.event.ActionListener)118 BoxLayout (javax.swing.BoxLayout)83 GridBagLayout (java.awt.GridBagLayout)81 JButton (javax.swing.JButton)75 JTextField (javax.swing.JTextField)70 JMenu (javax.swing.JMenu)69 GridBagConstraints (java.awt.GridBagConstraints)67 BorderLayout (java.awt.BorderLayout)64 Insets (java.awt.Insets)64 Dimension (java.awt.Dimension)58 JRadioButtonMenuItem (javax.swing.JRadioButtonMenuItem)57 FlowLayout (java.awt.FlowLayout)53 JMenuItem (javax.swing.JMenuItem)50 JCheckBox (javax.swing.JCheckBox)47 JScrollPane (javax.swing.JScrollPane)47