use of javax.swing.AbstractButton in project knime-core by knime.
the class CharsetNamePanel method checkSettings.
/**
* Checks if the settings in the panel are good for applying them.
*
* @return null if all settings are okay, or an error message if settings can't be taken over.
* @since 3.1
*/
public String checkSettings() {
boolean foundIt = false;
Enumeration<AbstractButton> buttons = m_group.getElements();
while (buttons.hasMoreElements()) {
AbstractButton b = buttons.nextElement();
if (b.isSelected()) {
foundIt = true;
if (CUSTOM_LABEL.equals(b.getActionCommand())) {
if ((m_custom.getText() == null) || (m_custom.getText().length() == 0)) {
return "Please enter a character set name";
}
if (!checkCustomCharsetName()) {
return "The entered character set name is not supported by this Java VM";
}
}
break;
}
}
if (!foundIt) {
return "Please select a character set";
}
return null;
}
use of javax.swing.AbstractButton in project knime-core by knime.
the class GUIUtils method createButtonGroupBox.
/**
* @param group the button group to put in a swing box
* @param vertical if the group should be layout vertical
* @param label the label of the swing box
* @param border <code>true</code> if the label should be displayed
* in a surrounding border
* @return a swing box with the buttons of the given group
*/
public static Box createButtonGroupBox(final ButtonGroup group, final boolean vertical, final String label, final boolean border) {
Box buttonBox = null;
if (vertical) {
buttonBox = Box.createVerticalBox();
buttonBox.add(Box.createVerticalGlue());
if (!border && label != null) {
buttonBox.add(new JLabel(label));
buttonBox.add(Box.createVerticalGlue());
}
} else {
buttonBox = Box.createHorizontalBox();
buttonBox.add(Box.createHorizontalGlue());
if (!border && label != null) {
buttonBox.add(new JLabel(label));
buttonBox.add(Box.createHorizontalGlue());
}
}
if (border && label != null) {
buttonBox.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), label));
}
for (final Enumeration<AbstractButton> buttons = group.getElements(); buttons.hasMoreElements(); ) {
final AbstractButton button = buttons.nextElement();
buttonBox.add(button);
if (vertical) {
buttonBox.add(Box.createVerticalGlue());
} else {
buttonBox.add(Box.createHorizontalGlue());
}
}
return buttonBox;
}
use of javax.swing.AbstractButton in project knime-core by knime.
the class RankNodeDialog method loadSettingsFrom.
/**
* {@inheritDoc}
*/
@Override
protected void loadSettingsFrom(final NodeSettingsRO settings, final DataTableSpec[] specs) throws NotConfigurableException {
// Check input spec
if (specs[0] == null || specs[0].getNumColumns() == 0) {
throw new NotConfigurableException("No input table found or no columns found in input table! " + "Please connect the node first or check input table.");
}
final DataTableSpec spec = specs[0];
// load settings models
try {
m_rankColsModel.loadSettingsFrom(settings);
m_rankOrderModel.loadSettingsFrom(settings);
m_groupColsModel.loadSettingsFrom(settings);
m_rankMode.loadSettingsFrom(settings);
m_rankOutColName.loadSettingsFrom(settings);
m_retainRowOrder.loadSettingsFrom(settings);
m_rankAsLong.loadSettingsFrom(settings);
} catch (InvalidSettingsException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
m_rankTableModel.setRowCount(0);
String[] rankColNames = m_rankColsModel.getStringArrayValue();
String[] order = m_rankOrderModel.getStringArrayValue();
m_rankCols.clear();
for (int i = 0; i < rankColNames.length; i++) {
DataColumnSpec colSpec = spec.getColumnSpec(rankColNames[i]);
if (colSpec != null) {
m_rankTableModel.addRow(new Object[] { colSpec, order[i] });
m_rankCols.add(colSpec);
}
}
m_groupTableModel.setRowCount(0);
m_groupCols.clear();
String[] groupColNames = m_groupColsModel.getStringArrayValue();
for (int r = 0; r < groupColNames.length; r++) {
DataColumnSpec colSpec = spec.getColumnSpec(groupColNames[r]);
if (colSpec != null) {
m_groupTableModel.addRow(new Object[] { colSpec });
m_groupCols.add(colSpec);
}
}
removeAllColSpecsFromAvailable();
for (int i = 0; i < spec.getNumColumns(); i++) {
DataColumnSpec colSpec = spec.getColumnSpec(i);
if (m_rankCols.contains(colSpec)) {
addItemRankColEditor(colSpec);
} else if (m_groupCols.contains(colSpec)) {
addItemGroupColEditor(colSpec);
} else {
addColSpec2Available(colSpec);
}
}
// select rank mode:
Enumeration<AbstractButton> radios = m_modusGroup.getElements();
JRadioButton modus = (JRadioButton) radios.nextElement();
while (!modus.getText().equals(m_rankMode.getStringValue())) {
modus.setSelected(false);
modus = (JRadioButton) radios.nextElement();
}
modus.setSelected(true);
// set retain order checkbox
m_retainOrderCheckBox.setSelected(m_retainRowOrder.getBooleanValue());
// set rank out col name text field
m_outColNameTextField.setText(m_rankOutColName.getStringValue());
// set rank as long checkbox
m_rankAsLongCheckBox.setSelected(m_rankAsLong.getBooleanValue());
}
use of javax.swing.AbstractButton in project knime-core by knime.
the class PieProperties method addAggrMethodListener.
/**
* @param listener adds the listener to the aggregation method button
* group
*/
protected void addAggrMethodListener(final ActionListener listener) {
final Enumeration<AbstractButton> buttons = m_aggrMethButtonGrp.getElements();
while (buttons.hasMoreElements()) {
final AbstractButton button = buttons.nextElement();
button.addActionListener(listener);
}
}
use of javax.swing.AbstractButton in project knime-core by knime.
the class PieProperties method addValueScaleListener.
/**
* @param listener the listener to listen if the label display policy has
* changed
*/
protected void addValueScaleListener(final ActionListener listener) {
final Enumeration<AbstractButton> buttons = m_valueScale.getElements();
while (buttons.hasMoreElements()) {
final AbstractButton button = buttons.nextElement();
button.addActionListener(listener);
}
}
Aggregations