Search in sources :

Example 1 with ColumnSelectionPanel

use of org.knime.core.node.util.ColumnSelectionPanel in project knime-core by knime.

the class RuleEngine2PortsNodeDialog method initControls.

/**
 * Creates and adds most of the controls to the dialog.
 */
private void initControls() {
    m_pmml = new JCheckBox("Enable PMML RuleSet generation (fails when result would not be a valid PMML RuleSet)");
    m_ruleSelectionMethod = new JComboBox<>(new Vector<>(RuleEngine2PortsSettings.POSSIBLE_RULE_SELECTION_METHODS));
    m_hasDefaultScore = new JCheckBox("Default value (when nothing matches): ");
    m_defaultScore = Util.createTextFieldWithWatermark(RuleEngine2PortsSettings.DEFAULT_DEFAULT_SCORE, 22, "Default score/value when nothing matches");
    m_hasDefaultConfidence = new JCheckBox("Default confidence value (when not specified in the confidence column): ");
    m_defaultConfidence = new JSpinner(new SpinnerNumberModel(RuleEngine2PortsSettings.DEFAULT_DEFAULT_CONFIDENCE, 0d, 1d, .1));
    @SuppressWarnings("unchecked") DataValueColumnFilter doubleValueFilter = new DataValueColumnFilter(DoubleValue.class);
    m_ruleConfidenceColumn = new ColumnSelectionPanel((Border) null, doubleValueFilter, true);
    m_hasDefaultWeight = new JCheckBox("Default weight value (when not specified in the weight column): ");
    m_defaultWeight = new JSpinner(new SpinnerNumberModel(RuleEngine2PortsSettings.DEFAULT_DEFAULT_WEIGHT, 0d, 1e6, .1));
    m_ruleWeightColumn = new ColumnSelectionPanel((Border) null, doubleValueFilter, true);
    m_computeConfidence = new JCheckBox("Confidence column name: ");
    m_predictionConfidenceColumn = Util.createTextFieldWithWatermark(RuleEngine2PortsSettings.DEFAULT_PREDICTION_CONFIDENCE_COLUMN, 22, "Computed confidence column name");
    m_provideStatistics = new JCheckBox("Provide statistics");
    @SuppressWarnings("unchecked") DataValueColumnFilter validationColumnFilter = new DataValueColumnFilter(StringValue.class, BooleanValue.class, DoubleValue.class);
    m_validationColumn = new ColumnSelectionPanel(null, validationColumnFilter, true);
    m_pmmlLabels = new ArrayList<>();
    m_pmmlBorders = new ArrayList<>();
    m_validateLabel = new JLabel("Validation column");
}
Also used : JCheckBox(javax.swing.JCheckBox) SpinnerNumberModel(javax.swing.SpinnerNumberModel) JSpinner(javax.swing.JSpinner) JLabel(javax.swing.JLabel) ColumnSelectionPanel(org.knime.core.node.util.ColumnSelectionPanel) DataValueColumnFilter(org.knime.core.node.util.DataValueColumnFilter) Vector(java.util.Vector) Border(javax.swing.border.Border) TitledBorder(javax.swing.border.TitledBorder)

Example 2 with ColumnSelectionPanel

use of org.knime.core.node.util.ColumnSelectionPanel in project knime-core by knime.

the class RulePanel method createNewColumnTextFieldWithReplace.

private Component createNewColumnTextFieldWithReplace(final String watermark, final int colWidth, final String label) {
    Box ret = Box.createVerticalBox();
    JPanel addColumnPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    JPanel replaceColumnPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    m_outputGroup = new ButtonGroup();
    final JRadioButton newColumn = new JRadioButton(label);
    m_replaceColRadio = new JRadioButton("Replace Column:");
    addColumnPanel.add(newColumn);
    JTextField comp = Util.createTextFieldWithWatermark(watermark, colWidth, /*label*/
    null);
    m_newColumnName = comp;
    addColumnPanel.add(comp);
    ActionListener actionListener = new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            m_newColumnName.setEnabled(newColumn.isSelected());
            m_replaceColumn.setEnabled(m_replaceColRadio.isSelected());
            m_replaceColumn.setRequired(m_replaceColRadio.isSelected());
        }
    };
    newColumn.addActionListener(actionListener);
    m_replaceColRadio.addActionListener(actionListener);
    m_outputGroup.add(newColumn);
    m_outputGroup.add(m_replaceColRadio);
    @SuppressWarnings("unchecked") ColumnSelectionPanel colSelectionPanel = new ColumnSelectionPanel((Border) null, DoubleValue.class, IntValue.class, StringValue.class, BooleanValue.class);
    m_replaceColumn = colSelectionPanel;
    m_outputType = new JLabel(DataValue.UTILITY.getIcon());
    addColumnPanel.add(m_outputType);
    replaceColumnPanel.add(m_replaceColRadio);
    replaceColumnPanel.add(m_replaceColumn);
    ret.add(addColumnPanel);
    ret.add(replaceColumnPanel);
    return ret;
}
Also used : JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) JRadioButton(javax.swing.JRadioButton) ActionListener(java.awt.event.ActionListener) ButtonGroup(javax.swing.ButtonGroup) ActionEvent(java.awt.event.ActionEvent) JLabel(javax.swing.JLabel) Box(javax.swing.Box) ColumnSelectionPanel(org.knime.core.node.util.ColumnSelectionPanel) JTextField(javax.swing.JTextField)

Example 3 with ColumnSelectionPanel

use of org.knime.core.node.util.ColumnSelectionPanel 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 4 with ColumnSelectionPanel

use of org.knime.core.node.util.ColumnSelectionPanel in project knime-core by knime.

the class LogRegLearnerNodeDialogPane method createTargetOptionsPanel.

