Search in sources :

Example 1 with NotificationEvent

use of org.uberfire.workbench.events.NotificationEvent in project kie-wb-common by kiegroup.

the class BuildExecutor method onBuildDeployProvisionSuccess.

private RemoteCallback onBuildDeployProvisionSuccess(final String containerId, final String containerAlias, final ServerTemplate serverTemplate, final boolean startContainer) {
    return (RemoteCallback<BuildResults>) result -> {
        final Boolean hasErrors = !result.getErrorMessages().isEmpty();
        final NotificationEvent event;
        if (!hasErrors) {
            event = new NotificationEvent(ProjectEditorResources.CONSTANTS.BuildSuccessful(), NotificationEvent.NotificationType.SUCCESS);
            saveContainerSpec(containerId, containerAlias, serverTemplate, startContainer, result.getParameters());
        } else {
            event = new NotificationEvent(ProjectEditorResources.CONSTANTS.BuildFailed(), NotificationEvent.NotificationType.ERROR);
        }
        notificationEvent.fire(event);
        buildResultsEvent.fire(result);
        view.hideBusyIndicator();
        building = false;
    };
}
Also used : NotificationEvent(org.uberfire.workbench.events.NotificationEvent) RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback)

Example 2 with NotificationEvent

use of org.uberfire.workbench.events.NotificationEvent in project kie-wb-common by kiegroup.

the class BuildExecutor method onBuildSuccess.

private RemoteCallback onBuildSuccess() {
    return (RemoteCallback<BuildResults>) result -> {
        final Boolean hasErrors = !result.getErrorMessages().isEmpty();
        final NotificationEvent event;
        if (!hasErrors) {
            event = new NotificationEvent(ProjectEditorResources.CONSTANTS.BuildSuccessful(), NotificationEvent.NotificationType.SUCCESS);
        } else {
            event = new NotificationEvent(ProjectEditorResources.CONSTANTS.BuildFailed(), NotificationEvent.NotificationType.ERROR);
        }
        notificationEvent.fire(event);
        buildResultsEvent.fire(result);
        view.hideBusyIndicator();
        building = false;
    };
}
Also used : NotificationEvent(org.uberfire.workbench.events.NotificationEvent) RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback)

Example 3 with NotificationEvent

use of org.uberfire.workbench.events.NotificationEvent in project kie-wb-common by kiegroup.

the class BuildExecutorTest method verifyNotification.

private void verifyNotification(final String message, final NotificationEvent.NotificationType type) {
    verify(notificationEvent).fire(argThat(new ArgumentMatcher<NotificationEvent>() {

        @Override
        public boolean matches(final Object argument) {
            final NotificationEvent event = (NotificationEvent) argument;
            final String notification = event.getNotification();
            final NotificationEvent.NotificationType type = event.getType();
            return notification.equals(message) && type.equals(type);
        }
    }));
}
Also used : ArgumentMatcher(org.mockito.ArgumentMatcher) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) Matchers.anyString(org.mockito.Matchers.anyString)

Example 4 with NotificationEvent

use of org.uberfire.workbench.events.NotificationEvent in project kie-wb-common by kiegroup.

the class DataModelerScreenPresenter method getSaveSuccessCallback.

