protected boolean initializeEMFContextFromContributors(IProject aProject, EMFWorkbenchContextBase emfContext, IEMFContextContributor contributor) { boolean contributorFound = false; if (aProject == null || emfContext == null) return contributorFound; List runtimes = EMFNature.getRegisteredRuntimes(aProject); for (int i = 0; i < runtimes.size(); i++) { IProjectNature nature = (IProjectNature) runtimes.get(i); if (nature != null && CONTRIBUTOR_CLASS.isInstance(nature)) { if (nature == contributor) contributorFound = true; ((IEMFContextContributor) nature).primaryContributeToContext(emfContext); } } return contributorFound; }
protected boolean flushPrimaryKeyClass(JavaClass primaryKeyClass) { // ensure the primary key class is flushed and reloaded to get latest // content IProject p = ProjectUtilities.getProject(primaryKeyClass); try { List natures = EMFNature.getRegisteredRuntimes(p); EMFNature nature = null; for (int i = 0; i < natures.size(); i++) { if (natures.get(i) instanceof EMFNature) nature = (EMFNature) natures.get(i); } List adapterFactories = nature.getResourceSet().getAdapterFactories(); AdapterFactory factory = EcoreUtil.getAdapterFactory(adapterFactories, ReadAdaptor.TYPE_KEY); if (factory instanceof JavaJDOMAdapterFactory) { JavaJDOMAdapterFactory javaFactory = (JavaJDOMAdapterFactory) factory; javaFactory.flushReflectionNoNotification(primaryKeyClass.getQualifiedName()); return true; } } catch (Exception e) { // We don't really care what the exception was, we'll just bail out // and return false; } return false; } }