Java Code Examples for org.eclipse.core.resources.IResourceChangeEvent#POST_CHANGE

The following examples show how to use org.eclipse.core.resources.IResourceChangeEvent#POST_CHANGE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SharedResourcesManager.java    From saros with GNU General Public License v2.0 6 votes vote down vote up
private void logPauseWarning(IResourceChangeEvent event) {
  if (event.getType() == IResourceChangeEvent.POST_CHANGE) {

    IResourceDelta delta = event.getDelta();
    if (delta == null) {
      log.error(
          "Resource changed while paused"
              + " but unexpected empty delta in "
              + "SharedResourcesManager: "
              + event);
      return;
    }

    log.warn("Resource changed while paused:\n" + deltaToString(delta));
  } else {
    log.error("Unexpected event type in in logPauseWarning: " + event);
  }
}
 
Example 2
Source File: StartupHandler.java    From CogniCrypt with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void resourceChanged(IResourceChangeEvent event) {

	IResourceDelta delta = event.getDelta();

	IResourceDelta[] affectedChildren = delta.getAffectedChildren();
	if (affectedChildren.length == 0) {
		return;
	}
	IResource deltaResource = affectedChildren[0].getResource();
	if (event.getType() == IResourceChangeEvent.POST_CHANGE && deltaResource instanceof IProject
			&& (delta.getKind() == IResourceDelta.ADDED || delta.getKind() == IResourceDelta.CHANGED)) {
		try {
			IProject project = (IProject) deltaResource;
			if (!CrySLBuilderUtils.hasCrySLBuilder(project) && CrySLBuilderUtils.hasCrySLFiles(project)) {
				CrySLBuilderUtils.addCrySLBuilderToProject(project);
			}
		}
		catch (CoreException e) {}
	}
}
 
Example 3
Source File: ProjectOpenedOrClosedListener.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void resourceChanged(final IResourceChangeEvent event) {
	if (workspace != null && workspace.isAutoBuilding()) {
		if (event.getType() == IResourceChangeEvent.POST_CHANGE) {
			try {
				final Set<IProject> toUpdate = findNewProjectsToBuild(event);
				scheduleBuildIfNecessary(toUpdate);
			} catch (CoreException e) {
				log.error(e.getMessage(), e);
			}
		} else if ((event.getType() == IResourceChangeEvent.PRE_CLOSE || event.getType() == IResourceChangeEvent.PRE_DELETE)) {
			if (event.getResource() instanceof IProject && (XtextProjectHelper.hasNature((IProject) event.getResource())
					|| event.getResource().isAccessible() && event.getResource().isHidden())) {
				scheduleRemoveProjectJob((IProject) event.getResource());
			}
		}
	}
}
 
Example 4
Source File: PlatformHolder.java    From hybris-commerce-eclipse-plugin with Apache License 2.0 6 votes vote down vote up
void workspaceChanged(IResourceChangeEvent event) {
	try {
		if (event.getType() == IResourceChangeEvent.PRE_DELETE || event.getType() == IResourceChangeEvent.PRE_CLOSE) {
			if (Platform.isPlatformProject((IProject)event.getResource())) {
				clear();
			}
		}
		else if (event.getType() == IResourceChangeEvent.POST_CHANGE) {
			event.getDelta().accept(new IResourceDeltaVisitor() {

				@Override
				public boolean visit(IResourceDelta delta) throws CoreException {
					if (delta.getKind() == IResourceDelta.ADDED
							&& delta.getResource().getType() == IResource.PROJECT) {
						projectAdded((IProject) delta.getResource());
					}
					return delta.getResource().getType() == IResource.ROOT;
				}

			});
		}
	} catch (CoreException e) {
		log.log(new Status(Status.ERROR, log.getBundle().getSymbolicName(), "Error when handling IResourceChangedEvent", e));
	}
}
 
Example 5
Source File: XBookmarksPlugin.java    From xds-ide with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void resourceChanged(IResourceChangeEvent event) {
    if (event.getType() == IResourceChangeEvent.POST_CHANGE) {
        try {
            event.getDelta().accept(new IResourceDeltaVisitor() {
                @Override
                public boolean visit(IResourceDelta delta) throws CoreException {
                    IResource res = delta.getResource();
                    switch (delta.getKind()) {
                    case IResourceDelta.REMOVED:
                        XBookmarksUtils.removeBookmarksFrom(res);
                        break;
                    }
                    return true; // visit the children
                }
            });
        } catch (CoreException e) {}
    }
}
 
