コード例 #1
0
  // -------------------------------------------------------------------------
  //   I N S T A N C E    M E T H O D S
  // -------------------------------------------------------------------------
  @Override
  public String toString() {
    String typeString = getNotificationTypePhrase();

    String resourceType = " "; // $NON-NLS-1$
    if (delta != null && delta.getResource() != null) {
      if (delta.getResource() instanceof IProject) {
        resourceType = " Project Notification: "; // $NON-NLS-1$
      } else if (delta.getResource() instanceof IFile) {
        resourceType = " File Notification: "; // $NON-NLS-1$
      } else if (delta.getResource() instanceof IFolder) {
        resourceType = " Folder Notification: "; // $NON-NLS-1$
      }
    }

    StringBuffer toString = new StringBuffer(typeString);
    toString.append(resourceType);
    toString.append(" on "); // $NON-NLS-1$
    toString.append(getNotifier());
    toString.append("\nisPreAutoBuild = " + isPreAutoBuild()); // $NON-NLS-1$
    toString.append("\nisPostAutoBuild = " + isPostAutoBuild()); // $NON-NLS-1$
    toString.append("\nisAutoBuild = " + isAutoBuild()); // $NON-NLS-1$
    toString.append("\nisRename = " + isRename()); // $NON-NLS-1$
    toString.append("\nisClose = " + isClose()); // $NON-NLS-1$
    toString.append("\nisOpen = " + isOpen()); // $NON-NLS-1$
    toString.append("\nisFile = " + isFile()); // $NON-NLS-1$
    toString.append("\nisFolder = " + isFolder()); // $NON-NLS-1$
    toString.append("\nisProject = " + isProject()); // $NON-NLS-1$
    toString.append("\nisPostChange = " + isPostChange()); // $NON-NLS-1$

    return toString.toString();
  }
コード例 #2
0
 private void handleChange(IResourceDelta delta) {
   if ((delta.getFlags() & IResourceDelta.REPLACED) != 0) {
     // A replace was added in place of a removed resource
     handleAdded(delta);
   } else if (delta.getResource().getType() == IResource.FILE) {
     ensureResourceCovered(delta.getResource(), changedRoots);
   }
 }
コード例 #3
0
 private void handleRemoved(IResourceDelta delta) {
   if ((delta.getFlags() & IResourceDelta.OPEN) != 0) {
     closedProjects.add(delta.getResource());
   } else if ((delta.getFlags() & IResourceDelta.MOVED_TO) != 0) {
     handleMove(delta);
   } else {
     ensureResourceCovered(delta.getResource(), removedRoots);
   }
 }
コード例 #4
0
ファイル: CIMBuilder.java プロジェクト: jimmy0415/CIMTool
    public boolean visit(IResourceDelta delta) throws CoreException {
      switch (delta.getKind()) {
        case IResourceDelta.ADDED:
        case IResourceDelta.REMOVED:
          collect(delta.getResource());
          break;

        case IResourceDelta.CHANGED:
          if ((delta.getFlags() & (IResourceDelta.CONTENT | IResourceDelta.REPLACED)) != 0)
            collect(delta.getResource());
          break;
      }
      return true;
    }
コード例 #5
0
  @Override
  public boolean visit(final IResourceDelta delta) throws CoreException {
    IResource source = delta.getResource();
    switch (source.getType()) {
      case IResource.ROOT:
      case IResource.PROJECT:
      case IResource.FOLDER:
        return true;
      case IResource.FILE:
        final IFile file = (IFile) source;
        if (isDiagramFile(file)) {
          updateModel(file);
          new UIJob("Update Process Model in CommonViewer") { // $NON-NLS-1$

            @Override
            public IStatus runInUIThread(IProgressMonitor monitor) {
              if (getStructuredViewer() != null
                  && !getStructuredViewer().getControl().isDisposed()) {
                getStructuredViewer().refresh(file);
              }
              return Status.OK_STATUS;
            }
          }.schedule();
        }
        return false;
    }
    return false;
  }
