Commit 7caa3629 authored by Romain Bioteau's avatar Romain Bioteau Committed by GitHub
Browse files

feat(profile) update publish organization wizard (#700)

* add user profile validator

Closes BS-17146
parent 2d9a3cb3
......@@ -4,19 +4,19 @@ Bundle-Name: %pluginName
Bundle-SymbolicName: org.bonitasoft.studio.actors;singleton:=true
Bundle-Version: 7.6.0.qualifier
Bundle-ClassPath: .
Bundle-Activator: org.bonitasoft.studio.actors.ActorsPlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Export-Package: org.bonitasoft.studio.actors,
org.bonitasoft.studio.actors.i18n;x-friends:="org.bonitasoft.studio.actors.tests,org.bonitasoft.studio.test.swtbot.util,org.bonitasoft.studio.tests",
org.bonitasoft.studio.actors.model.organization,
org.bonitasoft.studio.actors.model.organization.impl,
org.bonitasoft.studio.actors.model.organization.util,
org.bonitasoft.studio.actors.operation,
org.bonitasoft.studio.actors.repository,
org.bonitasoft.studio.actors.ui.handler,
org.bonitasoft.studio.actors.ui.wizard.page,
org.bonitasoft.studio.actors.validator
org.bonitasoft.studio.actors.i18n;x-friends:="org.bonitasoft.studio.actors.tests,org.bonitasoft.studio.test.swtbot.util,org.bonitasoft.studio.tests",
org.bonitasoft.studio.actors.model.organization,
org.bonitasoft.studio.actors.model.organization.impl,
org.bonitasoft.studio.actors.model.organization.util,
org.bonitasoft.studio.actors.operation,
org.bonitasoft.studio.actors.repository,
org.bonitasoft.studio.actors.ui.handler,
org.bonitasoft.studio.actors.ui.wizard.page,
org.bonitasoft.studio.actors.validator
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.ui,
org.eclipse.emf.ecore;visibility:=reexport,
......@@ -55,19 +55,22 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.emf.databinding,
org.eclipse.core.databinding.observable,
org.eclipse.jdt.groovy.core;bundle-version="2.9.1",
org.bonitasoft.studio.ui
Bundle-ActivationPolicy: lazy
org.bonitasoft.studio.ui,
org.eclipse.e4.ui.model.workbench;bundle-version="2.0.0.v20170228-1842",
org.eclipse.e4.core.di.annotations,
org.eclipse.e4.core.commands
Import-Package: org.bonitasoft.engine.api,
org.bonitasoft.engine.bpm,
org.bonitasoft.engine.bpm.bar,
org.bonitasoft.engine.bpm.process,
org.bonitasoft.engine.exception,
org.bonitasoft.engine.filter,
org.bonitasoft.engine.identity,
org.bonitasoft.engine.profile,
org.bonitasoft.engine.search,
org.bonitasoft.engine.session,
org.bonitasoft.studio.common.jface,
org.bonitasoft.studio.common.jface.databinding.validator,
org.bonitasoft.studio.expression.editor.filter
Bundle-Activator: org.bonitasoft.studio.actors.ActorsPlugin
org.bonitasoft.engine.bpm,
org.bonitasoft.engine.bpm.bar,
org.bonitasoft.engine.bpm.process,
org.bonitasoft.engine.exception,
org.bonitasoft.engine.filter,
org.bonitasoft.engine.identity,
org.bonitasoft.engine.profile,
org.bonitasoft.engine.search,
org.bonitasoft.engine.session,
org.bonitasoft.studio.common.jface,
org.bonitasoft.studio.common.jface.databinding.validator,
org.bonitasoft.studio.expression.editor.filter
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
# Copyright (C) 2009-2012 BonitaSoft S.A.
# BonitaSoft, 31 rue Gustave Eiffel - 38000 Grenoble
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2.0 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
src.excludes = src-test/java
bin.includes = .,\
META-INF/,\
plugin.xml,\
......@@ -23,8 +8,8 @@ bin.includes = .,\
filters-def/,\
filters-impl/,\
dependencies/,\
model/
model/,\
fragment.e4xmi
output.. = bin/
jars.compile.order = .
source.. = src/
output.. = bin/
src.excludes=src-test/java
\ No newline at end of file
<?xml version="1.0" encoding="ASCII"?>
<fragment:ModelFragments xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:commands="http://www.eclipse.org/ui/2010/UIModel/application/commands" xmlns:fragment="http://www.eclipse.org/ui/2010/UIModel/fragment" xmi:id="_xq6k0JPZEeefAocV7_rPmw">
<fragments xsi:type="fragment:StringModelFragment" xmi:id="_y-sg4JPZEeefAocV7_rPmw" featurename="commands" parentElementId="org.eclipse.e4.legacy.ide.application">
<elements xsi:type="commands:Command" xmi:id="_3qAZcJPZEeefAocV7_rPmw" elementId="org.bonitasoft.studio.organization.publish" commandName="%loadOrganization_Label"/>
<elements xsi:type="commands:Command" xmi:id="_tLmfcJbPEeew-Jqtlwxc8Q" elementId="org.bonitasoft.studio.organization.manage" commandName="%manageOrganization_Label"/>
<elements xsi:type="commands:Command" xmi:id="_bOsOIJb0Eeew-Jqtlwxc8Q" elementId="org.bonitasoft.studio.actors.import" commandName="%import_Label"/>
</fragments>
<fragments xsi:type="fragment:StringModelFragment" xmi:id="_9OWy0JPZEeefAocV7_rPmw" featurename="handlers" parentElementId="org.eclipse.e4.legacy.ide.application">
<elements xsi:type="commands:Handler" xmi:id="_AM0IAJPaEeefAocV7_rPmw" elementId="org.bonitasoft.studio.organization.publish.handler" contributionURI="bundleclass://org.bonitasoft.studio.actors/org.bonitasoft.studio.actors.ui.handler.DeployOrganizationHandler" command="_3qAZcJPZEeefAocV7_rPmw"/>
<elements xsi:type="commands:Handler" xmi:id="_uqPnsJbPEeew-Jqtlwxc8Q" elementId="org.bonitasoft.studio.organization.manage.handler" contributionURI="bundleclass://org.bonitasoft.studio.actors/org.bonitasoft.studio.actors.ui.handler.ManageOrganizationHandler" command="_tLmfcJbPEeew-Jqtlwxc8Q"/>
<elements xsi:type="commands:Handler" xmi:id="_cpyTIJb0Eeew-Jqtlwxc8Q" elementId="org.bonitasoft.studio.actors.import.handler" contributionURI="bundleclass://org.bonitasoft.studio.actors/org.bonitasoft.studio.actors.ui.handler.ImportOrganizationHandler" command="_bOsOIJb0Eeew-Jqtlwxc8Q"/>
</fragments>
</fragment:ModelFragments>
......@@ -74,8 +74,8 @@ addMembership=Add membership...
addMembershipEtc=Memberships...
newOrganizationMsg=Create a new organization
newOrganizationTitle=Create a new organization
synchronizeInformationTitle=Publish information
synchronizeOrganizationSuccessMsg=Organization {0} has been published successfully
deployInformationTitle=Deploy information
deployOrganizationSuccessMsg=Organization {0} has been deployed successfully
selectActorTitle=Select an actor
selectActorDesc=Choose an actor from the ones defined in this process
actorMappingDesc=Define the actor mappings using an existing organization
......@@ -103,10 +103,9 @@ exportOrganizationTitle=Export organization
defaultOrganizationName=Organization
manageOrganizationTitle=Manage organizations
manageOrganizationDesc=Add, edit or remove organizations
synchronizeOrganizationTitle=Upload to local Portal...
synchronizeOrganizationDesc=Load the selected organization into the local {0}
synchronize=Publish
synchronizingOrganization=Publishing organization...
deployOrganizationDesc=Install the selected organization into the local {0}
deploy=Deploy
deployOrganization=Deploying organization...
selectActor=Select an actor
illegalCharacter=The character '/' is not allowed
filtersSourceRepositoryName=Actor filters sources
......@@ -179,7 +178,7 @@ importOrganizationSuccessfullTitle=Import successful
importOrganizationSuccessfullMessage=Organization has been imported successfully.
errorSelectionGroups=You can't select a group and one of its affiliate.
exportActorFilterTitle=Export actor filter
UserDoesntExistError=User {0} does not exist in the current organization. Please provide another username.
UserDoesntExistError=User {0} does not exist in the current organization.
addActor=Add...
initiator=Initiator
newActor=New actor
......@@ -234,9 +233,15 @@ labelExplicationCustomUserInformation=The information below (default and custom)
details=Details
groupDisplayLengthTooLong=Group display name \"{0}\" exceed max length of 75 characters.
importOrganizationWithWarningTitle=Import completed with errors
importOrganizationWithWarningMessage=The import of organization completed but some errors has been found.\n{0}
importOrganizationWithWarningMessage=The import of organization completed but following issues has been found.
userNameIsEmpty=Username is empty
organizationName=Organization name
invalidCharInGroupName=The following groups contain the invalid character '/':\n%s
removeProcessInitiator=Unset initiator
unknownActorMappingElement=Some actors are bound to unknown organization entities (groups,roles,users,memberships). Fix the active organization before deploy.
defaultUser=Default username
publishFailed=Publish operation has failed
defaultUserTooltip=The default user used when login to the Bonita UIs (Portal, applications...)
deployOrganizationTitle=Deploy organization
deployOrganizationPageTitle=Select an organization to deploy
organizationValidationFailedMsg=Following issues have been found
\ No newline at end of file
......@@ -19,7 +19,7 @@ providerName=Bonitasoft S.A.
actors_Label=Organization
export_Label=Export...
import_Label=Import...
loadOrganization_Label=Publish...
loadOrganization_Label=Deploy...
actor_tab_label=Actors
manageOrganization_Label=Manage...
Filters=Actor filters
......
......@@ -130,12 +130,11 @@ public class Messages extends NLS {
public static String defaultOrganizationName;
public static String manageOrganizationTitle;
public static String manageOrganizationDesc;
public static String synchronizeOrganizationTitle;
public static String synchronizeInformationTitle;
public static String synchronizeOrganizationSuccessMsg;
public static String synchronizeOrganizationDesc;
public static String synchronize;
public static String synchronizingOrganization;
public static String deployInformationTitle;
public static String deployOrganizationSuccessMsg;
public static String deployOrganizationDesc;
public static String deploy;
public static String deployOrganization;
public static String selectActor;
public static String illegalCharacter;
public static String filterDefRepositoryName;
......@@ -269,4 +268,10 @@ public class Messages extends NLS {
public static String invalidCharInGroupName;
public static String removeProcessInitiator;
public static String unknownActorMappingElement;
public static String defaultUser;
public static String publishFailed;
public static String defaultUserTooltip;
public static String deployOrganizationTitle;
public static String deployOrganizationPageTitle;
public static String organizationValidationFailedMsg;
}
......@@ -79,6 +79,7 @@ public abstract class PublishOrganizationOperation implements IRunnableWithProgr
@Override
public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
Assert.isNotNull(organization);
flushSession = false;
BonitaStudioLog.info("Loading organization " + organization.getName() + " in portal...", ActorsPlugin.PLUGIN_ID);
try {
......
/**
* Copyright (C) 2012 BonitaSoft S.A.
* BonitaSoft, 31 rue Gustave Eiffel - 38000 Grenoble
* Copyright (C) 2017 Bonitasoft S.A.
* Bonitasoft, 32 rue Gustave Eiffel - 38000 Grenoble
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2.0 of the License, or
......@@ -12,70 +12,82 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.bonitasoft.studio.actors.ui.wizard.page;
package org.bonitasoft.studio.actors.ui.handler;
import static org.bonitasoft.studio.common.Messages.bonitaPortalModuleName;
import static org.bonitasoft.studio.ui.databinding.UpdateStrategyFactory.updateValueStrategy;
import java.util.stream.Stream;
import org.bonitasoft.studio.actors.i18n.Messages;
import org.bonitasoft.studio.actors.model.organization.Organization;
import org.bonitasoft.studio.actors.model.organization.User;
import org.bonitasoft.studio.actors.repository.OrganizationFileStore;
import org.bonitasoft.studio.actors.repository.OrganizationRepositoryStore;
import org.bonitasoft.studio.actors.ui.wizard.page.OrganizationLabelProvider;
import org.bonitasoft.studio.common.jface.TableColumnSorter;
import org.bonitasoft.studio.common.jface.databinding.validator.EmptyInputValidator;
import org.bonitasoft.studio.common.log.BonitaStudioLog;
import org.bonitasoft.studio.common.repository.RepositoryManager;
import org.bonitasoft.studio.common.repository.model.IRepositoryFileStore;
import org.bonitasoft.studio.common.repository.model.ReadFileStoreException;
import org.bonitasoft.studio.ui.databinding.UpdateStrategyFactory;
import org.bonitasoft.studio.ui.validator.MultiValidator;
import org.bonitasoft.studio.ui.validator.MultiValidator.Builder;
import org.bonitasoft.studio.ui.widget.TextWidget;
import org.bonitasoft.studio.ui.wizard.ControlSupplier;
import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.databinding.beans.PojoProperties;
import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.core.databinding.validation.ValidationStatus;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.databinding.viewers.ViewersObservables;
import org.eclipse.jface.fieldassist.SimpleContentProposalProvider;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.jface.layout.LayoutConstants;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.ColumnLabelProvider;
import org.eclipse.jface.viewers.ColumnWeightData;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.TableLayout;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TableViewerColumn;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.jface.wizard.IWizardContainer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.TableColumn;
/**
* @author Romain Bioteau
*/
public class SynchronizeOrganizationWizardPage extends WizardPage implements ISelectionChangedListener {
public class DeployOrganizationControlSupplier implements ControlSupplier {
private OrganizationFileStore file;
private TableViewer viewer;
private OrganizationFileStore fileStore;
private final OrganizationRepositoryStore organizationStore;
private String username;
public SynchronizeOrganizationWizardPage() {
super(SynchronizeOrganizationWizardPage.class.getName());
setTitle(Messages.synchronizeOrganizationTitle);
setDescription(Messages.bind(Messages.synchronizeOrganizationDesc, new Object[] { bonitaPortalModuleName }));
organizationStore = RepositoryManager.getInstance().getRepositoryStore(OrganizationRepositoryStore.class);
public DeployOrganizationControlSupplier(String username, OrganizationRepositoryStore organizationStore) {
this.organizationStore = organizationStore;
this.username = username;
}
/*
* (non-Javadoc)
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
* @see org.bonitasoft.studio.ui.wizard.ControlSupplier#createControl(org.eclipse.swt.widgets.Composite, org.eclipse.jface.wizard.IWizardContainer,
* org.eclipse.core.databinding.DataBindingContext)
*/
@Override
public void createControl(final Composite parent) {
public Control createControl(Composite parent, IWizardContainer wizardContainer, DataBindingContext ctx) {
final Composite mainComposite = new Composite(parent, SWT.NONE);
mainComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
mainComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(1).margins(10, 10).create());
mainComposite.setLayout(
GridLayoutFactory.swtDefaults().numColumns(1).spacing(LayoutConstants.getSpacing().x, 10).create());
viewer = new TableViewer(mainComposite, SWT.BORDER | SWT.FULL_SELECTION | SWT.SINGLE);
viewer.getTable().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).minSize(SWT.DEFAULT, 200).create());
TableViewer viewer = new TableViewer(mainComposite, SWT.BORDER | SWT.FULL_SELECTION | SWT.SINGLE);
viewer.getTable().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, 120).create());
final TableLayout layout = new TableLayout();
layout.addColumnData(new ColumnWeightData(30));
layout.addColumnData(new ColumnWeightData(70));
viewer.getTable().setLayout(layout);
viewer.getTable().setLinesVisible(true);
viewer.getTable().setHeaderVisible(true);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setContentProvider(ArrayContentProvider.getInstance());
TableViewerColumn column = new TableViewerColumn(viewer, SWT.FILL);
final TableColumn nameColumn = column.getColumn();
......@@ -100,31 +112,82 @@ public class SynchronizeOrganizationWizardPage extends WizardPage implements ISe
final TableColumnSorter sorter = new TableColumnSorter(viewer);
sorter.setColumn(nameColumn);
IObservableValue<OrganizationFileStore> fileStoreObservable = PojoProperties.value("fileStore").observe(this);
SimpleContentProposalProvider proposalProvider = new SimpleContentProposalProvider(usernames());
proposalProvider.setFiltering(true);
ctx.bindValue(ViewersObservables.observeSingleSelection(viewer),
fileStoreObservable,
updateValueStrategy()
.withValidator(value -> value == null ? ValidationStatus.error("") : ValidationStatus.ok()).create(),
updateValueStrategy().create());
viewer.setInput(organizationStore.getChildren());
viewer.addSelectionChangedListener(this);
setControl(mainComposite);
TextWidget widget = new TextWidget.Builder()
.withLabel(Messages.defaultUser)
.grabHorizontalSpace()
.fill()
.labelAbove()
.withProposalProvider(proposalProvider)
.withTootltip(Messages.defaultUserTooltip)
.bindTo(PojoProperties.value("username", String.class).observe(this))
.withTargetToModelStrategy(UpdateStrategyFactory.updateValueStrategy()
.withValidator(defaultUserValidator()))
.inContext(ctx)
.createIn(mainComposite);
fileStoreObservable.addValueChangeListener(event -> {
organizationChanged(event.diff.getNewValue().getContent(), ctx, proposalProvider);
//re-evaluate validators for selected organization
widget.getValueBinding().validateTargetToModel();
});
return mainComposite;
}
@Override
public void selectionChanged(final SelectionChangedEvent event) {
if (!event.getSelection().isEmpty()) {
file = (OrganizationFileStore) ((IStructuredSelection) event.getSelection()).getFirstElement();
final DefaultUserOrganizationWizardPage nextPage = (DefaultUserOrganizationWizardPage) getNextPage();
nextPage.setOrganization(file.getContent());
nextPage.refreshBindings();
protected void organizationChanged(Organization organization, DataBindingContext ctx,
SimpleContentProposalProvider proposalProvider) {
proposalProvider.setProposals(usernames());
}
protected Builder defaultUserValidator() {
return new MultiValidator.Builder()
.havingValidators(new EmptyInputValidator(Messages.defaultUser))
.havingValidators(this::userExistsInOrganization);
}
private IStatus userExistsInOrganization(Object user) {
if (Stream.of(usernames()).noneMatch(user::equals)) {
return ValidationStatus.error(Messages.bind(Messages.UserDoesntExistError, user));
}
return ValidationStatus.ok();
}
getContainer().updateButtons();
private String[] usernames() {
return fileStore == null ? new String[0] : fileStore.getContent()
.getUsers()
.getUser()
.stream()
.map(User::getUserName)
.toArray(String[]::new);
}
public OrganizationFileStore getFileStore() {
return file;
return fileStore;
}
@Override
public boolean isPageComplete() {
return !viewer.getSelection().isEmpty();
public void setFileStore(OrganizationFileStore file) {
this.fileStore = file;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
}
......@@ -12,141 +12,152 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.bonitasoft.studio.actors.ui.wizard;
package org.bonitasoft.studio.actors.ui.handler;
import static org.bonitasoft.studio.common.Messages.bonitaPortalModuleName;
import static org.bonitasoft.studio.ui.wizard.WizardPageBuilder.newPage;
import java.lang.reflect.InvocationTargetException;
import java.util.Objects;
import java.util.Optional;
import org.bonitasoft.studio.actors.ActorsPlugin;
import org.bonitasoft.studio.actors.i18n.Messages;
import org.bonitasoft.studio.actors.model.organization.Organization;
import org.bonitasoft.studio.actors.model.organization.PasswordType;
import org.bonitasoft.studio.actors.model.organization.User;
import org.bonitasoft.studio.actors.repository.OrganizationFileStore;
import org.bonitasoft.studio.actors.ui.wizard.page.DefaultUserOrganizationWizardPage;
import org.bonitasoft.studio.actors.ui.wizard.page.SynchronizeOrganizationWizardPage;
import org.bonitasoft.studio.actors.repository.OrganizationRepositoryStore;
import org.bonitasoft.studio.actors.validator.OrganizationValidationException;
import org.bonitasoft.studio.actors.validator.OrganizationValidator;
import org.bonitasoft.studio.common.log.BonitaStudioLog;
import org.bonitasoft.studio.common.repository.RepositoryManager;
import org.bonitasoft.studio.common.repository.RepositoryAccessor;
import org.bonitasoft.studio.common.repository.core.ActiveOrganizationProvider;
import org.bonitasoft.studio.common.repository.model.IRepositoryFileStore;
import org.bonitasoft.studio.pics.Pics;
import org.bonitasoft.studio.ui.dialog.ExceptionDialogHandler;
import org.bonitasoft.studio.ui.dialog.MultiStatusDialog;
import org.bonitasoft.studio.ui.wizard.WizardBuilder;
import org.eclipse.core.commands.Command;
import org.eclipse.core.commands.Parameterization;
import org.eclipse.core.commands.ParameterizedCommand;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.jface.wizard.IWizardContainer;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.commands.ICommandService;
import org.eclipse.ui.handlers.IHandlerService;
/**
* @author Romain Bioteau
*/
public class SynchronizeOrganizationWizard extends Wizard {
public class DeployOrganizationHandler {
protected IRepositoryFileStore file;
private SynchronizeOrganizationWizardPage page;
private DefaultUserOrganizationWizardPage userPage;
private Organization activeOrganization;
private final OrganizationValidator validator;
private final ActiveOrganizationProvider activeOrganizationProvider;
public SynchronizeOrganizationWizard() {
setWindowTitle(Messages.synchronizeOrganizationTitle);
setDefaultPageImageDescriptor(Pics.getWizban());
setForcePreviousAndNextButtons(false);
setNeedsProgressMonitor(true);
validator = new OrganizationValidator();
activeOrganizationProvider = new ActiveOrganizationProvider();
}
/*
* (non-Javadoc)
* @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
*/
@Execute
public void execute(ExceptionDialogHandler exceptionDialogHandler, RepositoryAccessor repositoryAccessor,
ActiveOrganizationProvider activeOrganizationProvider) {
DeployOrganizationControlSupplier controlSupplier = newPublishOrganizationControlSupplier(repositoryAccessor,
activeOrganizationProvider);
@Override
public void addPages() {
page = new SynchronizeOrganizationWizardPage();
userPage = new DefaultUserOrganizationWizardPage();
RepositoryManager.getInstance().getCurrentRepository().getScopeContext();
userPage.setUser(activeOrganizationProvider.getDefaultUser());
addPage(page);
addPage(userPage);
WizardBuilder.<IStatus> newWizard()
.withTitle(Messages.deployOrganizationTitle)
.needProgress()
.havingPage(newPage()
.withTitle(Messages.deployOrganizationPageTitle)
.withDescription(
Messages.bind(Messages.deployOrganizationDesc, new Object[] { bonitaPortalModuleName }))
.withControl(controlSupplier))
.onFinish(wizardContainer -> publish(wizardContainer, activeOrganizationProvider, controlSupplier))
.open(Display.getDefault().getActiveShell(), Messages.deploy)
.ifPresent(status -> openResultDialog(exceptionDialogHandler, controlSupplier, status));
}
@Override
public IWizardPage getNextPage(final IWizardPage page) {
if (page instanceof SynchronizeOrganizationWizardPage) {
activeOrganization = ((SynchronizeOrganizationWizardPage) page).getFileStore().getContent();
userPage.setOrganization(activeOrganization);
return userPage;
protected void openResultDialog(ExceptionDialogHandler exceptionDialogHandler,
DeployOrganizationControlSupplier controlSupplier, IStatus status) {
if (status.isOK()) {
final String organizationName = controlSupplier.getFileStore().getDisplayName();
MessageDialog.openInformation(Display.getDefault().getActiveShell(),
Messages.deployInformationTitle,
Messages.bind(Messages.deployOrganizationSuccessMsg, organizationName));