use of org.eclipse.core.internal.resources.ResourceInfo in project polymap4-core by Polymap4.
the class ResourceComparator method compare.
/**
* Compare the ElementInfos for two resources.
*/
public int compare(Object o1, Object o2) {
// == handles null, null.
if (o1 == o2)
return IResourceDelta.NO_CHANGE;
int result = 0;
if (o1 == null)
return ((ResourceInfo) o2).isSet(M_PHANTOM) ? IResourceDelta.ADDED_PHANTOM : IResourceDelta.ADDED;
if (o2 == null)
return ((ResourceInfo) o1).isSet(M_PHANTOM) ? IResourceDelta.REMOVED_PHANTOM : IResourceDelta.REMOVED;
if (!(o1 instanceof ResourceInfo && o2 instanceof ResourceInfo))
return IResourceDelta.NO_CHANGE;
ResourceInfo oldElement = (ResourceInfo) o1;
ResourceInfo newElement = (ResourceInfo) o2;
if (!oldElement.isSet(M_PHANTOM) && newElement.isSet(M_PHANTOM))
return IResourceDelta.REMOVED;
if (oldElement.isSet(M_PHANTOM) && !newElement.isSet(M_PHANTOM))
return IResourceDelta.ADDED;
if (!compareOpen(oldElement, newElement))
result |= IResourceDelta.OPEN;
if (!compareContents(oldElement, newElement)) {
if (oldElement.getType() == IResource.PROJECT)
result |= IResourceDelta.DESCRIPTION;
else if (newElement.getType() == IResource.FILE || oldElement.getType() == IResource.FILE)
result |= IResourceDelta.CONTENT;
}
if (!compareType(oldElement, newElement))
result |= IResourceDelta.TYPE;
if (!compareNodeIDs(oldElement, newElement)) {
result |= IResourceDelta.REPLACED;
// if the node was replaced and the old and new were files, this is also a content change.
if (oldElement.getType() == IResource.FILE && newElement.getType() == IResource.FILE)
result |= IResourceDelta.CONTENT;
}
if (compareLocal(oldElement, newElement))
result |= IResourceDelta.LOCAL_CHANGED;
if (!compareCharsets(oldElement, newElement))
result |= IResourceDelta.ENCODING;
if (notification && !compareSync(oldElement, newElement))
result |= IResourceDelta.SYNC;
if (notification && !compareMarkers(oldElement, newElement))
result |= IResourceDelta.MARKERS;
if (save && !compareUsed(oldElement, newElement))
result |= IResourceDelta.CHANGED;
return result == 0 ? 0 : result | IResourceDelta.CHANGED;
}
use of org.eclipse.core.internal.resources.ResourceInfo in project jbosstools-hibernate by jbosstools.
the class ProjectUtils method exists.
/**
* Checks is file, folder or project exist.
* @param file
* @return true if a resource exist
*/
public static boolean exists(IFile f) {
if (!(f instanceof File)) {
return false;
}
File file = (File) f;
ResourceInfo info = file.getResourceInfo(false, false);
int flags = file.getFlags(info);
if (flags != ICoreConstants.NULL_FLAG) {
int type = ResourceInfo.getType(flags);
if (type == IResource.FILE || type == IResource.FOLDER || type == IResource.PROJECT) {
return true;
}
}
return false;
}
Aggregations