コード例 #6
0
ファイル: DeltaAnalyzer.java プロジェクト: NVIDIA/cdt-nsight
 public void processResourceDelta(
     final IResourceDelta[] rDeltas, final ICElement element, Set<IResource> handled) {
   if (rDeltas != null) {
     for (IResourceDelta rd : rDeltas) {
       final int rdkind = rd.getKind();
       if (rdkind != IResourceDelta.ADDED) {
         IResource res = rd.getResource();
         if (!handled.add(res)) {
           continue;
         }
         if (res instanceof IFile) {
           switch (rdkind) {
             case IResourceDelta.CHANGED:
               if ((rd.getFlags() & IResourceDelta.CONTENT) != 0) {
                 fChanged.add(new PotentialTranslationUnit(element, (IFile) res));
               }
               break;
             case IResourceDelta.REMOVED:
               fRemoved.add(new PotentialTranslationUnit(element, (IFile) res));
               break;
           }
         }
       }
       processResourceDelta(
           rd.getAffectedChildren(IResourceDelta.CHANGED | IResourceDelta.REMOVED),
           element,
           handled);
     }
   }
 }
コード例 #7
0
  private void processResourceDelta(WorkingSetDelta result, IResourceDelta delta) {
    IResource resource = delta.getResource();
    int type = resource.getType();
    int index = result.indexOf(resource);
    int kind = delta.getKind();
    int flags = delta.getFlags();
    if (kind == IResourceDelta.CHANGED && type == IResource.PROJECT && index != -1) {
      if ((flags & IResourceDelta.OPEN) != 0) {
        result.set(index, resource);
      }
    }
    if (index != -1 && kind == IResourceDelta.REMOVED) {
      if ((flags & IResourceDelta.MOVED_TO) != 0) {
        result.set(
            index, ResourcesPlugin.getWorkspace().getRoot().findMember(delta.getMovedToPath()));
      } else {
        result.remove(index);
      }
    }

    // Don't dive into closed or opened projects
    if (projectGotClosedOrOpened(resource, kind, flags)) {
      return;
    }

    IResourceDelta[] children = delta.getAffectedChildren();
    for (int i = 0; i < children.length; i++) {
      processResourceDelta(result, children[i]);
    }
  }
コード例 #8
0
          public boolean visit(IResourceDelta delta) {
            if (delta.getResource().getType() != IResource.FILE) {
              return true;
            }
            int deltaKind = delta.getKind();
            if (deltaKind == IResourceDelta.CHANGED && delta.getFlags() != IResourceDelta.MARKERS) {
              URI platformURI = URI.createPlatformResourceURI(delta.getFullPath().toString(), true);
              Resource changedResource = resourceSet.getResource(platformURI, false);
              if (changedResource != null) {
                changedResource.unload();
                com.github.funthomas424242.rezeptsammler.rezept.resource.rezept.IRezeptTextResource
                    currentResource = getResource();
                if (changedResource.equals(currentResource)) {
                  // reload the resource displayed in the editor
                  resourceSet.getResource(currentResource.getURI(), true);
                }
                if (currentResource != null && currentResource.getErrors().isEmpty()) {
                  EcoreUtil.resolveAll(currentResource);
                }
                // reset the selected element in outline and properties by text position
                if (highlighting != null) {
                  highlighting.updateEObjectSelection();
                }
              }
            }

            return true;
          }
