use of org.eclipse.core.resources.IResourceDelta in project sling by apache.
the class JcrContentContentProvider method resourceChanged.
@Override
public void resourceChanged(IResourceChangeEvent event) {
if (viewer.getTree().isDisposed()) {
return;
}
try {
final Set<IProject> toBeRefreshed = new HashSet<>();
event.getDelta().accept(new IResourceDeltaVisitor() {
@Override
public boolean visit(IResourceDelta delta) throws CoreException {
if (delta.getResource() instanceof IContainer) {
return true;
}
IProject p = delta.getResource().getProject();
IFolder syncDir = getSyncDir(p);
if (syncDir == null) {
return false;
}
toBeRefreshed.add(syncDir.getProject());
return true;
}
});
for (final IProject project : toBeRefreshed) {
viewer.getTree().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
if (viewer.getTree().isDisposed()) {
return;
}
long start = System.currentTimeMillis();
viewer.refresh(project, true);
long end = System.currentTimeMillis();
Activator.getDefault().getPluginLogger().tracePerformance("viewer.refresh({0},true)", (end - start), project);
}
});
}
} catch (CoreException e) {
//TODO proper logging
e.printStackTrace();
}
}
use of org.eclipse.core.resources.IResourceDelta in project bndtools by bndtools.
the class NewProjectResourceListener method resourceChanged.
public void resourceChanged(IResourceChangeEvent event) {
IResourceDelta delta = event.getDelta();
if (delta == null)
return;
final List<IProject> newProjects = new LinkedList<IProject>();
try {
delta.accept(new IResourceDeltaVisitor() {
public boolean visit(IResourceDelta delta) throws CoreException {
if (delta.getFlags() == IResourceDelta.MARKERS)
// ignore marker-only deltas.
return false;
IResource resource = delta.getResource();
if (resource.getType() == IResource.ROOT)
return true;
if (resource.getType() == IResource.PROJECT) {
IProject project = (IProject) resource;
if (project.isOpen() && project.hasNature(BndtoolsConstants.NATURE_ID) && ((delta.getKind() & IResourceDelta.ADDED) != 0)) {
newProjects.add(project);
}
}
return false;
}
});
for (IProject project : newProjects) {
AdjustClasspathsForNewProjectJob adjustClasspathsJob = new AdjustClasspathsForNewProjectJob(project);
adjustClasspathsJob.setSystem(true);
adjustClasspathsJob.schedule();
}
} catch (CoreException e) {
logger.logError("An error occurred while analysing the resource change", e);
}
}
use of org.eclipse.core.resources.IResourceDelta in project bndtools by bndtools.
the class ProjectBuildPage method resourceChanged.
@Override
public void resourceChanged(IResourceChangeEvent event) {
IResource myResource = ResourceUtil.getResource(getEditorInput());
IResourceDelta delta = event.getDelta();
if (delta == null)
return;
IPath fullPath = myResource.getFullPath();
delta = delta.findMember(fullPath);
if (delta == null)
return;
if ((delta.getKind() & IResourceDelta.CHANGED) != 0 && (delta.getFlags() & IResourceDelta.MARKERS) != 0) {
getEditorSite().getShell().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
loadProblems();
reportProblemsInHeader();
}
});
}
}
use of org.eclipse.core.resources.IResourceDelta in project bndtools by bndtools.
the class FileUtils method dumpResourceDelta.
private static void dumpResourceDelta(IResourceDelta delta, PrintStream out, String indent) {
out.println(String.format("%s%s: kind=%h, flags=%h", indent, delta.getFullPath(), delta.getKind(), delta.getFlags()));
IResourceDelta[] children = delta.getAffectedChildren();
for (IResourceDelta child : children) {
dumpResourceDelta(child, out, indent + " ");
}
}
use of org.eclipse.core.resources.IResourceDelta in project bndtools by bndtools.
the class BndtoolsBuilder method hasUpstreamChanges.
/*
* Check if any of the projects of which we depend has changes.
* We use the generated/buildfiles as the marker.
*/
private boolean hasUpstreamChanges() throws Exception {
for (IProject upstream : dependsOn) {
if (!upstream.exists())
continue;
Project up = Central.getProject(upstream);
if (up == null)
continue;
IResourceDelta delta = getDelta(upstream);
DeltaWrapper dw = new DeltaWrapper(up, delta, buildLog);
if (dw.hasBuildfile()) {
buildLog.full("Upstream project %s changed", up);
return true;
}
}
return false;
}
Aggregations