Search in sources :

Example 61 with NotificationEvent

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

the class VariableListItemWidgetViewImpl method init.

@PostConstruct
public void init() {
    name.setRegExp(StringUtils.ALPHA_NUM_REGEXP, StunnerFormsClientFieldsConstants.CONSTANTS.Removed_invalid_characters_from_name(), StunnerFormsClientFieldsConstants.CONSTANTS.Invalid_character_in_name());
    name.addChangeHandler(event -> {
        String value = name.getText();
        if (isDuplicateName(value)) {
            notification.fire(new NotificationEvent(StunnerFormsClientFieldsConstants.CONSTANTS.DuplicatedVariableNameError(value), NotificationEvent.NotificationType.ERROR));
            name.setValue(currentName);
            ValueChangeEvent.fire(name, currentName);
        } else if (isBoundToNodes(currentName)) {
            errorPopupPresenter.showMessage(StunnerFormsClientFieldsConstants.CONSTANTS.RenameDiagramVariableError());
            name.setValue(currentName);
            ValueChangeEvent.fire(name, currentName);
        }
        notifyModelChanged();
    });
    dataTypeComboBox.init(this, true, dataType, customDataType, false, true, CUSTOM_PROMPT, ENTER_TYPE_PROMPT);
    customDataType.setRegExp(StringUtils.ALPHA_NUM_UNDERSCORE_DOT_REGEXP, StunnerFormsClientFieldsConstants.CONSTANTS.Removed_invalid_characters_from_name(), StunnerFormsClientFieldsConstants.CONSTANTS.Invalid_character_in_name());
    customDataType.addKeyDownHandler(this::preventSpaces);
    PopOver.jQuery(variableTagsSettings).popovers();
    setTagTittle("Tags: ");
    variableTagsSettings.onclick = e -> {
        e.preventDefault();
        openOverlayActions();
        return null;
    };
    customTagName.addFocusHandler(focusEvent -> setPreviousCustomValue(customTagName.getValue()));
    customTagName.addKeyDownHandler(this::preventSpaces);
    loadDefaultTagNames();
    setTagsListItems();
}
Also used : NotificationEvent(org.uberfire.workbench.events.NotificationEvent) PostConstruct(javax.annotation.PostConstruct)

Example 62 with NotificationEvent

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

the class ContainerProcessConfigPresenterTest method testSave.

@Test
public void testSave() {
    final String templateKey = "templateKey";
    final String containerKey = "containerKey";
    when(serverTemplateKey.getId()).thenReturn(templateKey);
    when(containerSpecKey.getId()).thenReturn(containerKey);
    when(view.getSaveSuccessMessage()).thenReturn("SUCCESS");
    presenter.save();
    verify(notification).fire(new NotificationEvent("SUCCESS", NotificationEvent.NotificationType.SUCCESS));
    verify(view).disableActions();
    verify(processConfigPresenter).buildProcessConfig();
    final ArgumentCaptor<ProcessConfig> processConfigCaptor = ArgumentCaptor.forClass(ProcessConfig.class);
    verify(specManagementService).updateContainerConfig(eq(templateKey), eq(containerKey), eq(Capability.PROCESS), processConfigCaptor.capture());
    verify(view).enableActions();
    verify(processConfigPresenter).setProcessConfig(processConfigCaptor.getValue());
}
Also used : ProcessConfig(org.kie.server.controller.api.model.spec.ProcessConfig) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) Test(org.junit.Test)

Example 63 with NotificationEvent

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

the class ContainerProcessConfigPresenterTest method testSaveError.

@Test
public void testSaveError() {
    final String templateKey = "templateKey";
    final String containerKey = "containerKey";
    when(serverTemplateKey.getId()).thenReturn(templateKey);
    when(containerSpecKey.getId()).thenReturn(containerKey);
    when(view.getSaveErrorMessage()).thenReturn("ERROR");
    doThrow(new RuntimeException()).when(specManagementService).updateContainerConfig(Mockito.<String>any(), Mockito.<String>any(), Mockito.<Capability>any(), Mockito.<ContainerConfig>any());
    presenter.save();
    verify(notification).fire(new NotificationEvent("ERROR", NotificationEvent.NotificationType.ERROR));
    verify(view).disableActions();
    verify(view).enableActions();
    verify(processConfigPresenter).setProcessConfig(processConfig);
}
Also used : NotificationEvent(org.uberfire.workbench.events.NotificationEvent) Test(org.junit.Test)

Example 64 with NotificationEvent

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

the class BPMNProjectBaseSessionDiagramHandlerTest method verifySaveOrUpdateWithErrors.

protected void verifySaveOrUpdateWithErrors() {
    verify(selectionControl).clearSelection();
    when(translationService.getValue(EditorGenerateSvgFileError)).thenReturn(EditorGenerateSvgFileError);
    verify(diagramService).saveOrUpdateSvg(eq(path), eq(SVG), serviceCallbackCaptor.capture());
    serviceCallbackCaptor.getValue().onError(new ClientRuntimeError("some error"));
    verify(notificationEvent).fire(new NotificationEvent(EditorGenerateSvgFileError, NotificationEvent.NotificationType.ERROR));
}
Also used : ClientRuntimeError(org.kie.workbench.common.stunner.core.client.service.ClientRuntimeError) NotificationEvent(org.uberfire.workbench.events.NotificationEvent)

Example 65 with NotificationEvent

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

the class KieMultipleDocumentEditorRestoreTest method testOnRestore.

@Test
public void testOnRestore() {
    final TestDocument document = createTestDocument();
    final ObservablePath currentPath = document.getCurrentPath();
    final ObservablePath latestPath = mock(ObservablePath.class);
    registerDocument(document);
    activateDocument(document);
    when(versionRecordManager.getCurrentPath()).thenReturn(currentPath);
    when(versionRecordManager.getPathToLatest()).thenReturn(latestPath);
    editor.onRestore(new RestoreEvent(currentPath));
    verify(document, times(1)).setVersion(eq(null));
    verify(document, times(1)).setLatestPath(latestPath);
    verify(document, times(1)).setCurrentPath(latestPath);
    verify(editor, times(2)).initialiseVersionManager(eq(document));
    verify(editor, times(1)).refreshDocument(eq(document));
    verify(notificationEvent, times(1)).fire(any(NotificationEvent.class));
}
Also used : NotificationEvent(org.uberfire.workbench.events.NotificationEvent) RestoreEvent(org.uberfire.ext.editor.commons.version.events.RestoreEvent) ObservablePath(org.uberfire.backend.vfs.ObservablePath) Test(org.junit.Test)

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