コード例 #9
0
  protected boolean checkForClassFileChanges(
      IResourceDelta binaryDelta, ClasspathMultiDirectory md, int segmentCount)
      throws CoreException {
    IResource resource = binaryDelta.getResource();
    // remember that if inclusion & exclusion patterns change then a full build is done
    boolean isExcluded =
        (md.exclusionPatterns != null || md.inclusionPatterns != null)
            && Util.isExcluded(resource, md.inclusionPatterns, md.exclusionPatterns);
    switch (resource.getType()) {
      case IResource.FOLDER:
        if (isExcluded && md.inclusionPatterns == null)
          return true; // no need to go further with this delta since its children cannot be
        // included

        IResourceDelta[] children = binaryDelta.getAffectedChildren();
        for (int i = 0, l = children.length; i < l; i++)
          if (!checkForClassFileChanges(children[i], md, segmentCount)) return false;
        return true;
      case IResource.FILE:
        if (!isExcluded
            && org.eclipse.jdt.internal.compiler.util.Util.isClassFileName(resource.getName())) {
          // perform full build if a managed class file has been changed
          IPath typePath =
              resource.getFullPath().removeFirstSegments(segmentCount).removeFileExtension();
          if (this.newState.isKnownType(typePath.toString())) {
            if (JavaBuilder.DEBUG)
              System.out.println(
                  "MUST DO FULL BUILD. Found change to class file " + typePath); // $NON-NLS-1$
            return false;
          }
          return true;
        }
    }
    return true;
  }
コード例 #10
0
  /** {@inheritDoc} */
  @Override
  public void resourceChanged(IResourceChangeEvent pEvent) {

    if (IResourceChangeEvent.POST_CHANGE == pEvent.getType()) {
      // Extract all the additions among the changes
      IResourceDelta delta = pEvent.getDelta();
      IResourceDelta[] added = delta.getAffectedChildren();

      // In all the added resources, process the projects
      for (int i = 0, length = added.length; i < length; i++) {
        IResourceDelta addedi = added[i];

        // Get the project
        IResource resource = addedi.getResource();
        IProject project = resource.getProject();

        if (ProjectsManager.getProject(project.getName()) == null && project.isOpen()) {
          ProjectAdderJob job = new ProjectAdderJob(project);
          job.schedule();
        }
      }
    } else if (IResourceChangeEvent.PRE_DELETE == pEvent.getType()) {
      // detect UNO IDL project about to be deleted
      IResource removed = pEvent.getResource();
      if (ProjectsManager.getProject(removed.getName()) != null) {
        ProjectsManager.removeProject(removed.getName());
      }
    } else if (IResourceChangeEvent.PRE_CLOSE == pEvent.getType()) {
      IResource res = pEvent.getResource();
      if (res != null && ProjectsManager.getProject(res.getName()) != null) {
        // Project about to be closed: remove for the available uno projects
        ProjectsManager.removeProject(res.getName());
      }
    }
  }
コード例 #11
0
ファイル: DCLBuilder.java プロジェクト: joyeliz/DCL
    public boolean visit(IResourceDelta delta) throws CoreException {
      IResource resource = delta.getResource();
      if (!(resource instanceof IFile)
          || !resource.getName().endsWith(".java")
          || !resource.exists()) {
        return true;
      }
      monitor.subTask(resource.getName());

      switch (delta.getKind()) {
        case IResourceDelta.ADDED:
          check(resource, architecture, true);
          monitor.worked(1);
          break;
        case IResourceDelta.REMOVED:
          delete(resource);
          monitor.worked(1);
          break;
        case IResourceDelta.CHANGED:
          check(resource, architecture, true);
          monitor.worked(1);
          break;
      }

      /* return true to continue visiting children */
      return true;
    }
コード例 #12
0
 private void handleMove(IResourceDelta delta) {
   if ((delta.getFlags() & IResourceDelta.MOVED_TO) != 0) {
     ensureResourceCovered(delta.getResource(), movedRoots);
   } else if ((delta.getFlags() & IResourceDelta.MOVED_FROM) != 0) {
     IResource source = createSourceResource(delta);
     ensureResourceCovered(source, movedRoots);
   }
 }
コード例 #13
0
 private void handleAdded(IResourceDelta delta) {
   if ((delta.getFlags() & IResourceDelta.MOVED_FROM) != 0) {
     handleMove(delta);
   } else if ((delta.getFlags() & IResourceDelta.COPIED_FROM) != 0) {
     handleCopy(delta);
   } else {
     ensureResourceCovered(delta.getResource(), addedRoots);
   }
 }
