Search in sources :

Example 51 with Command

use of org.uberfire.mvp.Command in project kie-wb-common by kiegroup.

the class BPMNClientSessionFactoryTest method init.

@Before
@SuppressWarnings("unchecked")
public void init() {
    doAnswer(invocationOnMock -> {
        Command callback = (Command) invocationOnMock.getArguments()[2];
        callback.execute();
        return null;
    }).when(registry).load(eq(session), eq(metadata), any(Command.class));
    tested = new TestBPMNClientSession();
}
Also used : Command(org.uberfire.mvp.Command) Before(org.junit.Before)

Example 52 with Command

use of org.uberfire.mvp.Command in project kie-wb-common by kiegroup.

the class WorkItemDefinitionClientRegistryTest method testLoad.

@Test
public void testLoad() {
    Command callback = mock(Command.class);
    tested.load(session, metadata, callback);
    verify(registry, times(1)).register(eq(DEF));
    verify(callback, times(1)).execute();
}
Also used : Command(org.uberfire.mvp.Command) Test(org.junit.Test)

Example 53 with Command

use of org.uberfire.mvp.Command in project kie-wb-common by kiegroup.

the class BPMNDiagramEditor method onMigrate.

protected void onMigrate() {
    final Command onMigrateCommand = () -> {
        if (isDirty(getCurrentDiagramHash())) {
            saveAndMigrate();
        } else {
            migrate();
        }
    };
    popupUtil.showConfirmPopup(getTranslationService().getValue(BPMNClientConstants.EditorMigrateActionTitle), getTranslationService().getValue(BPMNClientConstants.EditorMigrateActionWarning), InlineNotification.InlineNotificationType.WARNING, getTranslationService().getValue(BPMNClientConstants.EditorMigrateAction), org.uberfire.client.views.pfly.widgets.Button.ButtonStyleType.PRIMARY, getTranslationService().getValue(BPMNClientConstants.EditorMigrateConfirmAction), onMigrateCommand);
}
Also used : AbstractClientSessionCommand(org.kie.workbench.common.stunner.core.client.session.command.AbstractClientSessionCommand) GenerateProcessFormsSessionCommand(org.kie.workbench.common.stunner.forms.client.session.command.GenerateProcessFormsSessionCommand) GenerateDiagramFormsSessionCommand(org.kie.workbench.common.stunner.forms.client.session.command.GenerateDiagramFormsSessionCommand) ClientSessionCommand(org.kie.workbench.common.stunner.core.client.session.command.ClientSessionCommand) Command(org.uberfire.mvp.Command) GenerateSelectedFormsSessionCommand(org.kie.workbench.common.stunner.forms.client.session.command.GenerateSelectedFormsSessionCommand)

Example 54 with Command

use of org.uberfire.mvp.Command in project kie-wb-common by kiegroup.

the class BPMNDiagramEditorMenuItemsBuilder method newFormsGenerationMenuItem.

