@Override public boolean select(Saveable saveable, IWorkbenchPart[] containingParts) { if (isDescendantOfRoots(saveable)) { return true; } // For backwards compatibility, we need to check the parts for (int i = 0; i < containingParts.length; i++) { IWorkbenchPart workbenchPart = containingParts[i]; if (workbenchPart instanceof IEditorPart) { IEditorPart editorPart = (IEditorPart) workbenchPart; if (isEditingDescendantOf(editorPart)) { return true; } } } return false; }
/** * Return whether the given dirty editor part is editing resources that are * descendants of the given roots. * * @param part the dirty editor part * @return whether the given dirty editor part is editing resources that are * descendants of the given roots */ private boolean isEditingDescendantOf(IEditorPart part) { IFile file = ResourceUtil.getFile(part.getEditorInput()); if (file != null) { return isDescendantOfRoots(file); } return false; }
for (int j = 0; j < resources.length; j++) { IResource resource = resources[j]; if (isDescendantOfRoots(resource)) { return true; return isDescendantOfRoots(file);