Package org.eclipse.core.resources

Examples of org.eclipse.core.resources.IResourceDelta


  public void resourceChanged(IResourceChangeEvent event) {
    if (event.getDelta() != null) {
      IFile wgaconfig = getWGAConfigFile();
      if (wgaconfig != null && wgaconfig.isAccessible()) {
        IResourceDelta delta = event.getDelta().findMember(getWGAConfigFile().getFullPath());
        if (delta != null) {
          // wga config changed
          fireWGAConfigurationChanged();
        }
      }
View Full Code Here


  public void resourceChanged(IResourceChangeEvent event) {

    if (event.getType() != IResourceChangeEvent.POST_CHANGE)
      return;

    IResourceDelta rootDelta = event.getDelta();

    IResourceDelta docDelta = rootDelta.findMember(new Path(""));
    if (docDelta == null)
      return;

    final ArrayList<IResource> removed = new ArrayList<IResource>();
    IResourceDeltaVisitor rvisitor = new IResourceDeltaVisitor() {
      public boolean visit(IResourceDelta delta) {

        if (delta.getKind() != IResourceDelta.REMOVED)
          return true;

        IResource resource = delta.getResource();

        if (resource.getType() == IResource.FILE) {
          removed.add(resource);
        }
        return true;
      }
    };

    final ArrayList<IResource> added = new ArrayList<IResource>();
    IResourceDeltaVisitor avisitor = new IResourceDeltaVisitor() {
      public boolean visit(IResourceDelta delta) {

        if (delta.getKind() != IResourceDelta.ADDED)
          return true;

        IResource resource = delta.getResource();

        if (resource.getType() == IResource.FILE) {
          added.add(resource);
        }
        return true;
      }
    };

    try {
      docDelta.accept(rvisitor);
      docDelta.accept(avisitor);

    } catch (CoreException e) {

    }
View Full Code Here

  private Set<IFile> _metaDataFilesToRemove = new HashSet<IFile>();
  private Map<IFile, IFile> _metaDataFilesToMove = new HashMap<IFile, IFile>();

  public void resourceChanged(IResourceChangeEvent event) {
    if (event.getType() == IResourceChangeEvent.POST_CHANGE) {
      IResourceDelta delta = event.getDelta();
      if (delta != null) {
        try {
          delta.accept(new IResourceDeltaVisitor() {

            public boolean visit(IResourceDelta delta) throws CoreException {
              if (delta.getResource() instanceof IFile) {
                IFile file = (IFile) delta.getResource();
                if (file != null && file.getLocation() != null && file.getLocation().getFileExtension() != null &&
                    file.getLocation().getFileExtension().equals("tml")) {
                  // a tml file changed
                  if (delta.getKind() == IResourceDelta.REMOVED) {
                    // tml file removed
                    IFile metadataFile = WGADesignStructureHelper.getMetadataFile(file);
                    if (metadataFile.exists()) {
                      _metaDataFilesToRemove.add(metadataFile);
                    }
                   
                  } else if (delta.getKind() == IResourceDelta.ADDED && delta.getMovedFromPath() != null) {
                    // tml file moved from another location
                    IFile orgFile = ResourcesPlugin.getWorkspace().getRoot().getFile(delta.getMovedFromPath());
                    IFile metadataFileFrom = WGADesignStructureHelper.getMetadataFile(orgFile);
                    if (metadataFileFrom.exists()) {
                      IFile metadataFileTo = WGADesignStructureHelper.getMetadataFile(file);
                      _metaDataFilesToMove.put(metadataFileFrom, metadataFileTo);
                    }
View Full Code Here

   
  }

  public void resourceChanged(IResourceChangeEvent event) {
    if (event.getType() == IResourceChangeEvent.POST_CHANGE) {
      IResourceDelta delta = event.getDelta();
      if (delta != null) {
        try {
          delta.accept(new IResourceDeltaVisitor() {
            public boolean visit(IResourceDelta delta) throws CoreException {
              if (delta.getResource() instanceof IProject) {
                IProject project = (IProject) delta.getResource();
                if (delta.getKind() == IResourceDelta.ADDED || delta.getKind() == IResourceDelta.CHANGED) {
                  _projectsAddedOrChanged.add(project);
                }
              }
              return true;
            }           
View Full Code Here

  protected IProject[] build(int kind, Map args, IProgressMonitor monitor) throws CoreException {
    try {
      WGADeploymentManager manager = WGADesignerPlugin.getDefault().getWGADeploymentManager();
      WGADeployment deployment = manager.getDeployment(getProject().getName());
      if (deployment != null) {
        IResourceDelta delta = getDelta(getProject());
        if (delta != null) {
          if (WGADesignerPlugin.getDefault().isDebugging()) {
            System.out.println("Incremental update of WGA deployment '" + deployment.getName() + "'.");
          }
          deployment.updateWGA(delta, monitor);         
View Full Code Here

    if (monitor == null) {
      monitor = new NullProgressMonitor();
    }
    try {
      monitor.beginTask("Incremental updating wga deployment.", 1);
      IResourceDelta delta = projectDelta.findMember(new Path("WebContent"));
      if (delta != null) {
        IResourceDeltaVisitor visitor = new IResourceDeltaVisitor() {

          public boolean visit(IResourceDelta delta) throws CoreException {
            if (delta.getResource() != null) {
              if (delta.getResource() instanceof IFile) {
                IFile file = (IFile)delta.getResource();
                String absolutePath = file.getLocation().toString();
                // make path relative to WebContent folder
                int pos = absolutePath.lastIndexOf("WebContent/");
                if (pos != -1) {                 
                  String relativePathToFile = absolutePath.substring(pos + "WebContent/".length());
                  File targetFile = new File(getDeployDir(), relativePathToFile);
                  File sourceFile = file.getLocation().toFile();               
                  if (delta.getKind() == IResourceDelta.ADDED || delta.getKind() == IResourceDelta.CHANGED) {                                                                                   
                    try {
                      if (WGADesignerPlugin.getDefault().isDebugging()) {
                        System.out.println("Updating resource '" + targetFile.getAbsolutePath() + "' of deployment '" + getName() + "'.");
                      }
                      // ensure that target folder exists
                      if (!targetFile.getParentFile().exists()) {
                        targetFile.getParentFile().mkdirs();
                      }
                      FileUtils.copy(sourceFile, targetFile);
                    } catch (IOException e) {
                      WGADesignerPlugin.getDefault().logError("Unable to update resource '" + targetFile.getAbsolutePath() + "' in wga deployment '" + getName() + "'. Deployment is out of sync.");
                    }
                  } else if (delta.getKind() == IResourceDelta.REMOVED) {                     
                    if (targetFile.exists()) {
                      if (WGADesignerPlugin.getDefault().isDebugging()) {
                        System.out.println("Deleting resource '" + targetFile.getAbsolutePath() + "' of deployment '" + getName() + "'.");
                      }
                      if (!targetFile.delete()) {
                        WGADesignerPlugin.getDefault().logError("Unable to delete resource '" + targetFile.getAbsolutePath() + "' in wga deployment '" + getName() + "'. Deployment is out of sync.");                   
                      }
                    }
                  }                                   
                } else {
                  // invalid resource - should not happen - ignore
                }
              } else if (delta.getResource() instanceof IFolder) {
                IFolder folder = (IFolder)delta.getResource();
                String absolutePath = folder.getLocation().toString();
                // make path relative to WebContent folder
                int pos = absolutePath.lastIndexOf("WebContent/");
                if (pos != -1) {                 
                  String relativePathToFolder = absolutePath.substring(pos + "WebContent/".length());
                  File targetFolder = new File(getDeployDir(), relativePathToFolder);
                  if (delta.getKind() == IResourceDelta.ADDED) {
                    if (WGADesignerPlugin.getDefault().isDebugging()) {
                      System.out.println("Creating folder '" + targetFolder.getAbsolutePath() + "' in deployment '" + getName() + "'.");
                    }
                    targetFolder.mkdirs();
                  } else if (delta.getKind() == IResourceDelta.REMOVED) {
                    if (WGADesignerPlugin.getDefault().isDebugging()) {
                      System.out.println("Deleting folder '" + targetFolder.getAbsolutePath() + "' of deployment '" + getName() + "'.");
                    }
                    if (targetFolder.exists()) {
                      WGUtils.delTree(targetFolder);                     
                    }
                  }
                } else {
                  // invalid resource - should not happen - ignore
                }
              }
            }
            // continue with children
            return true;
          }
         
        };
       
        delta.accept(visitor);       
      }
      monitor.worked(1);
    } finally {
      monitor.done();     
    }
View Full Code Here

                throw new OperationCanceledException();

            if (kind == IncrementalProjectBuilder.FULL_BUILD) {
                fullBuild(monitor);
            } else {
                IResourceDelta delta = getDelta(getProject());
                if (delta == null) {
                    fullBuild(monitor);
                } else {
                    incrementalBuild(delta, monitor);
                }
View Full Code Here

  for (int i = 0; i < resourceDeltasCounter; i++) {
    buffer.append("\n");//$NON-NLS-1$
    for (int j = 0; j < depth+1; j++) {
      buffer.append('\t');
    }
    IResourceDelta resourceDelta = resourceDeltas[i];
    buffer.append(resourceDelta.toString());
    buffer.append("["); //$NON-NLS-1$
    switch (resourceDelta.getKind()) {
      case IResourceDelta.ADDED :
        buffer.append('+');
        break;
      case IResourceDelta.REMOVED :
        buffer.append('-');
View Full Code Here

      this.currentElement = null;
     
      // get the workspace delta, and start processing there.
      IResourceDelta[] deltas = changes.getAffectedChildren();
      for (int i = 0; i < deltas.length; i++) {
        IResourceDelta delta = deltas[i];
        IResource res = delta.getResource();
       
        // find out the element type
        RootInfo rootInfo = null;
        int elementType;
        IProject proj = (IProject)res;
        boolean wasJavaProject = this.state.findJavaProject(proj.getName()) != null;
        boolean isJavaProject = JavaProject.hasJavaNature(proj);
        if (!wasJavaProject && !isJavaProject) {
          elementType = NON_JAVA_RESOURCE;
        } else {
          rootInfo = this.enclosingRootInfo(res.getFullPath(), delta.getKind());
          if (rootInfo != null && rootInfo.isRootOfProject(res.getFullPath())) {
            elementType = IJavaElement.PACKAGE_FRAGMENT_ROOT;
          } else {
            elementType = IJavaElement.JAVA_PROJECT;
          }
        }
       
        // traverse delta
        this.traverseDelta(delta, elementType, rootInfo, null);
       
        if (elementType == NON_JAVA_RESOURCE
            || (wasJavaProject != isJavaProject && (delta.getKind()) == IResourceDelta.CHANGED)) { // project has changed nature (description or open/closed)
          try {
            // add child as non java resource
            nonJavaResourcesChanged((JavaModel)model, delta);
          } catch (JavaModelException e) {
            // java model could not be opened
View Full Code Here

   */
  public void resourceChanged(IResourceChangeEvent event) {

    int eventType = this.overridenEventType == -1 ? event.getType() : this.overridenEventType;
    IResource resource = event.getResource();
    IResourceDelta delta = event.getDelta();
   
    switch(eventType){
      case IResourceChangeEvent.PRE_DELETE :
        try {
          if(resource.getType() == IResource.PROJECT
View Full Code Here

TOP

Related Classes of org.eclipse.core.resources.IResourceDelta

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.