Search in sources :

Example 76 with ButtonGroup

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

the class StringManipulationNodeDialog method createStringManipulationPanel.

/**
 * @return the controls for the string manipulation node
 * @since 3.3
 */
public Component createStringManipulationPanel() {
    m_snippetPanel = new JSnippetPanel(StringManipulatorProvider.getDefault(), createCompletionProvider(), !m_isOnlyVariables);
    m_newNameField = new JTextField(10);
    String radioButtonName;
    String radioButtonToolTip;
    radioButtonName = "Append " + WordUtils.capitalize(m_columnOrVariable) + ": ";
    radioButtonToolTip = "Appends a new " + m_columnOrVariable + " to the input with a given name.";
    m_appendRadio = new JRadioButton(radioButtonName);
    m_appendRadio.setToolTipText(radioButtonToolTip);
    radioButtonName = "Replace " + WordUtils.capitalize(m_columnOrVariable) + ": ";
    if (m_isOnlyVariables) {
        radioButtonToolTip = "Replaces the " + m_columnOrVariable + " if the type stays the same.";
    } else {
        radioButtonToolTip = "Replaces the " + m_columnOrVariable + " and changes the " + m_columnOrVariable + " type accordingly.";
    }
    m_replaceRadio = new JRadioButton(radioButtonName);
    m_replaceRadio.setToolTipText(radioButtonToolTip);
    if (m_isOnlyVariables) {
        // show all variables
        m_replaceVariableCombo = new JComboBox<FlowVariable>(new DefaultComboBoxModel<FlowVariable>());
        m_replaceVariableCombo.setRenderer(new FlowVariableListCellRenderer());
    } else {
        // show all columns
        m_replaceColumnCombo = new ColumnSelectionPanel((Border) null, DataValue.class);
        m_replaceColumnCombo.setRequired(false);
    }
    ButtonGroup buttonGroup = new ButtonGroup();
    buttonGroup.add(m_appendRadio);
    buttonGroup.add(m_replaceRadio);
    ActionListener actionListener = new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            if (m_isOnlyVariables) {
                m_replaceVariableCombo.setEnabled(m_replaceRadio.isSelected());
            } else {
                m_replaceColumnCombo.setEnabled(m_replaceRadio.isSelected());
            }
            m_newNameField.setEnabled(m_appendRadio.isSelected());
        }
    };
    m_appendRadio.addActionListener(actionListener);
    m_replaceRadio.addActionListener(actionListener);
    m_compileOnCloseChecker = new JCheckBox("Syntax check on close");
    m_compileOnCloseChecker.setToolTipText("Checks the syntax of the expression on close.");
    m_insertMissingAsNullChecker = new JCheckBox("Insert Missing As Null");
    m_insertMissingAsNullChecker.setToolTipText("If unselected, missing values in the input will produce a missing cell result");
    return createPanel();
}
Also used : JRadioButton(javax.swing.JRadioButton) DataValue(org.knime.core.data.DataValue) ActionEvent(java.awt.event.ActionEvent) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) JTextField(javax.swing.JTextField) JCheckBox(javax.swing.JCheckBox) FlowVariableListCellRenderer(org.knime.core.node.util.FlowVariableListCellRenderer) ActionListener(java.awt.event.ActionListener) ButtonGroup(javax.swing.ButtonGroup) ColumnSelectionPanel(org.knime.core.node.util.ColumnSelectionPanel) JSnippetPanel(org.knime.base.node.util.JSnippetPanel) Border(javax.swing.border.Border) FlowVariable(org.knime.core.node.workflow.FlowVariable)

Example 77 with ButtonGroup

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

the class ListFilesNodeDialog method createFiltersModels.

/**
 * creates the filter radio buttons.
 */
