Search in sources :

Example 91 with JComboBox

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

the class MissingValuePanel method getFixTextField.

/*
     * Helper in constructor, generates the text field to enter the replacement
     * value.
     */
private static JComponent getFixTextField(final ColSetting setting, final DataColumnSpec spec) {
    JComponent fixText;
    // FIX text field
    DataCell fixCell = setting.getFixCell();
    switch(setting.getType()) {
        case ColSetting.TYPE_DOUBLE:
            fixText = new JFormattedTextField();
            ((JFormattedTextField) fixText).setColumns(8);
            Double doubel;
            if (fixCell == null) {
                doubel = new Double(0.0);
            } else {
                double d = ((DoubleValue) fixCell).getDoubleValue();
                doubel = new Double(d);
            }
            ((JFormattedTextField) fixText).setValue(doubel);
            break;
        case ColSetting.TYPE_INT:
            fixText = new JFormattedTextField();
            ((JFormattedTextField) fixText).setColumns(8);
            Integer integer;
            if (fixCell == null) {
                integer = new Integer(0);
            } else {
                int i = ((IntValue) fixCell).getIntValue();
                integer = new Integer(i);
            }
            ((JFormattedTextField) fixText).setValue(integer);
            break;
        case ColSetting.TYPE_STRING:
            DataCell[] vals;
            if (spec != null && spec.getDomain().hasValues()) {
                vals = spec.getDomain().getValues().toArray(new DataCell[0]);
            } else {
                vals = new DataCell[0];
            }
            DefaultComboBoxModel model = new DefaultComboBoxModel(vals);
            fixText = new JComboBox(model);
            ((JComboBox) fixText).setPrototypeDisplayValue("#########");
            ((JComboBox) fixText).setEditable(true);
            ((JComboBox) fixText).setRenderer(new DefaultListCellRenderer() {

                /**
                 * Overridden to set tooltip text properly.
                 * @see DefaultListCellRenderer#getListCellRendererComponent(
                 * JList, Object, int, boolean, boolean)
                 */
                @Override
                public Component getListCellRendererComponent(final JList list, final Object value, final int index, final boolean isSelected, final boolean cellHasFocus) {
                    Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
                    if (c instanceof JComponent) {
                        ((JComponent) c).setToolTipText(value.toString());
                    }
                    return c;
                }
            });
            String string;
            if (fixCell == null) {
                string = "";
            } else {
                string = ((StringValue) fixCell).getStringValue();
            }
            model.setSelectedItem(string);
            break;
        default:
            throw new InternalError("No such type");
    }
    return fixText;
}
Also used : JComboBox(javax.swing.JComboBox) JComponent(javax.swing.JComponent) JFormattedTextField(javax.swing.JFormattedTextField) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) DoubleValue(org.knime.core.data.DoubleValue) DefaultListCellRenderer(javax.swing.DefaultListCellRenderer) DataCell(org.knime.core.data.DataCell) JComponent(javax.swing.JComponent) Component(java.awt.Component) IntValue(org.knime.core.data.IntValue) JList(javax.swing.JList)

Example 92 with JComboBox

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

the class MissingValuePanel method getSettings.

/**
 * Get the settings currently entered in the dialog.
 *
 * @return the current settings
 */
public ColSetting getSettings() {
    int method;
    if (m_nothingButton.isSelected()) {
        method = ColSetting.METHOD_NO_HANDLING;
    } else if (m_removeButton.isSelected()) {
        method = ColSetting.METHOD_IGNORE_ROWS;
    } else if (m_fixButton != null && m_fixButton.isSelected()) {
        method = ColSetting.METHOD_FIX_VAL;
        DataCell cell;
        switch(m_setting.getType()) {
            case ColSetting.TYPE_INT:
                Object value = ((JFormattedTextField) m_fixText).getValue();
                cell = new IntCell(((Number) value).intValue());
                break;
            case ColSetting.TYPE_DOUBLE:
                value = ((JFormattedTextField) m_fixText).getValue();
                cell = new DoubleCell(((Number) value).doubleValue());
                break;
            case ColSetting.TYPE_STRING:
                value = ((JComboBox) m_fixText).getEditor().getItem();
                cell = new StringCell(value.toString());
                break;
            default:
                throw new RuntimeException("You shouldn't have come here.");
        }
        m_setting.setFixCell(cell);
    } else if (m_maxButton != null && m_maxButton.isSelected()) {
        method = ColSetting.METHOD_MAX;
    } else if (m_minButton != null && m_minButton.isSelected()) {
        method = ColSetting.METHOD_MIN;
    } else if (m_meanButton != null && m_meanButton.isSelected()) {
        method = ColSetting.METHOD_MEAN;
    } else if (m_mostFrequentButton != null && m_mostFrequentButton.isSelected()) {
        method = ColSetting.METHOD_MOST_FREQUENT;
    } else {
        assert false : "One button must be selected.";
        method = ColSetting.METHOD_NO_HANDLING;
    }
    m_setting.setMethod(method);
    return m_setting;
}
Also used : JComboBox(javax.swing.JComboBox) StringCell(org.knime.core.data.def.StringCell) DoubleCell(org.knime.core.data.def.DoubleCell) JFormattedTextField(javax.swing.JFormattedTextField) DataCell(org.knime.core.data.DataCell) IntCell(org.knime.core.data.def.IntCell)