Example 6
Source File: SharedResourcesManager.java    From saros with GNU General Public License v2.0 6 votes vote down vote up
/** This method is called from Eclipse when changes to resource are detected */
@Override
public void resourceChanged(IResourceChangeEvent event) {

  /*
   * FIXME this is REAL GARBAGE ! This is sometimes set by the
   * IncomingProjectNegotiation. So when it is set every change in an
   * already shared project is just SILENTLY IGNORED !!!
   */
  if (fileReplacementInProgressObservable.isReplacementInProgress()) return;

  if (pause) {
    logPauseWarning(event);
    return;
  }

  // Creations, deletions, modifications of files and folders.
  if (event.getType() == IResourceChangeEvent.POST_CHANGE) {
    handlePostChange(event);
  } else {
    log.warn("cannot handle event type : " + event);
  }
}
 
Example 7
Source File: ICEResourcePage.java    From ice with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void resourceChanged(IResourceChangeEvent event) {
	if (event.getType() == IResourceChangeEvent.POST_CHANGE) {
		try {
			event.getDelta().accept(new IResourceDeltaVisitor() {
				@Override
				public boolean visit(IResourceDelta delta)
						throws CoreException {
					for (ICEResource r : ICEResourcePage.this.resourceComponent
							.getResources()) {
						if (delta.getResource().getName().equals(
								(new File(r.getPath()).getName()))) {
							ICEResourcePage.this.update(r);
						}
					}
					return true;
				}
			});
		} catch (CoreException e) {
			e.printStackTrace();
		}
	}
}
 
Example 8
Source File: FileEntry.java    From ice with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void resourceChanged(IResourceChangeEvent event) {
	if (project != null) {
		if (event.getType() == IResourceChangeEvent.POST_CHANGE) {
			try {
				event.getDelta().accept(new IResourceDeltaVisitor() {
					public boolean visit(IResourceDelta delta) throws CoreException {
						IProject p = delta.getResource().getProject();
						if (p != null && p.getName().equals(project.getName())) {
							generateAllowedValues();
							notifyListeners();
						}
						return true;
					}
				});
			} catch (CoreException e) {
				e.printStackTrace();
			}
		}
	}
}
 
Example 9
Source File: DefaultValidationIssueStore.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void resourceChanged(IResourceChangeEvent event) {
	if ((IResourceChangeEvent.POST_CHANGE != event.getType())) {
		return;
	}

	ResourceDeltaToIssueResult markerChangeResult = null;
	synchronized (visibleIssues) {
		markerChangeResult = resourceChangeToIssues.process(event, connectedResource, visibleIssues);
		if (markerChangeResult != null)
			visibleIssues = markerChangeResult.getIssues();
	}

	if (markerChangeResult != null)
		for (String elementID : markerChangeResult.getChangedElementIDs()) {
			notifyListeners(elementID);
		}

}
 
Example 10
Source File: SyncGraphvizExportHandler.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void resourceChanged(IResourceChangeEvent event) {
	if (event.getType() != IResourceChangeEvent.POST_BUILD
			&& event.getType() != IResourceChangeEvent.POST_CHANGE) {
		return;
	}
	IResourceDelta rootDelta = event.getDelta();
	try {
		rootDelta.accept(resourceDeltaVisitor);
	} catch (CoreException e) {
		DotActivatorEx.logError(e);
	}
}
 
Example 11
Source File: DefaultProjectResourceListener.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void resourceChanged(IResourceChangeEvent resourceChange) {
	if(resourceChange.getType() != IResourceChangeEvent.POST_CHANGE) {
		return;
	}
	
	IResourceDelta workspaceDelta = resourceChange.getDelta();
	assertTrue(workspaceDelta != null);
	processWorkspaceDelta(workspaceDelta);
}
 
Example 12
Source File: BibtexEntryView.java    From slr-toolkit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Fired whenever a resource is changed
 */
@Override
public void resourceChanged(IResourceChangeEvent event) {
	if (event.getType() != IResourceChangeEvent.POST_CHANGE
			&& event.getType() != IResourceChangeEvent.PRE_DELETE) {
		return;
	}
	if (event.getType() == IResourceChangeEvent.POST_CHANGE) {
		handleResourceChangeEvent(event);
	} else if (event.getType() == IResourceChangeEvent.PRE_DELETE) {
		handleResourceDeleteEvent(event);
	}
}
 