private void createFiltersModels() {
    m_filterALLRadio = new JRadioButton();
    m_filterALLRadio.setText("none");
    m_filterALLRadio.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent arg0) {
            m_extensionField.setEnabled(false);
        }
    });
    m_filterExtensionsRadio = new JRadioButton();
    m_filterExtensionsRadio.setText("file extension(s)");
    m_filterExtensionsRadio.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent arg0) {
            m_extensionField.setEnabled(true);
        }
    });
    m_filterRegExpRadio = new JRadioButton();
    m_filterRegExpRadio.setText("regular expression");
    m_filterRegExpRadio.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent arg0) {
            m_extensionField.setEnabled(true);
        }
    });
    m_filterWildCardsRadio = new JRadioButton();
    m_filterWildCardsRadio.setText("wildcard pattern");
    m_filterWildCardsRadio.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent arg0) {
            m_extensionField.setEnabled(true);
        }
    });
    ButtonGroup group = new ButtonGroup();
    group.add(m_filterALLRadio);
    group.add(m_filterExtensionsRadio);
    group.add(m_filterRegExpRadio);
    group.add(m_filterWildCardsRadio);
}
Also used : JRadioButton(javax.swing.JRadioButton) ActionListener(java.awt.event.ActionListener) ButtonGroup(javax.swing.ButtonGroup) ActionEvent(java.awt.event.ActionEvent)

Example 78 with ButtonGroup

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

the class AutoBinnerLearnNodeDialogPane method createMethodUIControls.

private JPanel createMethodUIControls() {
    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.weightx = 0;
    c.gridy = 0;
    c.gridx = 0;
    c.gridwidth = GridBagConstraints.REMAINDER;
    m_methodFixedNumber = new JRadioButton("Fixed number of bins");
    m_methodFixedNumber.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            m_numBins.setEnabled(m_methodFixedNumber.isSelected());
            m_equalityMethod.setEnabled(m_methodFixedNumber.isSelected());
            m_sampleQuantiles.setEnabled(!m_methodFixedNumber.isSelected());
        }
    });
    p.add(m_methodFixedNumber, c);
    c.gridy++;
    // JPanel numBinsPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 0));
    JPanel numBinsPanel = new JPanel(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.insets = new Insets(2, 2, 2, 2);
    gbc.anchor = GridBagConstraints.NORTHWEST;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.weightx = 0;
    gbc.weighty = 0;
    gbc.gridx = 0;
    gbc.gridy = 0;
    numBinsPanel.add(new JLabel("Number of bins:"), gbc);
    gbc.gridx++;
    m_numBins = new JSpinner(new SpinnerNumberModel(5, 1, Integer.MAX_VALUE, 1));
    numBinsPanel.add(m_numBins, gbc);
    gbc.weightx = 1;
    gbc.gridx++;
    numBinsPanel.add(new JLabel(), gbc);
    gbc.weightx = 0;
    gbc.gridx = 0;
    gbc.gridy++;
    numBinsPanel.add(new JLabel("Equal:"), gbc);
    gbc.gridx++;
    m_equalityMethod = new JComboBox<EqualityMethod>(EqualityMethod.values());
    numBinsPanel.add(m_equalityMethod, gbc);
    numBinsPanel.setBorder(BorderFactory.createEmptyBorder(0, 17, 0, 0));
    p.add(numBinsPanel, c);
    c.gridy++;
    c.gridx = 0;
    c.gridwidth = GridBagConstraints.REMAINDER;
    m_methodSampleQuantiles = new JRadioButton("Sample quantiles");
    m_methodSampleQuantiles.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            m_numBins.setEnabled(!m_methodSampleQuantiles.isSelected());
            m_equalityMethod.setEnabled(!m_methodSampleQuantiles.isSelected());
            m_sampleQuantiles.setEnabled(m_methodSampleQuantiles.isSelected());
        }
    });
    p.add(m_methodSampleQuantiles, c);
    c.gridy++;
    JPanel quantilesPanel = new JPanel(new GridBagLayout());
    int gridy = c.gridy;
    c.gridy = 0;
    c.gridwidth = 1;
    quantilesPanel.add(new JLabel("Quantiles (comma separated):"), c);
    c.gridx++;
    c.gridwidth = 1;
    c.weightx = 1;
    m_sampleQuantiles = new JTextField();
    quantilesPanel.add(m_sampleQuantiles, c);
    quantilesPanel.setBorder(BorderFactory.createEmptyBorder(0, 17, 0, 0));
    c.gridy = gridy;
    c.gridx = 0;
    c.gridwidth = 1;
    p.add(quantilesPanel, c);
    ButtonGroup method = new ButtonGroup();
    method.add(m_methodFixedNumber);
    method.add(m_methodSampleQuantiles);
    p.setBorder(BorderFactory.createTitledBorder("Binning Method"));
    return p;
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) JRadioButton(javax.swing.JRadioButton) GridBagLayout(java.awt.GridBagLayout) ActionEvent(java.awt.event.ActionEvent) JLabel(javax.swing.JLabel) JTextField(javax.swing.JTextField) SpinnerNumberModel(javax.swing.SpinnerNumberModel) ActionListener(java.awt.event.ActionListener) ButtonGroup(javax.swing.ButtonGroup) JSpinner(javax.swing.JSpinner) EqualityMethod(org.knime.base.node.preproc.autobinner2.AutoBinnerLearnSettings.EqualityMethod)

