@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; }
@Override public void run() { IWorkbenchWindow w = PlatformUI.getWorkbench() .getActiveWorkbenchWindow(); if (w == null) { IWorkbenchWindow[] windows = PlatformUI.getWorkbench() .getWorkbenchWindows(); if (windows.length > 0) w = windows[0]; } if (w != null) { result[0] = PlatformUI.getWorkbench().saveAll(w, w, new ResourceSaveableFilter(resourceRoots), confirm); } } });
for (int j = 0; j < resources.length; j++) { IResource resource = resources[j]; if (isDescendantOfRoots(resource)) { return true; return isDescendantOfRoots(file);