Search in sources :

Example 41 with DefaultComboBoxModel

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

the class SendMailNodeDialog method loadSettingsFrom.

/**
 * {@inheritDoc}
 */
@Override
protected void loadSettingsFrom(final NodeSettingsRO settings, final PortObjectSpec[] specs) {
    SendMailConfiguration config = new SendMailConfiguration();
    config.loadConfigurationInDialog(settings);
    setValueInStringHistoryPanel(m_smtpHostPanel, config.getSmtpHost());
    setValueInStringHistoryPanel(m_smtpPortPanel, Integer.toString(config.getSmtpPort()));
    if (m_useAuthenticationChecker.isSelected() != config.isUseAuthentication()) {
        m_useAuthenticationChecker.doClick();
    }
    if (m_useCredentialsChecker.isSelected() != config.isUseCredentials()) {
        m_useCredentialsChecker.doClick();
    }
    DefaultComboBoxModel model = (DefaultComboBoxModel) m_credentialsCombo.getModel();
    model.removeAllElements();
    for (String s : getCredentialsNames()) {
        model.addElement(s);
    }
    m_credentialsCombo.setSelectedItem(config.getCredentialsId());
    setValueInStringHistoryPanel(m_smtpUserPanel, config.getSmtpUser());
    m_smtpPasswordField.setText(config.getSmtpPassword());
    m_connectionSecurityCombo.setSelectedItem(config.getConnectionSecurity());
    m_connectionPriorityCombo.setSelectedItem(config.getPriority());
    setValueInStringHistoryPanel(m_fromPanel, config.getFrom());
    setValueInStringHistoryPanel(m_toPanel, config.getTo());
    setValueInStringHistoryPanel(m_ccPanel, config.getCc());
    setValueInStringHistoryPanel(m_bccPanel, config.getBcc());
    setValueInStringHistoryPanel(m_subjectPanel, config.getSubject());
    DefaultListModel listModel = (DefaultListModel) m_flowVarList.getModel();
    listModel.removeAllElements();
    for (FlowVariable e : getAvailableFlowVariables().values()) {
        listModel.addElement(e);
    }
    m_textArea.setText(config.getText());
    switch(config.getFormat()) {
        case Html:
            m_formatHTMLButton.doClick();
            break;
        case Text:
            m_formatTextButton.doClick();
            break;
        default:
            throw new RuntimeException("Unsupported format");
    }
    URL[] attachedURLs = config.getAttachedURLs();
    m_attachmentList.setSelectedURLs(Arrays.asList(attachedURLs));
}
Also used : DefaultListModel(javax.swing.DefaultListModel) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) URL(java.net.URL) FlowVariable(org.knime.core.node.workflow.FlowVariable)

Example 42 with DefaultComboBoxModel

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

the class ROCNodeDialog method changeClassColumn.

/**
 * Called if the user changed the class column.
 *
 * @param parent the panel which is the parent for message boxes
 */
private void changeClassColumn(final JComponent parent) {
    String selCol = m_classColumn.getSelectedColumn();
    ((DefaultComboBoxModel<DataCell>) m_positiveClass.getModel()).removeAllElements();
    if ((selCol != null) && (m_spec != null)) {
        DataColumnSpec cs = m_spec.getColumnSpec(selCol);
        Set<DataCell> values = cs.getDomain().getValues();
        if (values == null) {
            m_warningLabel.setForeground(Color.RED);
            m_warningLabel.setText(" Column '" + selCol + "' contains no possible values");
            return;
        }
        if (values.size() > 2) {
            m_warningLabel.setForeground(ORANGE);
            m_warningLabel.setText(" Column '" + selCol + "' contains more than two possible values");
        } else {
            m_warningLabel.setText("");
        }
        for (DataCell cell : values) {
            m_positiveClass.addItem(cell);
        }
        parent.revalidate();
    }
}
Also used : DataColumnSpec(org.knime.core.data.DataColumnSpec) DataCell(org.knime.core.data.DataCell) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel)

Example 43 with DefaultComboBoxModel

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

the class ColumnRowFilterPanel method selectedColChanged.

/**
 * Called when the user selects a new column.
 */
protected void selectedColChanged() {
    // enable/disable the deep filtering option if the selected column is a collection column
    updateDeepFiltering();
    /*
         * fill the regExpr combo with the new possible values
         */
    // de-register the item listener - we are changing the selection
    m_regExpr.removeItemListener(this);
    String oldVal = (String) m_regExpr.getEditor().getItem();
    m_regExpr.setModel(new DefaultComboBoxModel(getPossibleValuesOfSelectedColumn()));
    m_regExpr.setSelectedItem(oldVal);
    // register us again with the regExpr box
    m_regExpr.addItemListener(this);
    regExprChanged();
    /*
         * trigger bounds check
         */
    boundsChanged();
}
Also used : DefaultComboBoxModel(javax.swing.DefaultComboBoxModel)