private RemoteCallback<GenerationResult> getSaveSuccessCallback(final JavaTypeInfo newTypeInfo, final Path currentPath) {
    return new RemoteCallback<GenerationResult>() {

        @Override
        public void callback(GenerationResult result) {
            view.hideBusyIndicator();
            if (newTypeInfo == null) {
                Boolean oldDirtyStatus = isDirty();
                if (result.hasErrors()) {
                    context.setParseStatus(DataModelerContext.ParseStatus.PARSE_ERRORS);
                    updateEditorView(null);
                    context.setDataObject(null);
                    if (isEditorTabSelected()) {
                        // un common case
                        showParseErrorsDialog(Constants.INSTANCE.modelEditor_message_file_parsing_errors(), true, result.getErrors(), getOnSaveParseErrorCommand());
                    }
                } else {
                    context.setParseStatus(DataModelerContext.ParseStatus.PARSED);
                    if (context.isSourceChanged()) {
                        updateEditorView(result.getDataObject());
                        context.setDataObject(result.getDataObject());
                    }
                    cleanSystemMessages(getCurrentMessageType());
                }
                setSource(result.getSource());
                context.setEditionStatus(DataModelerContext.EditionStatus.NO_CHANGES);
                setOriginalHash(context.getDataObject() != null ? context.getDataObject().hashCode() : null);
                originalSourceHash = getSource().hashCode();
                notification.fire(new NotificationEvent(org.kie.workbench.common.widgets.client.resources.i18n.CommonConstants.INSTANCE.ItemSavedSuccessfully(), NotificationEvent.NotificationType.SUCCESS));
                dataModelerEvent.fire(new DataModelStatusChangeEvent(context.getContextId(), DataModelerEvent.DATA_MODEL_BROWSER, oldDirtyStatus, false));
                dataModelerEvent.fire(new DataModelSaved(context.getContextId(), null));
                versionRecordManager.reloadVersions(currentPath);
            } else {
                notification.fire(new NotificationEvent(org.uberfire.ext.editor.commons.client.resources.i18n.CommonConstants.INSTANCE.ItemRenamedSuccessfully(), NotificationEvent.NotificationType.SUCCESS));
            // If the file was renamed as part of the file saving, don't do anything.
            // A rename event will arrive, the same as for the "Rename" case.
            // and the file will be automatically reloaded.
            }
        }
    };
}
Also used : DataModelStatusChangeEvent(org.kie.workbench.common.screens.datamodeller.events.DataModelStatusChangeEvent) DataModelSaved(org.kie.workbench.common.screens.datamodeller.events.DataModelSaved) GenerationResult(org.kie.workbench.common.screens.datamodeller.model.GenerationResult) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback)

Example 5 with NotificationEvent

use of org.uberfire.workbench.events.NotificationEvent in project kie-wb-common by kiegroup.

the class DataModelerScreenPresenter method onValidate.

protected Command onValidate() {
    return new Command() {

        @Override
        public void execute() {
            // at validation time we must do the same calculation as if we were about to save.
            final DataObject[] modifiedDataObject = new DataObject[1];
            if (isDirty()) {
                if (context.isEditorChanged()) {
                    // at save time the source has always priority over the model.
                    // If the source was properly parsed and the editor has changes, we need to send the DataObject
                    // to the server in order to let the source to be updated prior to save.
                    modifiedDataObject[0] = context.getDataObject();
                } else {
                    // if the source has changes, no update form the UI to the source will be performed.
                    // instead the parsed DataObject must be returned from the server.
                    modifiedDataObject[0] = null;
                }
            }
            modelerService.call(new RemoteCallback<List<org.guvnor.common.services.shared.validation.model.ValidationMessage>>() {

                @Override
                public void callback(final List<org.guvnor.common.services.shared.validation.model.ValidationMessage> results) {
                    if (results == null || results.isEmpty()) {
                        notification.fire(new NotificationEvent(org.kie.workbench.common.widgets.client.resources.i18n.CommonConstants.INSTANCE.ItemValidatedSuccessfully(), NotificationEvent.NotificationType.SUCCESS));
                    } else {
                        validationPopup.showMessages(results);
                    }
                }
            }).validate(getSource(), versionRecordManager.getCurrentPath(), modifiedDataObject[0]);
        }
    };
}
Also used : ValidationMessage(org.guvnor.common.services.shared.validation.model.ValidationMessage) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback) DataObject(org.kie.workbench.common.services.datamodeller.core.DataObject) ParameterizedCommand(org.uberfire.mvp.ParameterizedCommand) Command(org.uberfire.mvp.Command) List(java.util.List)

Aggregations

NotificationEvent (org.uberfire.workbench.events.NotificationEvent)151 Test (org.junit.Test)65 RemoteCallback (org.jboss.errai.common.client.api.RemoteCallback)34 ServerTemplate (org.kie.server.controller.api.model.spec.ServerTemplate)28 ContainerSpec (org.kie.server.controller.api.model.spec.ContainerSpec)22 ServerTemplateList (org.kie.server.controller.api.model.spec.ServerTemplateList)21 List (java.util.List)17 Path (org.uberfire.backend.vfs.Path)17 ErrorCallback (org.jboss.errai.common.client.api.ErrorCallback)16 ArrayList (java.util.ArrayList)14 Event (javax.enterprise.event.Event)14 Inject (javax.inject.Inject)12 ObservablePath (org.uberfire.backend.vfs.ObservablePath)12 PostConstruct (javax.annotation.PostConstruct)9 Observes (javax.enterprise.event.Observes)9 Caller (org.jboss.errai.common.client.api.Caller)9 Map (java.util.Map)8 Promise (elemental2.promise.Promise)7 Arrays (java.util.Arrays)7 Dependent (javax.enterprise.context.Dependent)7