Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2005-11-19 02:53:46 +0000
committerMichael Valenta2005-11-19 02:53:46 +0000
commit4cfdb274f9c56a16b6514cad26b4bd0fc2b09984 (patch)
tree6b721c7ecc127538acfe74f0fb6340fa3543a84c
parent7c94124e5eeec9b23d63979c13adc2940c3f7ffa (diff)
downloadeclipse.platform.team-4cfdb274f9c56a16b6514cad26b4bd0fc2b09984.tar.gz
eclipse.platform.team-4cfdb274f9c56a16b6514cad26b4bd0fc2b09984.tar.xz
eclipse.platform.team-4cfdb274f9c56a16b6514cad26b4bd0fc2b09984.zip
Working out the bugs in the EMF example
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/AbstractTeamAwareContentProvider.java27
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/IDisposeListener.java4
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/SynchronizationCache.java8
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/operations/SynchronizationContext.java2
4 files changed, 20 insertions, 21 deletions
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/AbstractTeamAwareContentProvider.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/AbstractTeamAwareContentProvider.java
index 01666644a..af3ae024f 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/AbstractTeamAwareContentProvider.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/AbstractTeamAwareContentProvider.java
@@ -13,8 +13,6 @@ package org.eclipse.team.internal.ui.mapping;
import org.eclipse.core.resources.mapping.ModelProvider;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.viewers.*;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.Viewer;
import org.eclipse.team.core.ITeamStatus;
import org.eclipse.team.core.synchronize.*;
import org.eclipse.team.internal.ui.Utils;
@@ -80,8 +78,7 @@ public abstract class AbstractTeamAwareContentProvider implements ICommonContent
* @see org.eclipse.jface.viewers.IContentProvider#dispose()
*/
public void dispose() {
- if (context != null)
- context.getSyncInfoTree().removeSyncSetChangedListener(this);
+ // Nothing to do
}
/* (non-Javadoc)
@@ -98,8 +95,6 @@ public abstract class AbstractTeamAwareContentProvider implements ICommonContent
public void init(IExtensionStateModel aStateModel, IMemento aMemento) {
scope = (IResourceMappingScope)aStateModel.getProperty(TeamUI.RESOURCE_MAPPING_SCOPE);
context = (ISynchronizationContext)aStateModel.getProperty(TeamUI.SYNCHRONIZATION_CONTEXT);
- if (context != null)
- context.getSyncInfoTree().addSyncSetChangedListener(this);
ITreeContentProvider provider = getDelegateContentProvider();
if (provider instanceof ICommonContentProvider) {
((ICommonContentProvider) provider).init(aStateModel, aMemento);
@@ -138,17 +133,16 @@ public abstract class AbstractTeamAwareContentProvider implements ICommonContent
* @see org.eclipse.team.core.synchronize.ISyncInfoSetChangeListener#syncInfoSetReset(org.eclipse.team.core.synchronize.SyncInfoSet, org.eclipse.core.runtime.IProgressMonitor)
*/
public void syncInfoSetReset(SyncInfoSet set, IProgressMonitor monitor) {
- // TODO Should refresh the whole view but this is the wrong place
- // as it would happen once per model.
-
+ // Nothing can be done at this level (i.e. content provider).
+ // The controller at the viewer level needs to handle this.
}
/* (non-Javadoc)
* @see org.eclipse.team.core.synchronize.ISyncInfoSetChangeListener#syncInfoSetErrors(org.eclipse.team.core.synchronize.SyncInfoSet, org.eclipse.team.core.ITeamStatus[], org.eclipse.core.runtime.IProgressMonitor)
*/
public void syncInfoSetErrors(SyncInfoSet set, ITeamStatus[] errors, IProgressMonitor monitor) {
- // TODO Need to have some way to indicate that an error occurred
-
+ // This should happen infrequently enough that a blanket refresh is acceptable
+ refresh();
}
/* (non-Javadoc)
@@ -163,18 +157,19 @@ public abstract class AbstractTeamAwareContentProvider implements ICommonContent
/**
* The set of out-of-sync resources has changed. The changes are described in the event.
- * This method is invoked by a non-ui thread.
+ * This method is invoked by a non-ui thread. By default, this method refreshs the
+ * subtree of this content provider. Subclasses may override.
*
* TODO: Should reduce the resources to those that apply to this model.
*
* @param event the event that indicates which resources have change sync state
* @param monitor a progress monitor
*/
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ui.mapping.AbstractTeamAwareContentProvider#syncStateChanged(org.eclipse.team.core.synchronize.ISyncInfoTreeChangeEvent, org.eclipse.core.runtime.IProgressMonitor)
- */
protected void syncStateChanged(ISyncInfoTreeChangeEvent event, IProgressMonitor monitor) {
- // TODO: for the time being, just refresh everything under the model provider
+ refresh();
+ }
+
+ protected void refresh() {
Utils.syncExec(new Runnable() {
public void run() {
((TreeViewer)getViewer()).refresh(getModelProvider());
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/IDisposeListener.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/IDisposeListener.java
index 9b8e3fd68..604b09ab0 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/IDisposeListener.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/IDisposeListener.java
@@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.team.internal.ui.mapping;
+import org.eclipse.team.ui.mapping.ISynchronizationContext;
+
/**
* Listener that, when registered with a synchronization context, gets invoked
* when the context is disposed.
@@ -28,5 +30,5 @@ public interface IDisposeListener {
/**
* The given context has been disposed.
*/
- void contextDisposed(ISynchronizationCache context);
+ void contextDisposed(ISynchronizationContext context);
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/SynchronizationCache.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/SynchronizationCache.java
index 3e9dbc40f..2f43738fc 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/SynchronizationCache.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/SynchronizationCache.java
@@ -16,6 +16,7 @@ import java.util.Map;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.util.ListenerList;
import org.eclipse.jface.util.SafeRunnable;
+import org.eclipse.team.ui.mapping.ISynchronizationContext;
/**
* A synchronize operation context that supports caching of
@@ -36,12 +37,13 @@ public class SynchronizationCache implements ISynchronizationCache {
Map properties;
ListenerList listeners;
+ private final ISynchronizationContext context;
/**
* CCreate an empty cache
*/
- public SynchronizationCache() {
- // nothing to do
+ public SynchronizationCache(ISynchronizationContext context) {
+ this.context = context;
}
/* (non-Javadoc)
@@ -100,7 +102,7 @@ public class SynchronizationCache implements ISynchronizationCache {
final Object listener = allListeners[i];
Platform.run(new SafeRunnable(){
public void run() throws Exception {
- ((IDisposeListener)listener).contextDisposed(SynchronizationCache.this);
+ ((IDisposeListener)listener).contextDisposed(context);
}
});
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/operations/SynchronizationContext.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/operations/SynchronizationContext.java
index 26b54cdad..b1fbd0b98 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/operations/SynchronizationContext.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/operations/SynchronizationContext.java
@@ -85,7 +85,7 @@ public abstract class SynchronizationContext implements ISynchronizationContext
*/
public synchronized ISynchronizationCache getCache() {
if (cache == null) {
- cache = new SynchronizationCache();
+ cache = new SynchronizationCache(this);
}
return cache;
}

Back to the top