Search in sources :

Example 1 with DefaultErrorCallback

use of org.uberfire.ext.widgets.common.client.callbacks.DefaultErrorCallback 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 2 with DefaultErrorCallback

use of org.uberfire.ext.widgets.common.client.callbacks.DefaultErrorCallback in project kie-wb-common by kiegroup.

the class PopulatedAssetsScreen method resolveAssetsCount.

private void resolveAssetsCount() {
    if (!isProjectNull()) {
        ProjectAssetsQuery query = this.createProjectQuery(filter, filterType, 0, 0);
        assetQueryService.getNumberOfAssets(query).call((Integer numberOfAssets) -> {
            int offset = getOffset();
            this.view.setPageIndicator(offset + 1, this.getAssetsCount(numberOfAssets, offset + this.pageSize), this.getAssetsCount(numberOfAssets, 0));
            this.setTotalPages(numberOfAssets, this.pageSize);
            this.view.setTotalPages(this.getTotalPages());
            this.checkPaginationButtons();
        }, new DefaultErrorCallback());
    }
}
Also used : ProjectAssetsQuery(org.kie.workbench.common.screens.library.api.ProjectAssetsQuery) DefaultErrorCallback(org.uberfire.ext.widgets.common.client.callbacks.DefaultErrorCallback)

Example 3 with DefaultErrorCallback

use of org.uberfire.ext.widgets.common.client.callbacks.DefaultErrorCallback 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 DefaultErrorCallback

use of org.uberfire.ext.widgets.common.client.callbacks.DefaultErrorCallback in project kie-wb-common by kiegroup.

the class PopulatedAssetsScreen method getAssets.

private void getAssets(String filter, String filterType, int startIndex, int amount, RemoteCallback<AssetQueryResult> callback) {
    if (!isProjectNull()) {
        ProjectAssetsQuery query = this.createProjectQuery(filter, filterType, startIndex, amount);
        assetQueryService.getAssets(query).call(callback, new DefaultErrorCallback());
    }
}
Also used : ProjectAssetsQuery(org.kie.workbench.common.screens.library.api.ProjectAssetsQuery) DefaultErrorCallback(org.uberfire.ext.widgets.common.client.callbacks.DefaultErrorCallback)

Example 5 with DefaultErrorCallback

use of org.uberfire.ext.widgets.common.client.callbacks.DefaultErrorCallback in project kie-wb-common by kiegroup.

the class SettingsPresenter method defaultErrorResolution.

Promise<Void> defaultErrorResolution(final Throwable e) {
    new DefaultErrorCallback().error(null, e);
    view.hideBusyIndicator();
    return promises.resolve();
}
Also used : DefaultErrorCallback(org.uberfire.ext.widgets.common.client.callbacks.DefaultErrorCallback)

Aggregations

DefaultErrorCallback (org.uberfire.ext.widgets.common.client.callbacks.DefaultErrorCallback)5 Message (org.jboss.errai.bus.client.api.messaging.Message)2 ProjectAssetsQuery (org.kie.workbench.common.screens.library.api.ProjectAssetsQuery)2 HashSet (java.util.HashSet)1 Set (java.util.Set)1 WorkspaceProject (org.guvnor.common.services.project.model.WorkspaceProject)1 OrganizationalUnit (org.guvnor.structure.organizationalunit.OrganizationalUnit)1 RemoteCallback (org.jboss.errai.common.client.api.RemoteCallback)1 ExampleProject (org.kie.workbench.common.screens.examples.model.ExampleProject)1 WizardPageSelectedEvent (org.uberfire.ext.widgets.core.client.wizards.WizardPageSelectedEvent)1