Commit 27b7ea65 authored by Aurelien Pupier's avatar Aurelien Pupier
Browse files

Merge pull request #266 from bonitasoft/feat/improveContractGenerationGuidance

BS-14273 improve generation guidance
parents 70e11ad0 48ebac10
......@@ -69,9 +69,10 @@ public abstract class FinishAndAddCustomWizardDialog extends CustomWizardDialog
protected void buttonPressed(final int buttonId) {
super.buttonPressed(buttonId);
if (buttonId == CREATE_AND_NEW_ID) {
getWizard().performFinish();
close();
actionOnFinishAndAdd();
if (getWizard().performFinish()) {
close();
actionOnFinishAndAdd();
}
}
}
......
......@@ -58,17 +58,18 @@ atLeastOneAttributeShouldBeSelectedError=At least one attribute should be checke
attributeName = Attribute name
warningAddFromData_noDataAvailable=Please create first a business variable from Data view.
warningAddFromData_noDataSelected=Please select a business variable in the list.
reminderForStepMessage=Contract elements and mapping operations will be generated and can be edited manually. Storage operations to update business variables can also be generated.\nSelect the option that suits your needs:
reminderForStepMessage=Contract elements and mapping operations will be generated and can be edited manually.\nStorage operations to update business variables can also be generated.\nSelect the option that suits your needs:
reminderForProcessMessage=Contract elements will be generated and can be edited manually.\nThe groovy script to initialize business variables can also be generated.\nSelect the option that best suits your needs:
contractInputDescriptionTooltip=Used in the automatically generated forms as user hint
errorTitle=Error
contractFromDataCreationErrorMessage=An error occurred while generating the contract from a data.
contractGenerationTitle=Contract generation
contractGenerationMsg=Generated contract elements and operations can be edited manually.\nHowever, in many cases, no refactoring is performed (e.g.: Updating name or multiple attribute in a Business object or contract element may break a generated operation).
contractOperationGenerationMsg=The contract inputs have been specified.\n\nOperations to set the values of the business variable attributes with the contract inputs values will be generated.They can be viewed in the Operations pane.\nIf operations have already been generated for these attributes, they will not be replaced. The new operations are added to the list.\n\nContract inputs and operations can be edited manually.\nHowever, there is no refactoring (for example, updating the attribute name or a multiple property in a business object or contract element will break the operation).
doNotShowMeAgain=Do not show me this dialog again
notAllAttributesGeneratedTitle=incomplete initialization of the business variable
notAllAttributesGeneratedMsg=Some attributes of the business variable will not be initialized from the contract elements as they have been deselected.
autoGeneratedOperationStepButton=Auto-generate storage operations
manuallyDefinedOperationStepButton=No, thanks. I'll manually define how to use the contract.
autoGeneratedOperationProcessButton=Auto-generate the initialization script
manuallyDefinedOperationProcessButton=No, thanks. I'll manually define how to use the contract.
\ No newline at end of file
manuallyDefinedOperationProcessButton=No, thanks. I'll manually define how to use the contract.
contractStrictGenerationMsg=The contract inputs have been specified.\nA script that sets the default values of the business variable attributes with the contract input values will be generated. It can be viewed and edited in the Data tab. If the default value of a business variable already exists, this script will override it.\n\nContract inputs and the script can be edited manually.\nHowever, there is no refactoring (for example, updating the attribute name or a multiple property in a business object or contract element will break the script).
\ No newline at end of file
......@@ -71,6 +71,9 @@ public class ContractInputGenerationWizardTest {
@Mock
private FieldToContractInputMappingExpressionBuilder expressionBuilder;
@Mock
private ContractInputGenerationInfoDialogFactory dialogFactory;
@Test
public void should_first_wizard_page_be_selectBusinessDataWizardPage() {
final BusinessObjectData data = aBusinessData().build();
......@@ -78,7 +81,7 @@ public class ContractInputGenerationWizardTest {
process.getData().add(data);
final ContractInputGenerationWizard wizard = new ContractInputGenerationWizard(process, editingDomain(), repositoryAccessor, operationBuilder,
expressionBuilder, preferenceStore, sharedImages);
expressionBuilder, preferenceStore, sharedImages, dialogFactory);
wizard.addPages();
assertThat(wizard.getPages()[0]).isInstanceOf(SelectBusinessDataWizardPage.class);
......@@ -91,7 +94,7 @@ public class ContractInputGenerationWizardTest {
process.getData().add(data);
final ContractInputGenerationWizard wizard = new ContractInputGenerationWizard(process, editingDomain(), repositoryAccessor, operationBuilder,
expressionBuilder, preferenceStore, sharedImages);
expressionBuilder, preferenceStore, sharedImages, dialogFactory);
wizard.addPages();
assertThat(wizard.getPages()[0]).isInstanceOf(SelectBusinessDataWizardPage.class);
......@@ -107,11 +110,11 @@ public class ContractInputGenerationWizardTest {
when(store.getBusinessObjectByQualifiedName("org.company.Employee")).thenReturn(
BusinessObjectBuilder.aBO("org.company.Employee").withField(SimpleFieldBuilder.aStringField("firstName").build()).build());
when(repositoryAccessor.getRepositoryStore(BusinessObjectModelRepositoryStore.class)).thenReturn(store);
when(preferenceStore.getString(ContractInputGenerationWizard.HIDE_GENERATION_SUCCESS_DIALOG)).thenReturn("always");
when(preferenceStore.getString(ContractInputGenerationInfoDialogFactory.SHOW_GENERATION_SUCCESS_DIALOG)).thenReturn("always");
final ContractInputGenerationWizard wizard = new ContractInputGenerationWizard(process, editingDomain(), repositoryAccessor, operationBuilder,
expressionBuilder,
preferenceStore, sharedImages);
preferenceStore, sharedImages, dialogFactory);
wizard.addPages();
final IWizardContainer wizardContainer = Mockito.mock(IWizardContainer.class);
when(wizardContainer.getShell()).thenReturn(realmWithDisplay.getShell());
......@@ -133,16 +136,16 @@ public class ContractInputGenerationWizardTest {
when(store.getBusinessObjectByQualifiedName("org.company.Employee")).thenReturn(
BusinessObjectBuilder.aBO("org.company.Employee").withField(SimpleFieldBuilder.aStringField("firstName").build()).build());
when(repositoryAccessor.getRepositoryStore(BusinessObjectModelRepositoryStore.class)).thenReturn(store);
when(preferenceStore.getString(ContractInputGenerationWizard.HIDE_GENERATION_SUCCESS_DIALOG)).thenReturn("always");
when(preferenceStore.getString(ContractInputGenerationInfoDialogFactory.SHOW_GENERATION_SUCCESS_DIALOG)).thenReturn("always");
final ContractInputGenerationWizard wizard = new ContractInputGenerationWizard(process, editingDomain(), repositoryAccessor, operationBuilder,
expressionBuilder,
preferenceStore, sharedImages);
preferenceStore, sharedImages, dialogFactory);
wizard.addPages();
final IWizardContainer wizardContainer = Mockito.mock(IWizardContainer.class);
when(wizardContainer.getShell()).thenReturn(realmWithDisplay.getShell());
wizard.setContainer(wizardContainer);
wizard.createPageControls(realmWithDisplay.createComposite());
wizard.getContractInputFromBusinessObjectWizardPage().setIsAutogeneratedOperation(false);
wizard.getContractInputFromBusinessObjectWizardPage().disableAutoGeneration();
wizard.performFinish();
assertThat(process.getData().get(0).getDefaultValue()).isNull();
......@@ -158,18 +161,17 @@ public class ContractInputGenerationWizardTest {
when(store.getBusinessObjectByQualifiedName("org.company.Employee")).thenReturn(
BusinessObjectBuilder.aBO("org.company.Employee").withField(SimpleFieldBuilder.aStringField("firstName").build()).build());
when(repositoryAccessor.getRepositoryStore(BusinessObjectModelRepositoryStore.class)).thenReturn(store);
when(preferenceStore.getString(ContractInputGenerationWizard.HIDE_GENERATION_SUCCESS_DIALOG)).thenReturn("always");
when(preferenceStore.getString(ContractInputGenerationInfoDialogFactory.SHOW_GENERATION_SUCCESS_DIALOG)).thenReturn("always");
when(expressionBuilder.toExpression(any(BusinessObjectData.class), any(FieldToContractInputMapping.class), anyBoolean())).thenReturn(
aGroovyScriptExpression().build());
final ContractInputGenerationWizard wizard = new ContractInputGenerationWizard(process, editingDomain(), repositoryAccessor, operationBuilder,
expressionBuilder,
preferenceStore, sharedImages);
preferenceStore, sharedImages, dialogFactory);
wizard.addPages();
final IWizardContainer wizardContainer = Mockito.mock(IWizardContainer.class);
when(wizardContainer.getShell()).thenReturn(realmWithDisplay.getShell());
wizard.setContainer(wizardContainer);
wizard.createPageControls(realmWithDisplay.createComposite());
wizard.getContractInputFromBusinessObjectWizardPage().setIsAutogeneratedOperation(true);
wizard.performFinish();
assertThat(process.getData().get(0).getDefaultValue()).isNotNull();
......@@ -187,16 +189,16 @@ public class ContractInputGenerationWizardTest {
when(store.getBusinessObjectByQualifiedName("org.company.Employee")).thenReturn(
BusinessObjectBuilder.aBO("org.company.Employee").withField(SimpleFieldBuilder.aStringField("firstName").build()).build());
when(repositoryAccessor.getRepositoryStore(BusinessObjectModelRepositoryStore.class)).thenReturn(store);
when(preferenceStore.getString(ContractInputGenerationWizard.HIDE_GENERATION_SUCCESS_DIALOG)).thenReturn("always");
when(preferenceStore.getString(ContractInputGenerationInfoDialogFactory.SHOW_GENERATION_SUCCESS_DIALOG)).thenReturn("always");
final ContractInputGenerationWizard wizard = new ContractInputGenerationWizard(task, editingDomain(), repositoryAccessor, operationBuilder,
expressionBuilder,
preferenceStore, sharedImages);
preferenceStore, sharedImages, dialogFactory);
wizard.addPages();
final IWizardContainer wizardContainer = Mockito.mock(IWizardContainer.class);
when(wizardContainer.getShell()).thenReturn(realmWithDisplay.getShell());
wizard.setContainer(wizardContainer);
wizard.createPageControls(realmWithDisplay.createComposite());
wizard.getContractInputFromBusinessObjectWizardPage().setIsAutogeneratedOperation(false);
wizard.getContractInputFromBusinessObjectWizardPage().disableAutoGeneration();
wizard.performFinish();
assertThat(task.getOperations().isEmpty()).isTrue();
......@@ -214,18 +216,17 @@ public class ContractInputGenerationWizardTest {
when(store.getBusinessObjectByQualifiedName("org.company.Employee")).thenReturn(
BusinessObjectBuilder.aBO("org.company.Employee").withField(SimpleFieldBuilder.aStringField("firstName").build()).build());
when(repositoryAccessor.getRepositoryStore(BusinessObjectModelRepositoryStore.class)).thenReturn(store);
when(preferenceStore.getString(ContractInputGenerationWizard.HIDE_GENERATION_SUCCESS_DIALOG)).thenReturn("always");
when(preferenceStore.getString(ContractInputGenerationInfoDialogFactory.SHOW_GENERATION_SUCCESS_DIALOG)).thenReturn("always");
when(operationBuilder.toOperation(any(BusinessObjectData.class), any(FieldToContractInputMapping.class))).thenReturn(
anOperation().build());
final ContractInputGenerationWizard wizard = new ContractInputGenerationWizard(task, editingDomain(), repositoryAccessor, operationBuilder,
expressionBuilder,
preferenceStore, sharedImages);
preferenceStore, sharedImages, dialogFactory);
wizard.addPages();
final IWizardContainer wizardContainer = Mockito.mock(IWizardContainer.class);
when(wizardContainer.getShell()).thenReturn(realmWithDisplay.getShell());
wizard.setContainer(wizardContainer);
wizard.createPageControls(realmWithDisplay.createComposite());
wizard.getContractInputFromBusinessObjectWizardPage().setIsAutogeneratedOperation(true);
wizard.performFinish();
assertThat(task.getOperations().isEmpty()).isFalse();
......@@ -235,7 +236,7 @@ public class ContractInputGenerationWizardTest {
public void should_canFinish_return_false_when_no_data_is_defined() {
final Pool process = aPool().havingContract(aContract()).build();
final ContractInputGenerationWizard wizard = new ContractInputGenerationWizard(process, editingDomain(), repositoryAccessor, operationBuilder,
expressionBuilder, preferenceStore, sharedImages);
expressionBuilder, preferenceStore, sharedImages, dialogFactory);
wizard.addPages();
final IWizardContainer wizardContainer = Mockito.mock(IWizardContainer.class);
when(wizardContainer.getShell()).thenReturn(realmWithDisplay.getShell());
......@@ -254,7 +255,7 @@ public class ContractInputGenerationWizardTest {
.getBusinessObjectByQualifiedName("com.company.Employee");
when(repositoryAccessor.getRepositoryStore(BusinessObjectModelRepositoryStore.class)).thenReturn(store);
final ContractInputGenerationWizard wizard = new ContractInputGenerationWizard(process, editingDomain(), repositoryAccessor, operationBuilder,
expressionBuilder, preferenceStore, sharedImages);
expressionBuilder, preferenceStore, sharedImages, dialogFactory);
wizard.addPages();
final IWizardContainer wizardContainer = Mockito.mock(IWizardContainer.class);
when(wizardContainer.getShell()).thenReturn(realmWithDisplay.getShell());
......
......@@ -92,7 +92,7 @@ public class Messages extends NLS {
public static String errorTitle;
public static String contractFromDataCreationErrorMessage;
public static String contractGenerationTitle;
public static String contractGenerationMsg;
public static String contractOperationGenerationMsg;
public static String doNotShowMeAgain;
public static String notAllAttributesGeneratedTitle;
public static String notAllAttributesGeneratedMsg;
......@@ -100,4 +100,5 @@ public class Messages extends NLS {
public static String manuallyDefinedOperationStepButton;
public static String autoGeneratedOperationProcessButton;
public static String manuallyDefinedOperationProcessButton;
public static String contractStrictGenerationMsg;
}
......@@ -27,6 +27,7 @@ import org.bonitasoft.studio.contract.ui.property.constraint.ContractConstraints
import org.bonitasoft.studio.contract.ui.property.input.ContractInputController;
import org.bonitasoft.studio.contract.ui.property.input.ContractInputTreeViewer;
import org.bonitasoft.studio.contract.ui.wizard.AddInputContractFromDataWizardDialog;
import org.bonitasoft.studio.contract.ui.wizard.ContractInputGenerationInfoDialogFactory;
import org.bonitasoft.studio.contract.ui.wizard.ContractInputGenerationWizard;
import org.bonitasoft.studio.designer.ui.contribution.CreateAndEditFormContributionItem;
import org.bonitasoft.studio.model.process.Contract;
......@@ -252,7 +253,7 @@ public class ContractPropertySection extends AbstractBonitaDescriptionSection {
fieldToContractInputMappingOperationBuilder,
fieldToContractInputMappingExpressionBuilder,
BonitaStudioPreferencesPlugin.getDefault().getPreferenceStore(),
sharedImages),
sharedImages, new ContractInputGenerationInfoDialogFactory()),
this, true);
dialog.open();
}
......
/**
* Copyright (C) 2015 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
* (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/>.
*/
package org.bonitasoft.studio.contract.ui.wizard;
import static com.google.common.base.Strings.isNullOrEmpty;
import org.bonitasoft.studio.contract.i18n.Messages;
import org.bonitasoft.studio.model.process.ContractContainer;
import org.bonitasoft.studio.model.process.OperationContainer;
import org.eclipse.jface.dialogs.MessageDialogWithToggle;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.swt.widgets.Shell;
/**
* @author aurelie
*/
public class ContractInputGenerationInfoDialogFactory {
public static final int NOT_OPENED = -2;
public static final String SHOW_GENERATION_SUCCESS_DIALOG = "SHOW_GENERATION_SUCCESS_DIALOG";
public int openInfoDialog(final IPreferenceStore preferenceStore, final Shell shell, final ContractContainer contractContainer,
final boolean isAutogeneratedScript) {
if (isNullOrEmpty(preferenceStore.getString(SHOW_GENERATION_SUCCESS_DIALOG))
&& isAutogeneratedScript) {
return MessageDialogWithToggle.openOkCancelConfirm(shell,
Messages.contractGenerationTitle,
getInfoMessage(contractContainer),
Messages.doNotShowMeAgain,
false,
preferenceStore,
SHOW_GENERATION_SUCCESS_DIALOG).getReturnCode();
}
return NOT_OPENED;
}
private String getInfoMessage(final ContractContainer contractContainer) {
if (contractContainer instanceof OperationContainer) {
return Messages.contractOperationGenerationMsg;
} else {
return Messages.contractStrictGenerationMsg;
}
}
}
......@@ -15,7 +15,6 @@
package org.bonitasoft.studio.contract.ui.wizard;
import static com.google.common.base.Predicates.instanceOf;
import static com.google.common.base.Strings.isNullOrEmpty;
import static com.google.common.collect.Iterables.filter;
import static com.google.common.collect.Lists.newArrayList;
......@@ -56,7 +55,6 @@ import org.eclipse.ui.ISharedImages;
*/
public class ContractInputGenerationWizard extends Wizard {
static final String HIDE_GENERATION_SUCCESS_DIALOG = "SHOW_GENERATION_SUCCESS_DIALOG";
private final EditingDomain editingDomain;
private final ContractContainer contractContainer;
private CreateContractInputFromBusinessObjectWizardPage contractInputFromBusinessObjectWizardPage;
......@@ -68,6 +66,8 @@ public class ContractInputGenerationWizard extends Wizard {
private final IPreferenceStore preferenceStore;
private final ISharedImages sharedImagesService;
private final FieldToContractInputMappingExpressionBuilder expressionBuilder;
private final ContractInputGenerationInfoDialogFactory infoDialogFactory;
private final GenerationOptions generationOptions;
public ContractInputGenerationWizard(final ContractContainer contractContainer,
final EditingDomain editingDomain,
......@@ -75,10 +75,12 @@ public class ContractInputGenerationWizard extends Wizard {
final FieldToContractInputMappingOperationBuilder operationBuilder,
final FieldToContractInputMappingExpressionBuilder expressionBuilder,
final IPreferenceStore preferenceStore,
final ISharedImages sharedImagesService) {
final ISharedImages sharedImagesService,
final ContractInputGenerationInfoDialogFactory infoDialogFactory) {
setWindowTitle(Messages.contractInputGenerationTitle);
setDefaultPageImageDescriptor(Pics.getWizban());
this.contractContainer = contractContainer;
generationOptions = new GenerationOptions();
this.editingDomain = editingDomain;
this.repositoryAccessor = repositoryAccessor;
fieldToContractInputMappingFactory = new FieldToContractInputMappingFactory();
......@@ -86,6 +88,7 @@ public class ContractInputGenerationWizard extends Wizard {
this.expressionBuilder = expressionBuilder;
this.preferenceStore = preferenceStore;
this.sharedImagesService = sharedImagesService;
this.infoDialogFactory = infoDialogFactory;
}
@Override
......@@ -97,9 +100,8 @@ public class ContractInputGenerationWizard extends Wizard {
}
addPage(new SelectBusinessDataWizardPage(availableBusinessData, selectedDataObservable,
repositoryAccessor.getRepositoryStore(BusinessObjectModelRepositoryStore.class)));
contractInputFromBusinessObjectWizardPage = new CreateContractInputFromBusinessObjectWizardPage(contractContainer.getContract(),
selectedDataObservable, fieldToContractInputMappingFactory, repositoryAccessor.getRepositoryStore(BusinessObjectModelRepositoryStore.class),
sharedImagesService);
contractInputFromBusinessObjectWizardPage = new CreateContractInputFromBusinessObjectWizardPage(contractContainer.getContract(), generationOptions,
selectedDataObservable, fieldToContractInputMappingFactory, repositoryAccessor.getRepositoryStore(BusinessObjectModelRepositoryStore.class));
contractInputFromBusinessObjectWizardPage.setTitle();
addPage(contractInputFromBusinessObjectWizardPage);
}
......@@ -130,32 +132,44 @@ public class ContractInputGenerationWizard extends Wizard {
final BusinessObjectData data = (BusinessObjectData) selectedDataObservable.getValue();
final RootContractInputGenerator contractInputGenerator = new RootContractInputGenerator(contractInputFromBusinessObjectWizardPage.getRootName(),
contractInputFromBusinessObjectWizardPage.getMappings(), repositoryAccessor, operationBuilder, expressionBuilder);
try {
if (contractContainer instanceof Pool) {
contractInputGenerator.buildForInstanciation(data);
} else {
contractInputGenerator.build(data);
final int returnCode = openInfoDialog();
if (returnCode == MessageDialogWithToggle.OK || returnCode == ContractInputGenerationInfoDialogFactory.NOT_OPENED) {
try {
if (contractContainer instanceof Pool) {
contractInputGenerator.buildForInstanciation(data);
} else {
contractInputGenerator.build(data);
}
} catch (final OperationCreationException e) {
BonitaStudioLog.error("Failed to create Operations from contract", e);
new BonitaErrorDialog(getShell(), Messages.errorTitle, Messages.contractFromDataCreationErrorMessage, e).open();
return false;
}
} catch (final OperationCreationException e) {
BonitaStudioLog.error("Failed to create Operations from contract", e);
new BonitaErrorDialog(getShell(), Messages.errorTitle, Messages.contractFromDataCreationErrorMessage, e).open();
return false;
editingDomain.getCommandStack().execute(createCommand(contractInputGenerator, data));
openWarningDialog(contractInputGenerator.isAllAttributesGenerated());
return true;
}
editingDomain.getCommandStack().execute(createCommand(contractInputGenerator, data));
openWarningDialog(contractInputGenerator.isAllAttributesGenerated());
openInfoDialog();
return true;
contractInputFromBusinessObjectWizardPage.disableAutoGeneration();
return false;
}
private int openInfoDialog() {
return infoDialogFactory.openInfoDialog(preferenceStore, getShell(), contractContainer,
generationOptions.isAutogeneratedScript());
}
protected CompoundCommand createCommand(final RootContractInputGenerator contractInputGenerator, final BusinessObjectData data) {
protected CompoundCommand createCommand(final RootContractInputGenerator contractInputGenerator, final BusinessObjectData data
) {
final CompoundCommand cc = new CompoundCommand();
cc.append(AddCommand.create(editingDomain, contractContainer.getContract(), ProcessPackage.Literals.CONTRACT__INPUTS,
contractInputGenerator.getRootContractInput()));
if (contractContainer instanceof OperationContainer && contractInputFromBusinessObjectWizardPage.getIsAutogeneratedOperation()) {
if (contractContainer instanceof OperationContainer
&& generationOptions.isAutogeneratedScript()) {
cc.appendIfCanExecute(AddCommand.create(editingDomain, contractContainer, ProcessPackage.Literals.OPERATION_CONTAINER__OPERATIONS,
contractInputGenerator.getMappingOperations()));
}
if (contractContainer instanceof Pool && contractInputFromBusinessObjectWizardPage.getIsAutogeneratedScript()) {
if (contractContainer instanceof Pool && generationOptions.isAutogeneratedScript()) {
cc.appendIfCanExecute(SetCommand.create(editingDomain, data, ProcessPackage.Literals.DATA__DEFAULT_VALUE,
contractInputGenerator.getInitialValueExpression()));
......@@ -163,25 +177,13 @@ public class ContractInputGenerationWizard extends Wizard {
return cc;
}
protected void openInfoDialog() {
if (contractContainer instanceof OperationContainer && isNullOrEmpty(preferenceStore.getString(HIDE_GENERATION_SUCCESS_DIALOG))) {
MessageDialogWithToggle.openInformation(getShell(),
Messages.contractGenerationTitle,
Messages.contractGenerationMsg,
Messages.doNotShowMeAgain,
false,
preferenceStore,
HIDE_GENERATION_SUCCESS_DIALOG);
}
}
protected void openWarningDialog(final boolean allAttributesGenerated) {
if (!allAttributesGenerated) {
MessageDialog.openWarning(getShell(), Messages.notAllAttributesGeneratedTitle, Messages.notAllAttributesGeneratedMsg);
}
}
/**
/**
* @return
*/
public CreateContractInputFromBusinessObjectWizardPage getContractInputFromBusinessObjectWizardPage() {
......
......@@ -74,7 +74,6 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.ISharedImages;
import com.google.common.base.Function;
......@@ -90,20 +89,21 @@ public class CreateContractInputFromBusinessObjectWizardPage extends WizardPage
private String rootName;
private final Contract contract;
private final BusinessObjectModelRepositoryStore businessObjectStore;
private final ISharedImages sharedImagesService;
private boolean isAutogeneratedOperation = true;
private boolean isAutogeneratedScript = true;
protected CreateContractInputFromBusinessObjectWizardPage(final Contract contract, final WritableValue selectedDataObservable,
final FieldToContractInputMappingFactory fieldToContractInputMappingFactory, final BusinessObjectModelRepositoryStore businessObjectStore,
final ISharedImages sharedImagesService) {
private final GenerationOptions generationOptions;
private SelectObservableValue actionObservable;
protected CreateContractInputFromBusinessObjectWizardPage(final Contract contract,
final GenerationOptions generationOptions,
final WritableValue selectedDataObservable,
final FieldToContractInputMappingFactory fieldToContractInputMappingFactory,
final BusinessObjectModelRepositoryStore businessObjectStore) {
super(CreateContractInputFromBusinessObjectWizardPage.class.getName());
setDescription(Messages.selectFieldToGenerateDescription);
this.selectedDataObservable = selectedDataObservable;
this.fieldToContractInputMappingFactory = fieldToContractInputMappingFactory;
this.contract = contract;
this.generationOptions = generationOptions;
this.businessObjectStore = businessObjectStore;
this.sharedImagesService = sharedImagesService;
}
public void setTitle() {
......@@ -145,49 +145,23 @@ public class CreateContractInputFromBusinessObjectWizardPage extends WizardPage
reminder.setLayoutData(GridDataFactory.fillDefaults().hint(600, SWT.DEFAULT).create());
final Button autoGeneratedOperationButton = new Button(composite, SWT.RADIO);
final Button manuallyDefinedOperationButton = new Button(composite, SWT.RADIO);
final SelectObservableValue actionObservable = new SelectObservableValue(Boolean.class);
actionObservable = new SelectObservableValue(Boolean.class);
actionObservable.addOption(Boolean.TRUE, SWTObservables.observeSelection(autoGeneratedOperationButton));
actionObservable.addOption(Boolean.FALSE, SWTObservables.observeSelection(manuallyDefinedOperationButton));
if (contract.eContainer() instanceof Task) {
reminder.setText(Messages.reminderForStepMessage);
autoGeneratedOperationButton.setText(Messages.autoGeneratedOperationStepButton);
manuallyDefinedOperationButton.setText(Messages.manuallyDefinedOperationStepButton);
dbc.bindValue(actionObservable, PojoObservables.observeValue(this, "isAutogeneratedOperation"));
} else {
reminder.setText(Messages.reminderForProcessMessage);
autoGeneratedOperationButton.setText(Messages.autoGeneratedOperationProcessButton);
manuallyDefinedOperationButton.setText(Messages.manuallyDefinedOperationProcessButton);
dbc.bindValue(actionObservable, PojoObservables.observeValue(this, "isAutogeneratedScript"));
}
dbc.bindValue(actionObservable, PojoObservables.observeValue(generationOptions, "autogeneratedScript"));
}
/**
* @return the isAutogeneratedOperation
*/
public boolean getIsAutogeneratedOperation() {
return isAutogeneratedOperation;
}
/**
* @return the isAutogeneratedScript
*/
public boolean getIsAutogeneratedScript() {
return isAutogeneratedScript;
}
/**
* @param isAutogeneratedOperation the isAutogeneratedOperation to set
*/
public void setIsAutogeneratedOperation(final boolean isAutogeneratedOperation) {
this.isAutogeneratedOperation = isAutogeneratedOperation;
}
/**
* @param isAutogeneratedScript the isAutogeneratedScript to set
*/
public void setIsAutogeneratedScript(final boolean isAutogeneratedScript) {
this.isAutogeneratedScript = isAutogeneratedScript;
public void disableAutoGeneration() {
actionObservable.setValue(false);
}
private void createRootNameControl(final EMFDataBindingContext dbc, final Composite composite) {
......
/**
* Copyright (C) 2015 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
* (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/>.
*/
package org.bonitasoft.studio.contract.ui.wizard;
/**
* @author aurelie
*/
public class GenerationOptions {
private boolean autogeneratedScript = true;
public boolean isAutogeneratedScript() {
return autogeneratedScript;
}
/**
* @param isAutogeneratedScript the isAutogeneratedScript to set
*/