예제 #1
0
 private void setContainmentLink(EObject eObject) {
   if (eObject.eContainer() != null) {
     EObject eContainer = eObject.eContainer();
     EReference eReference = eObject.eContainmentFeature();
     int position =
         eReference.isMany() ? position = getContainmentPosition(eContainer, eObject) : 0;
     addLink(eContainer, eObject, eReference, position);
   }
 }
예제 #2
0
 private static void getNsURI(StringBuilder s, EObject element) {
   if (element instanceof org.eclipse.ocl.examples.pivot.Package) {
     String nsURI = ((org.eclipse.ocl.examples.pivot.Package) element).getNsURI();
     if (nsURI != null) {
       s.append(nsURI);
       return;
     }
   } else if (element instanceof EPackage) {
     String nsURI = ((EPackage) element).getNsURI();
     if (nsURI != null) {
       s.append(nsURI);
       return;
     }
   }
   EObject eContainer = element.eContainer();
   if (eContainer instanceof org.eclipse.ocl.examples.pivot.Package) {
     String nsURI = ((org.eclipse.ocl.examples.pivot.Package) element).getNsURI();
     if (nsURI != null) {
       s.append(nsURI);
       s.append("#/");
     } else {
       getNsURI(s, eContainer);
     }
   } else if (eContainer instanceof EPackage) {
     String nsURI = ((EPackage) element).getNsURI();
     if (nsURI != null) {
       s.append(nsURI);
       s.append("#/");
     } else {
       getNsURI(s, eContainer);
     }
   } else if (eContainer == null) {
     String name = null;
     if (element instanceof org.eclipse.ocl.examples.pivot.Package) {
       name = ((org.eclipse.ocl.examples.pivot.Package) element).getName();
     } else if (element instanceof EPackage) {
       name = ((EPackage) element).getName();
     }
     if (name == null) {
       name = "$null$";
     }
     s.append(name);
     return;
   } else {
     getNsURI(s, eContainer);
   }
   EReference eFeature = element.eContainmentFeature();
   s.append("@");
   s.append(eFeature.getName());
   if (eFeature.isMany()) {
     int index = ((List<?>) eContainer.eGet(element.eContainingFeature())).indexOf(element);
     s.append(".");
     s.append(index);
   }
 }
예제 #3
0
 /** Remove this object from it's container, and make it and all it's children proxies */
 public static void unload(EObject root) {
   Resource res = root.eResource();
   EObject container = root.eContainer();
   /* Making sure the proxy is created first before unloading */
   if (res != null) becomeProxy(root, res);
   if (container == null)
     if (res != null) res.getContents().remove(root);
     else {
       EStructuralFeature feature = root.eContainmentFeature();
       if (feature != null) eUnsetOrRemove(container, feature, root);
     }
 }
예제 #4
0
 private static void getNsURI(@NonNull StringBuilder s, @NonNull EObject element) {
   if (element instanceof org.eclipse.ocl.pivot.Package) {
     String nsURI = ((org.eclipse.ocl.pivot.Package) element).getURI();
     if (nsURI != null) {
       s.append(nsURI);
       return;
     }
   } else if (element instanceof Model) {
     String nsURI = ((Model) element).getExternalURI();
     if (nsURI != null) {
       s.append(nsURI);
       return;
     }
   } else if (element instanceof EPackage) {
     String nsURI = ((EPackage) element).getNsURI();
     if (nsURI != null) {
       s.append(nsURI);
       return;
     }
   }
   EObject eContainer = element.eContainer();
   if ((eContainer instanceof org.eclipse.ocl.pivot.Package) || (eContainer instanceof Model)) {
     String nsURI = ((org.eclipse.ocl.pivot.Package) element).getURI();
     if (nsURI != null) {
       s.append(nsURI);
       s.append("#/");
     } else {
       @SuppressWarnings("null")
       @NonNull
       EObject eContainer2 = eContainer;
       getNsURI(s, eContainer2);
     }
   } else if (eContainer instanceof EPackage) {
     String nsURI = ((EPackage) element).getNsURI();
     if (nsURI != null) {
       s.append(nsURI);
       s.append("#/");
     } else {
       getNsURI(s, eContainer);
     }
   } else if (eContainer == null) {
     String name = null;
     if (element instanceof org.eclipse.ocl.pivot.Package) {
       name = ((org.eclipse.ocl.pivot.Package) element).getName();
     } else if (element instanceof EPackage) {
       name = ((EPackage) element).getName();
     }
     if (name == null) {
       name = "$null$";
     }
     s.append(name);
     return;
   } else {
     getNsURI(s, eContainer);
   }
   EReference eFeature = element.eContainmentFeature();
   s.append("@");
   s.append(eFeature.getName());
   if (eFeature.isMany()) {
     int index = ((List<?>) eContainer.eGet(element.eContainingFeature())).indexOf(element);
     s.append(".");
     s.append(index);
   }
 }
예제 #5
0
 private int getContainmentPosition(EObject eContainer, EObject eObject) {
   Object containmentReferenceValue = eContainer.eGet(eObject.eContainmentFeature());
   return ((List<?>) containmentReferenceValue).indexOf(eObject) + 1;
 }