/* (non-Javadoc)
   * @see org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent)
   */
  public void resourceChanged(final IResourceChangeEvent event) {
    String[] markerTypes = getMarkerTypes();
    Set handledResources = new HashSet();
    Set changes = new HashSet();

    // Accumulate all distinct resources that have had problem marker
    // changes
    for (int idx = 0; idx < markerTypes.length; idx++) {
      IMarkerDelta[] markerDeltas = event.findMarkerDeltas(markerTypes[idx], true);
      for (int i = 0; i < markerDeltas.length; i++) {
        IMarkerDelta delta = markerDeltas[i];
        IResource resource = delta.getResource();
        if (!handledResources.contains(resource)) {
          handledResources.add(resource);
          ISynchronizeModelElement[] elements =
              provider.getClosestExistingParents(delta.getResource());
          if (elements != null && elements.length > 0) {
            for (int j = 0; j < elements.length; j++) {
              ISynchronizeModelElement element = elements[j];
              changes.add(element);
            }
          }
        }
      }
    }

    if (!changes.isEmpty()) {
      updateMarkersFor(
          (ISynchronizeModelElement[])
              changes.toArray(new ISynchronizeModelElement[changes.size()]));
    }
  }
Exemplo n.º 2
0
    public void resourceChanged(IResourceChangeEvent event) {
      if (event.getBuildKind() == IncrementalProjectBuilder.CLEAN_BUILD) {
        Object source = event.getSource();
        try {
          if (source instanceof IProject) {
            IProject project = (IProject) source;
            ProjectIndexerManager.removeProject(project.getFullPath());
            ProjectIndexerManager.indexProject(project);

          } else if (source instanceof IWorkspace) {
            IWorkspace workspace = (IWorkspace) source;
            IProject[] projects = workspace.getRoot().getProjects();

            // remove from index:
            for (IProject project : projects) {
              if (!project.isAccessible()) {
                continue;
              }
              IScriptProject scriptProject = DLTKCore.create(project);
              if (scriptProject.isOpen()) {
                IProjectFragment[] projectFragments = scriptProject.getProjectFragments();
                for (IProjectFragment projectFragment : projectFragments) {
                  ProjectIndexerManager.removeProjectFragment(
                      scriptProject, projectFragment.getPath());
                }
                ProjectIndexerManager.removeProject(project.getFullPath());
              }
            }

            // add to index:
            for (IProject project : projects) {
              if (!project.isAccessible()) {
                continue;
              }
              ProjectIndexerManager.indexProject(project);
            }
          }
        } catch (CoreException e) {
          Logger.logException(e);
        }
      }
    }
Exemplo n.º 3
0
 @Override
 public void resourceChanged(IResourceChangeEvent e) {
   IResourceDelta delta = e.getDelta();
   try {
     if (delta != null && isInstalled) {
       delta.accept(this);
     }
   } catch (CoreException x) {
     log.warn("Error handling resourceChanged", x);
   }
 }
Exemplo n.º 4
0
    /*
     * Gathers all the projects that changed in the workspace and sends them
     * to the conversion method
     *
     * (non-Javadoc)
     *
     * @see
     * org.eclipse.core.resources.IResourceChangeListener#resourceChanged
     * (org.eclipse.core.resources.IResourceChangeEvent)
     */
    public void resourceChanged(IResourceChangeEvent event) {
      IResourceDelta delta = event.getDelta();
      IResourceDelta[] affectedChildren = delta.getAffectedChildren();
      IProject[] projects = new IProject[affectedChildren.length];
      for (int i = 0; i < affectedChildren.length; i++) {
        projects[i] = affectedChildren[i].getResource().getProject();
      }

      try {
        processProjects(projects);
      } catch (CoreException e) {
        Logger.logException(e);
      }
    }
Exemplo n.º 5
0
 /**
  * For any change to the encoding file or any resource with encoding set, just discard the cache
  * for the corresponding project.
  */
 @Override
 public void resourceChanged(IResourceChangeEvent event) {
   IResourceDelta delta = event.getDelta();
   if (delta == null) return;
   IResourceDelta[] projectDeltas = delta.getAffectedChildren();
   // process each project in the delta
   Map<IProject, Boolean> projectsToSave = new HashMap<>();
   for (int i = 0; i < projectDeltas.length; i++)
     // nothing to do if a project has been added/removed/moved
     if (projectDeltas[i].getKind() == IResourceDelta.CHANGED
         && (projectDeltas[i].getFlags() & IResourceDelta.OPEN) == 0)
       processEntryChanges(projectDeltas[i], projectsToSave);
   job.addChanges(projectsToSave);
 }