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));
}
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();
}
}
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();
}
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;
}
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;
}
Aggregations