public MenuItem newFormsGenerationMenuItem(final Command generateProcessForm, final Command generateAllForms, final Command generateSelectedForms) {
    final DropDownMenu menu = new DropDownMenu() {

        {
            setPull(Pull.RIGHT);
        }
    };
    menu.add(new AnchorListItem(translationService.getValue(BPMNClientConstants.EditorGenerateProcessForm)) {

        {
            setIcon(IconType.LIST_ALT);
            setIconPosition(IconPosition.LEFT);
            setTitle(translationService.getValue(BPMNClientConstants.EditorGenerateProcessForm));
            addClickHandler(event -> generateProcessForm.execute());
        }
    });
    menu.add(new AnchorListItem(translationService.getValue(BPMNClientConstants.EditorGenerateAllForms)) {

        {
            setIcon(IconType.LIST_ALT);
            setIconPosition(IconPosition.LEFT);
            setTitle(translationService.getValue(BPMNClientConstants.EditorGenerateAllForms));
            addClickHandler(event -> generateAllForms.execute());
        }
    });
    menu.add(new AnchorListItem(translationService.getValue(BPMNClientConstants.EditorGenerateSelectionForms)) {

        {
            setIcon(IconType.LIST_ALT);
            setIconPosition(IconPosition.LEFT);
            setTitle(translationService.getValue(BPMNClientConstants.EditorGenerateSelectionForms));
            addClickHandler(event -> generateSelectedForms.execute());
        }
    });
    final IsWidget group = new ButtonGroup() {

        {
            add(new Button() {

                {
                    setToggleCaret(true);
                    setDataToggle(Toggle.DROPDOWN);
                    setIcon(IconType.LIST_ALT);
                    setSize(ButtonSize.SMALL);
                    setTitle(translationService.getValue(BPMNClientConstants.EditorFormGenerationTitle));
                }
            });
            add(menu);
        }
    };
    return MenuUtils.buildItem(group);
}
Also used : AnchorListItem(org.gwtbootstrap3.client.ui.AnchorListItem) IconType(org.gwtbootstrap3.client.ui.constants.IconType) Pull(org.gwtbootstrap3.client.ui.constants.Pull) BPMNClientConstants(org.kie.workbench.common.stunner.bpmn.project.client.resources.BPMNClientConstants) DropDownMenu(org.gwtbootstrap3.client.ui.DropDownMenu) IconPosition(org.gwtbootstrap3.client.ui.constants.IconPosition) Button(org.gwtbootstrap3.client.ui.Button) Inject(javax.inject.Inject) ClientTranslationService(org.kie.workbench.common.stunner.core.client.i18n.ClientTranslationService) Toggle(org.gwtbootstrap3.client.ui.constants.Toggle) MenuUtils(org.kie.workbench.common.stunner.client.widgets.menu.MenuUtils) MenuItem(org.uberfire.workbench.model.menu.MenuItem) ApplicationScoped(javax.enterprise.context.ApplicationScoped) IsWidget(com.google.gwt.user.client.ui.IsWidget) ButtonSize(org.gwtbootstrap3.client.ui.constants.ButtonSize) Command(org.uberfire.mvp.Command) ButtonGroup(org.gwtbootstrap3.client.ui.ButtonGroup) IsWidget(com.google.gwt.user.client.ui.IsWidget) AnchorListItem(org.gwtbootstrap3.client.ui.AnchorListItem) ButtonGroup(org.gwtbootstrap3.client.ui.ButtonGroup) Button(org.gwtbootstrap3.client.ui.Button) DropDownMenu(org.gwtbootstrap3.client.ui.DropDownMenu)

Example 55 with Command

use of org.uberfire.mvp.Command 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)

Aggregations

Command (org.uberfire.mvp.Command)117 Test (org.junit.Test)66 ParameterizedCommand (org.uberfire.mvp.ParameterizedCommand)15 ClientSessionCommand (org.kie.workbench.common.stunner.core.client.session.command.ClientSessionCommand)11 Group (com.ait.lienzo.client.core.shape.Group)9 YesNoCancelPopup (org.uberfire.ext.widgets.common.client.common.popups.YesNoCancelPopup)9 Before (org.junit.Before)8 HasListSelectorControl (org.kie.workbench.common.dmn.client.widgets.grid.controls.list.HasListSelectorControl)7 Path (org.uberfire.backend.vfs.Path)7 ArrayList (java.util.ArrayList)6 Collection (java.util.Collection)6 PlaceRequest (org.uberfire.mvp.PlaceRequest)5 MenuItem (org.uberfire.workbench.model.menu.MenuItem)5 IsWidget (com.google.gwt.user.client.ui.IsWidget)4 Inject (javax.inject.Inject)4 OrganizationalUnit (org.guvnor.structure.organizationalunit.OrganizationalUnit)4 RemoteCallback (org.jboss.errai.common.client.api.RemoteCallback)4 DeleteHeaderValueCommand (org.kie.workbench.common.dmn.client.commands.general.DeleteHeaderValueCommand)4 SetCellValueCommand (org.kie.workbench.common.dmn.client.commands.general.SetCellValueCommand)4 SetHeaderValueCommand (org.kie.workbench.common.dmn.client.commands.general.SetHeaderValueCommand)4