Search in sources :

Example 1 with ListEditorComponent

use of com.genericworkflownodes.knime.generic_node.dialogs.param_dialog.list_editor.ListEditorComponent in project GenericKnimeNodes by genericworkflownodes.

the class ParamCellEditor method getTableCellEditorComponent.

@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
    param = (Parameter<?>) value;
    if (value instanceof StringChoiceParameter) {
        StringChoiceParameter scp = (StringChoiceParameter) value;
        String[] values = new String[scp.getLabels().size()];
        int i = 0;
        for (String s : scp.getLabels()) {
            values[i++] = s;
        }
        choiceComboBox = new JComboBox(values);
        // we need to make sure that we catch all edit operations.
        choiceComboBox.addItemListener(new ChoiceParamItemListener<StringChoiceParameter>(scp));
        choiceComboBox.setSelectedItem(scp.getValue());
        return choiceComboBox;
    }
    if (value instanceof StringParameter || value instanceof DoubleParameter || value instanceof IntegerParameter) {
        field = new JTextField(value.toString());
        field.setInputVerifier(new ParameterVerifier(param));
        return field;
    }
    if (value instanceof BoolParameter) {
        String[] values = new String[] { "true", "false" };
        choiceComboBox = new JComboBox(values);
        choiceComboBox.addItemListener(new ChoiceParamItemListener<BoolParameter>((BoolParameter) param));
        // Make sure that the old value is selected in the beginning.
        choiceComboBox.setSelectedIndex(((BoolParameter) value).getValue() ? 0 : 1);
        return choiceComboBox;
    }
    if (value instanceof ListParameter) {
        listEditorComponent = new ListEditorComponent((ListParameter) param, this);
        return listEditorComponent;
    }
    return null;
}
Also used : IntegerParameter(com.genericworkflownodes.knime.parameter.IntegerParameter) StringParameter(com.genericworkflownodes.knime.parameter.StringParameter) DoubleParameter(com.genericworkflownodes.knime.parameter.DoubleParameter) JComboBox(javax.swing.JComboBox) ListEditorComponent(com.genericworkflownodes.knime.generic_node.dialogs.param_dialog.list_editor.ListEditorComponent) StringChoiceParameter(com.genericworkflownodes.knime.parameter.StringChoiceParameter) JTextField(javax.swing.JTextField) ParameterVerifier(com.genericworkflownodes.knime.generic_node.dialogs.param_dialog.verifier.ParameterVerifier) BoolParameter(com.genericworkflownodes.knime.parameter.BoolParameter) ListParameter(com.genericworkflownodes.knime.parameter.ListParameter)

Aggregations

ListEditorComponent (com.genericworkflownodes.knime.generic_node.dialogs.param_dialog.list_editor.ListEditorComponent)1 ParameterVerifier (com.genericworkflownodes.knime.generic_node.dialogs.param_dialog.verifier.ParameterVerifier)1 BoolParameter (com.genericworkflownodes.knime.parameter.BoolParameter)1 DoubleParameter (com.genericworkflownodes.knime.parameter.DoubleParameter)1 IntegerParameter (com.genericworkflownodes.knime.parameter.IntegerParameter)1 ListParameter (com.genericworkflownodes.knime.parameter.ListParameter)1 StringChoiceParameter (com.genericworkflownodes.knime.parameter.StringChoiceParameter)1 StringParameter (com.genericworkflownodes.knime.parameter.StringParameter)1 JComboBox (javax.swing.JComboBox)1 JTextField (javax.swing.JTextField)1