Java Code Examples for org.eclipse.emf.ecore.EPackage#eAllContents()

The following examples show how to use org.eclipse.emf.ecore.EPackage#eAllContents() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
/** {@inheritDoc} */
@Override
public void refreshCaches() {
	for (final EPackage ePackage : getEPackages()) {
		for (final Iterator<EObject> i = ePackage.eAllContents(); i.hasNext();) {
			final EObject element = i.next();
			if (element instanceof EStructuralFeatureImpl) {
				final EStructuralFeatureImpl feature = (EStructuralFeatureImpl) element;
				feature.setSettingDelegate(null);
			}
			if (element instanceof EEnumLiteral) {
				final EEnumLiteral literal = (EEnumLiteral) element;
				literal.setInstance(literal);
			}
		}
	}
}
 
Example 2
protected Set<EPackage> getReferencedEPackages(final List<EPackage> packs) {
  final HashSet<EPackage> result = CollectionLiterals.<EPackage>newHashSet();
  for (final EPackage pkg : packs) {
    {
      final TreeIterator<EObject> iterator = pkg.eAllContents();
      while (iterator.hasNext()) {
        {
          final EObject obj = iterator.next();
          EList<EObject> _eCrossReferences = obj.eCrossReferences();
          for (final EObject crossRef : _eCrossReferences) {
            boolean _eIsProxy = crossRef.eIsProxy();
            if (_eIsProxy) {
              URI _eProxyURI = ((InternalEObject) crossRef).eProxyURI();
              String _plus = ("Proxy \'" + _eProxyURI);
              String _plus_1 = (_plus + "\' could not be resolved");
              EMFGeneratorFragment2.LOG.error(_plus_1);
            } else {
              final EPackage p = EcoreUtil2.<EPackage>getContainerOfType(crossRef, EPackage.class);
              if ((p != null)) {
                result.add(p);
              }
            }
          }
        }
      }
    }
  }
  result.removeAll(packs);
  result.remove(EcorePackage.eINSTANCE);
  result.remove(XMLTypePackage.eINSTANCE);
  result.remove(XMLNamespacePackage.eINSTANCE);
  return result;
}
 
Example 3
Source Project: ice   File: EMFComponent.java    License: Eclipse Public License 1.0 4 votes vote down vote up
/**
 * The constructor, takes a Java file pointing to the XML schema model.
 * 
 * @param file
 *            The XML Schema
 */
public EMFComponent(File file) {
	super();

	// Initialize class data
	iceEMFTree = new EMFTreeComposite();
	xmlResource = new XMLResourceImpl();

	// Make sure we have a valid File object.
	if (file != null) {
		// Create a new XMLProcessor to be used in creating
		// and persisting XML Resources
		try {
			xmlProcessor = new XMLProcessor(URI.createFileURI(file.getAbsolutePath()));
		} catch (SAXException e) {
			logger.error(getClass().getName() + " Exception!", e);
		}

		if (xmlProcessor != null) {

			// Get the package containing the model
			EPackage ePackage = (EPackage) xmlProcessor.getEPackageRegistry().values().toArray()[0];

			// Get the TreeIterator to walk over the elements
			TreeIterator<EObject> tree = ePackage.eAllContents();
			while (tree.hasNext()) {
				// Get the Element
				EObject obj = tree.next();

				// We only care about EClass instances bc those
				// are the nodes of the tree.
				if (obj instanceof EClass) {
					EClass eClass = (EClass) obj;
					// Add the new EMFTreeComposite corresponding to the
					// current
					// EClass instance to the mapping
					if ("DocumentRoot".equals(eClass.getName())) {
						// This will give us a root node, and the
						// constructor
						// will take care of constructing possible exemplar
						// children nodes.
						iceEMFTree = new EMFTreeComposite(eClass);
						break;
					}
				}
			}
		}
	}

	return;
}