public static boolean isWellbehavingFeature(EStructuralFeature feature) {
   if (contributedWellbehavingDerivedFeatures.contains(feature)) {
     return true;
   } else if (contributedWellbehavingDerivedClasses.contains(feature.getEContainingClass())) {
     return true;
   } else if (contributedWellbehavingDerivedPackages.contains(
       feature.getEContainingClass().getEPackage())) {
     return true;
   }
   return false;
 }
  protected Map<Declaration, Boolean> handleStyle(Style style) {
    if (style instanceof NamedStyle) {
      return Collections.emptyMap();
    }

    Map<Declaration, Boolean> declarations = new LinkedHashMap<Declaration, Boolean>();

    for (EStructuralFeature feature : style.eClass().getEAllStructuralFeatures()) {
      if (NotationPackage.eINSTANCE.getStyle().isSuperTypeOf(feature.getEContainingClass())) {
        Object currentValue = style.eGet(feature);
        Object defaultValue = feature.getDefaultValue();
        boolean check =
            currentValue == null
                ? currentValue != defaultValue
                : !currentValue.equals(defaultValue);

        Declaration declaration = handleStyleFeature(style, feature);
        if (declaration.getExpression()
            != null) { // If expression is null, the type of this property is not supported
          declarations.put(declaration, check);
        }
      }
    }

    return declarations;
  }
 public static <T extends EStructuralFeature> Collection<T> getValidEStructuralFeatures(
     Collection<T> structuralFeatures) {
   Collection<T> result = getValidEObjects(structuralFeatures);
   for (Iterator<T> it = result.iterator(); it.hasNext(); ) {
     EStructuralFeature nextFeature = it.next();
     if (nextFeature != null && (nextFeature.getEContainingClass() == null)) {
       it.remove();
     }
   }
   return result;
 }
 /**
  * This returns the label text for the adapted class.
  * <!-- begin-user-doc -->
  * <!-- end-user-doc -->
  *
  * @generated NOT
  */
 @Override
 public String getText(Object object) {
   StringBuffer s = new StringBuffer();
   EStructuralFeature end = ((OutlineElement) object).getFeature();
   if (end != null) {
     if (s.length() != 0) s.append(", ");
     s.append(getLocalName(end.getEContainingClass()));
     s.append(".");
     s.append(getLocalName(end));
   }
   return s.toString();
 }
 /**
  * Get the metaclass label (emitted by EMF Edit generation) for given object according given
  * editing domain.
  *
  * @param object_p
  * @param provider_p
  * @return <code>null</code> if one of parameters is <code>null</code> or if no label is found.
  */
 public static String getFeatureLabel(
     EStructuralFeature feature_p, ItemProviderAdapter provider_p) {
   String label = null;
   // Preconditions.
   if ((null == feature_p) || (null == provider_p)) {
     return label;
   }
   String featureKey =
       feature_p.getEContainingClass().getName()
           + ICommonConstants.UNDERSCORE_CHARACTER
           + feature_p.getName();
   label = provider_p.getString(GENERATED_KEY_PREFIX + featureKey + FEATURE_GENERATED_KEY_SUFFIX);
   return label;
 }
 public static <T extends EStructuralFeature> Collection<T> getEStructuralFeaturesOf(
     Collection<T> structuralFeatures, EClass featureContainerEClass) {
   Collection<T> result = getValidEStructuralFeatures(structuralFeatures);
   if (featureContainerEClass == null) {
     return result;
   }
   for (Iterator<T> it = result.iterator(); it.hasNext(); ) {
     EStructuralFeature nextFeature = it.next();
     if (nextFeature != null
         && !nextFeature.getEContainingClass().isSuperTypeOf(featureContainerEClass)) {
       it.remove();
     }
   }
   return result;
 }
 public void addNavigatedDependency(
     EStructuralFeature navigationFeature, EStructuralFeature dependantFeature) {
   if (navigationFeature == null || dependantFeature == null) {
     return;
   }
   if (!source.eClass().getEAllStructuralFeatures().contains(navigationFeature)) {
     return;
   }
   if (!(navigationFeature.getEType() instanceof EClass)
       || !dependantFeature
           .getEContainingClass()
           .isSuperTypeOf((EClass) navigationFeature.getEType())) {
     return;
   }
   addNavigatedDependencyInternal(navigationFeature, dependantFeature);
 }
 /** @generated */
 private static ImageDescriptor getProvidedImageDescriptor(ENamedElement element) {
   if (element instanceof EStructuralFeature) {
     EStructuralFeature feature = ((EStructuralFeature) element);
     EClass eContainingClass = feature.getEContainingClass();
     EClassifier eType = feature.getEType();
     if (eContainingClass != null && !eContainingClass.isAbstract()) {
       element = eContainingClass;
     } else if (eType instanceof EClass && !((EClass) eType).isAbstract()) {
       element = eType;
     }
   }
   if (element instanceof EClass) {
     EClass eClass = (EClass) element;
     if (!eClass.isAbstract()) {
       return ComponentsDiagramEditorPlugin.getInstance()
           .getItemImageDescriptor(eClass.getEPackage().getEFactoryInstance().create(eClass));
     }
   }
   // TODO : support structural features
   return null;
 }