Example 93 with JComboBox

use of javax.swing.JComboBox in project vcell by virtualcell.

the class MIRIAMAnnotationEditor method getJComboBoxQualifier.

/**
 * This method initializes jComboBoxQualifier
 *
 * @return javax.swing.JComboBox
 */
private JComboBox getJComboBoxQualifier() {
    if (jComboBoxQualifier == null) {
        jComboBoxQualifier = new JComboBox();
        jComboBoxQualifier.setModel(getQualifierComboBoxModel());
    }
    return jComboBoxQualifier;
}
Also used : JComboBox(javax.swing.JComboBox)

Example 94 with JComboBox

use of javax.swing.JComboBox in project vcell by virtualcell.

the class MIRIAMAnnotationEditor method getJComboBoxURI.

/**
 * This method initializes jComboBoxURI
 *
 * @return javax.swing.JComboBox
 */
private JComboBox getJComboBoxURI() {
    if (jComboBoxURI == null) {
        jComboBoxURI = new JComboBox();
        DefaultComboBoxModel defaultComboBoxModel = new DefaultComboBoxModel();
        for (DataType dataType : vcMetaData.getMiriamManager().getAllDataTypes().values()) {
            defaultComboBoxModel.addElement(dataType);
        }
        jComboBoxURI.setModel(defaultComboBoxModel);
        jComboBoxURI.setRenderer(new DefaultListCellRenderer() {

            public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
                return super.getListCellRendererComponent(list, ((DataType) value).getDataTypeName(), index, isSelected, cellHasFocus);
            }
        });
    }
    return jComboBoxURI;
}
Also used : JComboBox(javax.swing.JComboBox) DefaultListCellRenderer(javax.swing.DefaultListCellRenderer) DataType(cbit.vcell.biomodel.meta.MiriamManager.DataType) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) Component(java.awt.Component) JList(javax.swing.JList)

Example 95 with JComboBox

use of javax.swing.JComboBox in project vcell by virtualcell.

the class ParameterEstimationRunTaskPanel method getOptimizationMethodComboBox.

/**
 * Return the SolverTypeComboBox property value.
 * @return javax.swing.JComboBox
 */
private JComboBox getOptimizationMethodComboBox() {
    if (optimizationMethodComboBox == null) {
        try {
            optimizationMethodComboBox = new JComboBox();
            optimizationMethodComboBox.setName("SolverTypeComboBox");
        } catch (Throwable ivjExc) {
            handleException(ivjExc);
        }
    }
    return optimizationMethodComboBox;
}
Also used : JComboBox(javax.swing.JComboBox)

Aggregations

JComboBox (javax.swing.JComboBox)226 JLabel (javax.swing.JLabel)97 JPanel (javax.swing.JPanel)88 ActionEvent (java.awt.event.ActionEvent)69 ActionListener (java.awt.event.ActionListener)66 JButton (javax.swing.JButton)55 GridBagLayout (java.awt.GridBagLayout)42 GridBagConstraints (java.awt.GridBagConstraints)41 Insets (java.awt.Insets)40 Dimension (java.awt.Dimension)39 JScrollPane (javax.swing.JScrollPane)37 JTextField (javax.swing.JTextField)36 BoxLayout (javax.swing.BoxLayout)34 JCheckBox (javax.swing.JCheckBox)33 DefaultCellEditor (javax.swing.DefaultCellEditor)27 JTable (javax.swing.JTable)26 BorderLayout (java.awt.BorderLayout)25 Component (java.awt.Component)25 TableColumn (javax.swing.table.TableColumn)23 DefaultComboBoxModel (javax.swing.DefaultComboBoxModel)22