Commit 6f2eb50b authored by Romain Bioteau's avatar Romain Bioteau

Merge branch 'master' of git@github.com:bonitasoft/bonita-studio-sp.git

parents 6833b6da c9288b3f
......@@ -61,21 +61,31 @@ public class ExpressionPredicates {
};
}
public static java.util.function.Predicate<Expression> containingReferencedElement(final EObject referencedElement) {
return exp -> isElementIsReferencedInScript(exp, referencedElement);
}
private static boolean isElementIsReferencedInScript(final Expression expr, final EObject element) {
if (!expr.getReferencedElements().isEmpty()) {
for (final EObject o : expr.getReferencedElements()) {
if (element instanceof ContractInput && o instanceof ContractInput) {
return java.util.Objects.equals(((ContractInput) o).getName(), ((ContractInput) element).getName());
}
if (EcoreUtil.equals(element, o)) {
return true;
}
if (element instanceof Element && o instanceof Element && ModelHelper.isSameElement(element, o)) {
if (element instanceof ContractInput && expr.getReferencedElements().stream()
.filter(ContractInput.class::isInstance)
.map(ContractInput.class::cast)
.map(ContractInput::getName)
.anyMatch(((ContractInput) element).getName()::equals)) {
return true;
}
if (expr.getReferencedElements().stream()
.anyMatch(dep -> EcoreUtil.equals(element, dep))) {
return true;
}
for (final EObject o : expr.getReferencedElements()) {
if (element instanceof Element && o instanceof Element && ModelHelper.isSameElement(element, o)) {
return !ModelHelper.isReferencedElementIsInExpression(expr);
} else {
if (element instanceof Parameter && o instanceof Parameter
&& ((Parameter) element).getName().equals(((Parameter) o).getName())) {
return !ModelHelper.isReferencedElementIsInExpression(expr);
} else {
if (element instanceof Parameter && o instanceof Parameter && ((Parameter) element).getName().equals(((Parameter) o).getName())) {
return !ModelHelper.isReferencedElementIsInExpression(expr);
}
}
}
}
......
......@@ -66,7 +66,8 @@ public class RefactorContractInputOperationTest {
public void should_update_contract_input_reference_in_contract_input_expressions() throws Exception {
final Task aTaskWithContractAndOperations = aTaskWithContractAndOperations();
final Expression contractInputExpression = aTaskWithContractAndOperations.getOperations().get(0).getRightOperand();
final RefactorContractInputOperation refactorOperation = new RefactorContractInputOperation(aTaskWithContractAndOperations,
final RefactorContractInputOperation refactorOperation = new RefactorContractInputOperation(
aTaskWithContractAndOperations,
scriptRefactorOperationFactory, RefactoringOperationType.UPDATE);
final ContractInput oldItem = aTaskWithContractAndOperations.getContract().getInputs().get(0);
......@@ -89,12 +90,14 @@ public class RefactorContractInputOperationTest {
final ContractInput contractInput = aTaskWithContract.getContract().getInputs()
.get(0);
final Set<ScriptContainer<?>> allScriptWithReferencedElement = refactorOperation.allScriptWithReferencedElement(new ContractInputRefactorPair(
EcoreUtil.copy(contractInput),
contractInput));
final Set<ScriptContainer<?>> allScriptWithReferencedElement = refactorOperation
.allScriptWithReferencedElement(new ContractInputRefactorPair(
EcoreUtil.copy(contractInput),
contractInput));
assertThat(allScriptWithReferencedElement).extracting("script", "modelElement").contains(
tuple("firstName.length > 0 && lastName.length > 0", aTaskWithContract.getContract().getConstraints().get(0)));
tuple("firstName.length > 0 && lastName.length > 0",
aTaskWithContract.getContract().getConstraints().get(0)));
}
@Test
......@@ -108,9 +111,10 @@ public class RefactorContractInputOperationTest {
.get(0);
final ContractInput newProcessInput = EcoreUtil.copy(contractInput);
newProcessInput.setName("newInputName");
final Set<ScriptContainer<?>> allScriptWithReferencedElement = refactorOperation.allScriptWithReferencedElement(new ContractInputRefactorPair(
newProcessInput,
contractInput));
final Set<ScriptContainer<?>> allScriptWithReferencedElement = refactorOperation
.allScriptWithReferencedElement(new ContractInputRefactorPair(
newProcessInput,
contractInput));
assertThat(allScriptWithReferencedElement.iterator().next().getModelElement().eContainer()).isNotNull();
}
......@@ -119,11 +123,14 @@ public class RefactorContractInputOperationTest {
public void should_not_refactor_input_with_same_name_in_another_contract_container() throws Exception {
final Pool process = aPool().havingContract(aContract().havingInput(aContractInput().withName("myInput")))
.havingData(aData().withName("aTextData")
.havingDefaultValue(ExpressionHelper.createContractInputExpression(aContractInput().withName("myInput").build())))
.havingElements(aTask().havingContract(aContract().havingInput(aContractInput().withName("myInput"))).havingData(aData().withName("aTextData")
.havingDefaultValue(ExpressionHelper.createContractInputExpression(aContractInput().withName("myInput").build()))))
.havingDefaultValue(ExpressionHelper
.createContractInputExpression(aContractInput().withName("myInput").build())))
.havingElements(aTask().havingContract(aContract().havingInput(aContractInput().withName("myInput")))
.havingData(aData().withName("aTextData")
.havingDefaultValue(ExpressionHelper
.createContractInputExpression(aContractInput().withName("myInput").build()))))
.build();
final RefactorContractInputOperation refactorOperation = new RefactorContractInputOperation(process,
scriptRefactorOperationFactory,
RefactoringOperationType.UPDATE);
......@@ -132,18 +139,13 @@ public class RefactorContractInputOperationTest {
final ContractInput newInput = EcoreUtil.copy(processInput);
newInput.setName("newName");
refactorOperation.addItemToRefactor(newInput, processInput);
CompoundCommand cc = new CompoundCommand();
cc = refactorOperation.doBuildCompoundCommand(cc, monitor);
assertThat(cc.getCommandList()).hasSize(1);
}
@Test(expected = IllegalArgumentException.class)
public void should_have_a_container() throws Exception {
new RefactorContractInputOperation(null, scriptRefactorOperationFactory, RefactoringOperationType.UPDATE);
}
private TransactionalEditingDomainImpl transactionalEditingDomain() {
return new TransactionalEditingDomainImpl(new ProcessItemProviderAdapterFactory());
}
......@@ -152,7 +154,8 @@ public class RefactorContractInputOperationTest {
return aTask().havingContract(aContract()
.havingInput(aContractInput().withName("firstName"))
.havingInput(aContractInput().withName("lastName"))
.havingConstraint(aContractConstraint().withExpression("firstName.length > 0 && lastName.length > 0").havingInput("firstName", "lastName")))
.havingConstraint(aContractConstraint().withExpression("firstName.length > 0 && lastName.length > 0")
.havingInput("firstName", "lastName")))
.build();
}
......@@ -160,8 +163,10 @@ public class RefactorContractInputOperationTest {
return aTask().havingContract(aContract()
.havingInput(aContractInput().withName("firstName")))
.havingOperations(anOperation()
.havingLeftOperand(anExpression().withExpressionType(ExpressionConstants.VARIABLE_TYPE).withName("storedData"))
.havingRightOperand(ExpressionHelper.createContractInputExpression(aContractInput().withName("firstName").build())))
.havingLeftOperand(
anExpression().withExpressionType(ExpressionConstants.VARIABLE_TYPE).withName("storedData"))
.havingRightOperand(ExpressionHelper
.createContractInputExpression(aContractInput().withName("firstName").build())))
.build();
}
}
......@@ -15,20 +15,28 @@
package org.bonitasoft.studio.contract.ui.property.input.edit;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.util.Arrays;
import org.bonitasoft.studio.contract.core.refactoring.ContractInputRefactorOperationFactory;
import org.bonitasoft.studio.contract.core.refactoring.RefactorContractInputOperation;
import org.bonitasoft.studio.contract.ui.property.input.ContractInputController;
import org.bonitasoft.studio.fakes.FakeProgressService;
import org.bonitasoft.studio.model.process.ContractInput;
import org.bonitasoft.studio.model.process.ContractInputType;
import org.bonitasoft.studio.model.process.ProcessFactory;
import org.bonitasoft.studio.model.process.assertions.ContractInputAssert;
import org.bonitasoft.studio.model.process.provider.ProcessItemProviderAdapterFactory;
import org.bonitasoft.studio.swt.rules.RealmWithDisplay;
import org.eclipse.emf.common.command.CompoundCommand;
import org.eclipse.emf.ecore.resource.impl.ResourceImpl;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.emf.transaction.TransactionalEditingDomain.Factory;
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.jface.viewers.ColumnViewer;
import org.eclipse.jface.viewers.StructuredSelection;
......@@ -66,14 +74,31 @@ public class ContractInputTypeEditingSupportTest {
@Mock
private ContractInputController contractInputController;
@Mock
private ContractInputRefactorOperationFactory refactorOperationFactory;
@Mock
private RefactorContractInputOperation refactorOperation;
private ResourceSetImpl resourceSet;
@Mock
private Factory transactionalEditingDomainFactory;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
parent = realm.createComposite();
resourceSet = new ResourceSetImpl();
when(refactorOperationFactory.createRefactorOperation(any(), any(), any())).thenReturn(refactorOperation);
when(refactorOperation.getCompoundCommand()).thenReturn(new CompoundCommand());
when(transactionalEditingDomainFactory.getEditingDomain(resourceSet))
.thenReturn(mock(TransactionalEditingDomain.class));
contractInputTypeEditingSupport = new ContractInputTypeEditingSupport(viewer,
new AdapterFactoryContentProvider(new ProcessItemProviderAdapterFactory()), contractInputController);
new AdapterFactoryContentProvider(new ProcessItemProviderAdapterFactory()), contractInputController,
refactorOperationFactory, new FakeProgressService(), transactionalEditingDomainFactory);
}
@Test
......@@ -86,7 +111,9 @@ public class ContractInputTypeEditingSupportTest {
public void should_initializeCellEditorValue_add_ICellEditorListener() throws Exception {
viewer = new TableViewer(parent);
contractInputTypeEditingSupport = new ContractInputTypeEditingSupport(viewer,
new AdapterFactoryContentProvider(new ProcessItemProviderAdapterFactory()), new ContractInputController(new FakeProgressService()));
new AdapterFactoryContentProvider(new ProcessItemProviderAdapterFactory()),
new ContractInputController(new FakeProgressService()),
refactorOperationFactory, new FakeProgressService(), transactionalEditingDomainFactory);
when(cell.getElement()).thenReturn(ProcessFactory.eINSTANCE.createContractInput());
contractInputTypeEditingSupport.initializeCellEditorValue(cellEditor, cell);
......@@ -96,26 +123,37 @@ public class ContractInputTypeEditingSupportTest {
@Test
public void should_setValue_setContractInput_and_refresh_viewer() throws Exception {
final ContractInput contractInput = ProcessFactory.eINSTANCE.createContractInput();
final ResourceImpl res = new ResourceImpl();
res.getContents().add(contractInput);
resourceSet.getResources().add(res);
contractInputTypeEditingSupport.setValue(contractInput, ContractInputType.COMPLEX);
assertThat(contractInputTypeEditingSupport.getContractInput()).isEqualTo(contractInput);
ContractInputAssert.assertThat(contractInput).hasType(ContractInputType.COMPLEX);
verify(refactorOperation).run(any());
verify(contractInputTypeEditingSupport.getViewer()).refresh(true);
}
@Test
public void should_applyEditorValue_add_child_input_if_type_is_changed_to_complex_and_has_no_child() throws Exception {
final ContractInput contractInput = ProcessFactory.eINSTANCE.createContractInput();
final ResourceImpl res = new ResourceImpl();
res.getContents().add(contractInput);
resourceSet.getResources().add(res);
when(viewer.getSelection()).thenReturn(new StructuredSelection(Arrays.asList(contractInput)));
contractInputTypeEditingSupport.setValue(contractInput, ContractInputType.COMPLEX);
contractInputTypeEditingSupport.applyEditorValue();
verify(contractInputController).addChildInput(viewer);
verify(refactorOperation).run(any());
}
@Test
public void should_applyEditorValue_do_nothing_input_if_type_is_changed_to_complex_and_with_child() throws Exception {
final ContractInput contractInput = ProcessFactory.eINSTANCE.createContractInput();
contractInput.getInputs().add(ProcessFactory.eINSTANCE.createContractInput());
final ResourceImpl res = new ResourceImpl();
res.getContents().add(contractInput);
resourceSet.getResources().add(res);
when(viewer.getSelection()).thenReturn(new StructuredSelection(Arrays.asList(contractInput)));
contractInputTypeEditingSupport.setValue(contractInput, ContractInputType.COMPLEX);
contractInputTypeEditingSupport.applyEditorValue();
......@@ -125,6 +163,10 @@ public class ContractInputTypeEditingSupportTest {
@Test
public void should_applyEditorValue_do_nothing_input_if_type_is_changed_to_primitive() throws Exception {
final ContractInput contractInput = ProcessFactory.eINSTANCE.createContractInput();
final ResourceImpl res = new ResourceImpl();
res.getContents().add(contractInput);
resourceSet.getResources().add(res);
when(viewer.getSelection()).thenReturn(new StructuredSelection(Arrays.asList(contractInput)));
contractInputTypeEditingSupport.setValue(contractInput, ContractInputType.INTEGER);
contractInputTypeEditingSupport.applyEditorValue();
......
......@@ -35,7 +35,8 @@ public class ConstraintExpressionScriptContainer extends ScriptContainer<Contrac
private final IScriptRefactoringOperationFactory scriptRefactoringOperationFactory;
public ConstraintExpressionScriptContainer(final ContractConstraint constraint, final IScriptRefactoringOperationFactory scriptRefactoringOperationFactory) {
public ConstraintExpressionScriptContainer(final ContractConstraint constraint,
final IScriptRefactoringOperationFactory scriptRefactoringOperationFactory) {
super(constraint, ProcessPackage.Literals.CONTRACT_CONSTRAINT__EXPRESSION, null);
this.scriptRefactoringOperationFactory = scriptRefactoringOperationFactory;
}
......@@ -54,9 +55,11 @@ public class ConstraintExpressionScriptContainer extends ScriptContainer<Contrac
* @see org.bonitasoft.studio.refactoring.core.groovy.ScriptContainer#updateScript(java.util.List, org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
public void updateScript(final List<ReferenceDiff> referenceDiffs, final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
final IScriptRefactoringOperation scriptRefactoringOperation = scriptRefactoringOperationFactory.createScriptOperationFactory(getScript(),
referenceDiffs);
public void updateScript(final List<ReferenceDiff> referenceDiffs, final IProgressMonitor monitor)
throws InvocationTargetException, InterruptedException {
final IScriptRefactoringOperation scriptRefactoringOperation = scriptRefactoringOperationFactory
.createScriptOperationFactory(getScript(),
referenceDiffs);
scriptRefactoringOperation.run(monitor);
setNewScript(scriptRefactoringOperation.getRefactoredScript());
}
......@@ -73,11 +76,12 @@ public class ConstraintExpressionScriptContainer extends ScriptContainer<Contrac
for (final String inputName : constraint.getInputNames()) {
for (final RefactorPair<? extends EObject, ? extends EObject> pair : pairsToRefactor) {
final String oldValueName = pair.getOldValueName();
if (oldValueName.equals(inputName)) {
if (oldValueName.equals(inputName) && !oldValueName.equals(pair.getNewValueName())) {
compoundCommand.append(RemoveCommand.create(editingDomain, constraint,
ProcessPackage.Literals.CONTRACT_CONSTRAINT__INPUT_NAMES,
inputName));
compoundCommand.append(AddCommand.create(editingDomain, constraint, ProcessPackage.Literals.CONTRACT_CONSTRAINT__INPUT_NAMES,
compoundCommand.append(AddCommand.create(editingDomain, constraint,
ProcessPackage.Literals.CONTRACT_CONSTRAINT__INPUT_NAMES,
pair.getNewValueName()));
}
}
......
......@@ -19,6 +19,7 @@ import static com.google.common.base.Preconditions.checkArgument;
import org.bonitasoft.studio.common.emf.tools.ModelHelper;
import org.bonitasoft.studio.model.process.ContractContainer;
import org.bonitasoft.studio.model.process.ContractInput;
import org.bonitasoft.studio.model.process.ContractInputType;
import org.bonitasoft.studio.refactoring.core.RefactoringOperationType;
import org.bonitasoft.studio.refactoring.core.emf.IRefactorOperationFactory;
import org.bonitasoft.studio.refactoring.core.script.GroovyScriptRefactoringOperationFactory;
......@@ -37,18 +38,25 @@ public class ContractInputRefactorOperationFactory implements IRefactorOperation
public RefactorContractInputOperation createRefactorOperation(
final EditingDomain domain, final EObject item, final Object newValue) {
checkArgument(item instanceof ContractInput);
checkArgument(newValue instanceof String);
final RefactorContractInputOperation refactorContractInputOperation = new RefactorContractInputOperation(ModelHelper.getFirstContainerOfType(item,
ContractContainer.class), new GroovyScriptRefactoringOperationFactory(), RefactoringOperationType.UPDATE);
final RefactorContractInputOperation refactorContractInputOperation = new RefactorContractInputOperation(
ModelHelper.getFirstContainerOfType(item,
ContractContainer.class),
new GroovyScriptRefactoringOperationFactory(), RefactoringOperationType.UPDATE);
refactorContractInputOperation.setEditingDomain(domain);
refactorContractInputOperation.setAskConfirmation(true);
refactorContractInputOperation.addItemToRefactor(inputWithNewName((ContractInput) item, newValue), (ContractInput) item);
refactorContractInputOperation.addItemToRefactor(inputWithNewName((ContractInput) item, newValue),
(ContractInput) item);
return refactorContractInputOperation;
}
private ContractInput inputWithNewName(final ContractInput input, final Object newValue) {
final ContractInput copy = EcoreUtil.copy(input);
copy.setName((String) newValue);
if (newValue instanceof String) {
copy.setName((String) newValue);
}
if (newValue instanceof ContractInputType) {
copy.setType((ContractInputType) newValue);
}
return copy;
}
......
......@@ -14,10 +14,10 @@
*/
package org.bonitasoft.studio.contract.core.refactoring;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.collect.Iterables.filter;
import static com.google.common.collect.Iterables.transform;
import static com.google.common.collect.Sets.newHashSet;
import static java.util.Objects.requireNonNull;
import static org.bonitasoft.studio.common.emf.tools.ExpressionHelper.createContractInputExpression;
import static org.bonitasoft.studio.common.emf.tools.ModelHelper.getAllElementOfTypeIn;
import static org.bonitasoft.studio.common.predicate.ExpressionPredicates.withExpressionType;
......@@ -46,16 +46,17 @@ import org.eclipse.emf.ecore.util.EcoreUtil;
import com.google.common.base.Function;
import com.google.common.base.Predicate;
public class RefactorContractInputOperation extends AbstractRefactorOperation<ContractInput, ContractInput, ContractInputRefactorPair> {
public class RefactorContractInputOperation
extends AbstractRefactorOperation<ContractInput, ContractInput, ContractInputRefactorPair> {
private final ContractContainer container;
private final IScriptRefactoringOperationFactory scriptRefactorOperationFactory;
public RefactorContractInputOperation(final ContractContainer container, final IScriptRefactoringOperationFactory scriptRefactorOperationFactory,
public RefactorContractInputOperation(final ContractContainer container,
final IScriptRefactoringOperationFactory scriptRefactorOperationFactory,
final RefactoringOperationType operationType) {
super(operationType);
checkArgument(container != null);
this.container = container;
this.container = requireNonNull(container);
this.scriptRefactorOperationFactory = scriptRefactorOperationFactory;
}
......@@ -66,16 +67,32 @@ public class RefactorContractInputOperation extends AbstractRefactorOperation<Co
return cc;
}
/*
* (non-Javadoc)
* @see
* org.bonitasoft.studio.refactoring.core.AbstractRefactorOperation#shouldUpdateReferencesInScripts(org.bonitasoft.studio.refactoring.core.RefactorPair)
*/
@Override
protected boolean shouldUpdateReferencesInScripts(RefactorPair<ContractInput, ContractInput> pairRefactor) {
return super.shouldUpdateReferencesInScripts(pairRefactor) || hasContractInputTypeChanged(pairRefactor);
}
private boolean hasContractInputTypeChanged(RefactorPair<ContractInput, ContractInput> pairRefactor) {
return pairRefactor.getOldValue().getType() != pairRefactor.getNewValue().getType();
}
/*
* (non-Javadoc)
* @see org.bonitasoft.studio.refactoring.core.AbstractRefactorOperation#allScriptWithReferencedElement(org.bonitasoft.studio.refactoring.core.RefactorPair)
*/
@Override
protected Set<ScriptContainer<?>> allScriptWithReferencedElement(final RefactorPair<ContractInput, ContractInput> pairRefactor) {
protected Set<ScriptContainer<?>> allScriptWithReferencedElement(
final RefactorPair<ContractInput, ContractInput> pairRefactor) {
final Set<ScriptContainer<?>> allScriptWithReferencedElement = newHashSet(
filter(super.allScriptWithReferencedElement(pairRefactor), inContractContainer(
ModelHelper.getFirstContainerOfType(pairRefactor.getOldValue(), ContractContainer.class))));
allScriptWithReferencedElement.addAll(constraintExpressionsReferencing(ModelHelper.getFirstContainerOfType(pairRefactor.getOldValue(), Contract.class),
allScriptWithReferencedElement.addAll(constraintExpressionsReferencing(
ModelHelper.getFirstContainerOfType(pairRefactor.getOldValue(), Contract.class),
pairRefactor.getOldValue()));
return allScriptWithReferencedElement;
}
......@@ -85,12 +102,14 @@ public class RefactorContractInputOperation extends AbstractRefactorOperation<Co
@Override
public boolean apply(ScriptContainer<?> sc) {
return EcoreUtil.equals(ModelHelper.getFirstContainerOfType(sc.getModelElement(), ContractContainer.class), contractContainer);
return EcoreUtil.equals(ModelHelper.getFirstContainerOfType(sc.getModelElement(), ContractContainer.class),
contractContainer);
}
};
}
private Collection<? extends ScriptContainer<?>> constraintExpressionsReferencing(final Contract contract, final ContractInput contractInput) {
private Collection<? extends ScriptContainer<?>> constraintExpressionsReferencing(final Contract contract,
final ContractInput contractInput) {
return newHashSet(transform(
filter(contract.getConstraints(),
constraintReferencing(contractInput)),
......@@ -118,18 +137,21 @@ public class RefactorContractInputOperation extends AbstractRefactorOperation<Co
}
private void updateContractInputExpressions(final CompoundCommand cc) {
for (final Expression exp : filter(getAllElementOfTypeIn(container, Expression.class), withExpressionType(ExpressionConstants.CONTRACT_INPUT_TYPE))) {
for (final Expression exp : filter(getAllElementOfTypeIn(container, Expression.class),
withExpressionType(ExpressionConstants.CONTRACT_INPUT_TYPE))) {
for (final ContractInputRefactorPair pairToRefactor : filter(pairsToRefactor, matches(exp))) {
final ContractInput newValue = pairToRefactor.getNewValue();
cc.append(new UpdateExpressionCommand(getEditingDomain(), exp, newValue != null ? createContractInputExpression(newValue)
: createDefaultExpression(exp)));
cc.append(new UpdateExpressionCommand(getEditingDomain(), exp,
newValue != null ? createContractInputExpression(newValue)
: createDefaultExpression(exp)));
}
}
}
private Expression createDefaultExpression(final Expression exp) {
return ExpressionHelper.createConstantExpression("", exp.isReturnTypeFixed() ? exp.getReturnType() : String.class.getName());
return ExpressionHelper.createConstantExpression("",
exp.isReturnTypeFixed() ? exp.getReturnType() : String.class.getName());
}
private Predicate<ContractInputRefactorPair> matches(final Expression expression) {
......
......@@ -34,6 +34,7 @@ import org.eclipse.emf.databinding.EMFDataBindingContext;
import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider;
import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.jface.databinding.viewers.ObservableListTreeContentProvider;
import org.eclipse.jface.viewers.CellNavigationStrategy;
import org.eclipse.jface.viewers.ColumnViewerEditor;
......@@ -192,7 +193,9 @@ public class ContractInputTreeViewer extends TreeViewer {
final TreeViewerColumn typeColumnViewer = createColumnViewer(Messages.type, SWT.FILL);
typeColumnViewer.setLabelProvider(new ContractInputTypeCellLabelProvider());
typeColumnViewer
.setEditingSupport(new ContractInputTypeEditingSupport(this, propertySourceProvider, inputController));
.setEditingSupport(new ContractInputTypeEditingSupport(this, propertySourceProvider, inputController,
new ContractInputRefactorOperationFactory(), progressService,
TransactionalEditingDomain.Factory.INSTANCE));
}
protected void createMultipleColumn() {
......
......@@ -14,14 +14,25 @@
*/
package org.bonitasoft.studio.contract.ui.property.input.edit;
import java.lang.reflect.InvocationTargetException;
import org.bonitasoft.studio.common.log.BonitaStudioLog;
import org.bonitasoft.studio.contract.core.refactoring.ContractInputRefactorOperationFactory;
import org.bonitasoft.studio.contract.ui.property.input.ContractInputController;
import org.bonitasoft.studio.model.process.ContractInput;
import org.bonitasoft.studio.model.process.ContractInputType;
import org.bonitasoft.studio.model.process.ProcessPackage;
import org.bonitasoft.studio.refactoring.core.AbstractRefactorOperation;
import org.bonitasoft.studio.refactoring.core.RefactorPair;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.edit.command.SetCommand;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.emf.transaction.TransactionalEditingDomain.Factory;
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.jface.viewers.ColumnViewer;
import org.eclipse.jface.viewers.ICellEditorListener;
import org.eclipse.jface.viewers.ViewerCell;
import org.eclipse.ui.progress.IProgressService;
import org.eclipse.ui.views.properties.IPropertySourceProvider;
import org.eclipse.ui.views.properties.PropertyEditingSupport;
......@@ -32,11 +43,19 @@ public class ContractInputTypeEditingSupport extends PropertyEditingSupport impl
private final ContractInputController controller;
private ContractInput contractInput;
private final ContractInputRefactorOperationFactory contractInputRefactorOperationFactory;
private final IProgressService progressService;
private final Factory transactionalEditingDomainFactory;
public ContractInputTypeEditingSupport(final ColumnViewer viewer, final IPropertySourceProvider propertySourceProvider,
final ContractInputController controller) {
final ContractInputController controller, ContractInputRefactorOperationFactory refactorOperationFactory,
IProgressService progressService,
TransactionalEditingDomain.Factory transactionalEditingDomainFactory) {
super(viewer, propertySourceProvider, ProcessPackage.Literals.CONTRACT_INPUT__TYPE.getName());
this.controller = controller;
this.contractInputRefactorOperationFactory = refactorOperationFactory;
this.progressService = progressService;
this.transactionalEditingDomainFactory = transactionalEditingDomainFactory;
}