Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2003-01-13 11:23:05 -0500
committerMichael Valenta2003-01-13 11:23:05 -0500
commit5d8828205c26ed6e0ff8c2d5b3c204c536865819 (patch)
treec8c2bc4d0f0606389f020eee07e30723c6e74a02
parent6770e8244993f194e726c9b06c24adaa32b945ba (diff)
downloadeclipse.platform.team-TeamEarlyWarning_Branch.tar.gz
eclipse.platform.team-TeamEarlyWarning_Branch.tar.xz
eclipse.platform.team-TeamEarlyWarning_Branch.zip
Branched in case we can use thisTeamEarlyWarning_Branch
-rw-r--r--bundles/org.eclipse.team.core/plugin.xml3
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/core/RepositoryProvider.java9
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/core/Team.java138
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/TeamPlugin.java2
-rw-r--r--bundles/org.eclipse.team.cvs.core/plugin.xml8
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProviderPlugin.java14
6 files changed, 133 insertions, 41 deletions
diff --git a/bundles/org.eclipse.team.core/plugin.xml b/bundles/org.eclipse.team.core/plugin.xml
index b0d43c0bd..336e28eb9 100644
--- a/bundles/org.eclipse.team.core/plugin.xml
+++ b/bundles/org.eclipse.team.core/plugin.xml
@@ -24,6 +24,9 @@
<extension-point id="repository" name="%Repository"/>
<extension-point id="targets" name="%Targets"/>
+<!-- PROVISIONAL: required for ensuring that team-private members can be hidden -->
+<extension-point id="earlyWarning" name="%EarlyWarning"/>
+
<!-- Define common known file types -->
<extension point="org.eclipse.team.core.fileTypes">
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/RepositoryProvider.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/RepositoryProvider.java
index ef041c850..72b16abea 100644
--- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/RepositoryProvider.java
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/RepositoryProvider.java
@@ -570,4 +570,13 @@ public abstract class RepositoryProvider implements IProjectNature {
public boolean canHandleLinkedResources() {
return false;
}
+
+ /**
+ * Method getProviderId.
+ * @param project
+ * @return String
+ */
+ public static String getProviderId(IProject project) throws CoreException {
+ return project.getPersistentProperty(PROVIDER_PROP_KEY);
+ }
}
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/Team.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/Team.java
index 6846a0622..a3a2a4363 100644
--- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/Team.java
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/Team.java
@@ -22,10 +22,12 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
@@ -74,7 +76,88 @@ public final class Team {
private static Hashtable table;
// The ignore list that is read at startup from the persisted file
- private static Map globalIgnore = new HashMap(11);
+ private static Map globalIgnore;
+
+ // The table of repository provider's early warning delta listeners
+ private static final Map earlyWarningListeners = new HashMap();
+
+ private static final Object NULL_EARLY_WARNING_LISTENER = new Object();
+ private static IResourceChangeListener getEarlyWarningListener(String id) {
+ if (id == null) return null;
+ Object listener = earlyWarningListeners.get(id);
+ // return null if it is known that there is no listener
+ if (listener == NULL_EARLY_WARNING_LISTENER)
+ return null;
+ // if there is a listener, return it
+ if (listener != null)
+ return (IResourceChangeListener)listener;
+ // load the listener from the extension point
+ TeamPlugin plugin = TeamPlugin.getPlugin();
+ if (plugin != null) {
+ IExtensionPoint extension = plugin.getDescriptor().getExtensionPoint(TeamPlugin.EARLY_WARNING_EXTENSION);
+ if (extension != null) {
+ IExtension[] extensions = extension.getExtensions();
+ for (int i = 0; i < extensions.length; i++) {
+ IConfigurationElement [] configElements = extensions[i].getConfigurationElements();
+ for (int j = 0; j < configElements.length; j++) {
+ String extensionId = configElements[j].getAttribute("id"); //$NON-NLS-1$
+ if (extensionId != null && extensionId.equals(id)) {
+ try {
+ IResourceChangeListener newListener = (IResourceChangeListener) configElements[j].createExecutableExtension("class"); //$NON-NLS-1$
+ earlyWarningListeners.put(id, newListener);
+ return newListener;
+ } catch (CoreException e) {
+ TeamPlugin.log(e.getStatus());
+ return null;
+ }
+ }
+ }
+ }
+ }
+ }
+ // there is no extension defined for the given id
+ earlyWarningListeners.put(id, NULL_EARLY_WARNING_LISTENER);
+ return null;
+ }
+
+ private static final class EarlyWarningListener implements IResourceChangeListener {
+ public void resourceChanged(IResourceChangeEvent event) {
+ IResourceDelta[] projectDeltas = event.getDelta().getAffectedChildren();
+ Set earlyWarningSet = new HashSet();
+ for (int i = 0; i < projectDeltas.length; i++) {
+ IResourceDelta delta = projectDeltas[i];
+ IResource resource = delta.getResource();
+ // Only consider open projects
+ IProject project = resource.getProject();
+ if (!project.isAccessible()) continue;
+
+ // Call the early warning delta for projects that have a provider
+ // (making sure not to only load the delta listener)
+ try {
+ String id = RepositoryProvider.getProviderId(project);
+ IResourceChangeListener listener = getEarlyWarningListener(id);
+ if (listener != null) earlyWarningSet.add(listener);
+ } catch (CoreException e) {
+ TeamPlugin.log(e.getStatus());
+ }
+
+ // For project additions that are moves, make sure the provider is adjusted properly
+ if (delta.getKind() == IResourceDelta.ADDED && (delta.getFlags() & IResourceDelta.MOVED_FROM) != 0) {
+ // Only consider projects that have a provider
+ RepositoryProvider provider = RepositoryProvider.getProvider(project);
+ if (provider == null) continue;
+ // Only consider providers whose project is not mapped properly already
+ if (provider.getProject().equals(resource.getProject())) continue;
+ // Tell the provider about it's new project
+ provider.setProject(resource.getProject());
+ }
+ }
+ for (Iterator iter = earlyWarningSet.iterator(); iter.hasNext();) {
+ IResourceChangeListener listener = (IResourceChangeListener) iter.next();
+ listener.resourceChanged(event);
+ }
+ }
+ }
private static class FileTypeInfo implements IFileTypeInfo {
private String extension;
@@ -122,6 +205,7 @@ public final class Team {
public static int getType(IStorage storage) {
String extension = getFileExtension(storage.getName());
if (extension == null) return UNKNOWN;
+ Hashtable table = getFileTypeTable();
Integer integer = (Integer)table.get(extension);
if (integer == null) return UNKNOWN;
return integer.intValue();
@@ -174,6 +258,7 @@ public final class Team {
*/
public static IFileTypeInfo[] getAllTypes() {
List result = new ArrayList();
+ Hashtable table = getFileTypeTable();
Enumeration e = table.keys();
while (e.hasMoreElements()) {
String string = (String)e.nextElement();
@@ -187,6 +272,16 @@ public final class Team {
* Returns the list of global ignores.
*/
public static IIgnoreInfo[] getAllIgnores() {
+ if (globalIgnore == null) {
+ try {
+ readIgnoreState();
+ } catch (TeamException e) {
+ if (globalIgnore == null)
+ globalIgnore = new HashMap();
+ TeamPlugin.log(IStatus.ERROR, "Error loading ignore state from disk", e);
+ }
+ initializePluginIgnores();
+ }
IIgnoreInfo[] result = new IIgnoreInfo[globalIgnore.size()];
Iterator e = globalIgnore.keySet().iterator();
int i = 0;
@@ -207,6 +302,11 @@ public final class Team {
return result;
}
+ private static Hashtable getFileTypeTable() {
+ if (table == null) loadTextState();
+ return table;
+ }
+
/**
* Set the file type for the give extension to the given type.
*
@@ -321,7 +421,6 @@ public final class Team {
* @throws IOException if an I/O problem occurs
*/
private static void readTextState(DataInputStream dis) throws IOException {
- table = new Hashtable(11);
int extensionCount = 0;
try {
extensionCount = dis.readInt();
@@ -346,6 +445,7 @@ public final class Team {
* @throws IOException if an I/O problem occurs
*/
private static void writeTextState(DataOutputStream dos) throws IOException {
+ Hashtable table = getFileTypeTable();
dos.writeInt(table.size());
Iterator it = table.keySet().iterator();
while (it.hasNext()) {
@@ -363,6 +463,7 @@ public final class Team {
* contents, as well as discovering any values contributed by plug-ins.
*/
private static void loadTextState() {
+ table = new Hashtable(11);
IPath pluginStateLocation = TeamPlugin.getPlugin().getStateLocation().append(STATE_FILE);
File f = pluginStateLocation.toFile();
if (f.exists()) {
@@ -473,6 +574,7 @@ public final class Team {
*/
private static void writeIgnoreState(DataOutputStream dos) throws IOException {
// write the global ignore list
+ if (globalIgnore == null) getAllIgnores();
int ignoreLength = globalIgnore.size();
dos.writeInt(ignoreLength);
Iterator e = globalIgnore.keySet().iterator();
@@ -528,34 +630,10 @@ public final class Team {
* This method is called by the plug-in upon startup, clients should not call this method
*/
public static void startup() throws CoreException {
- try {
- table = new Hashtable(11);
- loadTextState();
- readIgnoreState();
- initializePluginIgnores();
- // Register a delta listener that will tell the provider about a project move
- ResourcesPlugin.getWorkspace().addResourceChangeListener(new IResourceChangeListener() {
- public void resourceChanged(IResourceChangeEvent event) {
- IResourceDelta[] projectDeltas = event.getDelta().getAffectedChildren();
- for (int i = 0; i < projectDeltas.length; i++) {
- IResourceDelta delta = projectDeltas[i];
- IResource resource = delta.getResource();
- RepositoryProvider provider = RepositoryProvider.getProvider(resource.getProject());
- // Only consider projects that have a provider
- if (provider == null) continue;
- // Only consider project additions that are moves
- if (delta.getKind() != IResourceDelta.ADDED) continue;
- if ((delta.getFlags() & IResourceDelta.MOVED_FROM) == 0) continue;
- // Only consider providers whose project is not mapped properly already
- if (provider.getProject().equals(resource.getProject())) continue;
- // Tell the provider about it's new project
- provider.setProject(resource.getProject());
- }
- }
- }, IResourceChangeEvent.PRE_AUTO_BUILD);
- } catch (TeamException e) {
- throw new CoreException(e.getStatus());
- }
+ // Register a delta listener that will tell the provider about a project move
+ // and make sure any repository providers that have requested it, get early warning
+ // about deltas to their projects
+ ResourcesPlugin.getWorkspace().addResourceChangeListener(new EarlyWarningListener(), IResourceChangeEvent.PRE_AUTO_BUILD);
}
/**
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/TeamPlugin.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/TeamPlugin.java
index fbf342a8e..f23e08564 100644
--- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/TeamPlugin.java
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/TeamPlugin.java
@@ -48,6 +48,8 @@ final public class TeamPlugin extends Plugin {
public static final String REPOSITORY_EXTENSION = "repository"; //$NON-NLS-1$
// The id of the targets extension point
public static final String TARGETS_EXTENSION = "targets"; //$NON-NLS-1$
+ // The id of the earlyWarning extension point
+ public static final String EARLY_WARNING_EXTENSION = "earlyWarning"; //$NON-NLS-1$
// The one and only plug-in instance
diff --git a/bundles/org.eclipse.team.cvs.core/plugin.xml b/bundles/org.eclipse.team.cvs.core/plugin.xml
index 6e467d853..e0e2cdc4b 100644
--- a/bundles/org.eclipse.team.cvs.core/plugin.xml
+++ b/bundles/org.eclipse.team.cvs.core/plugin.xml
@@ -49,6 +49,14 @@
id="org.eclipse.team.cvs.core.cvsnature">
</repository>
</extension>
+
+ <extension
+ point="org.eclipse.team.core.earlyWarning">
+ <repository
+ class="org.eclipse.team.internal.ccvs.core.util.SyncFileChangeListener"
+ id="org.eclipse.team.cvs.core.cvsnature">
+ </repository>
+ </extension>
<!-- *************** Resource patterns ignored by CVS **************** -->
<extension point="org.eclipse.team.core.ignore">
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 1cdb98246..87fe2e0a0 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
@@ -53,7 +53,6 @@ import org.eclipse.team.internal.ccvs.core.resources.FileModificationManager;
import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
import org.eclipse.team.internal.ccvs.core.util.AddDeleteMoveListener;
import org.eclipse.team.internal.ccvs.core.util.ProjectDescriptionManager;
-import org.eclipse.team.internal.ccvs.core.util.SyncFileChangeListener;
import org.eclipse.team.internal.ccvs.core.util.Util;
public class CVSProviderPlugin extends Plugin {
@@ -108,7 +107,6 @@ public class CVSProviderPlugin extends Plugin {
// CVS specific resource delta listeners
private IResourceChangeListener projectDescriptionListener;
- private IResourceChangeListener metaFileSyncListener;
private AddDeleteMoveListener addDeleteMoveListener;
private FileModificationManager fileModificationManager;
@@ -272,16 +270,10 @@ public class CVSProviderPlugin extends Plugin {
// Initialize CVS change listeners. Note tha the report type is important.
IWorkspace workspace = ResourcesPlugin.getWorkspace();
projectDescriptionListener = new ProjectDescriptionManager();
- metaFileSyncListener = new SyncFileChangeListener();
addDeleteMoveListener = new AddDeleteMoveListener();
fileModificationManager = new FileModificationManager();
- // Group the two PRE_AUTO_BUILD listeners together for efficiency
- workspace.addResourceChangeListener(new IResourceChangeListener() {
- public void resourceChanged(IResourceChangeEvent event) {
- projectDescriptionListener.resourceChanged(event);
- metaFileSyncListener.resourceChanged(event);
- }
- }, IResourceChangeEvent.PRE_AUTO_BUILD);
+ // The SyncFileChangeListener is registered with Team through the earlyWarning extension point
+ workspace.addResourceChangeListener(projectDescriptionListener, IResourceChangeEvent.PRE_AUTO_BUILD);
workspace.addResourceChangeListener(addDeleteMoveListener, IResourceChangeEvent.POST_AUTO_BUILD);
workspace.addResourceChangeListener(fileModificationManager, IResourceChangeEvent.POST_CHANGE);
fileModificationManager.registerSaveParticipant();
@@ -303,7 +295,7 @@ public class CVSProviderPlugin extends Plugin {
// remove listeners
IWorkspace workspace = ResourcesPlugin.getWorkspace();
workspace.removeResourceChangeListener(projectDescriptionListener);
- workspace.removeResourceChangeListener(metaFileSyncListener);
+ workspace.removeResourceChangeListener(fileModificationManager);
workspace.removeResourceChangeListener(addDeleteMoveListener);
deleteCacheDirectory();

Back to the top