/* (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();
    }
  }
Exemplo n.º 2
0
 @Override
 RefactoringStatus checkFinalConditions(
     final IProgressMonitor pm, final CheckConditionsContext ctxt) {
   RefactoringStatus result = new RefactoringStatus();
   try {
     pm.beginTask(UITexts.refDelegate_checking, 100);
     if (ctxt != null) {
       IConditionChecker checker = ctxt.getChecker(ValidateEditChecker.class);
       ValidateEditChecker editChecker = (ValidateEditChecker) checker;
       editChecker.addFile(info.getSourceFile());
     }
     change = createRenameChange(pm);
     if (change == null) {
       result.addFatalError(UITexts.mkPointFreeDelegate_notApplicable);
     }
   } finally {
     pm.done();
   }
   return result;
 }