Search in sources :

Example 1 with Message

use of org.jboss.errai.bus.client.api.messaging.Message in project kie-wb-common by kiegroup.

the class PopupHelperTest method testGetPopupErrorCallback.

@Test
public void testGetPopupErrorCallback() {
    Message message = mock(Message.class);
    popupHelper.getPopupErrorCallback().error(message, new Exception(MESSAGE));
    verify(popupHelper, times(1)).showErrorPopup(MESSAGE);
}
Also used : Message(org.jboss.errai.bus.client.api.messaging.Message) Test(org.junit.Test)

Example 2 with Message

use of org.jboss.errai.bus.client.api.messaging.Message in project kie-wb-common by kiegroup.

the class ProjectPage method fetchRepository.

private void fetchRepository(final ExampleRepository selectedRepository) {
    examplesService.call(new RemoteCallback<Set<ExampleProject>>() {

        @Override
        public void callback(final Set<ExampleProject> projects) {
            activeView = projectsView;
            model.getProjects().clear();
            model.setSourceRepository(selectedRepository);
            final List<ExampleProject> sortedProjects = sort(projects);
            projectsView.setProjectsInRepository(sortedProjects);
            exampleProjects = sortedProjects;
            pageSelectedEvent.fire(new WizardPageSelectedEvent(ProjectPage.this));
        }
    }, new DefaultErrorCallback() {

        @Override
        public boolean error(final Message message, final Throwable throwable) {
            model.setSourceRepository(null);
            model.getSelectedRepository().setUrlValid(false);
            return super.error(message, throwable);
        }
    }).getProjects(selectedRepository);
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) Message(org.jboss.errai.bus.client.api.messaging.Message) DefaultErrorCallback(org.uberfire.ext.widgets.common.client.callbacks.DefaultErrorCallback) WizardPageSelectedEvent(org.uberfire.ext.widgets.core.client.wizards.WizardPageSelectedEvent) RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback) ExampleProject(org.kie.workbench.common.screens.examples.model.ExampleProject)

Example 3 with Message

use of org.jboss.errai.bus.client.api.messaging.Message in project kie-wb-common by kiegroup.

the class ImportRepositoryPopUpPresenter method importRepository.

public void importRepository() {
    final String repositoryUrl = view.getRepositoryURL();
    if (isEmpty(repositoryUrl)) {
        view.showError(view.getEmptyRepositoryURLValidationMessage());
        return;
    }
    OrganizationalUnit ou = context.getActiveOrganizationalUnit().orElseThrow(() -> new IllegalStateException("Cannot import project without an active organizational unit."));
    view.showBusyIndicator(view.getLoadingMessage());
    libraryService.call((WorkspaceProject project) -> {
        view.hideBusyIndicator();
        view.hide();
        libraryPlaces.goToProject(project);
    }, new DefaultErrorCallback() {

        @Override
        public boolean error(Message message, Throwable throwable) {
            view.hideBusyIndicator();
            view.showError(view.getNoProjectsToImportMessage());
            return false;
        }
    }).importProject(ou, repositoryUrl, view.getUserName(), view.getPassword());
}
Also used : OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) Message(org.jboss.errai.bus.client.api.messaging.Message) DefaultErrorCallback(org.uberfire.ext.widgets.common.client.callbacks.DefaultErrorCallback) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject)

Example 4 with Message

use of org.jboss.errai.bus.client.api.messaging.Message in project kie-wb-common by kiegroup.

the class AssigneeLiveSearchService method search.

@Override
public void search(final String pattern, final int maxResults, final LiveSearchCallback<String> callback) {
    final List<String> filteredCustomEntries;
    if (pattern == null || pattern.isEmpty()) {
        filteredCustomEntries = customEntries;
    } else {
        filteredCustomEntries = customEntries.stream().filter(entry -> entry.contains(pattern)).collect(Collectors.toList());
    }
    RemoteCallback<AbstractEntityManager.SearchResponse<?>> searchResponseRemoteCallback = response -> processFilterResponse(response, filteredCustomEntries, maxResults, callback);
    ErrorCallback<Message> searchErrorCallback = (message, throwable) -> processError(callback);
    SearchRequestImpl request = new SearchRequestImpl(pattern, 1, maxResults);
    if (AssigneeType.USER.equals(type)) {
        userSystemManager.users(searchResponseRemoteCallback, searchErrorCallback).search(request);
    } else {
        userSystemManager.groups(searchResponseRemoteCallback, searchErrorCallback).search(request);
    }
}
Also used : ErrorCallback(org.jboss.errai.common.client.api.ErrorCallback) Group(org.jboss.errai.security.shared.api.Group) Set(java.util.Set) RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback) SearchRequestImpl(org.uberfire.ext.security.management.impl.SearchRequestImpl) Collectors(java.util.stream.Collectors) EntryCreationLiveSearchService(org.uberfire.ext.widgets.common.client.dropdown.EntryCreationLiveSearchService) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) LiveSearchResults(org.uberfire.ext.widgets.common.client.dropdown.LiveSearchResults) Inject(javax.inject.Inject) List(java.util.List) Message(org.jboss.errai.bus.client.api.messaging.Message) Dependent(javax.enterprise.context.Dependent) AbstractEntityManager(org.uberfire.ext.security.management.api.AbstractEntityManager) User(org.jboss.errai.security.shared.api.identity.User) Optional(java.util.Optional) LiveSearchCallback(org.uberfire.ext.widgets.common.client.dropdown.LiveSearchCallback) AssigneeType(org.kie.workbench.common.stunner.bpmn.forms.model.AssigneeType) ClientUserSystemManager(org.uberfire.ext.security.management.client.ClientUserSystemManager) Message(org.jboss.errai.bus.client.api.messaging.Message) SearchRequestImpl(org.uberfire.ext.security.management.impl.SearchRequestImpl)

