Search in sources :

Example 6 with DoubleParameter

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

the class ParameterVerifier method verify.

/*
     * (non-Javadoc)
     * 
     * @see javax.swing.InputVerifier#verify(javax.swing.JComponent)
     */
@Override
public boolean verify(JComponent input) {
    boolean returnVal = false;
    if (input instanceof JTextField) {
        String inputValue = ((JTextField) input).getText();
        if (m_parameter instanceof DoubleParameter) {
            DoubleParameter dp = (DoubleParameter) m_parameter;
            returnVal = verifyDouble(inputValue, dp.getLowerBound(), dp.getUpperBound());
        } else if (m_parameter instanceof DoubleListParameter) {
            DoubleListParameter dlp = (DoubleListParameter) m_parameter;
            returnVal = verifyDouble(inputValue, dlp.getLowerBound(), dlp.getUpperBound());
        } else if (m_parameter instanceof IntegerParameter) {
            IntegerParameter ip = (IntegerParameter) m_parameter;
            returnVal = verifyInteger(inputValue, ip.getLowerBound(), ip.getUpperBound());
        } else if (m_parameter instanceof IntegerListParameter) {
            IntegerListParameter ilp = (IntegerListParameter) m_parameter;
            returnVal = verifyInteger(inputValue, ilp.getLowerBound(), ilp.getUpperBound());
        } else {
            returnVal = true;
        }
        if (!returnVal) {
            // TODO we currently just show a message box in the ParamCellEditor (that uses the verify function).
            // input.setBackground(Color.PINK);
            LOGGER.debug("Tried to set Parameter to an invalid value. Please see the restrictrions of the parameter.");
        }
    }
    return returnVal;
}
Also used : IntegerParameter(com.genericworkflownodes.knime.parameter.IntegerParameter) DoubleParameter(com.genericworkflownodes.knime.parameter.DoubleParameter) IntegerListParameter(com.genericworkflownodes.knime.parameter.IntegerListParameter) JTextField(javax.swing.JTextField) DoubleListParameter(com.genericworkflownodes.knime.parameter.DoubleListParameter)

Example 7 with DoubleParameter

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

Aggregations

DoubleParameter (com.genericworkflownodes.knime.parameter.DoubleParameter)7 IntegerParameter (com.genericworkflownodes.knime.parameter.IntegerParameter)4 StringChoiceParameter (com.genericworkflownodes.knime.parameter.StringChoiceParameter)4 StringParameter (com.genericworkflownodes.knime.parameter.StringParameter)4 BoolParameter (com.genericworkflownodes.knime.parameter.BoolParameter)3 ParameterVerifier (com.genericworkflownodes.knime.generic_node.dialogs.param_dialog.verifier.ParameterVerifier)2 ListParameter (com.genericworkflownodes.knime.parameter.ListParameter)2 JTextField (javax.swing.JTextField)2 GalaxyNodeConfigurationReader (com.genericworkflownodes.knime.config.impl.GalaxyNodeConfigurationReader)1 ListEditorComponent (com.genericworkflownodes.knime.generic_node.dialogs.param_dialog.list_editor.ListEditorComponent)1 DoubleListParameter (com.genericworkflownodes.knime.parameter.DoubleListParameter)1 IntegerListParameter (com.genericworkflownodes.knime.parameter.IntegerListParameter)1 InvalidParameterValueException (com.genericworkflownodes.knime.parameter.InvalidParameterValueException)1 DoubleRangeExtractor (com.genericworkflownodes.util.ranges.DoubleRangeExtractor)1 ArrayList (java.util.ArrayList)1 JComboBox (javax.swing.JComboBox)1 Node (org.dom4j.Node)1 Test (org.junit.Test)1