blob: c23c8ed3711e64342eba443c6993f29e2d79013b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
/***************************************************************************
* Copyright (c) 2007 Conselleria de Infraestructuras y Transporte,
* Generalitat de la Comunitat Valenciana . 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 http://www.eclipse.org/legal/epl-v10.html
*
* Contributors: Gabriel Merin Cubero (Prodevelop) – Sequence Diagram implementation
*
******************************************************************************/
package org.eclipse.papyrus.diagram.sequence.edit.policies;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.gmf.runtime.diagram.core.util.ViewType;
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEditPolicy;
import org.eclipse.gmf.runtime.notation.Diagram;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.uml2.uml.UMLPackage;
import org.eclipse.papyrus.diagram.common.util.MDTUtil;
import org.eclipse.papyrus.diagram.common.util.MultiDiagramUtil;
import org.eclipse.papyrus.diagram.sequence.edit.parts.BehaviorExecutionSpecificationEditPart;
import org.eclipse.papyrus.diagram.sequence.part.UMLDiagramUpdater;
import org.eclipse.papyrus.diagram.sequence.part.UMLNodeDescriptor;
import org.eclipse.papyrus.diagram.sequence.part.UMLVisualIDRegistry;
/**
* @generated
*/
public class LifelineCanonicalEditPolicy extends CanonicalEditPolicy {
/**
* @generated
*/
Set myFeaturesToSynchronize;
/**
* @generated
*/
@Override
protected List getSemanticChildrenList() {
View viewObject = (View) getHost().getModel();
List result = new LinkedList();
for (Iterator it = UMLDiagramUpdater.getLifeline_2002SemanticChildren(
viewObject).iterator(); it.hasNext();) {
EObject nextValue = ((UMLNodeDescriptor) it.next())
.getModelElement();
if (MultiDiagramUtil.findEObjectReferencedInEAnnotation(getHost(),
nextValue)) {
result.add(nextValue);
}
}
return result;
}
/**
* @generated
*/
@Override
protected boolean isOrphaned(Collection semanticChildren, final View view) {
if (view.getType() == ViewType.NOTE || view.getType() == ViewType.TEXT) {
return false;
}
if (view.getElement() != null) {
int actualID = UMLVisualIDRegistry.getVisualID(view);
int suggestedID = UMLVisualIDRegistry.getNodeVisualID(
(View) getHost().getModel(), view.getElement());
switch (actualID) {
case BehaviorExecutionSpecificationEditPart.VISUAL_ID:
return actualID != suggestedID;
}
return false;
}
return true;
}
/**
* @generated
*/
@Override
protected String getDefaultFactoryHint() {
return null;
}
/**
* @generated
*/
@Override
protected Set getFeaturesToSynchronize() {
if (myFeaturesToSynchronize == null) {
myFeaturesToSynchronize = new HashSet();
myFeaturesToSynchronize.add(UMLPackage.eINSTANCE
.getInteraction_Fragment());
}
return myFeaturesToSynchronize;
}
/**
* @generated
*/
@Override
protected void refreshSemantic() {
super.refreshSemantic();
// this will take care of the filtering of views
Diagram diagram = MDTUtil.getHostDiagram(this);
if (diagram != null) {
MDTUtil.filterDiagramViews(diagram);
}
}
}
|