本文整理匯總了Java中org.eclipse.core.resources.IResourceDelta.MOVED_FROM屬性的典型用法代碼示例。如果您正苦於以下問題:Java IResourceDelta.MOVED_FROM屬性的具體用法?Java IResourceDelta.MOVED_FROM怎麽用?Java IResourceDelta.MOVED_FROM使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類org.eclipse.core.resources.IResourceDelta
的用法示例。
在下文中一共展示了IResourceDelta.MOVED_FROM屬性的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: handleAddedResource
/**
* Adds patch file to admin folder.
*
* @param res
* changed resource
* @param delta
* resource delta
* @param flag
*/
private void handleAddedResource(IResource res, IResourceDelta delta,
int flag) {
if ((flag & IResourceDelta.MARKERS) == 0
|| (flag & IResourceDelta.MOVED_FROM) != 0) {
try {
persistanceOperations.addAdminResource(res);
} catch (FileOperationException e) {
LogOperations.logError(
"Change file could not be created in admin folder.", e);
}
VariantSyncPlugin.getDefault().logMessage(
RESOURCE + res.getFullPath() + " was added "
+ getFlagTxt(flag));
update();
}
}
示例2: visit
@Override
public boolean visit(IResourceDelta delta) {
if (delta == null) {
return false;
}
if (0 != (delta.getFlags() & IResourceDelta.OPEN) && 0 == (delta.getFlags() & IResourceDelta.MOVED_FROM)) {
handleProjectResourceOpenStateChange(delta.getResource());
return false;
}
return true;
}
示例3: processAddedDelta
/**
* Process {@link IResourceDelta} with {@link IResourceDelta#ADDED added} {@link IResourceDelta#getKind()
* kind}.
*
* @param delta
* the {@link IResourceDelta} with {@link IResourceDelta#ADDED added}
* {@link IResourceDelta#getKind() kind}
* @param movedResources
* mapping of moved {@link IResource}
* @param base
* the current {@link IBase}
*/
private void processAddedDelta(IResourceDelta delta, HashMap<IPath, IResource> movedResources,
IBase base) {
if ((delta.getFlags() & IResourceDelta.MOVED_FROM) != 0) {
final IResource source = movedResources.get(delta.getMovedFromPath());
if (source != null) {
moveResource(base, source, delta.getResource());
} else {
movedResources.put(delta.getResource().getFullPath(), delta.getResource());
}
} else {
updateLocation(base, delta.getResource());
}
}
示例4: processAddedDelta
/**
* Process {@link IResourceDelta} with {@link IResourceDelta#ADDED added} {@link IResourceDelta#getKind()
* kind}.
*
* @param delta
* the {@link IResourceDelta} with {@link IResourceDelta#ADDED added}
* {@link IResourceDelta#getKind() kind}
* @param movedResources
* mapping of moved {@link IResource}
*/
private void processAddedDelta(IResourceDelta delta, HashMap<IPath, IResource> movedResources) {
if ((delta.getFlags() & IResourceDelta.MOVED_FROM) != 0) {
final IResource source = movedResources.get(delta.getMovedFromPath());
if (source != null) {
resourceMoved((IFile)source, (IFile)delta.getResource());
} else {
movedResources.put(delta.getResource().getFullPath(), delta.getResource());
}
} else {
register((IFile)delta.getResource());
}
}
示例5: assertTrue
private static boolean assertTrue(IResourceDelta expected, IResourceDelta actual) {
assertEqual(expected.getResource(), actual.getResource());
int actualKind = actual.getKind();
int actualFlags = actual.getFlags();
// The real delta can't combine kinds so we remove it from the received one as well.
if ((actualKind & (IResourceDelta.ADDED | IResourceDelta.REMOVED)) != 0) {
actualKind = actualKind & ~IResourceDelta.CHANGED;
}
// The expected delta doesn't support copy from flag. So remove it
actualFlags = actualFlags & ~IResourceDelta.COPIED_FROM;
int expectKind = expected.getKind();
int expectedFlags = expected.getFlags() & PRE_DELTA_FLAGS;
if ((expectKind & IResourceDelta.ADDED) != 0
&& (expectedFlags & IResourceDelta.MOVED_FROM) != 0) {
expectedFlags = expectedFlags & ~IResourceDelta.OPEN;
}
if (expectKind != actualKind || expectedFlags != actualFlags) {
return false;
}
IResourceDelta[] expectedChildren = getExpectedChildren(expected);
IResourceDelta[] actualChildren = getActualChildren(actual, expectedChildren);
if (expectedChildren.length != actualChildren.length) {
return false;
}
Arrays.sort(expectedChildren, COMPARATOR);
Arrays.sort(actualChildren, COMPARATOR);
for (int i = 0; i < expectedChildren.length; i++) {
boolean res = assertTrue(expectedChildren[i], actualChildren[i]);
if (!res) {
Assert.assertEquals(printDelta(expected), printDelta(actual));
}
}
return true;
}
示例6: change
public void change(IFile file) {
ProposedResourceDelta delta = getDelta(file);
if (delta.getKind() == 0) delta.setKind(IResourceDelta.CHANGED);
// the CONTENT flag only applies to the changed and moved from cases
if (delta.getKind() == IResourceDelta.CHANGED
|| (delta.getFlags() & IResourceDelta.MOVED_FROM) != 0
|| (delta.getFlags() & IResourceDelta.COPIED_FROM) != 0)
delta.addFlags(IResourceDelta.CONTENT);
}
示例7: handleAdded
private void handleAdded(IResourceDelta delta) {
if ((delta.getFlags() & IResourceDelta.MOVED_FROM) != 0) {
handleMove(delta);
} else if ((delta.getFlags() & IResourceDelta.COPIED_FROM) != 0) {
handleCopy(delta);
} else {
ensureResourceCovered(delta.getResource(), addedRoots);
}
}
示例8: handleMove
private void handleMove(IResourceDelta delta) {
if ((delta.getFlags() & IResourceDelta.MOVED_TO) != 0) {
movedRoots.add(delta.getResource());
} else if ((delta.getFlags() & IResourceDelta.MOVED_FROM) != 0) {
IResource source = createSourceResource(delta);
ensureResourceCovered(source, movedRoots);
}
}
示例9: getFlagTxt
/**
* Adds debug messages.
*
* @param flag
* @return debug message
*/
private String getFlagTxt(int flag) {
String flags = "F_";
if ((flag & IResourceDelta.ADDED) != 0) {
flags += "ADDED ";
}
if ((flag & IResourceDelta.ADDED_PHANTOM) != 0) {
flags += "ADDED_PHANTOM ";
}
if ((flag & IResourceDelta.ALL_WITH_PHANTOMS) != 0) {
flags += "ALL_WITH_PHANTOMS ";
}
if ((flag & IResourceDelta.CHANGED) != 0) {
flags += "CHANGED ";
}
if ((flag & IResourceDelta.CONTENT) != 0) {
flags += "CONTENT ";
}
if ((flag & IResourceDelta.COPIED_FROM) != 0) {
flags += "COPIED_FROM ";
}
if ((flag & IResourceDelta.DERIVED_CHANGED) != 0) {
flags += "DERIVED_CHANGED ";
}
if ((flag & IResourceDelta.DESCRIPTION) != 0) {
flags += "DESCRIPTION ";
}
if ((flag & IResourceDelta.ENCODING) != 0) {
flags += "ENCODING ";
}
if ((flag & IResourceDelta.LOCAL_CHANGED) != 0) {
flags += "LOCAL_CHANGED ";
}
if ((flag & IResourceDelta.MARKERS) != 0) {
flags += "MARKERS ";
}
if ((flag & IResourceDelta.MOVED_FROM) != 0) {
flags += "MOVED_FROM ";
}
if ((flag & IResourceDelta.MOVED_TO) != 0) {
flags += "MOVED_TO ";
}
if ((flag & IResourceDelta.NO_CHANGE) != 0) {
flags += "NO_CHANGE ";
}
if ((flag & IResourceDelta.OPEN) != 0) {
flags += "OPEN ";
}
if ((flag & IResourceDelta.REMOVED) != 0) {
flags += "REMOVED ";
}
if ((flag & IResourceDelta.REMOVED_PHANTOM) != 0) {
flags += "REMOVED_PHANTOM ";
}
if ((flag & IResourceDelta.REPLACED) != 0) {
flags += "REPLACED ";
}
if ((flag & IResourceDelta.SYNC) != 0) {
flags += "SYNC ";
}
if ((flag & IResourceDelta.TYPE) != 0) {
flags += "TYPE ";
}
return flags;
}
示例10: moveOrCopy
/**
* Builds the delta representing a single resource being moved or copied.
*
* @param resource The resource being moved
* @param sourcePrefix The root of the sub-tree being moved
* @param destinationPrefix The root of the destination sub-tree
* @param move <code>true</code> for a move, <code>false</code> for a copy
* @return Whether to move or copy the child
*/
boolean moveOrCopy(
IResource resource,
final IPath sourcePrefix,
final IPath destinationPrefix,
final boolean move) {
ProposedResourceDelta sourceDelta = getDelta(resource);
if (sourceDelta.getKind() == IResourceDelta.REMOVED) {
// There is already a removed delta here so there
// is nothing to move/copy
return false;
}
IResource destinationResource =
getDestinationResource(resource, sourcePrefix, destinationPrefix);
ProposedResourceDelta destinationDelta = getDelta(destinationResource);
if ((destinationDelta.getKind() & (IResourceDelta.ADDED | IResourceDelta.CHANGED)) > 0) {
// There is already a resource at the destination
// TODO: What do we do
return false;
}
// First, create the delta for the source
IPath fromPath = resource.getFullPath();
boolean wasAdded = false;
final int sourceFlags = sourceDelta.getFlags();
if (move) {
// We transfer the source flags to the destination
if (sourceDelta.getKind() == IResourceDelta.ADDED) {
if ((sourceFlags & IResourceDelta.MOVED_FROM) != 0) {
// The resource was moved from somewhere else so
// we need to transfer the path to the new location
fromPath = sourceDelta.getMovedFromPath();
sourceDelta.setMovedFromPath(null);
}
// The source was added and then moved so we'll
// make it an add at the destination
sourceDelta.setKind(0);
wasAdded = true;
} else {
// We reset the status to be a remove/move_to
sourceDelta.setKind(IResourceDelta.REMOVED);
sourceDelta.setFlags(IResourceDelta.MOVED_TO);
sourceDelta.setMovedToPath(
destinationPrefix.append(fromPath.removeFirstSegments(sourcePrefix.segmentCount())));
}
}
// Next, create the delta for the destination
if (destinationDelta.getKind() == IResourceDelta.REMOVED) {
// The destination was removed and is being re-added
destinationDelta.setKind(IResourceDelta.CHANGED);
destinationDelta.addFlags(IResourceDelta.REPLACED);
} else {
destinationDelta.setKind(IResourceDelta.ADDED);
}
if (!wasAdded || !fromPath.equals(resource.getFullPath())) {
// The source wasn't added so it is a move/copy
destinationDelta.addFlags(move ? IResourceDelta.MOVED_FROM : IResourceDelta.COPIED_FROM);
destinationDelta.setMovedFromPath(fromPath);
// Apply the source flags
if (move) destinationDelta.addFlags(sourceFlags);
}
return true;
}