|
Added
Link Here
|
| 1 |
package org.eclipse.uml2.diagram.clazz.edit.policies; |
| 2 |
|
| 3 |
import java.util.Collection; |
| 4 |
import java.util.Collections; |
| 5 |
import java.util.HashMap; |
| 6 |
import java.util.Iterator; |
| 7 |
import java.util.LinkedList; |
| 8 |
import java.util.List; |
| 9 |
import java.util.Map; |
| 10 |
|
| 11 |
import org.eclipse.core.runtime.IAdaptable; |
| 12 |
import org.eclipse.emf.ecore.EClass; |
| 13 |
import org.eclipse.emf.ecore.EObject; |
| 14 |
import org.eclipse.gef.EditPart; |
| 15 |
import org.eclipse.gef.commands.Command; |
| 16 |
import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil; |
| 17 |
import org.eclipse.gmf.runtime.diagram.ui.commands.DeferredLayoutCommand; |
| 18 |
import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy; |
| 19 |
import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; |
| 20 |
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalConnectionEditPolicy; |
| 21 |
import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewRequest; |
| 22 |
import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants; |
| 23 |
import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter; |
| 24 |
import org.eclipse.gmf.runtime.emf.type.core.IElementType; |
| 25 |
import org.eclipse.gmf.runtime.notation.Diagram; |
| 26 |
import org.eclipse.gmf.runtime.notation.Edge; |
| 27 |
import org.eclipse.gmf.runtime.notation.View; |
| 28 |
import org.eclipse.uml2.diagram.clazz.association.AssociationEndConvention; |
| 29 |
import org.eclipse.uml2.diagram.clazz.edit.parts.AssociationClass2EditPart; |
| 30 |
import org.eclipse.uml2.diagram.clazz.edit.parts.AssociationClassEditPart; |
| 31 |
import org.eclipse.uml2.diagram.clazz.edit.parts.AssociationEditPart; |
| 32 |
import org.eclipse.uml2.diagram.clazz.edit.parts.Class2EditPart; |
| 33 |
import org.eclipse.uml2.diagram.clazz.edit.parts.Class3EditPart; |
| 34 |
import org.eclipse.uml2.diagram.clazz.edit.parts.ClassEditPart; |
| 35 |
import org.eclipse.uml2.diagram.clazz.edit.parts.ConstraintConstrainedElementEditPart; |
| 36 |
import org.eclipse.uml2.diagram.clazz.edit.parts.ConstraintEditPart; |
| 37 |
import org.eclipse.uml2.diagram.clazz.edit.parts.DataType2EditPart; |
| 38 |
import org.eclipse.uml2.diagram.clazz.edit.parts.DataTypeEditPart; |
| 39 |
import org.eclipse.uml2.diagram.clazz.edit.parts.Dependency2EditPart; |
| 40 |
import org.eclipse.uml2.diagram.clazz.edit.parts.DependencyClientEditPart; |
| 41 |
import org.eclipse.uml2.diagram.clazz.edit.parts.DependencyEditPart; |
| 42 |
import org.eclipse.uml2.diagram.clazz.edit.parts.DependencySupplierEditPart; |
| 43 |
import org.eclipse.uml2.diagram.clazz.edit.parts.Enumeration2EditPart; |
| 44 |
import org.eclipse.uml2.diagram.clazz.edit.parts.EnumerationEditPart; |
| 45 |
import org.eclipse.uml2.diagram.clazz.edit.parts.EnumerationLiteralEditPart; |
| 46 |
import org.eclipse.uml2.diagram.clazz.edit.parts.GeneralizationEditPart; |
| 47 |
import org.eclipse.uml2.diagram.clazz.edit.parts.InstanceSpecification2EditPart; |
| 48 |
import org.eclipse.uml2.diagram.clazz.edit.parts.InstanceSpecificationEditPart; |
| 49 |
import org.eclipse.uml2.diagram.clazz.edit.parts.InterfaceEditPart; |
| 50 |
import org.eclipse.uml2.diagram.clazz.edit.parts.InterfaceRealizationEditPart; |
| 51 |
import org.eclipse.uml2.diagram.clazz.edit.parts.LiteralStringEditPart; |
| 52 |
import org.eclipse.uml2.diagram.clazz.edit.parts.Operation2EditPart; |
| 53 |
import org.eclipse.uml2.diagram.clazz.edit.parts.Operation3EditPart; |
| 54 |
import org.eclipse.uml2.diagram.clazz.edit.parts.Operation4EditPart; |
| 55 |
import org.eclipse.uml2.diagram.clazz.edit.parts.Operation5EditPart; |
| 56 |
import org.eclipse.uml2.diagram.clazz.edit.parts.OperationEditPart; |
| 57 |
import org.eclipse.uml2.diagram.clazz.edit.parts.Package2EditPart; |
| 58 |
import org.eclipse.uml2.diagram.clazz.edit.parts.Package3EditPart; |
| 59 |
import org.eclipse.uml2.diagram.clazz.edit.parts.PackageEditPart; |
| 60 |
import org.eclipse.uml2.diagram.clazz.edit.parts.PortEditPart; |
| 61 |
import org.eclipse.uml2.diagram.clazz.edit.parts.PrimitiveType2EditPart; |
| 62 |
import org.eclipse.uml2.diagram.clazz.edit.parts.PrimitiveTypeEditPart; |
| 63 |
import org.eclipse.uml2.diagram.clazz.edit.parts.Property2EditPart; |
| 64 |
import org.eclipse.uml2.diagram.clazz.edit.parts.Property3EditPart; |
| 65 |
import org.eclipse.uml2.diagram.clazz.edit.parts.Property4EditPart; |
| 66 |
import org.eclipse.uml2.diagram.clazz.edit.parts.Property5EditPart; |
| 67 |
import org.eclipse.uml2.diagram.clazz.edit.parts.Property6EditPart; |
| 68 |
import org.eclipse.uml2.diagram.clazz.edit.parts.PropertyEditPart; |
| 69 |
import org.eclipse.uml2.diagram.clazz.edit.parts.SlotEditPart; |
| 70 |
import org.eclipse.uml2.diagram.clazz.edit.parts.UsageEditPart; |
| 71 |
import org.eclipse.uml2.diagram.clazz.part.UMLVisualIDRegistry; |
| 72 |
import org.eclipse.uml2.diagram.clazz.providers.UMLElementTypes; |
| 73 |
import org.eclipse.uml2.uml.Association; |
| 74 |
import org.eclipse.uml2.uml.BehavioredClassifier; |
| 75 |
import org.eclipse.uml2.uml.Classifier; |
| 76 |
import org.eclipse.uml2.uml.Constraint; |
| 77 |
import org.eclipse.uml2.uml.Dependency; |
| 78 |
import org.eclipse.uml2.uml.Generalization; |
| 79 |
import org.eclipse.uml2.uml.InterfaceRealization; |
| 80 |
import org.eclipse.uml2.uml.Property; |
| 81 |
import org.eclipse.uml2.uml.TypedElement; |
| 82 |
import org.eclipse.uml2.uml.UMLPackage; |
| 83 |
|
| 84 |
/** |
| 85 |
* @generated |
| 86 |
*/ |
| 87 |
public class PackageCanonicalEditPolicy extends CanonicalConnectionEditPolicy { |
| 88 |
|
| 89 |
/** |
| 90 |
* @generated |
| 91 |
*/ |
| 92 |
protected List getSemanticChildrenList() { |
| 93 |
List result = new LinkedList(); |
| 94 |
EObject modelObject = ((View) getHost().getModel()).getElement(); |
| 95 |
View viewObject = (View) getHost().getModel(); |
| 96 |
EObject nextValue; |
| 97 |
int nodeVID; |
| 98 |
for (Iterator values = ((org.eclipse.uml2.uml.Package) modelObject).getNestedPackages().iterator(); values.hasNext();) { |
| 99 |
nextValue = (EObject) values.next(); |
| 100 |
nodeVID = UMLVisualIDRegistry.getNodeVisualID(viewObject, nextValue); |
| 101 |
if (Package2EditPart.VISUAL_ID == nodeVID) { |
| 102 |
result.add(nextValue); |
| 103 |
} |
| 104 |
} |
| 105 |
for (Iterator values = ((org.eclipse.uml2.uml.Package) modelObject).getOwnedTypes().iterator(); values.hasNext();) { |
| 106 |
nextValue = (EObject) values.next(); |
| 107 |
nodeVID = UMLVisualIDRegistry.getNodeVisualID(viewObject, nextValue); |
| 108 |
switch (nodeVID) { |
| 109 |
case Class2EditPart.VISUAL_ID: { |
| 110 |
result.add(nextValue); |
| 111 |
break; |
| 112 |
} |
| 113 |
case AssociationClass2EditPart.VISUAL_ID: { |
| 114 |
result.add(nextValue); |
| 115 |
break; |
| 116 |
} |
| 117 |
case DataType2EditPart.VISUAL_ID: { |
| 118 |
result.add(nextValue); |
| 119 |
break; |
| 120 |
} |
| 121 |
case PrimitiveType2EditPart.VISUAL_ID: { |
| 122 |
result.add(nextValue); |
| 123 |
break; |
| 124 |
} |
| 125 |
case Enumeration2EditPart.VISUAL_ID: { |
| 126 |
result.add(nextValue); |
| 127 |
break; |
| 128 |
} |
| 129 |
case InterfaceEditPart.VISUAL_ID: { |
| 130 |
result.add(nextValue); |
| 131 |
break; |
| 132 |
} |
| 133 |
} |
| 134 |
} |
| 135 |
for (Iterator values = ((org.eclipse.uml2.uml.Package) modelObject).getPackagedElements().iterator(); values.hasNext();) { |
| 136 |
nextValue = (EObject) values.next(); |
| 137 |
nodeVID = UMLVisualIDRegistry.getNodeVisualID(viewObject, nextValue); |
| 138 |
switch (nodeVID) { |
| 139 |
case ConstraintEditPart.VISUAL_ID: { |
| 140 |
result.add(nextValue); |
| 141 |
break; |
| 142 |
} |
| 143 |
case InstanceSpecification2EditPart.VISUAL_ID: { |
| 144 |
result.add(nextValue); |
| 145 |
break; |
| 146 |
} |
| 147 |
case DependencyEditPart.VISUAL_ID: { |
| 148 |
result.add(nextValue); |
| 149 |
break; |
| 150 |
} |
| 151 |
} |
| 152 |
} |
| 153 |
return result; |
| 154 |
} |
| 155 |
|
| 156 |
/** |
| 157 |
* @generated |
| 158 |
*/ |
| 159 |
protected boolean shouldDeleteView(View view) { |
| 160 |
return view.isSetElement() && view.getElement() != null && view.getElement().eIsProxy(); |
| 161 |
} |
| 162 |
|
| 163 |
/** |
| 164 |
* @generated |
| 165 |
*/ |
| 166 |
protected String getDefaultFactoryHint() { |
| 167 |
return null; |
| 168 |
} |
| 169 |
|
| 170 |
/** |
| 171 |
* @generated |
| 172 |
*/ |
| 173 |
protected List getSemanticConnectionsList() { |
| 174 |
return Collections.EMPTY_LIST; |
| 175 |
} |
| 176 |
|
| 177 |
/** |
| 178 |
* @generated |
| 179 |
*/ |
| 180 |
protected EObject getSourceElement(EObject relationship) { |
| 181 |
return null; |
| 182 |
} |
| 183 |
|
| 184 |
/** |
| 185 |
* @generated |
| 186 |
*/ |
| 187 |
protected EObject getTargetElement(EObject relationship) { |
| 188 |
return null; |
| 189 |
} |
| 190 |
|
| 191 |
/** |
| 192 |
* @generated |
| 193 |
*/ |
| 194 |
protected boolean shouldIncludeConnection(Edge connector, Collection children) { |
| 195 |
return false; |
| 196 |
} |
| 197 |
|
| 198 |
/** |
| 199 |
* @generated |
| 200 |
*/ |
| 201 |
protected void refreshSemantic() { |
| 202 |
List createdViews = new LinkedList(); |
| 203 |
createdViews.addAll(refreshSemanticChildren()); |
| 204 |
List createdConnectionViews = new LinkedList(); |
| 205 |
createdConnectionViews.addAll(refreshSemanticConnections()); |
| 206 |
createdConnectionViews.addAll(refreshConnections()); |
| 207 |
|
| 208 |
if (createdViews.size() > 1) { |
| 209 |
// perform a layout of the container |
| 210 |
DeferredLayoutCommand layoutCmd = new DeferredLayoutCommand(host().getEditingDomain(), createdViews, host()); |
| 211 |
executeCommand(new ICommandProxy(layoutCmd)); |
| 212 |
} |
| 213 |
|
| 214 |
createdViews.addAll(createdConnectionViews); |
| 215 |
makeViewsImmutable(createdViews); |
| 216 |
} |
| 217 |
|
| 218 |
/** |
| 219 |
* @generated |
| 220 |
*/ |
| 221 |
private Collection myLinkDescriptors = new LinkedList(); |
| 222 |
|
| 223 |
/** |
| 224 |
* @generated |
| 225 |
*/ |
| 226 |
private Map myEObject2ViewMap = new HashMap(); |
| 227 |
|
| 228 |
/** |
| 229 |
* @generated |
| 230 |
*/ |
| 231 |
private Collection refreshConnections() { |
| 232 |
try { |
| 233 |
collectAllLinks(getDiagram()); |
| 234 |
Collection existingLinks = new LinkedList(getDiagram().getEdges()); |
| 235 |
for (Iterator diagramLinks = existingLinks.iterator(); diagramLinks.hasNext();) { |
| 236 |
Edge nextDiagramLink = (Edge) diagramLinks.next(); |
| 237 |
EObject diagramLinkObject = nextDiagramLink.getElement(); |
| 238 |
EObject diagramLinkSrc = nextDiagramLink.getSource().getElement(); |
| 239 |
EObject diagramLinkDst = nextDiagramLink.getTarget().getElement(); |
| 240 |
int diagramLinkVisualID = UMLVisualIDRegistry.getVisualID(nextDiagramLink); |
| 241 |
for (Iterator modelLinkDescriptors = myLinkDescriptors.iterator(); modelLinkDescriptors.hasNext();) { |
| 242 |
LinkDescriptor nextLinkDescriptor = (LinkDescriptor) modelLinkDescriptors.next(); |
| 243 |
if (diagramLinkObject == nextLinkDescriptor.getLinkElement() && diagramLinkSrc == nextLinkDescriptor.getSource() && diagramLinkDst == nextLinkDescriptor.getDestination() |
| 244 |
&& diagramLinkVisualID == nextLinkDescriptor.getVisualID()) { |
| 245 |
diagramLinks.remove(); |
| 246 |
modelLinkDescriptors.remove(); |
| 247 |
} |
| 248 |
} |
| 249 |
} |
| 250 |
deleteViews(existingLinks.iterator()); |
| 251 |
return createConnections(myLinkDescriptors); |
| 252 |
} finally { |
| 253 |
myLinkDescriptors.clear(); |
| 254 |
myEObject2ViewMap.clear(); |
| 255 |
} |
| 256 |
} |
| 257 |
|
| 258 |
/** |
| 259 |
* @generated |
| 260 |
*/ |
| 261 |
private void collectAllLinks(View view) { |
| 262 |
EObject modelElement = view.getElement(); |
| 263 |
int diagramElementVisualID = UMLVisualIDRegistry.getVisualID(view); |
| 264 |
switch (diagramElementVisualID) { |
| 265 |
case Package2EditPart.VISUAL_ID: |
| 266 |
case Class2EditPart.VISUAL_ID: |
| 267 |
case AssociationClass2EditPart.VISUAL_ID: |
| 268 |
case DataType2EditPart.VISUAL_ID: |
| 269 |
case PrimitiveType2EditPart.VISUAL_ID: |
| 270 |
case Enumeration2EditPart.VISUAL_ID: |
| 271 |
case InterfaceEditPart.VISUAL_ID: |
| 272 |
case ConstraintEditPart.VISUAL_ID: |
| 273 |
case InstanceSpecification2EditPart.VISUAL_ID: |
| 274 |
case DependencyEditPart.VISUAL_ID: |
| 275 |
case Package3EditPart.VISUAL_ID: |
| 276 |
case ClassEditPart.VISUAL_ID: |
| 277 |
case DataTypeEditPart.VISUAL_ID: |
| 278 |
case PrimitiveTypeEditPart.VISUAL_ID: |
| 279 |
case EnumerationEditPart.VISUAL_ID: |
| 280 |
case AssociationClassEditPart.VISUAL_ID: |
| 281 |
case InstanceSpecificationEditPart.VISUAL_ID: |
| 282 |
case PropertyEditPart.VISUAL_ID: |
| 283 |
case OperationEditPart.VISUAL_ID: |
| 284 |
case Class3EditPart.VISUAL_ID: |
| 285 |
case PortEditPart.VISUAL_ID: |
| 286 |
case Property2EditPart.VISUAL_ID: |
| 287 |
case Operation2EditPart.VISUAL_ID: |
| 288 |
case Property3EditPart.VISUAL_ID: |
| 289 |
case Operation3EditPart.VISUAL_ID: |
| 290 |
case Property4EditPart.VISUAL_ID: |
| 291 |
case Operation4EditPart.VISUAL_ID: |
| 292 |
case EnumerationLiteralEditPart.VISUAL_ID: |
| 293 |
case Property5EditPart.VISUAL_ID: |
| 294 |
case Operation5EditPart.VISUAL_ID: |
| 295 |
case LiteralStringEditPart.VISUAL_ID: |
| 296 |
case SlotEditPart.VISUAL_ID: |
| 297 |
case PackageEditPart.VISUAL_ID: { |
| 298 |
myEObject2ViewMap.put(modelElement, view); |
| 299 |
storeLinks(modelElement, getDiagram()); |
| 300 |
} |
| 301 |
default: { |
| 302 |
} |
| 303 |
for (Iterator children = view.getChildren().iterator(); children.hasNext();) { |
| 304 |
View childView = (View) children.next(); |
| 305 |
collectAllLinks(childView); |
| 306 |
} |
| 307 |
} |
| 308 |
} |
| 309 |
|
| 310 |
/** |
| 311 |
* @generated |
| 312 |
*/ |
| 313 |
private Collection createConnections(Collection linkDescriptors) { |
| 314 |
if (linkDescriptors.isEmpty()) { |
| 315 |
return Collections.EMPTY_LIST; |
| 316 |
} |
| 317 |
List adapters = new LinkedList(); |
| 318 |
for (Iterator linkDescriptorsIterator = linkDescriptors.iterator(); linkDescriptorsIterator.hasNext();) { |
| 319 |
final LinkDescriptor nextLinkDescriptor = (LinkDescriptor) linkDescriptorsIterator.next(); |
| 320 |
EditPart sourceEditPart = getEditPartFor(nextLinkDescriptor.getSource()); |
| 321 |
EditPart targetEditPart = getEditPartFor(nextLinkDescriptor.getDestination()); |
| 322 |
if (sourceEditPart == null || targetEditPart == null) { |
| 323 |
continue; |
| 324 |
} |
| 325 |
CreateConnectionViewRequest.ConnectionViewDescriptor descriptor = new CreateConnectionViewRequest.ConnectionViewDescriptor(nextLinkDescriptor.getSemanticAdapter(), null, ViewUtil.APPEND, |
| 326 |
false, ((IGraphicalEditPart) getHost()).getDiagramPreferencesHint()); |
| 327 |
CreateConnectionViewRequest ccr = new CreateConnectionViewRequest(descriptor); |
| 328 |
ccr.setType(RequestConstants.REQ_CONNECTION_START); |
| 329 |
ccr.setSourceEditPart(sourceEditPart); |
| 330 |
sourceEditPart.getCommand(ccr); |
| 331 |
ccr.setTargetEditPart(targetEditPart); |
| 332 |
ccr.setType(RequestConstants.REQ_CONNECTION_END); |
| 333 |
Command cmd = targetEditPart.getCommand(ccr); |
| 334 |
if (cmd != null && cmd.canExecute()) { |
| 335 |
executeCommand(cmd); |
| 336 |
IAdaptable viewAdapter = (IAdaptable) ccr.getNewObject(); |
| 337 |
if (viewAdapter != null) { |
| 338 |
adapters.add(viewAdapter); |
| 339 |
} |
| 340 |
} |
| 341 |
} |
| 342 |
return adapters; |
| 343 |
} |
| 344 |
|
| 345 |
/** |
| 346 |
* @generated |
| 347 |
*/ |
| 348 |
private EditPart getEditPartFor(EObject modelElement) { |
| 349 |
View view = (View) myEObject2ViewMap.get(modelElement); |
| 350 |
if (view != null) { |
| 351 |
return (EditPart) getHost().getViewer().getEditPartRegistry().get(view); |
| 352 |
} |
| 353 |
return null; |
| 354 |
} |
| 355 |
|
| 356 |
/** |
| 357 |
*@generated |
| 358 |
*/ |
| 359 |
private void storeLinks(EObject container, Diagram diagram) { |
| 360 |
EClass containerMetaclass = container.eClass(); |
| 361 |
storeFeatureModelFacetLinks(container, containerMetaclass, diagram); |
| 362 |
storeTypeModelFacetLinks(container, containerMetaclass); |
| 363 |
} |
| 364 |
|
| 365 |
/** |
| 366 |
* @generated |
| 367 |
*/ |
| 368 |
private void storeTypeModelFacetLinks(EObject container, EClass containerMetaclass) { |
| 369 |
storeTypeModelFacetLinks_Generalization_4001(container, containerMetaclass); |
| 370 |
storeTypeModelFacetLinks_Dependency_4002(container, containerMetaclass); |
| 371 |
storeTypeModelFacetLinks_Property_4003(container, containerMetaclass); |
| 372 |
storeTypeModelFacetLinks_Association_4005(container, containerMetaclass); |
| 373 |
storeTypeModelFacetLinks_InterfaceRealization_4008(container, containerMetaclass); |
| 374 |
storeTypeModelFacetLinks_Usage_4009(container, containerMetaclass); |
| 375 |
} |
| 376 |
|
| 377 |
/** |
| 378 |
* @generated |
| 379 |
*/ |
| 380 |
private void storeTypeModelFacetLinks_Generalization_4001(EObject container, EClass containerMetaclass) { |
| 381 |
if (UMLPackage.eINSTANCE.getClassifier().isSuperTypeOf(containerMetaclass)) { |
| 382 |
for (Iterator values = ((Classifier) container).getGeneralizations().iterator(); values.hasNext();) { |
| 383 |
EObject nextValue = ((EObject) values.next()); |
| 384 |
int linkVID = UMLVisualIDRegistry.getLinkWithClassVisualID(nextValue); |
| 385 |
if (GeneralizationEditPart.VISUAL_ID == linkVID) { |
| 386 |
Object structuralFeatureResult = ((Generalization) nextValue).getGeneral(); |
| 387 |
if (structuralFeatureResult instanceof EObject) { |
| 388 |
EObject dst = (EObject) structuralFeatureResult; |
| 389 |
EObject src = container; |
| 390 |
myLinkDescriptors.add(new LinkDescriptor(src, dst, nextValue, linkVID)); |
| 391 |
} |
| 392 |
} |
| 393 |
} |
| 394 |
} |
| 395 |
} |
| 396 |
|
| 397 |
/** |
| 398 |
* @generated |
| 399 |
*/ |
| 400 |
private void storeTypeModelFacetLinks_Dependency_4002(EObject container, EClass containerMetaclass) { |
| 401 |
if (UMLPackage.eINSTANCE.getPackage().isSuperTypeOf(containerMetaclass)) { |
| 402 |
for (Iterator values = ((org.eclipse.uml2.uml.Package) container).getPackagedElements().iterator(); values.hasNext();) { |
| 403 |
EObject nextValue = ((EObject) values.next()); |
| 404 |
int linkVID = UMLVisualIDRegistry.getLinkWithClassVisualID(nextValue); |
| 405 |
if (Dependency2EditPart.VISUAL_ID == linkVID) { |
| 406 |
Object structuralFeatureResult = ((Dependency) nextValue).getSuppliers(); |
| 407 |
List targets = (List) structuralFeatureResult; |
| 408 |
structuralFeatureResult = targets.size() == 1 ? targets.get(0) : null; |
| 409 |
if (structuralFeatureResult instanceof EObject) { |
| 410 |
EObject dst = (EObject) structuralFeatureResult; |
| 411 |
structuralFeatureResult = ((Dependency) nextValue).getClients(); |
| 412 |
List sources = (List) structuralFeatureResult; |
| 413 |
structuralFeatureResult = sources.size() == 1 ? sources.get(0) : null; |
| 414 |
if (structuralFeatureResult instanceof EObject) { |
| 415 |
EObject src = (EObject) structuralFeatureResult; |
| 416 |
myLinkDescriptors.add(new LinkDescriptor(src, dst, nextValue, linkVID)); |
| 417 |
} |
| 418 |
} |
| 419 |
} |
| 420 |
} |
| 421 |
} |
| 422 |
} |
| 423 |
|
| 424 |
/** |
| 425 |
* @generated |
| 426 |
*/ |
| 427 |
private void storeTypeModelFacetLinks_Property_4003(EObject container, EClass containerMetaclass) { |
| 428 |
if (UMLPackage.eINSTANCE.getAssociation().isSuperTypeOf(containerMetaclass)) { |
| 429 |
for (Iterator values = ((Association) container).getOwnedEnds().iterator(); values.hasNext();) { |
| 430 |
EObject nextValue = ((EObject) values.next()); |
| 431 |
int linkVID = UMLVisualIDRegistry.getLinkWithClassVisualID(nextValue); |
| 432 |
if (Property6EditPart.VISUAL_ID == linkVID) { |
| 433 |
Object structuralFeatureResult = ((TypedElement) nextValue).getType(); |
| 434 |
if (structuralFeatureResult instanceof EObject) { |
| 435 |
EObject dst = (EObject) structuralFeatureResult; |
| 436 |
EObject src = container; |
| 437 |
myLinkDescriptors.add(new LinkDescriptor(src, dst, nextValue, linkVID)); |
| 438 |
} |
| 439 |
} |
| 440 |
} |
| 441 |
} |
| 442 |
} |
| 443 |
|
| 444 |
/** |
| 445 |
* @generated NOT |
| 446 |
*/ |
| 447 |
private void storeTypeModelFacetLinks_Association_4005(EObject container, EClass containerMetaclass) { |
| 448 |
if (UMLPackage.eINSTANCE.getPackage().isSuperTypeOf(containerMetaclass)) { |
| 449 |
for (Iterator values = ((org.eclipse.uml2.uml.Package) container).getPackagedElements().iterator(); values.hasNext();) { |
| 450 |
EObject nextValue = ((EObject) values.next()); |
| 451 |
int linkVID = UMLVisualIDRegistry.getLinkWithClassVisualID(nextValue); |
| 452 |
if (AssociationEditPart.VISUAL_ID == linkVID) { |
| 453 |
Association association = (Association) nextValue; |
| 454 |
if (association.isBinary()) { |
| 455 |
Property sourceEnd = AssociationEndConvention.getSourceEnd(association); |
| 456 |
Property targetEnd = AssociationEndConvention.getTargetEnd(association); |
| 457 |
EObject gmfSource = sourceEnd.getType(); |
| 458 |
EObject gmfTarget = targetEnd.getType(); |
| 459 |
myLinkDescriptors.add(new LinkDescriptor(gmfSource, gmfTarget, association, linkVID)); |
| 460 |
} |
| 461 |
} |
| 462 |
} |
| 463 |
} |
| 464 |
} |
| 465 |
|
| 466 |
/** |
| 467 |
* @generated |
| 468 |
*/ |
| 469 |
private void storeTypeModelFacetLinks_InterfaceRealization_4008(EObject container, EClass containerMetaclass) { |
| 470 |
if (UMLPackage.eINSTANCE.getBehavioredClassifier().isSuperTypeOf(containerMetaclass)) { |
| 471 |
for (Iterator values = ((BehavioredClassifier) container).getInterfaceRealizations().iterator(); values.hasNext();) { |
| 472 |
EObject nextValue = ((EObject) values.next()); |
| 473 |
int linkVID = UMLVisualIDRegistry.getLinkWithClassVisualID(nextValue); |
| 474 |
if (InterfaceRealizationEditPart.VISUAL_ID == linkVID) { |
| 475 |
Object structuralFeatureResult = ((InterfaceRealization) nextValue).getContract(); |
| 476 |
if (structuralFeatureResult instanceof EObject) { |
| 477 |
EObject dst = (EObject) structuralFeatureResult; |
| 478 |
structuralFeatureResult = ((InterfaceRealization) nextValue).getImplementingClassifier(); |
| 479 |
if (structuralFeatureResult instanceof EObject) { |
| 480 |
EObject src = (EObject) structuralFeatureResult; |
| 481 |
myLinkDescriptors.add(new LinkDescriptor(src, dst, nextValue, linkVID)); |
| 482 |
} |
| 483 |
} |
| 484 |
} |
| 485 |
} |
| 486 |
} |
| 487 |
} |
| 488 |
|
| 489 |
/** |
| 490 |
* @generated |
| 491 |
*/ |
| 492 |
private void storeTypeModelFacetLinks_Usage_4009(EObject container, EClass containerMetaclass) { |
| 493 |
if (UMLPackage.eINSTANCE.getPackage().isSuperTypeOf(containerMetaclass)) { |
| 494 |
for (Iterator values = ((org.eclipse.uml2.uml.Package) container).getPackagedElements().iterator(); values.hasNext();) { |
| 495 |
EObject nextValue = ((EObject) values.next()); |
| 496 |
int linkVID = UMLVisualIDRegistry.getLinkWithClassVisualID(nextValue); |
| 497 |
if (UsageEditPart.VISUAL_ID == linkVID) { |
| 498 |
Object structuralFeatureResult = ((Dependency) nextValue).getSuppliers(); |
| 499 |
List targets = (List) structuralFeatureResult; |
| 500 |
structuralFeatureResult = targets.size() == 1 ? targets.get(0) : null; |
| 501 |
if (structuralFeatureResult instanceof EObject) { |
| 502 |
EObject dst = (EObject) structuralFeatureResult; |
| 503 |
structuralFeatureResult = ((Dependency) nextValue).getClients(); |
| 504 |
List sources = (List) structuralFeatureResult; |
| 505 |
structuralFeatureResult = sources.size() == 1 ? sources.get(0) : null; |
| 506 |
if (structuralFeatureResult instanceof EObject) { |
| 507 |
EObject src = (EObject) structuralFeatureResult; |
| 508 |
myLinkDescriptors.add(new LinkDescriptor(src, dst, nextValue, linkVID)); |
| 509 |
} |
| 510 |
} |
| 511 |
} |
| 512 |
} |
| 513 |
} |
| 514 |
} |
| 515 |
|
| 516 |
/** |
| 517 |
*@generated |
| 518 |
*/ |
| 519 |
private void storeFeatureModelFacetLinks(EObject container, EClass containerMetaclass, Diagram diagram) { |
| 520 |
|
| 521 |
if (UMLPackage.eINSTANCE.getConstraint().isSuperTypeOf(containerMetaclass)) { |
| 522 |
for (Iterator destinations = ((Constraint) container).getConstrainedElements().iterator(); destinations.hasNext();) { |
| 523 |
EObject nextDestination = (EObject) destinations.next(); |
| 524 |
myLinkDescriptors.add(new LinkDescriptor(container, nextDestination, UMLElementTypes.ConstraintConstrainedElement_4004, ConstraintConstrainedElementEditPart.VISUAL_ID)); |
| 525 |
|
| 526 |
} |
| 527 |
} |
| 528 |
|
| 529 |
if (UMLPackage.eINSTANCE.getDependency().isSuperTypeOf(containerMetaclass)) { |
| 530 |
for (Iterator destinations = ((Dependency) container).getSuppliers().iterator(); destinations.hasNext();) { |
| 531 |
EObject nextDestination = (EObject) destinations.next(); |
| 532 |
myLinkDescriptors.add(new LinkDescriptor(container, nextDestination, UMLElementTypes.DependencySupplier_4006, DependencySupplierEditPart.VISUAL_ID)); |
| 533 |
|
| 534 |
} |
| 535 |
} |
| 536 |
if (UMLPackage.eINSTANCE.getDependency().isSuperTypeOf(containerMetaclass)) { |
| 537 |
for (Iterator destinations = ((Dependency) container).getClients().iterator(); destinations.hasNext();) { |
| 538 |
EObject nextDestination = (EObject) destinations.next(); |
| 539 |
myLinkDescriptors.add(new LinkDescriptor(container, nextDestination, UMLElementTypes.DependencyClient_4007, DependencyClientEditPart.VISUAL_ID)); |
| 540 |
|
| 541 |
} |
| 542 |
} |
| 543 |
|
| 544 |
} |
| 545 |
|
| 546 |
/** |
| 547 |
* @generated |
| 548 |
*/ |
| 549 |
private Diagram getDiagram() { |
| 550 |
return ((View) getHost().getModel()).getDiagram(); |
| 551 |
} |
| 552 |
|
| 553 |
/** |
| 554 |
* @generated |
| 555 |
*/ |
| 556 |
private class LinkDescriptor { |
| 557 |
|
| 558 |
/** |
| 559 |
* @generated |
| 560 |
*/ |
| 561 |
private EObject mySource; |
| 562 |
|
| 563 |
/** |
| 564 |
* @generated |
| 565 |
*/ |
| 566 |
private EObject myDestination; |
| 567 |
|
| 568 |
/** |
| 569 |
* @generated |
| 570 |
*/ |
| 571 |
private EObject myLinkElement; |
| 572 |
|
| 573 |
/** |
| 574 |
* @generated |
| 575 |
*/ |
| 576 |
private int myVisualID; |
| 577 |
|
| 578 |
/** |
| 579 |
* @generated |
| 580 |
*/ |
| 581 |
private IAdaptable mySemanticAdapter; |
| 582 |
|
| 583 |
/** |
| 584 |
* @generated |
| 585 |
*/ |
| 586 |
protected LinkDescriptor(EObject source, EObject destination, EObject linkElement, int linkVID) { |
| 587 |
this(source, destination, linkVID); |
| 588 |
myLinkElement = linkElement; |
| 589 |
mySemanticAdapter = new EObjectAdapter(linkElement); |
| 590 |
} |
| 591 |
|
| 592 |
/** |
| 593 |
* @generated |
| 594 |
*/ |
| 595 |
protected LinkDescriptor(EObject source, EObject destination, IElementType elementType, int linkVID) { |
| 596 |
this(source, destination, linkVID); |
| 597 |
myLinkElement = null; |
| 598 |
final IElementType elementTypeCopy = elementType; |
| 599 |
mySemanticAdapter = new IAdaptable() { |
| 600 |
|
| 601 |
public Object getAdapter(Class adapter) { |
| 602 |
if (IElementType.class.equals(adapter)) { |
| 603 |
return elementTypeCopy; |
| 604 |
} |
| 605 |
return null; |
| 606 |
} |
| 607 |
}; |
| 608 |
} |
| 609 |
|
| 610 |
/** |
| 611 |
* @generated |
| 612 |
*/ |
| 613 |
private LinkDescriptor(EObject source, EObject destination, int linkVID) { |
| 614 |
mySource = source; |
| 615 |
myDestination = destination; |
| 616 |
myVisualID = linkVID; |
| 617 |
} |
| 618 |
|
| 619 |
/** |
| 620 |
* @generated |
| 621 |
*/ |
| 622 |
protected EObject getSource() { |
| 623 |
return mySource; |
| 624 |
} |
| 625 |
|
| 626 |
/** |
| 627 |
* @generated |
| 628 |
*/ |
| 629 |
protected EObject getDestination() { |
| 630 |
return myDestination; |
| 631 |
} |
| 632 |
|
| 633 |
/** |
| 634 |
* @generated |
| 635 |
*/ |
| 636 |
protected EObject getLinkElement() { |
| 637 |
return myLinkElement; |
| 638 |
} |
| 639 |
|
| 640 |
/** |
| 641 |
* @generated |
| 642 |
*/ |
| 643 |
protected int getVisualID() { |
| 644 |
return myVisualID; |
| 645 |
} |
| 646 |
|
| 647 |
/** |
| 648 |
* @generated |
| 649 |
*/ |
| 650 |
protected IAdaptable getSemanticAdapter() { |
| 651 |
return mySemanticAdapter; |
| 652 |
} |
| 653 |
} |
| 654 |
|
| 655 |
} |