コード例 #14
0
 /** {@inheritDoc} */
 public boolean visit(IResourceDelta delta) throws CoreException {
   boolean visitChildren = true;
   IResource res = delta.getResource();
   if (res.getType() == IResource.PROJECT) {
     visitChildren = visitProject(delta, (IProject) res);
   } else if (res.getType() == IResource.FILE) {
     visitChildren = visitFile(delta, (IFile) res);
   }
   return visitChildren;
 }
コード例 #15
0
 public void resourceChanged(IResourceChangeEvent event) {
   if (event.getType() == IResourceChangeEvent.PRE_DELETE
       || event.getType() == IResourceChangeEvent.PRE_CLOSE) {
     IResource r = event.getResource();
     if (r instanceof IProject) {
       KbProject n = (KbProject) KbProjectFactory.getKbProject((IProject) r, false, true);
       if (n != null) {
         n.dispose();
       }
     }
   } else if (event.getType() == IResourceChangeEvent.POST_CHANGE) {
     IResourceDelta[] cs = event.getDelta().getAffectedChildren(IResourceDelta.CHANGED);
     for (IResourceDelta c : cs) {
       if ((c.getFlags() & IResourceDelta.OPEN) != 0 && c.getResource() instanceof IProject) {
         IProject p = (IProject) c.getResource();
         KbProjectFactory.getKbProject(p, true, true);
       }
     }
   }
 }
コード例 #16
0
ファイル: DBNProject.java プロジェクト: thecocce/dbeaver
 @Override
 protected void handleChildResourceChange(IResourceDelta delta) {
   final String name = delta.getResource().getName();
   if (name.startsWith(DBPDataSourceRegistry.CONFIG_FILE_PREFIX)
       && name.endsWith(DBPDataSourceRegistry.CONFIG_FILE_EXT)) {
     // DS registry configuration changed
     getDatabases().getDataSourceRegistry().refreshConfig();
   } else {
     super.handleChildResourceChange(delta);
   }
 }
コード例 #17
0
 /**
  * Overridden to detect a support image change in the workspace.
  *
  * <p>{@inheritDoc}
  */
 public boolean visit(IResourceDelta delta) throws CoreException {
   boolean continueToVisit = true;
   boolean isWorkspaceImageChange = false;
   IResource resource = delta.getResource();
   if (isWorkspaceImage(resource)) {
     switch (delta.getKind()) {
       case IResourceDelta.ADDED:
         isWorkspaceImageChange = true;
         break;
       case IResourceDelta.CHANGED:
       case IResourceDelta.REMOVED:
         isWorkspaceImageChange = needClearCache(delta.getResource());
         break;
       default:
         break;
     }
     workspaceImageChangeDetected = workspaceImageChangeDetected || isWorkspaceImageChange;
     continueToVisit = !workspaceImageChangeDetected;
   }
   return continueToVisit;
 }
コード例 #18
0
 public boolean visit(IResourceDelta delta) {
   // only interested in changed resources (not added or removed)
   if (delta.getKind() != IResourceDelta.REMOVED) {
     return true;
   }
   IResource resource = delta.getResource();
   if (resource.getType() == IResource.FILE
       && CALSourcePathMapper.CAL_FILE_EXTENSION.equalsIgnoreCase(resource.getFileExtension())) {
     removedCalFileFound = true;
   }
   return true;
 }
コード例 #19
0
ファイル: HtmlBuildParticipant.java プロジェクト: aam/dartdev
 @Override
 public boolean visit(IResourceDelta delta, IProgressMonitor monitor) throws CoreException {
   if (delta.getKind() == IResourceDelta.CHANGED) {
     IResource resource = delta.getResource();
     if (resource.getType() == IResource.FILE) {
       if (DartCore.isHTMLLikeFileName(resource.getName())) {
         processHtml((IFile) resource);
       }
     }
   }
   return true;
 }
