Search in sources :

Example 16 with NotificationEvent

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

the class EnableProviderTypeWizardTest method testEnableProviderFailure.

@Test
public void testEnableProviderFailure() {
    // initialize and start the wizard.
    wizard.start(providerTypeStatus);
    // emulate the user completing the wizard.
    preCompleteWizard();
    prepareServiceCallerError(providerTypeService, providerTypeServiceCaller);
    // emulates the user pressing the finish button
    wizard.complete();
    verify(providerTypeService, times(1)).enableProviderTypes(selectedProviders);
    verify(notification, times(1)).fire(new NotificationEvent(ERROR_MESSAGE, NotificationEvent.NotificationType.ERROR));
}
Also used : NotificationEvent(org.uberfire.workbench.events.NotificationEvent) Test(org.junit.Test)

Example 17 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 Path currentPath) {
    return new RemoteCallback<GenerationResult>() {

        @Override
        public void callback(GenerationResult result) {
            view.hideBusyIndicator();
            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);
        }
    };
}
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 18 with NotificationEvent

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

the class DataModelerScreenPresenter method getRenameSuccessCallback.

private RemoteCallback<Path> getRenameSuccessCallback(final RenamePopUpPresenter.View renamePopupView) {
    return new RemoteCallback<Path>() {

        @Override
        public void callback(final Path targetPath) {
            renamePopupView.hide();
            view.hideBusyIndicator();
            notification.fire(new NotificationEvent(org.kie.workbench.common.widgets.client.resources.i18n.CommonConstants.INSTANCE.ItemRenamedSuccessfully(), NotificationEvent.NotificationType.SUCCESS));
        }
    };
}
Also used : ObservablePath(org.uberfire.backend.vfs.ObservablePath) Path(org.uberfire.backend.vfs.Path) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback)

Example 19 with NotificationEvent

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

the class NewDataSourceDefWizard method getCreateSuccessCallback.

private RemoteCallback<Path> getCreateSuccessCallback() {
    return new RemoteCallback<Path>() {

        @Override
        public void callback(Path path) {
            notification.fire(new NotificationEvent(translationService.format(DataSourceManagementConstants.NewDataSourceDefWizard_DataSourceCreatedMessage, path.toString())));
            NewDataSourceDefWizard.super.complete();
        }
    };
}
Also used : Path(org.uberfire.backend.vfs.Path) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback)

Example 20 with NotificationEvent

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

the class NewDriverWizardTest method testCreate.

/**
 * Emulates a sequence of valid data entering and the wizard completion.
 */
private void testCreate(final Module module) {
    when(path.toString()).thenReturn("target_driver_path");
    when(translationService.format(eq(DataSourceManagementConstants.NewDriverDefWizard_DriverCreatedMessage), anyVararg())).thenReturn("OkMessage");
    if (module != null) {
        when(driverDefService.create(any(DriverDef.class), eq(module))).thenReturn(path);
        driverDefWizard.setModule(module);
    } else {
        when(driverDefService.createGlobal(any(DriverDef.class))).thenReturn(path);
    }
    driverDefWizard.start();
    completeValidDefPage();
    driverDefWizard.complete();
    DriverDef expectedDriverDef = new DriverDef();
    expectedDriverDef.setName(NAME);
    expectedDriverDef.setGroupId(GROUP_ID);
    expectedDriverDef.setArtifactId(ARTIFACT_ID);
    expectedDriverDef.setVersion(VERSION);
    expectedDriverDef.setDriverClass(DRIVER_CLASS);
    if (module != null) {
        verify(driverDefService, times(1)).create(expectedDriverDef, module);
    } else {
        verify(driverDefService, times(1)).createGlobal(expectedDriverDef);
    }
    verify(notificationEvent, times(1)).fire(new NotificationEvent("OkMessage"));
}
Also used : NotificationEvent(org.uberfire.workbench.events.NotificationEvent) DriverDef(org.kie.workbench.common.screens.datasource.management.model.DriverDef)

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