Search in sources :

Example 1 with DefaultReexecutionCallback

use of org.knime.core.node.interactive.DefaultReexecutionCallback in project knime-core by knime.

the class InteractiveHiLiteCollectorNodeView method appendAnnotation.

private void appendAnnotation(final String anno, final boolean newColumn) {
    if (anno != null && !anno.isEmpty()) {
        getNodeModel().appendAnnotation(anno, newColumn);
        // FIXME: Put annotation map in view content
        triggerReExecution(new InteractiveHiLiteCollectorViewContent(), false, new DefaultReexecutionCallback());
    }
}
Also used : DefaultReexecutionCallback(org.knime.core.node.interactive.DefaultReexecutionCallback)

Example 2 with DefaultReexecutionCallback

use of org.knime.core.node.interactive.DefaultReexecutionCallback in project knime-core by knime.

the class AbstractWizardNodeView method applyTriggered.

/**
 * @param useAsDefault true if changed values are supposed to be applied as new node default, false otherwise
 * @return true if apply was successful, false otherwise
 * @since 3.4
 */
protected boolean applyTriggered(final boolean useAsDefault) {
    if (!viewInteractionPossible() || !checkSettingsChanged()) {
        return true;
    }
    boolean valid = validateCurrentValueInView();
    if (valid) {
        String jsonString = retrieveCurrentValueFromView();
        try {
            VAL viewValue = getModel().createEmptyViewValue();
            viewValue.loadFromStream(new ByteArrayInputStream(jsonString.getBytes(Charset.forName("UTF-8"))));
            setLastRetrievedValue(viewValue);
            ValidationError error = getModel().validateViewValue(viewValue);
            if (error != null) {
                showValidationErrorInView(error.getError());
                return false;
            }
            if (getModel() instanceof NodeModel) {
                triggerReExecution(viewValue, useAsDefault, new DefaultReexecutionCallback());
            } else {
                getModel().loadViewValue(viewValue, useAsDefault);
            }
            return true;
        } catch (Exception e) {
            LOGGER.error("Could not set error message or trigger re-execution: " + e.getMessage(), e);
            return false;
        }
    } else {
        return false;
    }
}
Also used : NodeModel(org.knime.core.node.NodeModel) DefaultReexecutionCallback(org.knime.core.node.interactive.DefaultReexecutionCallback) ByteArrayInputStream(java.io.ByteArrayInputStream) ValidationError(org.knime.core.node.web.ValidationError)

Aggregations

DefaultReexecutionCallback (org.knime.core.node.interactive.DefaultReexecutionCallback)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 NodeModel (org.knime.core.node.NodeModel)1 ValidationError (org.knime.core.node.web.ValidationError)1