use of javax.swing.AbstractButton in project vcell by virtualcell.
the class CartoonTool method updateButtonGroup.
public final void updateButtonGroup(ButtonGroup buttonGroup, String actionCommand) {
if (buttonGroup == null) {
return;
}
// if selected button does not have this action command, select the
// first button we find with appropriate action command
String currSelectedString = (buttonGroup.getSelection() != null ? buttonGroup.getSelection().getActionCommand() : null);
if (currSelectedString != null) {
if (currSelectedString.equals(actionCommand)) {
return;
}
}
Enumeration<AbstractButton> buttons = buttonGroup.getElements();
while (buttons.hasMoreElements()) {
ButtonModel button = buttons.nextElement().getModel();
if (button.getActionCommand().equals(actionCommand)) {
button.setSelected(true);
return;
}
}
System.out.println("ERROR: button with actionCommand " + actionCommand + " not found");
return;
}
use of javax.swing.AbstractButton in project knime-core by knime.
the class EditNumericDomainNodeDialogPane method loadSettingsFrom.
/**
* {@inheritDoc}
*/
@Override
protected void loadSettingsFrom(final NodeSettingsRO settings, final DataTableSpec[] specs) throws NotConfigurableException {
if (specs[0].getNumColumns() == 0) {
throw new NotConfigurableException("No data at input.");
}
EditNumericDomainConfiguration forConfig = new EditNumericDomainConfiguration();
forConfig.loadConfigurationInDialog(settings, specs[0]);
m_filterPanel.loadConfiguration(forConfig.getColumnspecFilterConfig(), specs[0]);
m_upperBField.setText(Double.isNaN(forConfig.getUpperBound()) ? "1.0" : Double.toString(forConfig.getUpperBound()));
m_lowerBField.setText(Double.isNaN(forConfig.getLowerBound()) ? "0.0" : Double.toString(forConfig.getLowerBound()));
m_handler = forConfig.getDomainOverflowPolicy();
Enumeration<AbstractButton> elements = m_buttonGrp.getElements();
while (elements.hasMoreElements()) {
AbstractButton abstractButton = elements.nextElement();
if (abstractButton.getActionCommand().equals(m_handler.toString())) {
abstractButton.setSelected(true);
}
}
}
use of javax.swing.AbstractButton in project knime-core by knime.
the class TreeEnsembleShrinkerNodeDialog method loadSettingsFrom.
@Override
protected void loadSettingsFrom(final NodeSettingsRO settings, final PortObjectSpec[] specs) throws NotConfigurableException {
TreeEnsembleShrinkerNodeConfig config = new TreeEnsembleShrinkerNodeConfig();
config.loadInDialog(settings);
String resultSizeType = config.getResultSizeType();
Enumeration<AbstractButton> buttons = m_resultSizeType.getElements();
while (buttons.hasMoreElements()) {
AbstractButton button = buttons.nextElement();
if (button.getActionCommand().equals(resultSizeType)) {
button.setSelected(true);
break;
}
}
m_resultSizeRelative.setValue(config.getResultSizeRelative());
m_resultSizeAbsolute.setValue(config.getResultSizeAbsolute());
m_targetColumn.update((DataTableSpec) specs[1], config.getTargetColumn());
}
use of javax.swing.AbstractButton in project knime-core by knime.
the class DialogComponentButtonGroup method updateComponent.
/**
* {@inheritDoc}
*/
@Override
protected void updateComponent() {
final String val = ((SettingsModelString) getModel()).getStringValue();
final ButtonModel selectedButton = m_buttonGroup.getSelection();
final String actionCommand;
if (selectedButton != null) {
actionCommand = selectedButton.getActionCommand();
} else {
actionCommand = null;
}
boolean update;
if (val == null) {
update = (actionCommand != null);
} else {
update = !val.equals(actionCommand);
}
if (update) {
final Enumeration<AbstractButton> buttons = m_buttonGroup.getElements();
while (buttons.hasMoreElements()) {
final AbstractButton button = buttons.nextElement();
if (button.getActionCommand().equals(val)) {
button.setSelected(true);
}
}
}
// also update the enable status
setEnabledComponents(getModel().isEnabled());
}
use of javax.swing.AbstractButton in project knime-core by knime.
the class JavaScriptingPanel method loadSettingsFrom.
/**
* Load settings from arg.
* @param s To load from.
* @param spec The input spec.
*/
public void loadSettingsFrom(final JavaScriptingSettings s, final DataTableSpec spec) {
String exp = s.getExpression();
String header = s.getHeader();
String rType = s.getReturnType().getName();
boolean isArrayReturn = s.isArrayReturn();
String defaultNewName = m_customizer.getOutputIsVariable() ? "new variable" : "new column";
String newName = s.getColName();
boolean isReplace = s.isReplace();
boolean isTestCompilation = s.isTestCompilationOnDialogClose();
boolean isInsertMissingAsNull = s.isInsertMissingAsNull();
m_currentVersion = s.getExpressionVersion();
m_newNameField.setText("");
// will select newColName only if it is in the spec list
try {
m_replaceColumnCombo.update(spec, newName);
} catch (NotConfigurableException e1) {
NodeLogger.getLogger(getClass()).coding("Combo box throws " + "exception although content is not required", e1);
}
DefaultComboBoxModel cmbModel = (DefaultComboBoxModel) m_replaceVariableCombo.getModel();
cmbModel.removeAllElements();
final Map<String, FlowVariable> availableFlowVariables = m_varProvider.getAvailableFlowVariables();
for (FlowVariable v : availableFlowVariables.values()) {
switch(v.getScope()) {
case Flow:
cmbModel.addElement(v);
break;
default:
}
}
if (isReplace && availableFlowVariables.containsKey(newName)) {
m_replaceVariableCombo.setSelectedItem(availableFlowVariables.get(newName));
}
m_currentSpec = spec;
// whether there are variables or columns available
// -- which of two depends on the customizer
boolean fieldsAvailable;
if (m_customizer.getOutputIsVariable()) {
fieldsAvailable = m_replaceVariableCombo.getModel().getSize() > 0;
} else {
fieldsAvailable = m_replaceColumnCombo.getNrItemsInList() > 0;
}
if (isReplace && fieldsAvailable) {
m_replaceRadio.doClick();
} else {
m_appendRadio.doClick();
String newNameString = (newName != null ? newName : defaultNewName);
m_newNameField.setText(newNameString);
}
m_replaceRadio.setEnabled(fieldsAvailable);
m_headerEdit.setText(header);
m_expEdit.setText(exp);
m_expEdit.requestFocus();
ButtonModel firstButton = null;
for (Enumeration<?> e = m_returnTypeButtonGroup.getElements(); e.hasMoreElements(); ) {
AbstractButton b = (AbstractButton) e.nextElement();
if (firstButton == null) {
firstButton = b.getModel();
}
if (b.getActionCommand().equals(rType)) {
m_returnTypeButtonGroup.setSelected(b.getModel(), true);
}
}
if (m_returnTypeButtonGroup.getSelection() == null) {
m_returnTypeButtonGroup.setSelected(firstButton, true);
}
m_isArrayReturnChecker.setSelected(isArrayReturn);
DefaultListModel listModel = (DefaultListModel) m_colList.getModel();
listModel.removeAllElements();
if (m_currentVersion == Expression.VERSION_1X) {
listModel.addElement(Expression.ROWKEY);
listModel.addElement(Expression.ROWNUMBER);
} else {
listModel.addElement(Expression.ROWID);
listModel.addElement(Expression.ROWINDEX);
listModel.addElement(Expression.ROWCOUNT);
}
for (int i = 0; i < spec.getNumColumns(); i++) {
DataColumnSpec colSpec = spec.getColumnSpec(i);
listModel.addElement(colSpec);
}
DefaultListModel fvListModel = (DefaultListModel) m_flowVarsList.getModel();
fvListModel.removeAllElements();
for (FlowVariable v : availableFlowVariables.values()) {
fvListModel.addElement(v);
}
m_compileOnCloseChecker.setSelected(isTestCompilation);
m_insertMissingAsNullChecker.setSelected(isInsertMissingAsNull);
}
Aggregations