コード例 #20
0
 @Override
 public boolean visit(IResourceDelta delta) throws CoreException {
   IResource res = delta.getResource();
   if (res instanceof IProject && delta.getKind() == IResourceDelta.CHANGED) {
     IProject project = (IProject) res;
     if (!project.isAccessible()) {
       // only track open C projects
       return false;
     }
   }
   checkInvalidate(delta, res);
   return true;
 }
コード例 #21
0
  static boolean isRemove(IResourceDelta delta) {
    int kind = delta.getKind();

    if (IResourceDelta.REMOVED == kind) {
      return true;
    }

    if (IResourceDelta.CHANGED == kind && delta.getResource() instanceof IContainer) {
      return true;
    }

    return false;
  }
コード例 #22
0
  /**
   * Construct an instance of ModelWorkspaceNotificationImpl.
   *
   * @param eventType
   * @param delta
   * @param isPre
   * @param isAutoBuild
   */
  public ModelWorkspaceNotificationImpl(
      final int eventType, final IResourceDelta delta, final IResourceChangeEvent event) {
    super(eventType, null, delta);
    CoreArgCheck.isNotNull(event);

    this.delta = delta;
    this.event = event;
    if (delta != null) {
      this.notifier = delta.getResource();
    } else {
      this.notifier = event.getResource();
    }
  }
コード例 #23
0
 public boolean visit(IResourceDelta delta) throws CoreException {
   IResource resource = delta.getResource();
   if (resource instanceof IFile) {
     if (delta.getKind() == IResourceDelta.ADDED
         || (delta.getKind() == IResourceDelta.CHANGED
             && ((delta.getFlags() & (IResourceDelta.CONTENT | IResourceDelta.ENCODING))
                 != 0))) {
       updatedFiles.add((IFile) resource);
     } else if (delta.getKind() == IResourceDelta.REMOVED) {
       removedFiles.add((IFile) resource);
     }
   }
   return true;
 }
コード例 #24
0
 private IResource createSourceResource(IResourceDelta delta) {
   IPath sourcePath = delta.getMovedFromPath();
   IResource resource = delta.getResource();
   IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot();
   switch (resource.getType()) {
     case IResource.PROJECT:
       return wsRoot.getProject(sourcePath.segment(0));
     case IResource.FOLDER:
       return wsRoot.getFolder(sourcePath);
     case IResource.FILE:
       return wsRoot.getFile(sourcePath);
   }
   return null;
 }
コード例 #25
0
  /**
   * Process a resource delta.
   *
   * @return true if the parent got refreshed
   */
  private boolean processResourceDelta(IResourceDelta delta, Object parent) {
    int status = delta.getKind();
    int flags = delta.getFlags();

    IResource resource = delta.getResource();
    // filter out changes affecting the output folder
    if (resource == null) return false;

    // this could be optimized by handling all the added children in the parent
    if ((status & IResourceDelta.REMOVED) != 0) {
      if (parent instanceof ISourceFolder) {
        Object grandparent = internalGetParent(parent);
        // if grandparent is src folder root that is equal to project, refresh project
        if (grandparent instanceof ISourceFolderRoot
            && ((ISourceFolderRoot) grandparent)
                .getResource()
                .equals(((ISourceFolderRoot) grandparent).getRubyProject().getProject())) {
          parent = grandparent;
          grandparent = internalGetParent(parent);
        }
        // refresh one level above to deal with empty package filtering properly
        postRefresh(grandparent, PARENT, parent);
        return true;
      } else postRemove(resource);
    }
    if ((status & IResourceDelta.ADDED) != 0) {
      if (parent instanceof ISourceFolder) {
        Object grandparent = internalGetParent(parent);
        // if grandparent is src folder root that is equal to project, refresh project
        if (grandparent instanceof ISourceFolderRoot
            && ((ISourceFolderRoot) grandparent)
                .getResource()
                .equals(((ISourceFolderRoot) grandparent).getRubyProject().getProject())) {
          parent = grandparent;
          grandparent = internalGetParent(parent);
        }
        // refresh one level above to deal with empty package filtering properly
        postRefresh(grandparent, PARENT, parent);
        return true;
      } else postAdd(parent, resource);
    }
    // open/close state change of a project
    if ((flags & IResourceDelta.OPEN) != 0) {
      postProjectStateChanged(internalGetParent(parent));
      return true;
    }
    processResourceDeltas(delta.getAffectedChildren(), resource);
    return false;
  }