Example 79 with ButtonGroup

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

the class AutoBinnerLearnNodeDialogPane method createNumberFormatSettingsTab.

private JPanel createNumberFormatSettingsTab() {
    JPanel p = new JPanel(new GridBagLayout());
    m_defaultFormatting = new JRadioButton("Default formatting");
    m_advancedFormatting = new JRadioButton("Advanced formatting");
    ButtonGroup formatting = new ButtonGroup();
    formatting.add(m_defaultFormatting);
    formatting.add(m_advancedFormatting);
    m_outputFormat = new JComboBox<OutputFormat>(OutputFormat.values());
    m_precision = new JSpinner(new SpinnerNumberModel(3, 0, Integer.MAX_VALUE, 1));
    m_precisionMode = new JComboBox<PrecisionMode>(PrecisionMode.values());
    m_roundingMode = new JComboBox<RoundingMode>(getRoundingModes());
    ActionListener formattingListener = new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            m_outputFormat.setEnabled(m_advancedFormatting.isSelected());
            m_precision.setEnabled(m_advancedFormatting.isSelected());
            m_precisionMode.setEnabled(m_advancedFormatting.isSelected());
            m_roundingMode.setEnabled(m_advancedFormatting.isSelected());
        }
    };
    m_defaultFormatting.addActionListener(formattingListener);
    m_advancedFormatting.addActionListener(formattingListener);
    GridBagConstraints gbc = new GridBagConstraints();
    Insets indentedInsets = new Insets(5, 15, 5, 5);
    Insets normalInsets = new Insets(5, 5, 5, 5);
    gbc.insets = normalInsets;
    gbc.anchor = GridBagConstraints.NORTHWEST;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.weightx = 0;
    gbc.weighty = 0;
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.gridwidth = 2;
    p.add(m_defaultFormatting, gbc);
    gbc.gridy++;
    p.add(m_advancedFormatting, gbc);
    gbc.gridwidth = 1;
    gbc.gridy++;
    gbc.insets = indentedInsets;
    p.add(new JLabel("Output format"), gbc);
    gbc.gridx++;
    gbc.insets = normalInsets;
    p.add(m_outputFormat, gbc);
    gbc.gridx = 0;
    gbc.gridy++;
    gbc.insets = indentedInsets;
    p.add(new JLabel("Precision"), gbc);
    gbc.gridx++;
    gbc.insets = normalInsets;
    p.add(m_precision, gbc);
    gbc.gridx = 0;
    gbc.gridy++;
    gbc.insets = indentedInsets;
    p.add(new JLabel("Precision mode"), gbc);
    gbc.gridx++;
    gbc.insets = normalInsets;
    p.add(m_precisionMode, gbc);
    gbc.gridx = 0;
    gbc.gridy++;
    gbc.insets = indentedInsets;
    p.add(new JLabel("Rounding mode"), gbc);
    gbc.gridx++;
    gbc.insets = normalInsets;
    p.add(m_roundingMode, gbc);
    gbc.gridx++;
    gbc.gridy++;
    gbc.weightx = 1;
    gbc.weighty = 1;
    gbc.insets = new Insets(0, 0, 0, 0);
    p.add(new JLabel(), gbc);
    return p;
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) JRadioButton(javax.swing.JRadioButton) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) RoundingMode(java.math.RoundingMode) ActionEvent(java.awt.event.ActionEvent) OutputFormat(org.knime.base.node.preproc.autobinner2.AutoBinnerLearnSettings.OutputFormat) JLabel(javax.swing.JLabel) SpinnerNumberModel(javax.swing.SpinnerNumberModel) PrecisionMode(org.knime.base.node.preproc.autobinner2.AutoBinnerLearnSettings.PrecisionMode) ActionListener(java.awt.event.ActionListener) ButtonGroup(javax.swing.ButtonGroup) JSpinner(javax.swing.JSpinner)

