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

The following examples show how to use org.eclipse.emf.ecore.EPackage#eAllContents() . 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 check out the related API usage on the sidebar.
Example 1
Source File: MetamodelImpl.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/** {@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
Source File: EMFGeneratorFragment2.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
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 File: EMFComponent.java    From ice with 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;
}