public boolean updateStorage(
     final IProgressMonitor monitor, final ToBeBuilt toBeBuilt, IStorage storage) {
   if (!isHandled(storage)) return true;
   URI uri = getUri(storage);
   if (uri != null) {
     toBeBuilt.getToBeUpdated().add(uri);
   }
   return true;
 }
Exemplo n.º 2
0
  protected void scheduleRemoveProjectJob(final IProject project) {
    final ToBeBuilt toBeBuilt =
        getToBeBuiltComputer().removeProject(project, new NullProgressMonitor());
    if (toBeBuilt.getToBeDeleted().isEmpty() && toBeBuilt.getToBeUpdated().isEmpty()) return;
    new Job(
        Messages.ProjectOpenedOrClosedListener_RemovingProject
            + project.getName()
            + Messages.ProjectOpenedOrClosedListener_FromIndex) {
      {
        setRule(workspace.getRoot());
      }

      @Override
      public boolean belongsTo(Object family) {
        return family == ResourcesPlugin.FAMILY_AUTO_BUILD;
      }

      @Override
      protected IStatus run(IProgressMonitor monitor) {
        try {
          new WorkspaceModifyOperation(getRule()) {
            @Override
            protected void execute(IProgressMonitor monitor)
                throws CoreException, InvocationTargetException, InterruptedException {
              SubMonitor progress = SubMonitor.convert(monitor, 1);
              try {
                ResourceSet resourceSet = getResourceSetProvider().get(project);
                resourceSet
                    .getLoadOptions()
                    .put(ResourceDescriptionsProvider.NAMED_BUILDER_SCOPE, Boolean.TRUE);
                if (resourceSet instanceof ResourceSetImpl) {
                  ((ResourceSetImpl) resourceSet)
                      .setURIResourceMap(Maps.<URI, Resource>newHashMap());
                }
                BuildData buildData =
                    new BuildData(project.getName(), resourceSet, toBeBuilt, queuedBuildData);
                getBuilderState().update(buildData, progress.newChild(1));

                resourceSet.getResources().clear();
                resourceSet.eAdapters().clear();
              } finally {
                if (monitor != null) monitor.done();
              }
            }
          }.run(monitor);
        } catch (InvocationTargetException e) {
          log.error(e.getMessage(), e);
        } catch (InterruptedException e) {
          log.error(e.getMessage(), e);
        }
        return Status.OK_STATUS;
      }
    }.schedule();
  }
 public ToBeBuilt updateProjectNewResourcesOnly(IProject project, IProgressMonitor monitor)
     throws CoreException {
   SubMonitor progress =
       SubMonitor.convert(monitor, Messages.ToBeBuiltComputer_CollectingReosurces, 1);
   progress.subTask(Messages.ToBeBuiltComputer_CollectingReosurces);
   ToBeBuilt toBeBuilt = updateProject(project, progress.newChild(1));
   Iterable<URI> existingURIs =
       Iterables.transform(
           builderState.getAllResourceDescriptions(),
           new Function<IResourceDescription, URI>() {
             public URI apply(IResourceDescription from) {
               return from.getURI();
             }
           });
   for (URI existingURI : existingURIs) {
     toBeBuilt.getToBeDeleted().remove(existingURI);
     toBeBuilt.getToBeUpdated().remove(existingURI);
   }
   return toBeBuilt;
 }