Search in sources :

Example 6 with StringParameter

use of com.genericworkflownodes.knime.parameter.StringParameter 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)

Example 7 with StringParameter

use of com.genericworkflownodes.knime.parameter.StringParameter in project GenericKnimeNodes by genericworkflownodes.

the class GalaxyNodeConfigurationReader method processParameter.

private void processParameter(Node n) throws Exception {
    Parameter<?> ret = null;
    String type = n.valueOf("@type");
    if (type.equals("")) {
        throw new Exception("type information for parameter not set");
    }
    String key = n.valueOf("@name");
    String val = n.valueOf("@value");
    System.out.println("processing param " + key + " type:" + type + " value: " + val);
    if (type.equals("integer")) {
        ret = new IntegerParameter(key, val);
    }
    if (type.equals("float")) {
        ret = new DoubleParameter(key, val);
    }
    if (type.equals("boolean")) {
        ret = new BoolParameter(key, val);
    }
    if (type.equals("text")) {
        ret = new StringParameter(key, val);
    }
    if (type.equals("select")) {
        List<Node> options = DOMHelper.selectNodes(n, "option");
        List<String> opts = new ArrayList<String>();
        List<String> labs = new ArrayList<String>();
        for (Node option : options) {
            String optval = option.valueOf("@value");
            String label = option.valueOf("text()");
            opts.add(optval);
            labs.add(label);
        }
        ret = new StringChoiceParameter(key, opts, labs);
        ((StringChoiceParameter) ret).setValue(val);
        ret.setIsOptional(false);
    }
    String descr = n.valueOf("label/text()");
    if (ret != null) {
        ret.setKey(key);
        ret.setDescription(descr);
    }
    config.addParameter(key, ret);
}
Also used : IntegerParameter(com.genericworkflownodes.knime.parameter.IntegerParameter) StringParameter(com.genericworkflownodes.knime.parameter.StringParameter) DoubleParameter(com.genericworkflownodes.knime.parameter.DoubleParameter) Node(org.dom4j.Node) ArrayList(java.util.ArrayList) StringChoiceParameter(com.genericworkflownodes.knime.parameter.StringChoiceParameter) BoolParameter(com.genericworkflownodes.knime.parameter.BoolParameter)

Example 8 with StringParameter

use of com.genericworkflownodes.knime.parameter.StringParameter in project GenericKnimeNodes by genericworkflownodes.

the class CLICommandGenerator method handleListParameter.

private void handleListParameter(final List<List<? extends CommandLineElement>> extractedParameterValues, final ListParameter listParameter) {
    final int nValues = listParameter.getStrings().size();
    final String key = ((Parameter<?>) listParameter).getKey();
    final List<CommandLineElement> tmpList = new LinkedList<CommandLineElement>();
    // there's only one element in the list
    if (nValues > 1) {
        int sequence = 0;
        for (final String value : listParameter.getStrings()) {
            final CommandLineElement commandLineElement;
            if (listParameter instanceof IFileParameter) {
                commandLineElement = new CommandLineFile(new FileParameter(key, value));
            } else {
                commandLineElement = new CommandLineParameter(new StringParameter(key, value));
            }
            commandLineElement.setSequenceNumber(sequence++);
            tmpList.add(commandLineElement);
        }
    } else {
        // only one value in the list, no need to use sequence numbers
        final String value = listParameter.getStrings().get(0);
        if (listParameter instanceof IFileParameter) {
            tmpList.add(new CommandLineFile(new FileParameter(key, value)));
        } else {
            tmpList.add(new CommandLineParameter(new StringParameter(key, value)));
        }
    }
    extractedParameterValues.add(tmpList);
}
Also used : IFileParameter(com.genericworkflownodes.knime.parameter.IFileParameter) StringParameter(com.genericworkflownodes.knime.parameter.StringParameter) CommandLineParameter(com.genericworkflownodes.knime.commandline.impl.CommandLineParameter) CommandLineFile(com.genericworkflownodes.knime.commandline.impl.CommandLineFile) ListParameter(com.genericworkflownodes.knime.parameter.ListParameter) BoolParameter(com.genericworkflownodes.knime.parameter.BoolParameter) FileParameter(com.genericworkflownodes.knime.parameter.FileParameter) CommandLineParameter(com.genericworkflownodes.knime.commandline.impl.CommandLineParameter) StringParameter(com.genericworkflownodes.knime.parameter.StringParameter) Parameter(com.genericworkflownodes.knime.parameter.Parameter) IFileParameter(com.genericworkflownodes.knime.parameter.IFileParameter) CommandLineFixedString(com.genericworkflownodes.knime.commandline.impl.CommandLineFixedString) CommandLineElement(com.genericworkflownodes.knime.commandline.CommandLineElement) FileParameter(com.genericworkflownodes.knime.parameter.FileParameter) IFileParameter(com.genericworkflownodes.knime.parameter.IFileParameter) LinkedList(java.util.LinkedList)

Aggregations

StringParameter (com.genericworkflownodes.knime.parameter.StringParameter)8 BoolParameter (com.genericworkflownodes.knime.parameter.BoolParameter)7 StringChoiceParameter (com.genericworkflownodes.knime.parameter.StringChoiceParameter)7 DoubleParameter (com.genericworkflownodes.knime.parameter.DoubleParameter)4 IntegerParameter (com.genericworkflownodes.knime.parameter.IntegerParameter)3 ListParameter (com.genericworkflownodes.knime.parameter.ListParameter)3 Test (org.junit.Test)3 INodeConfiguration (com.genericworkflownodes.knime.config.INodeConfiguration)2 ParameterVerifier (com.genericworkflownodes.knime.generic_node.dialogs.param_dialog.verifier.ParameterVerifier)2 IntegerListParameter (com.genericworkflownodes.knime.parameter.IntegerListParameter)2 TestDataSource (com.genericworkflownodes.knime.test.data.TestDataSource)2 CommandLineElement (com.genericworkflownodes.knime.commandline.CommandLineElement)1 CommandLineFile (com.genericworkflownodes.knime.commandline.impl.CommandLineFile)1 CommandLineFixedString (com.genericworkflownodes.knime.commandline.impl.CommandLineFixedString)1 CommandLineParameter (com.genericworkflownodes.knime.commandline.impl.CommandLineParameter)1 GalaxyNodeConfigurationReader (com.genericworkflownodes.knime.config.impl.GalaxyNodeConfigurationReader)1 CTDConfigurationReader (com.genericworkflownodes.knime.config.reader.CTDConfigurationReader)1 CTDHandler (com.genericworkflownodes.knime.config.reader.handler.CTDHandler)1 ListEditorComponent (com.genericworkflownodes.knime.generic_node.dialogs.param_dialog.list_editor.ListEditorComponent)1 FileParameter (com.genericworkflownodes.knime.parameter.FileParameter)1