Example 5 with Message

use of org.jboss.errai.bus.client.api.messaging.Message in project kie-wb-common by kiegroup.

the class AssigneeLiveSearchService method searchEntry.

@Override
public void searchEntry(String key, LiveSearchCallback<String> callback) {
    SearchRequestImpl request = new SearchRequestImpl(key, 1, 1);
    ErrorCallback<Message> searchErrorCallback = (message, throwable) -> processError(callback);
    RemoteCallback<AbstractEntityManager.SearchResponse<?>> searchResponseRemoteCallback = response -> searchEntry(key, response, callback);
    if (AssigneeType.USER.equals(type)) {
        userSystemManager.users(searchResponseRemoteCallback, searchErrorCallback).search(request);
    } else {
        userSystemManager.groups(searchResponseRemoteCallback, searchErrorCallback).search(request);
    }
}
Also used : ErrorCallback(org.jboss.errai.common.client.api.ErrorCallback) Group(org.jboss.errai.security.shared.api.Group) Set(java.util.Set) RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback) SearchRequestImpl(org.uberfire.ext.security.management.impl.SearchRequestImpl) Collectors(java.util.stream.Collectors) EntryCreationLiveSearchService(org.uberfire.ext.widgets.common.client.dropdown.EntryCreationLiveSearchService) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) LiveSearchResults(org.uberfire.ext.widgets.common.client.dropdown.LiveSearchResults) Inject(javax.inject.Inject) List(java.util.List) Message(org.jboss.errai.bus.client.api.messaging.Message) Dependent(javax.enterprise.context.Dependent) AbstractEntityManager(org.uberfire.ext.security.management.api.AbstractEntityManager) User(org.jboss.errai.security.shared.api.identity.User) Optional(java.util.Optional) LiveSearchCallback(org.uberfire.ext.widgets.common.client.dropdown.LiveSearchCallback) AssigneeType(org.kie.workbench.common.stunner.bpmn.forms.model.AssigneeType) ClientUserSystemManager(org.uberfire.ext.security.management.client.ClientUserSystemManager) Message(org.jboss.errai.bus.client.api.messaging.Message) SearchRequestImpl(org.uberfire.ext.security.management.impl.SearchRequestImpl)

Aggregations

Message (org.jboss.errai.bus.client.api.messaging.Message)7 RemoteCallback (org.jboss.errai.common.client.api.RemoteCallback)5 ArrayList (java.util.ArrayList)4 List (java.util.List)4 Set (java.util.Set)3 Optional (java.util.Optional)2 TreeSet (java.util.TreeSet)2 Collectors (java.util.stream.Collectors)2 Dependent (javax.enterprise.context.Dependent)2 Inject (javax.inject.Inject)2 BusErrorCallback (org.jboss.errai.bus.client.api.BusErrorCallback)2 ErrorCallback (org.jboss.errai.common.client.api.ErrorCallback)2 Group (org.jboss.errai.security.shared.api.Group)2 User (org.jboss.errai.security.shared.api.identity.User)2 AssigneeType (org.kie.workbench.common.stunner.bpmn.forms.model.AssigneeType)2 DataTypesService (org.kie.workbench.common.stunner.bpmn.service.DataTypesService)2 AbstractEntityManager (org.uberfire.ext.security.management.api.AbstractEntityManager)2 ClientUserSystemManager (org.uberfire.ext.security.management.client.ClientUserSystemManager)2 SearchRequestImpl (org.uberfire.ext.security.management.impl.SearchRequestImpl)2 DefaultErrorCallback (org.uberfire.ext.widgets.common.client.callbacks.DefaultErrorCallback)2