Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2002-02-15 15:07:54 -0500
committerMichael Valenta2002-02-15 15:07:54 -0500
commit36d479f1ebc5c739b729a2af898b97aa84f225ab (patch)
tree6b6ba23f2026348393226ffa41f9bf099739a694
parent2a7a05f5aa8032781758fd77a33e53b3bc13e01d (diff)
downloadeclipse.platform.team-36d479f1ebc5c739b729a2af898b97aa84f225ab.tar.gz
eclipse.platform.team-36d479f1ebc5c739b729a2af898b97aa84f225ab.tar.xz
eclipse.platform.team-36d479f1ebc5c739b729a2af898b97aa84f225ab.zip
8314: Accidental copying of CVS/ folders is problematic
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProviderPlugin.java2
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/OrphanedFolderListener.java69
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ResourceDeltaVisitor.java14
3 files changed, 82 insertions, 3 deletions
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProviderPlugin.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProviderPlugin.java
index 794c680b0..fd30e7288 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProviderPlugin.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProviderPlugin.java
@@ -26,6 +26,7 @@ import org.eclipse.team.internal.ccvs.core.client.Command.QuietOption;
import org.eclipse.team.internal.ccvs.core.resources.ICVSSynchronizer;
import org.eclipse.team.internal.ccvs.core.syncinfo.*;
import org.eclipse.team.internal.ccvs.core.syncinfo.FileSystemSynchronizer;
+import org.eclipse.team.internal.ccvs.core.util.OrphanedFolderListener;
import org.eclipse.team.internal.ccvs.core.util.ProjectDescriptionManager;
import org.eclipse.team.internal.ccvs.core.util.Util;
@@ -156,6 +157,7 @@ public class CVSProviderPlugin extends Plugin {
CVSProvider.startup();
ProjectDescriptionManager.initializeChangeListener();
+ new OrphanedFolderListener().register();
}
/**
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/OrphanedFolderListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/OrphanedFolderListener.java
new file mode 100644
index 000000000..0675ae320
--- /dev/null
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/OrphanedFolderListener.java
@@ -0,0 +1,69 @@
+package org.eclipse.team.internal.ccvs.core.util;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceChangeEvent;
+import org.eclipse.team.ccvs.core.CVSProviderPlugin;
+import org.eclipse.team.internal.ccvs.core.CVSException;
+import org.eclipse.team.internal.ccvs.core.Policy;
+import org.eclipse.team.internal.ccvs.core.client.Session;
+import org.eclipse.team.internal.ccvs.core.resources.ICVSFolder;
+
+/**
+ * Listen for the addition of orphaned subtrees as a result of a copy or move.
+ *
+ * Listen in IResourceChangeEvent.PRE_AUTO_BUILD so that other interested parties
+ * (most notably, the file synchronizer) will receive up to date notifications
+ */
+public class OrphanedFolderListener extends ResourceDeltaVisitor {
+
+ private void handleOrphanedSubtree(IResource resource) {
+ if (resource.getType() == IResource.FOLDER) {
+ try {
+ ICVSFolder mFolder = (ICVSFolder)Session.getManagedResource(resource);
+ if (mFolder.isCVSFolder() && ! mFolder.isManaged() && mFolder.getParent().isCVSFolder()) {
+ mFolder.unmanage();
+ CVSProviderPlugin.getSynchronizer().reload(resource.getLocation().toFile(), Policy.monitorFor(null));
+ }
+ } catch (CVSException e) {
+ CVSProviderPlugin.log(e);
+ }
+ }
+ }
+
+ /*
+ * @see ResourceDeltaVisitor#handleAdded(IResource[])
+ */
+ protected void handleAdded(IResource[] resources) {
+ for (int i = 0; i < resources.length; i++) {
+ handleOrphanedSubtree(resources[i]);
+ }
+ }
+
+ /*
+ * @see ResourceDeltaVisitor#handleRemoved(IResource[])
+ */
+ protected void handleRemoved(IResource[] resources) {
+ }
+
+ /*
+ * @see ResourceDeltaVisitor#handleChanged(IResource[])
+ */
+ protected void handleChanged(IResource[] resources) {
+ }
+
+ /*
+ * @see ResourceDeltaVisitor#finished()
+ */
+ protected void finished() {
+ }
+
+ protected int getEventMask() {
+ return IResourceChangeEvent.PRE_AUTO_BUILD;
+ }
+
+}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ResourceDeltaVisitor.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ResourceDeltaVisitor.java
index ebc00b40e..f400af600 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ResourceDeltaVisitor.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ResourceDeltaVisitor.java
@@ -27,8 +27,8 @@ import org.eclipse.team.internal.ccvs.core.Policy;
public abstract class ResourceDeltaVisitor implements IResourceDeltaVisitor {
- private static IResourceChangeListener listener;
- private static ResourceDeltaVisitor visitor;
+ private IResourceChangeListener listener;
+ private ResourceDeltaVisitor visitor;
private Map removals;
private Map additions;
@@ -65,7 +65,7 @@ public abstract class ResourceDeltaVisitor implements IResourceDeltaVisitor {
}
}
};
- ResourcesPlugin.getWorkspace().addResourceChangeListener(listener, IResourceChangeEvent.POST_CHANGE);
+ ResourcesPlugin.getWorkspace().addResourceChangeListener(listener, getEventMask());
return visitor;
}
@@ -223,5 +223,13 @@ public abstract class ResourceDeltaVisitor implements IResourceDeltaVisitor {
protected abstract void handleChanged(IResource[] resources);
protected abstract void finished();
+
+ /**
+ * Return the event mask for determining when to receive delta notifications.
+ * Subclasses can override this method to change from the default of IResourceChangeEvent.POST_CHANGE
+ */
+ protected int getEventMask() {
+ return IResourceChangeEvent.POST_CHANGE;
+ }
}

Back to the top