diff options
author | Christian W. Damus | 2015-05-12 19:06:51 +0000 |
---|---|---|
committer | Christian W. Damus | 2015-05-12 19:13:41 +0000 |
commit | 678507300d73e5d9c6369697f5849da9a4d7673f (patch) | |
tree | 11f0329cbb35d87d87bfea009ace93638ce80b3f /extraplugins | |
parent | 743facd124957c79853d2efce281621a936c8703 (diff) | |
download | org.eclipse.papyrus-678507300d73e5d9c6369697f5849da9a4d7673f.tar.gz org.eclipse.papyrus-678507300d73e5d9c6369697f5849da9a4d7673f.tar.xz org.eclipse.papyrus-678507300d73e5d9c6369697f5849da9a4d7673f.zip |
Bug 465416: Synchronization of diagrams with other diagrams
https://bugs.eclipse.org/bugs/show_bug.cgi?id=465416
Fix exceptions on attempt to delete and init-synchronize FinalState because the
nested floating label edit-part is taken as a region. This is fixed generally by
adding filtering of child edit-parts in the iteration of a parent to process only those
that visualize elements of the semantic child type; and specifically by not adding the
regions sync-features to the sync-buckets for FinalStates in both the semantic and
notation synchronization.
Diffstat (limited to 'extraplugins')
4 files changed, 37 insertions, 13 deletions
diff --git a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/internal/sync/UMLRTChildNodesSyncFeature.java b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/internal/sync/UMLRTChildNodesSyncFeature.java index 9deca016894..68a6b768291 100644 --- a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/internal/sync/UMLRTChildNodesSyncFeature.java +++ b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/internal/sync/UMLRTChildNodesSyncFeature.java @@ -24,17 +24,20 @@ import org.eclipse.papyrus.infra.sync.SyncItem; /** * Synchronization feature for the edit-parts visualizing the nodes in an UML-RT diagram. */ -public abstract class UMLRTChildNodesSyncFeature<M extends EObject, N extends EObject> extends ContainerChildrenSyncFeature<M, EditPart> { - private final UMLRTSyncRegistry<N> nestedRegistry; - +public abstract class UMLRTChildNodesSyncFeature<M extends EObject, N extends EObject> extends ContainerChildrenSyncFeature<M, N, EditPart> { public UMLRTChildNodesSyncFeature(SyncBucket<M, EditPart, Notification> bucket) { super(bucket); - - nestedRegistry = getSyncRegistry(getNestedSyncRegistryType()); } + @Override protected abstract Class<? extends UMLRTSyncRegistry<N>> getNestedSyncRegistryType(); + @Override + protected UMLRTSyncRegistry<N> getNestedSyncRegistry() { + // This cast is safe because we narrowed the result type of the getNestedSyncRegistryType() method + return (UMLRTSyncRegistry<N>) super.getNestedSyncRegistry(); + } + protected abstract SyncBucket<N, EditPart, Notification> createNestedSyncBucket(N model, EditPart editPart); protected abstract Iterable<? extends N> getModelContents(M model); @@ -43,6 +46,8 @@ public abstract class UMLRTChildNodesSyncFeature<M extends EObject, N extends EO protected boolean match(EObject sourceModel, EObject targetModel) { boolean result = false; + final UMLRTSyncRegistry<N> nestedRegistry = getNestedSyncRegistry(); + // One case of a match is when I already have established synchronization between these elements result = nestedRegistry.getModelType().isInstance(sourceModel) && nestedRegistry.getSemanticSyncRegistry().synchronizes(targetModel, nestedRegistry.getModelType().cast(sourceModel)); @@ -64,6 +69,7 @@ public abstract class UMLRTChildNodesSyncFeature<M extends EObject, N extends EO * an object added to the {@link SyncItem#getModel() model} of the {@code from} item * @return the corresponding object in the {@code model} of the {@code to} item */ + @SuppressWarnings("unchecked") @Override protected EObject getTargetModel(SyncItem<M, EditPart> from, SyncItem<M, EditPart> to, EObject sourceModel) { EObject result = sourceModel; @@ -80,6 +86,8 @@ public abstract class UMLRTChildNodesSyncFeature<M extends EObject, N extends EO @Override protected Command onTargetAdded(SyncItem<M, EditPart> from, EObject source, SyncItem<M, EditPart> to, EditPart target) { + final UMLRTSyncRegistry<N> nestedRegistry = getNestedSyncRegistry(); + N nested = nestedRegistry.getModelOf(target); N masterNested = (nested == null) ? null : nestedRegistry.getRedefinedElement(nested); @@ -105,6 +113,8 @@ public abstract class UMLRTChildNodesSyncFeature<M extends EObject, N extends EO @Override protected Command onTargetRemoved(SyncItem<M, EditPart> to, EditPart target) { + final UMLRTSyncRegistry<N> nestedRegistry = getNestedSyncRegistry(); + N nested = nestedRegistry.getModelOf(target); N masterNested = (nested == null) ? null : nestedRegistry.getRedefinedElement(nested); diff --git a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/internal/sync/UMLRTDiagramEdgesSyncFeature.java b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/internal/sync/UMLRTDiagramEdgesSyncFeature.java index 4ba36859403..6f60b801ec2 100644 --- a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/internal/sync/UMLRTDiagramEdgesSyncFeature.java +++ b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/internal/sync/UMLRTDiagramEdgesSyncFeature.java @@ -24,23 +24,28 @@ import org.eclipse.papyrus.infra.sync.SyncItem; /** * Synchronization feature for the edit-parts visualizing connections in an UML-RT diagram. */ -public abstract class UMLRTDiagramEdgesSyncFeature<M extends EObject, N extends EObject> extends DiagramEdgesSyncFeature<M, EditPart> { - private final UMLRTSyncRegistry<N> nestedRegistry; - +public abstract class UMLRTDiagramEdgesSyncFeature<M extends EObject, N extends EObject> extends DiagramEdgesSyncFeature<M, N, EditPart> { public UMLRTDiagramEdgesSyncFeature(SyncBucket<M, EditPart, Notification> bucket) { super(bucket); - - nestedRegistry = getSyncRegistry(getNestedSyncRegistryType()); } + @Override protected abstract Class<? extends UMLRTSyncRegistry<N>> getNestedSyncRegistryType(); + @Override + protected UMLRTSyncRegistry<N> getNestedSyncRegistry() { + // This cast is safe because we narrowed the result type of the getNestedSyncRegistryType() method + return (UMLRTSyncRegistry<N>) super.getNestedSyncRegistry(); + } + protected abstract SyncBucket<N, EditPart, Notification> createNestedSyncBucket(N model, EditPart editPart); protected abstract Iterable<? extends N> getModelContents(M model); @Override protected boolean match(EObject sourceModel, EObject targetModel) { + final UMLRTSyncRegistry<N> nestedRegistry = getNestedSyncRegistry(); + // Is the source object redefined by the target object? return nestedRegistry.getRedefinedElement(nestedRegistry.getModelType().cast(targetModel)) == sourceModel; } @@ -57,6 +62,7 @@ public abstract class UMLRTDiagramEdgesSyncFeature<M extends EObject, N extends * an object added to the {@link SyncItem#getModel() model} of the {@code from} item * @return the corresponding object in the {@code model} of the {@code to} item */ + @SuppressWarnings("unchecked") @Override protected EObject getTargetModel(SyncItem<M, EditPart> from, SyncItem<M, EditPart> to, EObject sourceModel) { EObject result = sourceModel; @@ -73,6 +79,8 @@ public abstract class UMLRTDiagramEdgesSyncFeature<M extends EObject, N extends @Override protected Command onTargetAdded(SyncItem<M, EditPart> from, EObject source, SyncItem<M, EditPart> to, EditPart target) { + final UMLRTSyncRegistry<N> nestedRegistry = getNestedSyncRegistry(); + N nested = nestedRegistry.getModelOf(target); N masterNested = (nested == null) ? null : nestedRegistry.getRedefinedElement(nested); @@ -98,6 +106,8 @@ public abstract class UMLRTDiagramEdgesSyncFeature<M extends EObject, N extends @Override protected Command onTargetRemoved(SyncItem<M, EditPart> to, EditPart target) { + final UMLRTSyncRegistry<N> nestedRegistry = getNestedSyncRegistry(); + N nested = nestedRegistry.getModelOf(target); N masterNested = (nested == null) ? null : nestedRegistry.getRedefinedElement(nested); diff --git a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/internal/sync/statemachine/VertexSyncBucket.java b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/internal/sync/statemachine/VertexSyncBucket.java index 2be4e20f214..7995bc83c65 100644 --- a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/internal/sync/statemachine/VertexSyncBucket.java +++ b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/internal/sync/statemachine/VertexSyncBucket.java @@ -17,6 +17,7 @@ import org.eclipse.gef.EditPart; import org.eclipse.papyrus.infra.gmfdiag.common.sync.NodePositionSyncFeature; import org.eclipse.papyrus.infra.gmfdiag.common.sync.NodeSizeSyncFeature; import org.eclipse.papyrus.umlrt.ui.internal.sync.UMLRTMasterSlaveSyncBucket; +import org.eclipse.uml2.uml.FinalState; import org.eclipse.uml2.uml.State; import org.eclipse.uml2.uml.Vertex; @@ -31,7 +32,8 @@ public class VertexSyncBucket extends UMLRTMasterSlaveSyncBucket<Vertex> { add(new NodeSizeSyncFeature<>(this)); add(new NodePositionSyncFeature<>(this)); - if (model instanceof State) { + // Final states don't contain regions + if ((model instanceof State) && !(model instanceof FinalState)) { add(new StateMachineRegionsSyncFeature<>(this)); } } diff --git a/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/internal/sync/statemachine/RegionVerticesSyncFeature.java b/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/internal/sync/statemachine/RegionVerticesSyncFeature.java index 5db8556e85b..fc0c25a03bd 100644 --- a/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/internal/sync/statemachine/RegionVerticesSyncFeature.java +++ b/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/internal/sync/statemachine/RegionVerticesSyncFeature.java @@ -21,6 +21,7 @@ import org.eclipse.papyrus.infra.sync.SyncBucket; import org.eclipse.papyrus.infra.sync.SyncItem; import org.eclipse.papyrus.infra.sync.SyncRegistry; import org.eclipse.papyrus.umlrt.internal.sync.UMLSyncFeature; +import org.eclipse.uml2.uml.FinalState; import org.eclipse.uml2.uml.Region; import org.eclipse.uml2.uml.State; import org.eclipse.uml2.uml.UMLPackage; @@ -65,8 +66,9 @@ public class RegionVerticesSyncFeature extends UMLSyncFeature<Region, Vertex> { result = synchronizingWrapper(registry, vertex, result); } - // And if it's a state, it has additional synchronization to be done - if (vertex instanceof State) { + // And if it's a state, it has additional synchronization to be done for its regions (supporting composite states). + // Note that FinalStates, though they are states, do not have regions + if ((vertex instanceof State) && !(vertex instanceof FinalState)) { State state = (State) vertex; State superState = (State) superVertex; StateSyncRegistry stateRegistry = getSyncRegistry(StateSyncRegistry.class); |