Search in sources :

Example 46 with Command

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

the class OrganizationalUnitPopUpPresenter method saveCreation.

void saveCreation(final String name, final String defaultGroupId, final String owner) {
    final Command saveCommand = () -> {
        final Collection<Repository> repositories = new ArrayList<>();
        final List<String> contributors = contributorsManagementPresenter.getSelectedContributorsUserNames();
        final RemoteCallback<OrganizationalUnit> successCallback = (OrganizationalUnit newOrganizationalUnit) -> {
            afterCreateOrganizationalUnitEvent.fire(new AfterCreateOrganizationalUnitEvent(newOrganizationalUnit));
            view.hideBusyIndicator();
            notificationEvent.fire(new NotificationEvent(view.getSaveSuccessMessage(), NotificationEvent.NotificationType.SUCCESS));
            view.hide();
        };
        final HasBusyIndicatorDefaultErrorCallback errorCallback = new HasBusyIndicatorDefaultErrorCallback(view);
        organizationalUnitService.call(successCallback, errorCallback).createOrganizationalUnit(name, owner, defaultGroupId, repositories, contributors);
    };
    validateDuplicatedOrganizationalUnit(name, saveCommand);
}
Also used : OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) Command(org.uberfire.mvp.Command) AfterCreateOrganizationalUnitEvent(org.guvnor.structure.events.AfterCreateOrganizationalUnitEvent) HasBusyIndicatorDefaultErrorCallback(org.uberfire.ext.widgets.common.client.callbacks.HasBusyIndicatorDefaultErrorCallback) Collection(java.util.Collection) ArrayList(java.util.ArrayList) List(java.util.List) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback)

Example 47 with Command

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

the class AddProjectPopUpPresenter method validateFields.

private void validateFields(final String name, final String groupId, final String artifactId, final String version, final Command successCallback) {
    final Command validateVersion = () -> validateVersion(version, successCallback);
    final Command validateArtifactId = () -> validateArtifactId(artifactId, validateVersion);
    final Command validateGroupId = () -> validateGroupId(groupId, validateArtifactId);
    validateName(name, view.isAdvancedOptionsSelected() ? validateGroupId : successCallback);
}
Also used : Command(org.uberfire.mvp.Command)

Example 48 with Command

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

the class EmptyAssetsScreenTest method setUp.

@Before
public void setUp() {
    this.emptyAssetsScreen = spy(new EmptyAssetsScreen(this.view, this.newFileUploader, this.newResourcePresenter, this.projectController, this.libraryPlaces));
    Command command = mock(Command.class);
    doNothing().when(command).execute();
    when(this.newFileUploader.getCommand(any())).thenReturn(command);
}
Also used : Command(org.uberfire.mvp.Command) Before(org.junit.Before)

Example 49 with Command

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

the class DataObjectBrowser method openDataObject.

private void openDataObject(final DataObject dataObject) {
    final Path objectPath = getContext().getDataObjectPath(dataObject.getClassName());
    if (objectPath != null) {
        view.showBusyIndicator(org.kie.workbench.common.widgets.client.resources.i18n.CommonConstants.INSTANCE.Loading());
        modelerService.call(new RemoteCallback<Boolean>() {

            @Override
            public void callback(Boolean exists) {
                view.hideBusyIndicator();
                if (Boolean.TRUE.equals(exists)) {
                    placeManager.goTo(new PathPlaceRequest(objectPath));
                } else {
                    view.showYesNoCancelPopup(CommonConstants.INSTANCE.Warning(), Constants.INSTANCE.objectBrowser_message_file_not_exists_or_renamed(objectPath.toURI()), new Command() {

                        @Override
                        public void execute() {
                        // do nothing.
                        }
                    }, CommonConstants.INSTANCE.Close(), ButtonType.WARNING, null, null, null, null, null, null);
                }
            }
        }, new DataModelerErrorCallback(CommonConstants.INSTANCE.ExceptionNoSuchFile0(objectPath.toURI()))).exists(objectPath);
    }
}
Also used : Path(org.uberfire.backend.vfs.Path) DataModelCommand(org.kie.workbench.common.screens.datamodeller.client.command.DataModelCommand) Command(org.uberfire.mvp.Command) AddPropertyCommand(org.kie.workbench.common.screens.datamodeller.client.command.AddPropertyCommand) PathPlaceRequest(org.uberfire.mvp.impl.PathPlaceRequest) DataModelerErrorCallback(org.kie.workbench.common.screens.datamodeller.client.DataModelerErrorCallback) RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback)

Example 50 with Command

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

the class JPADataObjectEditor method onEntityFieldChange.

@Override
public void onEntityFieldChange(String newValue) {
    if (getDataObject() != null) {
        final Boolean doAdd = Boolean.parseBoolean(newValue);
        if (doAdd) {
            if (!hasIdField(getDataObject())) {
                List<ObjectProperty> configurableFields = persistenceConfigurableFields(getDataObject());
                String message = buildOnSetPersistableRefactoringMessage(false, configurableFields);
                view.showYesNoCancelPopup(CommonConstants.INSTANCE.Warning(), message, new Command() {

                    @Override
                    public void execute() {
                        doEntityFieldChange(doAdd, true);
                    }
                }, Constants.INSTANCE.persistence_domain_objectEditor_add_identifier_action(), ButtonType.PRIMARY, new Command() {

                    @Override
                    public void execute() {
                        doEntityFieldChange(doAdd, false);
                    }
                }, Constants.INSTANCE.persistence_domain_objectEditor_dont_add_identifier_action(), ButtonType.DANGER, new Command() {

                    @Override
                    public void execute() {
                        updateEntityField(null);
                        loadPropertyEditor();
                    }
                }, CommonConstants.INSTANCE.Cancel(), ButtonType.DEFAULT);
            } else {
                doEntityFieldChange(doAdd, false);
            }
        } else {
            doEntityFieldChange(doAdd, false);
        }
    }
}
Also used : ObjectProperty(org.kie.workbench.common.services.datamodeller.core.ObjectProperty) DataModelCommand(org.kie.workbench.common.screens.datamodeller.client.command.DataModelCommand) Command(org.uberfire.mvp.Command)

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