コード例 #26
0
  /**
   * Prepares two list of modified resources : source files and binary class files
   *
   * @param aDeltaRoot Root file container
   * @param aJavaResourcesList Java source files list
   * @param aJavaClasslist Java class files list
   * @return True if the metadata.xml file was modified (not added to aJavaResourcesList)
   */
  protected boolean loadResourceDelta(
      final IResourceDelta aDeltaRoot,
      final List<IResource> aJavaResourcesList,
      final List<IResource> aJavaClasslist) {

    boolean metadataModified = false;

    // Test resource name
    final String resourceName = aDeltaRoot.getResource().getName();

    if (resourceName.endsWith(".java")) {
      // Test Java source file
      aJavaResourcesList.add(aDeltaRoot.getResource());

    } else if (resourceName.endsWith("metadata.xml")) {
      // Tests Metadata file
      metadataModified = true;

    } else if (resourceName.endsWith(".class")) {
      // Tests binary .class file
      aJavaClasslist.add(aDeltaRoot.getResource());

    } else {
      // Test sub directories, if any
      final IResourceDelta[] subdeltas =
          aDeltaRoot.getAffectedChildren(IResourceDelta.ADDED | IResourceDelta.CHANGED);

      if (subdeltas != null && subdeltas.length > 0) {
        for (final IResourceDelta subdelta : subdeltas) {
          metadataModified |= loadResourceDelta(subdelta, aJavaResourcesList, aJavaClasslist);
        }
      }
    }

    return metadataModified;
  }
コード例 #27
0
ファイル: VdmCoreBuilder.java プロジェクト: henriknj/overture
    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;
    }
    private void processEntryChanges(IResourceDelta projectDelta, Set projectsToSave) {
      // check each resource with css content setting to see if it has
      // been moved/deleted
      boolean resourceChanges = false;

      // project affected
      IProject currentProject = (IProject) projectDelta.getResource();

      resourceChanges =
          processPreferences(
              currentProject, CSSContentProperties.CSS_PROFILE, projectDelta, projectsToSave);

      // if there was a preference key change, need to save preferences
      if (resourceChanges) projectsToSave.add(currentProject);
    }
コード例 #29
0
  /**
   * @see
   *     org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent)
   */
  @Override
  public void resourceChanged(IResourceChangeEvent event) {
    final IResourceDelta rootDelta = event.getDelta();
    if (rootDelta == null) return;

    final IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
    for (IProject project : projects) {
      final IPath roughnessPath = project.getFullPath().append(ROUGHNESS_DATABASE_PATH);
      final IResourceDelta fileDelta = rootDelta.findMember(roughnessPath);
      if (fileDelta != null) {
        if ((fileDelta.getFlags() & IResourceDelta.CONTENT) != 0)
          startStyleUpdateJob((IFile) fileDelta.getResource());
      }
    }
  }
コード例 #30
0
  public boolean visit(IResourceDelta delta) {
    IResource res = delta.getResource();

    if (res != null && res instanceof IFile && delta.getKind() == IResourceDelta.CHANGED) {

      IFile file = (IFile) res;
      if (PatternRegistry.getInstance().getFiles().contains(file)) {
        RuntimeMatcherRegistrator registrator = new RuntimeMatcherRegistrator((IFile) file);
        injector.injectMembers(registrator);
        Display.getDefault().syncExec(registrator);
      }
      return false;
    }
    return true;
  }