Search in sources :

Example 1 with SpaceScreenModel

use of org.kie.workbench.common.screens.library.api.settings.SpaceScreenModel in project kie-wb-common by kiegroup.

the class SettingsScreenPresenter method setupUsingCurrentSection.

public Promise<Void> setupUsingCurrentSection() {
    this.view.init(this);
    showBusyIndicator(ts.getTranslation(LibraryConstants.Loading));
    view.enableActions(canUpdate());
    return setupSections(new SpaceScreenModel()).then(o -> {
        hideBusyIndicator();
        if (sectionManager.manages(sectionManager.getCurrentSection())) {
            return sectionManager.goToCurrentSection();
        } else {
            return sectionManager.goToFirstAvailable();
        }
    }).catch_(o -> promises.catchOrExecute(o, e -> {
        hideBusyIndicator();
        return promises.reject(e);
    }, i -> {
        notificationEvent.fire(new NotificationEvent(ts.getTranslation(LibraryConstants.SettingsLoadError), ERROR));
        hideBusyIndicator();
        return promises.resolve();
    }));
}
Also used : HasBusyIndicator(org.uberfire.ext.widgets.common.client.common.HasBusyIndicator) SectionManager(org.kie.workbench.common.screens.library.client.settings.util.sections.SectionManager) Promises(org.uberfire.client.promise.Promises) SpaceSettings(org.kie.workbench.common.screens.library.client.screens.organizationalunit.settings.annotation.SpaceSettings) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) Promise(elemental2.promise.Promise) Supplier(java.util.function.Supplier) SettingsSectionChange(org.kie.workbench.common.screens.library.client.settings.SettingsSectionChange) ArrayList(java.util.ArrayList) SettingsSectionChangeType(org.kie.workbench.common.screens.library.client.settings.SettingsSectionChangeType) Inject(javax.inject.Inject) ERROR(org.uberfire.workbench.events.NotificationEvent.NotificationType.ERROR) HTMLElement(elemental2.dom.HTMLElement) Observes(javax.enterprise.event.Observes) SettingsSections(org.kie.workbench.common.screens.library.client.settings.sections.SettingsSections) OrganizationalUnitController(org.guvnor.structure.client.security.OrganizationalUnitController) Event(javax.enterprise.event.Event) OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) LibraryConstants(org.kie.workbench.common.screens.library.client.resources.i18n.LibraryConstants) BusyIndicatorView(org.uberfire.ext.widgets.common.client.common.BusyIndicatorView) TranslationService(org.jboss.errai.ui.client.local.spi.TranslationService) WARNING(org.uberfire.workbench.events.NotificationEvent.NotificationType.WARNING) WorkspaceProjectContext(org.guvnor.common.services.project.client.context.WorkspaceProjectContext) SpaceScreenModel(org.kie.workbench.common.screens.library.api.settings.SpaceScreenModel) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) Stream(java.util.stream.Stream) Dependent(javax.enterprise.context.Dependent) SUCCESS(org.uberfire.workbench.events.NotificationEvent.NotificationType.SUCCESS) PostConstruct(javax.annotation.PostConstruct) Section(org.kie.workbench.common.screens.library.client.settings.util.sections.Section) UberElement(org.uberfire.client.mvp.UberElement) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) SpaceScreenModel(org.kie.workbench.common.screens.library.api.settings.SpaceScreenModel)

Example 2 with SpaceScreenModel

use of org.kie.workbench.common.screens.library.api.settings.SpaceScreenModel in project kie-wb-common by kiegroup.

the class SettingsScreenPresenterTest method createSectionMock.

private Section<SpaceScreenModel> createSectionMock() {
    final Section<SpaceScreenModel> section = mock(Section.class);
    doReturn(mock(MenuItem.class)).when(section).getMenuItem();
    doReturn(promises.resolve()).when(section).setup(any());
    doReturn(promises.resolve()).when(section).save(any(), any());
    final SectionView view = mock(SectionView.class);
    doReturn("title").when(view).getTitle();
    doReturn(view).when(section).getView();
    return section;
}
Also used : SectionView(org.kie.workbench.common.screens.library.client.settings.util.sections.SectionView) MenuItem(org.kie.workbench.common.screens.library.client.settings.util.sections.MenuItem) SpaceScreenModel(org.kie.workbench.common.screens.library.api.settings.SpaceScreenModel)

