Search in sources :

Example 1 with ColumnPairsSelectionPanel

use of org.knime.core.node.util.ColumnPairsSelectionPanel 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)

Example 2 with ColumnPairsSelectionPanel

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

the class DBJoinerNodeDialog method createJoinPredicateUIControls.

private JPanel createJoinPredicateUIControls() {
    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;
    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(false) {

        private static final long serialVersionUID = 1738914698074362596L;

        @SuppressWarnings("rawtypes")
        @Override
        protected void initComboBox(final DataTableSpec spec, final JComboBox comboBox, final String selected) {
            super.initComboBox(spec, comboBox, selected);
            if (selected == null && comboBox.getModel().getSize() > 0) {
                comboBox.setSelectedIndex(0);
            }
        }
    };
    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)

Example 3 with ColumnPairsSelectionPanel

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

the class PairedTTestNodeDialog method createPanel.

/**
 * Create the configuration panel.
 */
@SuppressWarnings({ "unchecked", "serial" })
private Component createPanel() {
    JPanel p = new JPanel(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.BOTH;
    c.anchor = GridBagConstraints.BASELINE;
    c.insets = new Insets(2, 2, 2, 2);
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 1;
    c.weightx = 0;
    c.weighty = 0;
    Insets leftInsets = new Insets(3, 8, 3, 8);
    Insets rightInsets = new Insets(3, 0, 3, 8);
    Insets leftCategoryInsets = new Insets(11, 8, 3, 8);
    c.gridx = 0;
    c.insets = leftCategoryInsets;
    c.gridwidth = 2;
    c.weightx = 1;
    c.weighty = 1;
    m_columnPairs = new ColumnPairsSelectionPanel() {

        @Override
        protected void initComboBox(final DataTableSpec spec, final JComboBox comboBox, final String selected) {
            DefaultComboBoxModel comboBoxModel = (DefaultComboBoxModel) comboBox.getModel();
            comboBoxModel.removeAllElements();
            for (DataColumnSpec colSpec : spec) {
                if (colSpec.getType().isCompatible(DoubleValue.class)) {
                    comboBoxModel.addElement(colSpec);
                    if (null != selected && colSpec.getName().equals(selected)) {
                        comboBoxModel.setSelectedItem(colSpec);
                    }
                }
            }
        }
    };
    JScrollPane scrollPane = new JScrollPane(m_columnPairs);
    m_columnPairs.setBackground(Color.white);
    Component header = m_columnPairs.getHeaderView("Left Column", "Right Column");
    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);
    c.gridwidth = 1;
    c.weightx = 0;
    c.weighty = 0;
    c.gridx = 0;
    c.gridy++;
    c.insets = leftInsets;
    p.add(new JLabel("Confidence Interval (in %):"), c);
    c.gridx++;
    c.insets = rightInsets;
    m_confidenceIntervalProb = new JTextField("95");
    p.add(m_confidenceIntervalProb, c);
    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) GridBagLayout(java.awt.GridBagLayout) JComboBox(javax.swing.JComboBox) JLabel(javax.swing.JLabel) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) Dimension(java.awt.Dimension) JTextField(javax.swing.JTextField) DataColumnSpec(org.knime.core.data.DataColumnSpec) DoubleValue(org.knime.core.data.DoubleValue) Component(java.awt.Component) ColumnPairsSelectionPanel(org.knime.core.node.util.ColumnPairsSelectionPanel)

Aggregations

Component (java.awt.Component)3 Dimension (java.awt.Dimension)3 GridBagConstraints (java.awt.GridBagConstraints)3 GridBagLayout (java.awt.GridBagLayout)3 Insets (java.awt.Insets)3 JComboBox (javax.swing.JComboBox)3 JPanel (javax.swing.JPanel)3 JScrollPane (javax.swing.JScrollPane)3 DataTableSpec (org.knime.core.data.DataTableSpec)3 ColumnPairsSelectionPanel (org.knime.core.node.util.ColumnPairsSelectionPanel)3 FlowLayout (java.awt.FlowLayout)2 ButtonGroup (javax.swing.ButtonGroup)2 JComponent (javax.swing.JComponent)2 DefaultComboBoxModel (javax.swing.DefaultComboBoxModel)1 JLabel (javax.swing.JLabel)1 JTextField (javax.swing.JTextField)1 DataColumnSpec (org.knime.core.data.DataColumnSpec)1 DoubleValue (org.knime.core.data.DoubleValue)1