/* (non-Javadoc)
   * @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#checkFinalConditions(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext)
   */
  public RefactoringStatus checkFinalConditions(IProgressMonitor pm, CheckConditionsContext context)
      throws CoreException, OperationCanceledException {
    pm.beginTask("", 1); // $NON-NLS-1$
    try {
      RefactoringStatus result = new RefactoringStatus();

      for (int i = 0; i < fResources.length; i++) {
        IResource resource = fResources[i];
        if (!resource.isSynchronized(IResource.DEPTH_INFINITE)) {
          if (resource instanceof IFile) {
            result.addInfo(
                Messages.format(
                    RefactoringCoreMessages.DeleteResourcesProcessor_warning_out_of_sync_file,
                    BasicElementLabels.getPathLabel(resource.getFullPath(), false)));
          } else {
            result.addInfo(
                Messages.format(
                    RefactoringCoreMessages.DeleteResourcesProcessor_warning_out_of_sync_container,
                    BasicElementLabels.getPathLabel(resource.getFullPath(), false)));
          }
        }
      }

      checkDirtyResources(result);

      ResourceChangeChecker checker =
          (ResourceChangeChecker) context.getChecker(ResourceChangeChecker.class);
      IResourceChangeDescriptionFactory deltaFactory = checker.getDeltaFactory();
      for (int i = 0; i < fResources.length; i++) {
        if (fResources[i].isPhantom()) {
          result.addFatalError(
              Messages.format(
                  RefactoringCoreMessages.DeleteResourcesProcessor_delete_error_phantom,
                  BasicElementLabels.getPathLabel(fResources[i].getFullPath(), false)));
        } else if (fDeleteContents && Resources.isReadOnly(fResources[i])) {
          result.addFatalError(
              Messages.format(
                  RefactoringCoreMessages.DeleteResourcesProcessor_delete_error_read_only,
                  BasicElementLabels.getPathLabel(fResources[i].getFullPath(), false)));
        } else {
          deltaFactory.delete(fResources[i]);
        }
      }
      return result;
    } finally {
      pm.done();
    }
  }
 private void checkDirtyFile(RefactoringStatus result, IFile file) {
   if (!file.exists()) return;
   ITextFileBuffer buffer =
       FileBuffers.getTextFileBufferManager()
           .getTextFileBuffer(file.getFullPath(), LocationKind.IFILE);
   if (buffer != null && buffer.isDirty()) {
     String message = RefactoringCoreMessages.DeleteResourcesProcessor_warning_unsaved_file;
     if (buffer.isStateValidated() && buffer.isSynchronized()) {
       result.addWarning(
           Messages.format(message, BasicElementLabels.getPathLabel(file.getFullPath(), false)));
     } else {
       result.addFatalError(
           Messages.format(message, BasicElementLabels.getPathLabel(file.getFullPath(), false)));
     }
   }
 }
 private String getDeleteDescription() {
   if (fResources.length == 1) {
     return Messages.format(
         RefactoringCoreMessages.DeleteResourcesProcessor_description_single,
         BasicElementLabels.getPathLabel(fResources[0].getFullPath(), false));
   }
   return Messages.format(
       RefactoringCoreMessages.DeleteResourcesProcessor_description_multi,
       new Integer(fResources.length));
 }