Example 13
Source File: ResourcesWatcher.java    From typescript.java with MIT License 5 votes vote down vote up
@Override
public void resourceChanged(IResourceChangeEvent event) {
	try {
		IResource resource = event.getResource();
		switch (event.getType()) {
		case IResourceChangeEvent.PRE_DELETE:
			if (resource != null) {
				switch (resource.getType()) {
				case IResource.PROJECT:
					// called when project is deleted.
					deleteProject((IProject) resource);
					break;
				}
			}
			break;
		case IResourceChangeEvent.PRE_CLOSE:
			if (resource != null) {
				switch (resource.getType()) {
				case IResource.PROJECT:
					// called when project is closed.
					closeProject((IProject) resource);
					break;
				}
			}
			break;
		case IResourceChangeEvent.POST_CHANGE:
			IResourceDelta delta = event.getDelta();
			if (delta != null) {
				delta.accept(this);
			}
			break;
		}
	} catch (Throwable e) {
		Trace.trace(Trace.SEVERE, "Error while TypeScript resource changed", e);
	}
}
 
Example 14
Source File: PubspecChangeListener.java    From dartboard with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void resourceChanged(IResourceChangeEvent event) {
	if (event.getType() == IResourceChangeEvent.POST_CHANGE) {
		try {
			event.getDelta().accept(new IResourceDeltaVisitor() {

				@Override
				public boolean visit(IResourceDelta delta) throws CoreException {
					IResource resource = delta.getResource();
					if (resource.getType() == IResource.FILE && GlobalConstants.PUBSPEC_YAML.equals(resource.getName())
							&& (delta.getKind() == ADDED || isContentChanged(delta))) {
						for (IPubService abstractPubService : pubServices) {
							// At this point, resource is the pubspec.yaml
							if (abstractPubService.test(resource.getProject())) {
								abstractPubService.get(resource.getProject());
								break;
							}
						}
					}
					return true;
				}
			});
		} catch (CoreException e) {
			LOG.log(DartLog.createError(e.getMessage(), e));
		}
	}
}
 
Example 15
Source File: DotGraphView.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void resourceChanged(final IResourceChangeEvent event) {
	if (event.getType() != IResourceChangeEvent.POST_BUILD && event
			.getType() != IResourceChangeEvent.POST_CHANGE) {
		return;
	}
	IResourceDelta rootDelta = event.getDelta();
	try {
		rootDelta.accept(resourceVisitor);
	} catch (CoreException e) {
		DotActivatorEx.logError(e);
	}
}
 
Example 16
Source File: N4JSProjectExplorerContentProvider.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates a new content provider for the navigator with N4JS content support.
 *
 * @param store
 *            the preference store;
 */
@Inject
public N4JSProjectExplorerContentProvider(final ExternalLibraryPreferenceStore store) {
	store.addListener(this);
	int eventMask = IResourceChangeEvent.PRE_BUILD | IResourceChangeEvent.POST_CHANGE;
	getWorkspace().addResourceChangeListener(this::cleanBuildOrManifestChangedEvent, eventMask);
}
 
Example 17
Source File: ProjectStateChangeListener.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void resourceChanged(final IResourceChangeEvent event) {
	IWorkspace workspace = getWorkspace();
	if (workspace != null) {
		if (event.getType() == IResourceChangeEvent.POST_CHANGE) {
			try {
				final Set<IProject> affectedProjects = Sets.newLinkedHashSet();
				event.getDelta().accept(projectCollector(affectedProjects));
				if (!affectedProjects.isEmpty()) {
					ToBeBuilt toBeBuilt = new ToBeBuilt();
					Set<URI> toBeUpdated = toBeBuilt.getToBeUpdated();
					Set<String> projectNames = new LinkedHashSet<>();
					for (IProject project : affectedProjects) {
						IFile file = project.getFile(N4JSGlobals.PACKAGE_JSON);
						if (file.exists()) {
							projectNames.add(project.getName());
							toBeUpdated.add(URI.createPlatformResourceURI(file.getFullPath().toString(), true));
						}

					}
					packageJsonQueue.enqueue(projectNames, toBeBuilt, false);
					syncIndexJob.schedule();
				}
			} catch (CoreException e) {
				LOGGER.error(e.getMessage(), e);
			}
		}
	}
	super.resourceChanged(event);
}