use of org.eclipse.core.resources.IResourceDelta in project bndtools by bndtools.
the class DeltaWrapper method hasProjectChanged.
/*
* Any change other then src, test, test_bin, or generated is fair game.
*/
boolean hasProjectChanged() throws Exception {
if (delta == null) {
log.basic("Full build because delta is null");
return true;
}
final AtomicBoolean result = new AtomicBoolean(false);
delta.accept(new IResourceDeltaVisitor() {
@Override
public boolean visit(IResourceDelta visitDelta) throws CoreException {
if ((delta.getKind() & (IResourceDelta.ADDED | IResourceDelta.CHANGED | IResourceDelta.REMOVED)) == 0)
return false;
IResource resource = visitDelta.getResource();
if (resource.getType() == IResource.ROOT || resource.getType() == IResource.PROJECT)
return true;
String path = resource.getProjectRelativePath().toString();
if (resource.getType() == IResource.FOLDER) {
if (//
check(path, model.getProperty(Constants.DEFAULT_PROP_SRC_DIR)) || //
check(path, model.getProperty(Constants.DEFAULT_PROP_TESTSRC_DIR)) || //
check(path, model.getProperty(Constants.DEFAULT_PROP_TESTBIN_DIR)) || check(path, model.getProperty(Constants.DEFAULT_PROP_TARGET_DIR))) {
return false;
}
}
if (IResourceDelta.MARKERS == delta.getFlags())
return false;
if (check(path, Project.BNDFILE))
return false;
log.basic("%s changed", resource);
result.set(true);
return false;
}
});
return result.get();
}
use of org.eclipse.core.resources.IResourceDelta in project bndtools by bndtools.
the class DeltaWrapper method toFiles.
private List<String> toFiles(final boolean dirsAlso) throws CoreException {
if (delta == null)
return null;
final List<String> files = new ArrayList<String>();
delta.accept(new IResourceDeltaVisitor() {
@Override
public boolean visit(IResourceDelta d) throws CoreException {
IResource r = d.getResource();
if (r != null) {
if (r.getType() == IResource.PROJECT) {
return true;
}
if (r.getType() == IResource.FILE) {
files.add(d.getProjectRelativePath().toString());
return false;
}
if (r.getType() == IResource.FOLDER) {
if (dirsAlso)
files.add(d.getProjectRelativePath().toString());
return true;
}
}
return false;
}
});
return files;
}
use of org.eclipse.core.resources.IResourceDelta in project bndtools by bndtools.
the class DeltaWrapper method has.
private boolean has(File f) throws Exception {
if (f == null)
return false;
if (delta == null)
return false;
IPath path = Central.toPath(f);
if (path == null)
return false;
IPath relativePath = path.makeRelativeTo(delta.getFullPath());
if (relativePath == null)
return false;
IResourceDelta delta = this.delta.findMember(relativePath);
if (delta == null)
return false;
if ((delta.getFlags() == IResourceDelta.MARKERS))
return false;
if (delta.getKind() == IResourceDelta.ADDED || delta.getKind() == IResourceDelta.CHANGED || delta.getKind() == IResourceDelta.REMOVED)
return true;
return false;
}
use of org.eclipse.core.resources.IResourceDelta in project che by eclipse.
the class ResourceChangeChecker method getChangedFiles.
/* package */
IFile[] getChangedFiles() throws CoreException {
IResourceDelta root = fDeltaFactory.getDelta();
final List result = new ArrayList();
root.accept(new IResourceDeltaVisitor() {
public boolean visit(IResourceDelta delta) throws CoreException {
final IResource resource = delta.getResource();
if (resource.getType() == IResource.FILE) {
final int kind = delta.getKind();
if (isSet(kind, IResourceDelta.CHANGED)) {
result.add(resource);
} else if (isSet(kind, IResourceDelta.ADDED) && isSet(delta.getFlags(), IResourceDelta.CONTENT | IResourceDelta.MOVED_FROM)) {
final IFile movedFrom = resource.getWorkspace().getRoot().getFile(delta.getMovedFromPath());
result.add(movedFrom);
}
}
return true;
}
});
return (IFile[]) result.toArray(new IFile[result.size()]);
}
use of org.eclipse.core.resources.IResourceDelta in project che by eclipse.
the class DeltaProcessor method mergeDeltas.
/*
* Merges all awaiting deltas.
*/
private IJavaElementDelta mergeDeltas(Collection deltas) {
if (deltas.size() == 0)
return null;
if (deltas.size() == 1)
return (IJavaElementDelta) deltas.iterator().next();
if (VERBOSE) {
System.out.println(//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
"MERGING " + deltas.size() + " DELTAS [" + Thread.currentThread() + "]");
}
Iterator iterator = deltas.iterator();
JavaElementDelta rootDelta = new JavaElementDelta(this.manager.javaModel);
boolean insertedTree = false;
while (iterator.hasNext()) {
JavaElementDelta delta = (JavaElementDelta) iterator.next();
if (VERBOSE) {
System.out.println(delta.toString());
}
IJavaElement element = delta.getElement();
if (this.manager.javaModel.equals(element)) {
IJavaElementDelta[] children = delta.getAffectedChildren();
for (int j = 0; j < children.length; j++) {
JavaElementDelta projectDelta = (JavaElementDelta) children[j];
rootDelta.insertDeltaTree(projectDelta.getElement(), projectDelta);
insertedTree = true;
}
IResourceDelta[] resourceDeltas = delta.getResourceDeltas();
if (resourceDeltas != null) {
for (int i = 0, length = resourceDeltas.length; i < length; i++) {
rootDelta.addResourceDelta(resourceDeltas[i]);
insertedTree = true;
}
}
} else {
rootDelta.insertDeltaTree(element, delta);
insertedTree = true;
}
}
if (insertedTree)
return rootDelta;
return null;
}
Aggregations