I am currently making a view which searches for all EObjects matching a certain criteria. This view would search in all opened EMF editors. Is there any programmatic way to retrieve the EMF roots from the editors?
[Edit] I meant the editors like the automatically generated tree view editor from the emf plugin. Given that one editor is open, I would like to get the root EObject from this model tree.
I managed to do it. I added a PartListener2 to my active page and searched for active editors. Then I just added this method.
private void addRoot(IEditorReference editorRef) {
IEditorPart editorPart = editorRef.getEditor(false);
if (editorPart instanceof IEditingDomainProvider) {
IEditingDomainProvider editingDomainProvider = (IEditingDomainProvider) editorPart;
EList<Resource> resourceList = editingDomainProvider.getEditingDomain().getResourceSet().getResources();
for (Resource resource : resourceList) {
for (EObject content : resource.getContents()) {
rootMap.put(content, editorRef);
}
}
}
}