Example #9
0
 protected void updateInvalidFeature(EObject eObject, EStructuralFeature feature, Object object) {
   super.updateInvalidFeature(eObject, feature, object);
   if (eObject.eContainer() instanceof org.eclipse.e4.tm.widgets.Composite) {
     org.eclipse.e4.tm.widgets.Composite comp =
         (org.eclipse.e4.tm.widgets.Composite) eObject.eContainer();
     if (eObject == comp.getLayout()) {
       ((Composite) context.getObject(comp, Composite.class)).layout();
     }
   }
   String invalidateStyle =
       AbstractBuilder.getClassAnnotation(
           feature.getEContainingClass(), AbstractBinder.ANNOTATION_URI, "invalidateStyle", null);
   if (invalidateStyle != null) {
     EObject parent = eObject;
     while (parent != null) {
       if (parent instanceof Styled) {
         context.updateStyle((Styled) parent);
         break;
       }
     }
   }
 }
 private void writeList(PrintWriter out, EObject object, EStructuralFeature feature)
     throws SerializerException {
   List<?> list = (List<?>) object.eGet(feature);
   List<?> doubleStingList = null;
   if (feature.getEType() == EcorePackage.eINSTANCE.getEDouble() && model.isUseDoubleStrings()) {
     EStructuralFeature doubleStringFeature =
         feature.getEContainingClass().getEStructuralFeature(feature.getName() + "AsString");
     if (doubleStringFeature == null) {
       throw new SerializerException("Field " + feature.getName() + "AsString" + " not found");
     }
     doubleStingList = (List<?>) object.eGet(doubleStringFeature);
   }
   if (list.isEmpty()) {
     if (!feature.isUnsettable()) {
       out.print(OPEN_CLOSE_PAREN);
     } else {
       out.print("$");
     }
   } else {
     out.print(OPEN_PAREN);
     boolean first = true;
     int index = 0;
     for (Object listObject : list) {
       if (!first) {
         out.print(COMMA);
       }
       if ((listObject instanceof IdEObject) && model.contains((IdEObject) listObject)) {
         IdEObject eObject = (IdEObject) listObject;
         out.print(DASH);
         out.print(String.valueOf(getExpressId(eObject)));
       } else {
         if (listObject == null) {
           out.print(DOLLAR);
         } else {
           if (listObject instanceof IdEObject
               && feature.getEType().getEAnnotation("wrapped") != null) {
             IdEObject eObject = (IdEObject) listObject;
             Object realVal = eObject.eGet(eObject.eClass().getEStructuralFeature("wrappedValue"));
             if (realVal instanceof Double) {
               Object stringVal =
                   eObject.eGet(eObject.eClass().getEStructuralFeature("wrappedValueAsString"));
               if (stringVal != null && model.isUseDoubleStrings()) {
                 out.print(stringVal);
               } else {
                 out.print(realVal);
               }
             } else {
               writePrimitive(out, realVal);
             }
           } else if (listObject instanceof EObject) {
             IdEObject eObject = (IdEObject) listObject;
             EClass class1 = eObject.eClass();
             EStructuralFeature structuralFeature = class1.getEStructuralFeature(WRAPPED_VALUE);
             if (structuralFeature != null) {
               Object realVal = eObject.eGet(structuralFeature);
               out.print(upperCases.get(class1));
               out.print(OPEN_PAREN);
               if (realVal instanceof Double) {
                 Object stringVal =
                     eObject.eGet(
                         class1.getEStructuralFeature(structuralFeature.getName() + "AsString"));
                 if (stringVal != null && model.isUseDoubleStrings()) {
                   out.print(stringVal);
                 } else {
                   out.print(realVal);
                 }
               } else {
                 writePrimitive(out, realVal);
               }
               out.print(CLOSE_PAREN);
             } else {
               LOGGER.info(
                   "Unfollowable reference found from "
                       + object
                       + "."
                       + feature.getName()
                       + " to "
                       + eObject);
             }
           } else {
             if (doubleStingList != null) {
               if (index < doubleStingList.size()) {
                 String val = (String) doubleStingList.get(index);
                 if (val == null) {
                   writePrimitive(out, listObject);
                 } else {
                   out.write(val);
                 }
               } else {
                 writePrimitive(out, listObject);
               }
             } else {
               writePrimitive(out, listObject);
             }
           }
         }
       }
       first = false;
       index++;
     }
     out.print(CLOSE_PAREN);
   }
 }
 public void initializeUsedGenPackages(final GenModel genModel) {
   this.genModelInitializer.initialize(genModel, true);
   HashSet<EPackage> _hashSet = new HashSet<EPackage>();
   final HashSet<EPackage> referencedEPackages = _hashSet;
   UniqueEList<EPackage> _uniqueEList = new UniqueEList<EPackage>();
   final List<EPackage> ePackages = _uniqueEList;
   EList<GenPackage> _genPackages = genModel.getGenPackages();
   for (final GenPackage genPackage : _genPackages) {
     EPackage _ecorePackage = genPackage.getEcorePackage();
     ePackages.add(_ecorePackage);
   }
   int i = 0;
   int _size = ePackages.size();
   boolean _lessThan = (i < _size);
   boolean _while = _lessThan;
   while (_while) {
     {
       final EPackage ePackage = ePackages.get(i);
       int _plus = (i + 1);
       i = _plus;
       final TreeIterator<EObject> allContents = ePackage.eAllContents();
       boolean _hasNext = allContents.hasNext();
       boolean _while_1 = _hasNext;
       while (_while_1) {
         {
           final EObject eObject = allContents.next();
           if ((eObject instanceof EPackage)) {
             allContents.prune();
           } else {
             EList<EObject> _eCrossReferences = eObject.eCrossReferences();
             for (final EObject eCrossReference : _eCrossReferences) {
               boolean _matched = false;
               if (!_matched) {
                 if (eCrossReference instanceof EClassifier) {
                   final EClassifier _eClassifier = (EClassifier) eCrossReference;
                   _matched = true;
                   final EPackage referencedEPackage = _eClassifier.getEPackage();
                   ePackages.add(referencedEPackage);
                   referencedEPackages.add(referencedEPackage);
                 }
               }
               if (!_matched) {
                 if (eCrossReference instanceof EStructuralFeature) {
                   final EStructuralFeature _eStructuralFeature =
                       (EStructuralFeature) eCrossReference;
                   _matched = true;
                   EClass _eContainingClass = _eStructuralFeature.getEContainingClass();
                   final EPackage referencedEPackage = _eContainingClass.getEPackage();
                   ePackages.add(referencedEPackage);
                   referencedEPackages.add(referencedEPackage);
                 }
               }
             }
           }
         }
         boolean _hasNext_1 = allContents.hasNext();
         _while_1 = _hasNext_1;
       }
     }
     int _size_1 = ePackages.size();
     boolean _lessThan_1 = (i < _size_1);
     _while = _lessThan_1;
   }
   for (final EPackage referencedEPackage : referencedEPackages) {
     GenPackage _findGenPackage = genModel.findGenPackage(referencedEPackage);
     boolean _equals = Objects.equal(_findGenPackage, null);
     if (_equals) {
       ToXcoreMapping _toXcoreMapping = this.mapper.getToXcoreMapping(referencedEPackage);
       XNamedElement _xcoreElement = _toXcoreMapping.getXcoreElement();
       GenBase _gen = this.mapper.getGen(_xcoreElement);
       GenPackage usedGenPackage = ((GenPackage) _gen);
       boolean _equals_1 = Objects.equal(usedGenPackage, null);
       if (_equals_1) {
         GenPackage _findLocalGenPackage = this.findLocalGenPackage(referencedEPackage);
         usedGenPackage = _findLocalGenPackage;
       }
       boolean _notEquals = (!Objects.equal(usedGenPackage, null));
       if (_notEquals) {
         EList<GenPackage> _usedGenPackages = genModel.getUsedGenPackages();
         _usedGenPackages.add(usedGenPackage);
       } else {
         Resource _eResource = genModel.eResource();
         ResourceSet _resourceSet = _eResource.getResourceSet();
         final EList<Resource> resources = _resourceSet.getResources();
         i = 0;
         boolean found = false;
         boolean _and = false;
         int _size_1 = resources.size();
         boolean _lessThan_1 = (i < _size_1);
         if (!_lessThan_1) {
           _and = false;
         } else {
           boolean _not = (!found);
           _and = (_lessThan_1 && _not);
         }
         boolean _while_1 = _and;
         while (_while_1) {
           {
             final Resource resource = resources.get(i);
             boolean _and_1 = false;
             URI _uRI = resource.getURI();
             String _fileExtension = _uRI.fileExtension();
             boolean _equals_2 = "genmodel".equals(_fileExtension);
             if (!_equals_2) {
               _and_1 = false;
             } else {
               EList<EObject> _contents = resource.getContents();
               boolean _isEmpty = _contents.isEmpty();
               boolean _not_1 = (!_isEmpty);
               _and_1 = (_equals_2 && _not_1);
             }
             if (_and_1) {
               EList<EObject> _contents_1 = resource.getContents();
               EObject _get = _contents_1.get(0);
               GenPackage _findGenPackage_1 = ((GenModel) _get).findGenPackage(referencedEPackage);
               usedGenPackage = _findGenPackage_1;
               boolean _notEquals_1 = (!Objects.equal(usedGenPackage, null));
               if (_notEquals_1) {
                 EList<GenPackage> _usedGenPackages_1 = genModel.getUsedGenPackages();
                 _usedGenPackages_1.add(usedGenPackage);
                 found = true;
               }
             }
             int _plus = (i + 1);
             i = _plus;
           }
           boolean _and_1 = false;
           int _size_2 = resources.size();
           boolean _lessThan_2 = (i < _size_2);
           if (!_lessThan_2) {
             _and_1 = false;
           } else {
             boolean _not_1 = (!found);
             _and_1 = (_lessThan_2 && _not_1);
           }
           _while_1 = _and_1;
         }
         boolean _not_1 = (!found);
         if (_not_1) {
           String _plus = ("No GenPackage found for " + referencedEPackage);
           RuntimeException _runtimeException = new RuntimeException(_plus);
           throw _runtimeException;
         }
       }
     }
   }
 }
 private Object getStructuralFeatureValue(View view, EStructuralFeature feature) {
   return ViewUtil.getPropertyValue(view, feature, feature.getEContainingClass());
 }