Skip to content

Commit

Permalink
[1972] Transitions locks are not released after a merge then cancel
Browse files Browse the repository at this point in the history
Bug: 1972
Change-Id: I39055abf5bfdd1f36a24e9e56a144ab182696641
Signed-off-by: Philippe DUL <philippe.dul@thalesgroup.com>
  • Loading branch information
pdulth committed Mar 13, 2018
1 parent 3abd3fe commit dcccfa3
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 13 deletions.
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2016 THALES GLOBAL SERVICES.
* Copyright (c) 2006, 2018 THALES GLOBAL SERVICES.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
Expand All @@ -16,8 +16,10 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.emf.diffmerge.api.diff.IDifference;
import org.eclipse.emf.diffmerge.api.scopes.IEditableModelScope;
import org.polarsys.capella.core.transition.common.constants.ITransitionConstants;
import org.polarsys.capella.core.transition.common.handlers.merge.MergeHandlerHelper;
import org.polarsys.capella.core.transition.common.merge.scope.ITargetModelScope;
import org.polarsys.kitalpha.cadence.core.api.parameter.ActivityParameters;
import org.polarsys.kitalpha.transposer.api.ITransposerWorkflow;
import org.polarsys.kitalpha.transposer.rules.handler.rules.api.IContext;
Expand Down Expand Up @@ -48,6 +50,11 @@ public IStatus _run(ActivityParameters activityParams) {
return Status.OK_STATUS;
}

IEditableModelScope targetScope = (IEditableModelScope) context.get(ITransitionConstants.MERGE_TARGET_SCOPE);
if (targetScope instanceof ITargetModelScope.Edit) {
((ITargetModelScope.Edit) targetScope).setDirty(false);
}

return Status.CANCEL_STATUS;

}
Expand Down
Expand Up @@ -22,4 +22,10 @@ public interface ITargetModelScope {
public boolean isDirty();

Collection<EObject> retrieveTransformedElementsFromTarget(EObject targetElement);

interface Edit {

public void setDirty(boolean dirty);

}
}
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2016 THALES GLOBAL SERVICES.
* Copyright (c) 2006, 2018 THALES GLOBAL SERVICES.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -29,40 +29,43 @@
/**
* A model scope covering target model scope.
*/
public class TargetModelScope extends ContextModelScope implements ITargetModelScope {
public class TargetModelScope extends ContextModelScope implements ITargetModelScope, ITargetModelScope.Edit {

public TargetModelScope(List<? extends EObject> elements, IContext context) {
super(elements, context);
}


protected boolean dirty;

public boolean isDirty() {
return dirty;
}

public void setDirty(boolean dirty) {
this.dirty = dirty;
}

@Override
public boolean add(EObject element) {
dirty = true;
setDirty(true);
return super.add(element);
}

@Override
public boolean add(EObject element, boolean includeChildren) {
dirty = true;
setDirty(true);
return super.add(element, includeChildren);
}

@Override
public boolean add(EObject source, EReference reference, EObject value) {
dirty = true;
setDirty(true);
return super.add(source, reference, value);
}

@Override
public boolean remove(EObject element) {
dirty = true;
setDirty(true);
return super.remove(element);
}

Expand All @@ -74,31 +77,31 @@ public void removeFromScope(EObject element) {

@Override
public boolean add(EObject source_p, EAttribute attribute_p, Object value_p) {
dirty = true;
setDirty(true);
return super.add(source_p, attribute_p, value_p);
}

@Override
public Object move(EObject source_p, EStructuralFeature feature_p, int newPosition_p, int oldPosition_p) {
dirty = true;
setDirty(true);
return super.move(source_p, feature_p, newPosition_p, oldPosition_p);
}

@Override
public boolean remove(EObject source_p, EAttribute attribute_p, Object value_p) {
dirty = true;
setDirty(true);
return super.remove(source_p, attribute_p, value_p);
}

@Override
public boolean remove(EObject source_p, EReference reference_p, EObject value_p) {
dirty = true;
setDirty(true);
return super.remove(source_p, reference_p, value_p);
}

@Override
protected boolean removeValue(EObject source_p, EStructuralFeature feature_p, Object value_p) {
dirty = true;
setDirty(true);
return super.removeValue(source_p, feature_p, value_p);
}

Expand Down Expand Up @@ -153,4 +156,5 @@ protected List<EObject> retains(List<EObject> object) {
return object;
}


}

0 comments on commit dcccfa3

Please sign in to comment.