Search in sources :

Example 46 with AbstractButton

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;
}
Also used : AbstractButton(javax.swing.AbstractButton) ButtonModel(javax.swing.ButtonModel)

Example 47 with AbstractButton

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);
        }
    }
}
Also used : NotConfigurableException(org.knime.core.node.NotConfigurableException) AbstractButton(javax.swing.AbstractButton)

Example 48 with AbstractButton

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());
}
Also used : AbstractButton(javax.swing.AbstractButton)

Example 49 with AbstractButton

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());
}
Also used : AbstractButton(javax.swing.AbstractButton) ButtonModel(javax.swing.ButtonModel)

Example 50 with AbstractButton

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);
}
Also used : NotConfigurableException(org.knime.core.node.NotConfigurableException) AbstractButton(javax.swing.AbstractButton) DataColumnSpec(org.knime.core.data.DataColumnSpec) DefaultListModel(javax.swing.DefaultListModel) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) ButtonModel(javax.swing.ButtonModel) FlowVariable(org.knime.core.node.workflow.FlowVariable)

Aggregations

AbstractButton (javax.swing.AbstractButton)50 JLabel (javax.swing.JLabel)8 JPanel (javax.swing.JPanel)8 Component (java.awt.Component)7 ButtonModel (javax.swing.ButtonModel)7 JRadioButton (javax.swing.JRadioButton)5 JButton (javax.swing.JButton)4 Dimension (java.awt.Dimension)3 File (java.io.File)3 ArrayList (java.util.ArrayList)3 NotConfigurableException (org.knime.core.node.NotConfigurableException)3 FlowLayout (java.awt.FlowLayout)2 GridBagConstraints (java.awt.GridBagConstraints)2 Insets (java.awt.Insets)2 ActionEvent (java.awt.event.ActionEvent)2 MouseEvent (java.awt.event.MouseEvent)2 JComboBox (javax.swing.JComboBox)2 JComponent (javax.swing.JComponent)2 JFileChooser (javax.swing.JFileChooser)2 JTextField (javax.swing.JTextField)2