Example 80 with ButtonGroup

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

the class AutoBinnerLearnNodeDialogPane method createBinNamingUIControls.

private JPanel createBinNamingUIControls() {
    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.gridy = 0;
    c.gridx = 0;
    c.weightx = 0;
    c.gridwidth = 2;
    m_binNamingNumbered = new JRadioButton("Numbered");
    p.add(m_binNamingNumbered, c);
    c.gridx = 2;
    c.gridwidth = 1;
    c.weightx = 1;
    c.insets = new Insets(6, 2, 2, 2);
    JLabel exampleNumbered = new JLabel("e.g.: Bin 1, Bin 2, Bin 3");
    exampleNumbered.setEnabled(false);
    p.add(exampleNumbered, c);
    c.weightx = 0;
    c.insets = new Insets(2, 2, 2, 2);
    c.gridy++;
    c.gridx = 0;
    c.gridwidth = 1;
    m_binNamingEdges = new JRadioButton("Borders");
    p.add(m_binNamingEdges, c);
    c.gridx = 1;
    c.gridwidth = 2;
    c.weightx = 1;
    c.insets = new Insets(6, 2, 2, 2);
    JLabel exampleEdges = new JLabel("e.g.: [-10,0], (0,10], (10,20]");
    exampleEdges.setEnabled(false);
    p.add(exampleEdges, c);
    c.weightx = 0;
    c.insets = new Insets(2, 2, 2, 2);
    c.gridy++;
    c.gridx = 0;
    c.gridwidth = 1;
    m_binNamingMidpoints = new JRadioButton("Midpoints");
    p.add(m_binNamingMidpoints, c);
    c.gridx = 1;
    c.gridwidth = 2;
    c.weightx = 1;
    c.insets = new Insets(6, 2, 2, 2);
    JLabel exampleMidpoints = new JLabel("e.g.: -5, 5, 15");
    exampleMidpoints.setEnabled(false);
    p.add(exampleMidpoints, c);
    c.weightx = 0;
    c.insets = new Insets(2, 2, 2, 2);
    ButtonGroup method = new ButtonGroup();
    method.add(m_binNamingNumbered);
    method.add(m_binNamingEdges);
    method.add(m_binNamingMidpoints);
    p.setBorder(BorderFactory.createTitledBorder("Bin Naming"));
    return p;
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) JRadioButton(javax.swing.JRadioButton) GridBagLayout(java.awt.GridBagLayout) ButtonGroup(javax.swing.ButtonGroup) JLabel(javax.swing.JLabel)

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