Search in sources :

Example 1 with EditorToolbar

use of org.kie.workbench.common.stunner.client.widgets.toolbar.impl.EditorToolbar in project kie-wb-common by kiegroup.

the class SessionDiagramEditorScreen method validateAndSave.

private void validateAndSave() {
    final Command save = this::save;
    final EditorToolbar toolbar = (EditorToolbar) presenter.getToolbar();
    toolbar.getValidateToolbarCommand().execute(new ClientSessionCommand.Callback<Collection<DiagramElementViolation<RuleViolation>>>() {

        @Override
        public void onSuccess() {
            log(Level.INFO, "Validation success.");
            save.execute();
        }

        @Override
        public void onError(final Collection<DiagramElementViolation<RuleViolation>> violations) {
            log(Level.WARNING, "Validation failed [violations=" + violations.toString() + "].");
            // Allow saving when only warnings founds.
            final Violation.Type maxSeverity = ValidationUtils.getMaxSeverity(violations);
            if (!maxSeverity.equals(Violation.Type.ERROR)) {
                save.execute();
            }
        }
    });
}
Also used : ClientSessionCommand(org.kie.workbench.common.stunner.core.client.session.command.ClientSessionCommand) Command(org.uberfire.mvp.Command) Collection(java.util.Collection) DiagramElementViolation(org.kie.workbench.common.stunner.core.validation.DiagramElementViolation) RuleViolation(org.kie.workbench.common.stunner.core.rule.RuleViolation) EditorToolbar(org.kie.workbench.common.stunner.client.widgets.toolbar.impl.EditorToolbar) ClientSessionCommand(org.kie.workbench.common.stunner.core.client.session.command.ClientSessionCommand)

Example 2 with EditorToolbar

use of org.kie.workbench.common.stunner.client.widgets.toolbar.impl.EditorToolbar in project kie-wb-common by kiegroup.

the class SessionDiagramEditorScreen method validateAndSave.

private void validateAndSave() {
    final Command save = this::save;
    final EditorToolbar toolbar = (EditorToolbar) presenter.getToolbar();
    toolbar.getValidateToolbarCommand().execute(new ClientSessionCommand.Callback<Collection<DiagramElementViolation<RuleViolation>>>() {

        @Override
        public void onSuccess() {
            log(Level.INFO, "Validation success.");
            save.execute();
        }

        @Override
        public void onError(final Collection<DiagramElementViolation<RuleViolation>> violations) {
            log(Level.WARNING, "Validation failed [violations=" + violations.toString() + "].");
            // Allow saving when only warnings founds.
            final Violation.Type maxSeverity = ValidationUtils.getMaxSeverity(violations);
            if (!maxSeverity.equals(Violation.Type.ERROR)) {
                save.execute();
            }
        }
    });
}
Also used : ClientSessionCommand(org.kie.workbench.common.stunner.core.client.session.command.ClientSessionCommand) Command(org.uberfire.mvp.Command) NavigateToExpressionEditorCommand(org.kie.workbench.common.dmn.client.commands.general.NavigateToExpressionEditorCommand) Collection(java.util.Collection) DiagramElementViolation(org.kie.workbench.common.stunner.core.validation.DiagramElementViolation) RuleViolation(org.kie.workbench.common.stunner.core.rule.RuleViolation) EditorToolbar(org.kie.workbench.common.stunner.client.widgets.toolbar.impl.EditorToolbar) ClientSessionCommand(org.kie.workbench.common.stunner.core.client.session.command.ClientSessionCommand)

Aggregations

Collection (java.util.Collection)2 EditorToolbar (org.kie.workbench.common.stunner.client.widgets.toolbar.impl.EditorToolbar)2 ClientSessionCommand (org.kie.workbench.common.stunner.core.client.session.command.ClientSessionCommand)2 RuleViolation (org.kie.workbench.common.stunner.core.rule.RuleViolation)2 DiagramElementViolation (org.kie.workbench.common.stunner.core.validation.DiagramElementViolation)2 Command (org.uberfire.mvp.Command)2 NavigateToExpressionEditorCommand (org.kie.workbench.common.dmn.client.commands.general.NavigateToExpressionEditorCommand)1