コード例 #1
0
  /* (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();
    }
  }
コード例 #2
0
 @Override
 public RefactoringStatus checkFinalConditions(
     IProgressMonitor pm, CheckConditionsContext checkContext)
     throws CoreException, OperationCanceledException {
   RefactoringStatus result = new RefactoringStatus();
   if (context.isDefinitionSeparate()) {
     findDefinitionInsertLocation(pm);
     if (definitionInsertLocation == null
         || definitionInsertLocation.getTranslationUnit() == null) {
       result.addInfo(Messages.GenerateGettersAndSettersRefactoring_NoImplFile);
     }
   }
   Checks.addModifiedFilesToChecker(getAllFilesToModify(), checkContext);
   return result;
 }