Example 44 with DefaultComboBoxModel

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

the class FileReaderNodeDialog method loadDelimSettings.

/**
 * Loads the settings from the global settings object into the delimiter box
 * and creates the basicDelim vector.
 */
private void loadDelimSettings() {
    if (m_insideDelimChange) {
        return;
    }
    m_insideLoadDelim = true;
    m_delimField.removeAllItems();
    m_delimField.setModel(new DefaultComboBoxModel(DEFAULT_DELIMS));
    // the above selects the first in the list - which is the <none>.
    m_delimApplied = DEFAULT_DELIMS[0].getDelimiter();
    for (Delimiter delim : m_frSettings.getAllDelimiters()) {
        if (m_frSettings.isRowDelimiter(delim.getDelimiter(), false)) {
            continue;
        }
        if (((DefaultComboBoxModel) m_delimField.getModel()).getIndexOf(delim) < 0) {
            // add all delimiters to the selection list of the combo box
            m_delimField.addItem(delim);
        }
        m_delimField.setSelectedItem(delim);
        m_delimApplied = delim.getDelimiter();
    }
    m_insideLoadDelim = false;
}
Also used : Delimiter(org.knime.core.util.tokenizer.Delimiter) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel)

Example 45 with DefaultComboBoxModel

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

the class FileReaderNodeDialog method createSettingsPanel.

