Exemple #1
0
 /**
  * Checks if the given resources are in sync with the underlying file system.
  *
  * @param resources the resources to be checked
  * @return IStatus status describing the check's result. If <code>status.
  *  isOK() </code> returns <code>true</code> then the resources are in sync
  */
 public static IStatus checkInSync(IResource[] resources) {
   IStatus result = null;
   for (int i = 0; i < resources.length; i++) {
     IResource resource = resources[i];
     if (!resource.isSynchronized(IResource.DEPTH_INFINITE)) {
       result = addOutOfSync(result, resource);
     }
   }
   if (result != null) return result;
   return new Status(IStatus.OK, DLTKUIPlugin.PLUGIN_ID, IStatus.OK, "", null); // $NON-NLS-1$
 }
Exemple #2
0
 /**
  * Checks if the given resources are in sync with the underlying file system.
  *
  * @param resources the resources to be checked
  * @return IStatus status describing the check's result. If <code>status.
  *  isOK() </code> returns <code>true</code> then the resources are in sync
  */
 public static IStatus checkInSync(IResource[] resources) {
   IStatus result = null;
   for (int i = 0; i < resources.length; i++) {
     IResource resource = resources[i];
     if (!resource.isSynchronized(IResource.DEPTH_INFINITE)) {
       result = addOutOfSync(result, resource);
     }
   }
   if (result != null) return result;
   return Status.OK_STATUS;
 }
    public boolean visit(IResourceDelta delta) throws CoreException {
      IResource resource = delta.getResource();

      if (resource instanceof IFile
          && resource.exists()
          && resource.isSynchronized(IResource.DEPTH_ZERO)
          && ((IFile) resource).getContentDescription() != null) {

        if (getVdmProject().isModelFile((IFile) resource)) {
          sourceFound = true;
          return false; // do not visit children
        }
      }
      return true;
    }
  /* (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();
    }
  }