Example 3 with SpaceScreenModel

use of org.kie.workbench.common.screens.library.api.settings.SpaceScreenModel in project kie-wb-common by kiegroup.

the class SettingsScreenPresenter method setupSection.

Promise<Object> setupSection(final SpaceScreenModel model, final Section<SpaceScreenModel> section) {
    return section.setup(model).then(i -> {
        sectionManager.resetDirtyIndicator(section);
        return promises.resolve();
    }).catch_(e -> {
        sectionManager.remove(section);
        notificationEvent.fire(new NotificationEvent(getSectionSetupErrorMessage(section), WARNING));
        return promises.resolve();
    });
}
Also used : HasBusyIndicator(org.uberfire.ext.widgets.common.client.common.HasBusyIndicator) SectionManager(org.kie.workbench.common.screens.library.client.settings.util.sections.SectionManager) Promises(org.uberfire.client.promise.Promises) SpaceSettings(org.kie.workbench.common.screens.library.client.screens.organizationalunit.settings.annotation.SpaceSettings) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) Promise(elemental2.promise.Promise) Supplier(java.util.function.Supplier) SettingsSectionChange(org.kie.workbench.common.screens.library.client.settings.SettingsSectionChange) ArrayList(java.util.ArrayList) SettingsSectionChangeType(org.kie.workbench.common.screens.library.client.settings.SettingsSectionChangeType) Inject(javax.inject.Inject) ERROR(org.uberfire.workbench.events.NotificationEvent.NotificationType.ERROR) HTMLElement(elemental2.dom.HTMLElement) Observes(javax.enterprise.event.Observes) SettingsSections(org.kie.workbench.common.screens.library.client.settings.sections.SettingsSections) OrganizationalUnitController(org.guvnor.structure.client.security.OrganizationalUnitController) Event(javax.enterprise.event.Event) OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) LibraryConstants(org.kie.workbench.common.screens.library.client.resources.i18n.LibraryConstants) BusyIndicatorView(org.uberfire.ext.widgets.common.client.common.BusyIndicatorView) TranslationService(org.jboss.errai.ui.client.local.spi.TranslationService) WARNING(org.uberfire.workbench.events.NotificationEvent.NotificationType.WARNING) WorkspaceProjectContext(org.guvnor.common.services.project.client.context.WorkspaceProjectContext) SpaceScreenModel(org.kie.workbench.common.screens.library.api.settings.SpaceScreenModel) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) Stream(java.util.stream.Stream) Dependent(javax.enterprise.context.Dependent) SUCCESS(org.uberfire.workbench.events.NotificationEvent.NotificationType.SUCCESS) PostConstruct(javax.annotation.PostConstruct) Section(org.kie.workbench.common.screens.library.client.settings.util.sections.Section) UberElement(org.uberfire.client.mvp.UberElement) NotificationEvent(org.uberfire.workbench.events.NotificationEvent)

Aggregations

SpaceScreenModel (org.kie.workbench.common.screens.library.api.settings.SpaceScreenModel)3 HTMLElement (elemental2.dom.HTMLElement)2 Promise (elemental2.promise.Promise)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Supplier (java.util.function.Supplier)2 Collectors.toList (java.util.stream.Collectors.toList)2 Stream (java.util.stream.Stream)2 PostConstruct (javax.annotation.PostConstruct)2 Dependent (javax.enterprise.context.Dependent)2 Event (javax.enterprise.event.Event)2 Observes (javax.enterprise.event.Observes)2 Inject (javax.inject.Inject)2 WorkspaceProjectContext (org.guvnor.common.services.project.client.context.WorkspaceProjectContext)2 OrganizationalUnitController (org.guvnor.structure.client.security.OrganizationalUnitController)2 OrganizationalUnit (org.guvnor.structure.organizationalunit.OrganizationalUnit)2 TranslationService (org.jboss.errai.ui.client.local.spi.TranslationService)2 LibraryConstants (org.kie.workbench.common.screens.library.client.resources.i18n.LibraryConstants)2 SpaceSettings (org.kie.workbench.common.screens.library.client.screens.organizationalunit.settings.annotation.SpaceSettings)2 SettingsSectionChange (org.kie.workbench.common.screens.library.client.settings.SettingsSectionChange)2