/**
 * Create options panel for the target.
 */
private JPanel createTargetOptionsPanel() {
    JPanel p = new JPanel(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0;
    c.weighty = 0;
    c.gridx = 0;
    c.gridy = 0;
    c.anchor = GridBagConstraints.BASELINE_LEADING;
    c.insets = new Insets(5, 5, 0, 0);
    p.add(new JLabel("Target Column:"), c);
    c.gridx++;
    m_selectionPanel = new ColumnSelectionPanel(new EmptyBorder(0, 0, 0, 0), NominalValue.class);
    m_selectionPanel.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            updateTargetCategories((DataCell) m_targetReferenceCategory.getSelectedItem());
        }
    });
    p.add(m_selectionPanel, c);
    c.gridx = 0;
    c.gridy++;
    p.add(new JLabel("Reference Category:"), c);
    c.gridx++;
    m_targetReferenceCategory = new JComboBox();
    p.add(m_targetReferenceCategory, c);
    c.gridx = 0;
    c.gridy++;
    c.gridwidth = 3;
    c.weightx = 1;
    m_notSortTarget = new JCheckBox("Use order from target column domain (only relevant for output representation)");
    p.add(m_notSortTarget, c);
    m_selectionPanel.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(final ItemEvent e) {
            Object selected = e.getItem();
            if (selected instanceof DataColumnSpec) {
                m_filterPanel.resetHiding();
                m_filterPanel.hideColumns((DataColumnSpec) selected);
            }
        }
    });
    return p;
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) ItemEvent(java.awt.event.ItemEvent) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) JComboBox(javax.swing.JComboBox) NominalValue(org.knime.core.data.NominalValue) ActionEvent(java.awt.event.ActionEvent) JLabel(javax.swing.JLabel) JCheckBox(javax.swing.JCheckBox) DataColumnSpec(org.knime.core.data.DataColumnSpec) ActionListener(java.awt.event.ActionListener) DataCell(org.knime.core.data.DataCell) ItemListener(java.awt.event.ItemListener) ColumnSelectionPanel(org.knime.core.node.util.ColumnSelectionPanel) EmptyBorder(javax.swing.border.EmptyBorder)

Example 5 with ColumnSelectionPanel

use of org.knime.core.node.util.ColumnSelectionPanel in project knime-core by knime.

the class LogRegLearnerNodeDialogPane method createTargetOptionsPanel.

/**
 * Create options panel for the target.
 */
private JPanel createTargetOptionsPanel() {
    JPanel p = new JPanel(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0;
    c.weighty = 0;
    c.gridx = 0;
    c.gridy = 0;
    c.anchor = GridBagConstraints.BASELINE_LEADING;
    c.insets = new Insets(5, 5, 0, 0);
    p.add(new JLabel("Target Column:"), c);
    c.gridx++;
    @SuppressWarnings("unchecked") final ColumnSelectionPanel columnSelectionPanel = new ColumnSelectionPanel(new EmptyBorder(0, 0, 0, 0), NominalValue.class);
    m_selectionPanel = columnSelectionPanel;
    m_selectionPanel.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            updateTargetCategories((DataCell) m_targetReferenceCategory.getSelectedItem());
        }
    });
    p.add(m_selectionPanel, c);
    c.gridx = 0;
    c.gridy++;
    p.add(new JLabel("Reference Category:"), c);
    c.gridx++;
    m_targetReferenceCategory = new JComboBox<>();
    p.add(m_targetReferenceCategory, c);
    c.gridx = 0;
    c.gridy++;
    c.gridwidth = 3;
    c.weightx = 1;
    m_notSortTarget = new JCheckBox("Use order from target column domain (only relevant for output representation)");
    p.add(m_notSortTarget, c);
    m_selectionPanel.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(final ItemEvent e) {
            Object selected = e.getItem();
            if (selected instanceof DataColumnSpec) {
                m_filterPanel.resetHiding();
                m_filterPanel.hideNames((DataColumnSpec) selected);
            }
        }
    });
    return p;
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) ItemEvent(java.awt.event.ItemEvent) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) ActionEvent(java.awt.event.ActionEvent) JLabel(javax.swing.JLabel) JCheckBox(javax.swing.JCheckBox) DataColumnSpec(org.knime.core.data.DataColumnSpec) ActionListener(java.awt.event.ActionListener) DataCell(org.knime.core.data.DataCell) ItemListener(java.awt.event.ItemListener) ColumnSelectionPanel(org.knime.core.node.util.ColumnSelectionPanel) EmptyBorder(javax.swing.border.EmptyBorder)

Aggregations

ColumnSelectionPanel (org.knime.core.node.util.ColumnSelectionPanel)9 JLabel (javax.swing.JLabel)7 JPanel (javax.swing.JPanel)6 GridBagConstraints (java.awt.GridBagConstraints)5 GridBagLayout (java.awt.GridBagLayout)5 Insets (java.awt.Insets)5 ActionEvent (java.awt.event.ActionEvent)5 ActionListener (java.awt.event.ActionListener)5 JCheckBox (javax.swing.JCheckBox)5 JTextField (javax.swing.JTextField)4 JRadioButton (javax.swing.JRadioButton)3 Border (javax.swing.border.Border)3 DoubleValue (org.knime.core.data.DoubleValue)3 NominalValue (org.knime.core.data.NominalValue)3 ItemEvent (java.awt.event.ItemEvent)2 ItemListener (java.awt.event.ItemListener)2 ButtonGroup (javax.swing.ButtonGroup)2 JComboBox (javax.swing.JComboBox)2 EmptyBorder (javax.swing.border.EmptyBorder)2 DataCell (org.knime.core.data.DataCell)2