public static boolean isDeleteAvailable(final Object[] objects) throws ModelException { if (objects.length != 0) { final IResource[] resources = RefactoringAvailabilityTester.getResources(objects); final IModelElement[] elements = RefactoringAvailabilityTester.getScriptElements(objects); if (objects.length != resources.length + elements.length) return false; for (int index = 0; index < resources.length; index++) { if (!isDeleteAvailable(resources[index])) return false; } for (int index = 0; index < elements.length; index++) { if (!isDeleteAvailable(elements[index])) return false; } return true; } return false; }
public static boolean isDeleteAvailable(final IModelElement element) throws ModelException { if (!element.exists()) return false; if (element instanceof IScriptModel || element instanceof IScriptProject) return false; if (element.getParent() != null && element.getParent().isReadOnly()) return false; if (element instanceof IProjectFragment) { IProjectFragment root = (IProjectFragment) element; if (root.isExternal() || Checks.isBuildpathDelete(root)) // TODO // rename // isClasspathDelete return false; } if (element.getResource() == null && !RefactoringAvailabilityTester.isWorkingCopyElement(element)) return false; // if (element instanceof IMember && ((IMember) element).isBinary()) // return false; if (ReorgUtils.isDeletedFromEditor(element)) return false; return true; }