public static boolean isManagedByEMFStore(EObject object) { Workspace currentWorkspace = WorkspaceManager.getInstance().getCurrentWorkspace(); for (Resource resource : currentWorkspace.getResourceSet().getResources()) { TreeIterator<EObject> allContents = resource.getAllContents(); while (allContents.hasNext()) { EObject currentObject = allContents.next(); if (object.equals(currentObject)) { return true; } } } return false; }
private EObject findManagedEObject(String uriFragment) { Workspace currentWorkspace = WorkspaceManager.getInstance().getCurrentWorkspace(); for (Resource resource : currentWorkspace.getResourceSet().getResources()) { TreeIterator<EObject> allContents = resource.getAllContents(); while (allContents.hasNext()) { EObject currentObject = allContents.next(); if (uriFragment.equals(currentObject.eResource().getURIFragment(currentObject))) { return currentObject; } } } return null; }