private JPanel createSettingsPanel() {
    JButton advanced = new JButton("Advanced...");
    int buttonHeight = advanced.getPreferredSize().height;
    m_hasRowHeaders = new JCheckBox("read row IDs");
    m_hasRowHeaders.setToolTipText("Check if the file contains row IDs" + " in the first column");
    m_hasColHeaders = new JCheckBox("read column headers");
    m_hasColHeaders.setToolTipText("Check if the file contains column" + " headers in the first line");
    JLabel deliLabel = new JLabel("Column delimiter:");
    m_delimField = new JComboBox();
    m_delimField.setMaximumSize(new Dimension(70, buttonHeight));
    m_delimField.setMinimumSize(new Dimension(70, buttonHeight));
    m_delimField.setPreferredSize(new Dimension(70, buttonHeight));
    m_delimField.setEditable(true);
    Delimiter[] selDelims = DEFAULT_DELIMS;
    m_delimField.setModel(new DefaultComboBoxModel(selDelims));
    deliLabel.setToolTipText("Specify the data delimiter character(s)");
    m_delimField.setToolTipText("Specify the data delimiter character(s)");
    m_cStyleComment = new JCheckBox("Java-style comments");
    m_cStyleComment.setToolTipText("Check to add support for '//' and " + "\"'/*' and '*/'\" comment");
    m_singleLineComment = new JTextField(2);
    m_singleLineComment.setMaximumSize(new Dimension(55, buttonHeight));
    m_singleLineComment.setMinimumSize(new Dimension(55, buttonHeight));
    m_singleLineComment.setPreferredSize(new Dimension(55, buttonHeight));
    JLabel commentLabel = new JLabel("Single line comment:");
    m_ignoreWS = new JCheckBox("ignore spaces and tabs");
    m_ignoreWS.setToolTipText("If checked, whitespaces (spaces and tabs)" + " will be discarded (if not quoted)");
    JPanel panel = new JPanel();
    panel.setLayout(new GridLayout(3, 3));
    panel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Basic Settings"));
    // top row
    Box rowBox = Box.createHorizontalBox();
    rowBox.add(m_hasRowHeaders);
    rowBox.add(Box.createGlue());
    Box delimBox = Box.createHorizontalBox();
    delimBox.add(Box.createHorizontalStrut(4));
    delimBox.add(deliLabel);
    delimBox.add(Box.createHorizontalStrut(3));
    delimBox.add(m_delimField);
    delimBox.add(Box.createGlue());
    Box advBox = Box.createHorizontalBox();
    advBox.add(Box.createGlue());
    advBox.add(advanced);
    advBox.add(Box.createGlue());
    // middle row
    Box colBox = Box.createHorizontalBox();
    colBox.add(m_hasColHeaders);
    colBox.add(Box.createGlue());
    Box wsBox = Box.createHorizontalBox();
    wsBox.add(m_ignoreWS);
    wsBox.add(Box.createGlue());
    // bottom row
    Box pValBox = Box.createHorizontalBox();
    // placeholder
    pValBox.add(new JLabel(""));
    pValBox.add(Box.createGlue());
    Box cCmtBox = Box.createHorizontalBox();
    cCmtBox.add(m_cStyleComment);
    cCmtBox.add(Box.createGlue());
    Box slcBox = Box.createHorizontalBox();
    slcBox.add(commentLabel);
    slcBox.add(Box.createHorizontalStrut(3));
    slcBox.add(m_singleLineComment);
    slcBox.add(Box.createGlue());
    // now fill the grid: first row
    panel.add(rowBox);
    panel.add(delimBox);
    panel.add(advBox);
    // second row
    panel.add(colBox);
    panel.add(wsBox);
    panel.add(new JLabel(""));
    // third row
    panel.add(pValBox);
    panel.add(cCmtBox);
    panel.add(slcBox);
    int componentsHeight = (2 * COMP_HEIGHT) + 30 + buttonHeight;
    panel.setMaximumSize(new Dimension(PANEL_WIDTH, componentsHeight));
    advanced.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            advancedSettings();
        }
    });
    m_hasRowHeaders.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(final ItemEvent e) {
            rowHeadersSettingsChanged();
        }
    });
    m_hasColHeaders.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(final ItemEvent e) {
            colHeadersSettingsChanged();
        }
    });
    m_cStyleComment.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(final ItemEvent e) {
            commentSettingsChanged();
        }
    });
    m_delimField.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            delimSettingsChanged();
        }
    });
    m_ignoreWS.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(final ItemEvent e) {
            ignoreWSChanged();
        }
    });
    m_singleLineComment.getDocument().addDocumentListener(new DocumentListener() {

        @Override
        public void changedUpdate(final DocumentEvent e) {
            commentSettingsChanged();
        }

        @Override
        public void insertUpdate(final DocumentEvent e) {
            commentSettingsChanged();
        }

        @Override
        public void removeUpdate(final DocumentEvent e) {
            commentSettingsChanged();
        }
    });
    // add a panel for the errors:
    m_errorLabel = new JLabel("");
    m_errorLabel.setForeground(Color.red);
    m_errorDetail = new JLabel("");
    m_errorDetail.setForeground(Color.red);
    JPanel errorBox = new JPanel();
    errorBox.setLayout(new BoxLayout(errorBox, BoxLayout.X_AXIS));
    errorBox.add(Box.createHorizontalGlue());
    errorBox.add(m_errorLabel);
    // reserve a certain height for the (in the beginning invisible) label
    errorBox.add(Box.createVerticalStrut(17));
    errorBox.add(Box.createHorizontalGlue());
    JPanel detailBox = new JPanel();
    detailBox.setLayout(new BoxLayout(detailBox, BoxLayout.X_AXIS));
    detailBox.add(Box.createHorizontalGlue());
    detailBox.add(m_errorDetail);
    // reserve a certain height for the (in the beginning invisible) label
    detailBox.add(Box.createVerticalStrut(17));
    detailBox.add(Box.createHorizontalGlue());
    JPanel result = new JPanel();
    result.setLayout(new BoxLayout(result, BoxLayout.Y_AXIS));
    result.add(panel);
    result.add(errorBox);
    result.add(detailBox);
    return result;
}
Also used : JPanel(javax.swing.JPanel) DocumentListener(javax.swing.event.DocumentListener) ItemEvent(java.awt.event.ItemEvent) JComboBox(javax.swing.JComboBox) Delimiter(org.knime.core.util.tokenizer.Delimiter) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) JComboBox(javax.swing.JComboBox) Box(javax.swing.Box) JCheckBox(javax.swing.JCheckBox) Dimension(java.awt.Dimension) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) JTextField(javax.swing.JTextField) DocumentEvent(javax.swing.event.DocumentEvent) JCheckBox(javax.swing.JCheckBox) GridLayout(java.awt.GridLayout) ActionListener(java.awt.event.ActionListener) ItemListener(java.awt.event.ItemListener)

Aggregations

DefaultComboBoxModel (javax.swing.DefaultComboBoxModel)119 JComboBox (javax.swing.JComboBox)22 JPanel (javax.swing.JPanel)21 JLabel (javax.swing.JLabel)17 ActionEvent (java.awt.event.ActionEvent)15 ActionListener (java.awt.event.ActionListener)15 JButton (javax.swing.JButton)15 Insets (java.awt.Insets)14 GridBagConstraints (java.awt.GridBagConstraints)13 GridBagLayout (java.awt.GridBagLayout)12 Dimension (java.awt.Dimension)11 JTextField (javax.swing.JTextField)11 JCheckBox (javax.swing.JCheckBox)10 JScrollPane (javax.swing.JScrollPane)10 ArrayList (java.util.ArrayList)9 Vector (java.util.Vector)9 JList (javax.swing.JList)9 DataColumnSpec (org.knime.core.data.DataColumnSpec)9 BorderLayout (java.awt.BorderLayout)8 ItemEvent (java.awt.event.ItemEvent)8