Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2004-01-26 16:04:57 -0500
committerMichael Valenta2004-01-26 16:04:57 -0500
commit89ef0a4de08ab6322fc04c7b5b3f050401fbf1be (patch)
treeb2543d3cfbd53e8d02161fe6964cdbf26c0286fa
parent789b38a85b397ddd1d99a7f5b1aa6abbeb8ef19d (diff)
downloadeclipse.platform.team-89ef0a4de08ab6322fc04c7b5b3f050401fbf1be.tar.gz
eclipse.platform.team-89ef0a4de08ab6322fc04c7b5b3f050401fbf1be.tar.xz
eclipse.platform.team-89ef0a4de08ab6322fc04c7b5b3f050401fbf1be.zip
*** empty log message ***
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/ChangeLogContentProvider.java4
-rw-r--r--bundles/org.eclipse.team.ui/org.eclipse.jdt.ui.team/src/org/eclipse/jdt/ui/team/JavaLogicalViewProvider.java4
-rw-r--r--bundles/org.eclipse.team.ui/org.eclipse.jdt.ui.team/src/org/eclipse/jdt/ui/team/JavaSyncInfoSetContentProvider.java4
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/OpenFileInSystemEditorAction.java4
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/OpenWithActionGroup.java4
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/RefactorActionGroup.java6
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/views/CompressFolderView.java (renamed from bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/content/CompressFolderView.java)6
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/views/CompressedFolderContentProvider.java3
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/views/CompressedFolderLabelProvider.java3
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoDiffNode.java26
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoSetCompareConfiguration.java36
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/TeamSubscriberParticipantLabelProvider.java20
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/actions/RefreshAction.java4
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/content/LogicalViewProvider.java4
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/content/SyncInfoLabelProvider.java5
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/content/SyncInfoSetContentProvider.java (renamed from bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/views/SyncSetContentProvider.java)238
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/content/SyncInfoSetTreeContentProvider.java (renamed from bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/views/SyncSetTreeContentProvider.java)88
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/content/SyncViewerSorter.java (renamed from bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/views/SyncViewerSorter.java)4
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/launchConfigurations/One CVS Test.launch9
19 files changed, 281 insertions, 191 deletions
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/ChangeLogContentProvider.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/ChangeLogContentProvider.java
index df517d657..5f0655317 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/ChangeLogContentProvider.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/ChangeLogContentProvider.java
@@ -20,13 +20,13 @@ import org.eclipse.team.core.subscribers.*;
import org.eclipse.team.core.subscribers.SyncInfo;
import org.eclipse.team.internal.ccvs.core.CVSSyncInfo;
import org.eclipse.team.internal.ccvs.core.ICVSRemoteResource;
-import org.eclipse.team.internal.ui.synchronize.views.SyncSetTreeContentProvider;
import org.eclipse.team.ui.synchronize.*;
+import org.eclipse.team.ui.synchronize.content.SyncInfoSetTreeContentProvider;
/**
* Seeing change comments makes sense it two ways.
*/
-public class ChangeLogContentProvider extends SyncSetTreeContentProvider {
+public class ChangeLogContentProvider extends SyncInfoSetTreeContentProvider {
private Map commentRoots = new HashMap();
diff --git a/bundles/org.eclipse.team.ui/org.eclipse.jdt.ui.team/src/org/eclipse/jdt/ui/team/JavaLogicalViewProvider.java b/bundles/org.eclipse.team.ui/org.eclipse.jdt.ui.team/src/org/eclipse/jdt/ui/team/JavaLogicalViewProvider.java
index 76f4baa9f..f7ec09f07 100644
--- a/bundles/org.eclipse.team.ui/org.eclipse.jdt.ui.team/src/org/eclipse/jdt/ui/team/JavaLogicalViewProvider.java
+++ b/bundles/org.eclipse.team.ui/org.eclipse.jdt.ui.team/src/org/eclipse/jdt/ui/team/JavaLogicalViewProvider.java
@@ -10,7 +10,7 @@
*******************************************************************************/
package org.eclipse.jdt.ui.team;
-import org.eclipse.team.internal.ui.synchronize.views.SyncSetContentProvider;
+import org.eclipse.team.ui.synchronize.content.*;
import org.eclipse.team.ui.synchronize.content.LogicalViewProvider;
import org.eclipse.team.ui.synchronize.content.SyncInfoLabelProvider;
@@ -22,7 +22,7 @@ public class JavaLogicalViewProvider extends LogicalViewProvider {
/* (non-Javadoc)
* @see org.eclipse.team.ui.synchronize.content.LogicalViewProvider#getContentProvider()
*/
- public SyncSetContentProvider getContentProvider() {
+ public SyncInfoSetContentProvider getContentProvider() {
return new JavaSyncInfoSetContentProvider();
}
diff --git a/bundles/org.eclipse.team.ui/org.eclipse.jdt.ui.team/src/org/eclipse/jdt/ui/team/JavaSyncInfoSetContentProvider.java b/bundles/org.eclipse.team.ui/org.eclipse.jdt.ui.team/src/org/eclipse/jdt/ui/team/JavaSyncInfoSetContentProvider.java
index 193193260..529feda95 100644
--- a/bundles/org.eclipse.team.ui/org.eclipse.jdt.ui.team/src/org/eclipse/jdt/ui/team/JavaSyncInfoSetContentProvider.java
+++ b/bundles/org.eclipse.team.ui/org.eclipse.jdt.ui.team/src/org/eclipse/jdt/ui/team/JavaSyncInfoSetContentProvider.java
@@ -17,14 +17,14 @@ import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.jdt.core.*;
import org.eclipse.team.core.subscribers.SyncInfoSet;
-import org.eclipse.team.internal.ui.synchronize.views.SyncSetTreeContentProvider;
+import org.eclipse.team.ui.synchronize.content.SyncInfoSetTreeContentProvider;
/**
* Extend the SyncSetTreeContentProvider to show a Java model elements in the view.
*
* TODO: Refresh behavior needs to be added
*/
-public class JavaSyncInfoSetContentProvider extends SyncSetTreeContentProvider {
+public class JavaSyncInfoSetContentProvider extends SyncInfoSetTreeContentProvider {
/* (non-Javadoc)
* @see org.eclipse.team.internal.ui.synchronize.views.SyncSetContentProvider#getModelObject(org.eclipse.core.resources.IResource)
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/OpenFileInSystemEditorAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/OpenFileInSystemEditorAction.java
index f5f90cc77..773d8a1cb 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/OpenFileInSystemEditorAction.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/OpenFileInSystemEditorAction.java
@@ -17,7 +17,7 @@ import java.util.List;
import org.eclipse.core.resources.IResource;
import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.team.internal.ui.synchronize.views.SyncSetContentProvider;
+import org.eclipse.team.ui.synchronize.content.SyncInfoSetContentProvider;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.actions.OpenFileAction;
@@ -35,7 +35,7 @@ public class OpenFileInSystemEditorAction extends OpenFileAction {
IStructuredSelection selection = getStructuredSelection();
for (Iterator e = selection.iterator(); e.hasNext();) {
Object next = e.next();
- IResource resource = SyncSetContentProvider.getResource(next);
+ IResource resource = SyncInfoSetContentProvider.getResource(next);
if(resource != null) {
resources.add(resource);
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/OpenWithActionGroup.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/OpenWithActionGroup.java
index 13790aebd..2127c5e9d 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/OpenWithActionGroup.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/OpenWithActionGroup.java
@@ -15,8 +15,8 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.team.internal.ui.synchronize.views.SyncSetContentProvider;
import org.eclipse.team.ui.synchronize.*;
+import org.eclipse.team.ui.synchronize.content.SyncInfoSetContentProvider;
import org.eclipse.ui.actions.ActionGroup;
import org.eclipse.ui.actions.OpenWithMenu;
import org.eclipse.ui.views.navigator.ResourceNavigatorMessages;
@@ -92,7 +92,7 @@ public class OpenWithActionGroup extends ActionGroup {
}
private IResource getResource(Object obj) {
- return SyncSetContentProvider.getResource(obj);
+ return SyncInfoSetContentProvider.getResource(obj);
}
public void openInCompareEditor() {
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/RefactorActionGroup.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/RefactorActionGroup.java
index 13930ea8c..8749fa739 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/RefactorActionGroup.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/RefactorActionGroup.java
@@ -22,7 +22,7 @@ import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.team.internal.ui.Policy;
-import org.eclipse.team.internal.ui.synchronize.views.SyncSetContentProvider;
+import org.eclipse.team.ui.synchronize.content.SyncInfoSetContentProvider;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IKeyBindingService;
import org.eclipse.ui.ISharedImages;
@@ -80,7 +80,7 @@ public class RefactorActionGroup extends ActionGroup {
List resources = new ArrayList();
Iterator it = selection.iterator();
while(it.hasNext()) {
- IResource resource = SyncSetContentProvider.getResource(it.next());
+ IResource resource = SyncInfoSetContentProvider.getResource(it.next());
if(resource != null) {
resources.add(resource);
}
@@ -140,7 +140,7 @@ public class RefactorActionGroup extends ActionGroup {
resource = (IResource)adaptable.getAdapter(IResource.class);
}
if(resource == null) {
- resource = SyncSetContentProvider.getResource(next);
+ resource = SyncInfoSetContentProvider.getResource(next);
}
if (resource == null || (resource.getType() & resourceMask) == 0) {
return false;
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/content/CompressFolderView.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/views/CompressFolderView.java
index e5a740dd0..2dab6d8cd 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/content/CompressFolderView.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/views/CompressFolderView.java
@@ -8,9 +8,9 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.team.ui.synchronize.content;
+package org.eclipse.team.internal.ui.synchronize.views;
-import org.eclipse.team.internal.ui.synchronize.views.*;
+import org.eclipse.team.ui.synchronize.content.*;
/**
* This implementation compresses folder paths that do not contain out-of-sync resource.
@@ -22,7 +22,7 @@ public class CompressFolderView extends LogicalViewProvider {
/* (non-Javadoc)
* @see org.eclipse.team.ui.synchronize.content.ILogicalSyncInfoSetView#getContentProvider()
*/
- public SyncSetContentProvider getContentProvider() {
+ public SyncInfoSetContentProvider getContentProvider() {
return new CompressedFolderContentProvider();
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/views/CompressedFolderContentProvider.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/views/CompressedFolderContentProvider.java
index 502614d30..efd39c43e 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/views/CompressedFolderContentProvider.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/views/CompressedFolderContentProvider.java
@@ -18,11 +18,12 @@ import org.eclipse.team.core.subscribers.ISyncInfoSetChangeEvent;
import org.eclipse.team.core.subscribers.SyncInfo;
import org.eclipse.team.internal.core.subscribers.SyncSetChangedEvent;
import org.eclipse.team.ui.synchronize.SyncInfoDiffNode;
+import org.eclipse.team.ui.synchronize.content.*;
/**
* The contents provider compressed in-sync folder paths
*/
-public class CompressedFolderContentProvider extends SyncSetTreeContentProvider {
+public class CompressedFolderContentProvider extends SyncInfoSetTreeContentProvider {
/* (non-Javadoc)
* @see org.eclipse.team.internal.ui.synchronize.views.SyncSetContentProvider#handleResourceChanges(org.eclipse.team.core.subscribers.ISyncInfoSetChangeEvent)
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/views/CompressedFolderLabelProvider.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/views/CompressedFolderLabelProvider.java
index 4891e128a..9d7f7a6c6 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/views/CompressedFolderLabelProvider.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/views/CompressedFolderLabelProvider.java
@@ -14,6 +14,7 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.swt.graphics.Image;
import org.eclipse.team.internal.ui.TeamUIPlugin;
import org.eclipse.team.ui.ISharedImages;
+import org.eclipse.team.ui.synchronize.content.*;
import org.eclipse.team.ui.synchronize.content.SyncInfoLabelProvider;
/**
@@ -55,7 +56,7 @@ public class CompressedFolderLabelProvider extends SyncInfoLabelProvider {
*/
public String getText(Object element) {
if (element instanceof CompressedFolder) {
- IResource resource = SyncSetContentProvider.getResource(element);
+ IResource resource = SyncInfoSetContentProvider.getResource(element);
return resource.getProjectRelativePath().toString();
}
return super.getText(element);
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoDiffNode.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoDiffNode.java
index 770e0c104..603664f34 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoDiffNode.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoDiffNode.java
@@ -217,6 +217,10 @@ public class SyncInfoDiffNode extends DiffNode implements IAdaptable {
}
}
+ /**
+ * Return the <code>SyncInfoSet</code> from which this diff node was derived.
+ * @return a <code>SyncInfoSet</code>
+ */
public SyncInfoSet getSyncInfoSet() {
return input;
}
@@ -243,4 +247,26 @@ public class SyncInfoDiffNode extends DiffNode implements IAdaptable {
public boolean isResourcePath() {
return false;
}
+
+ /**
+ * Return whether this diff node has descendant conflicts in the view in which it appears.
+ * @return whether the node has descendant conflicts
+ */
+ public boolean hasDecendantConflicts() {
+ // If this node has no resource, we can't tell
+ // The subclass which created the node with no resource should have overridden this method
+ if (resource == null || resource.getType() == IResource.FILE) return false;
+ // If the set has no conflicts then the node doesn't either
+ if (getSyncInfoSet().countFor(SyncInfo.CONFLICTING, SyncInfo.DIRECTION_MASK) == 0) {
+ return false;
+ }
+ SyncInfo[] infos = getDescendantSyncInfos();
+ for (int i = 0; i < infos.length; i++) {
+ SyncInfo info = infos[i];
+ if ((info.getKind() & SyncInfo.DIRECTION_MASK) == SyncInfo.CONFLICTING) {
+ return true;
+ }
+ }
+ return false;
+ }
} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoSetCompareConfiguration.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoSetCompareConfiguration.java
index 5e29be513..f8ac2ab36 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoSetCompareConfiguration.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoSetCompareConfiguration.java
@@ -28,6 +28,7 @@ import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.*;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.subscribers.SyncInfoSet;
+import org.eclipse.team.internal.core.Assert;
import org.eclipse.team.internal.ui.*;
import org.eclipse.team.internal.ui.registry.LogicalViewRegistry;
import org.eclipse.team.internal.ui.synchronize.actions.LogicalViewActionGroup;
@@ -54,7 +55,8 @@ public class SyncInfoSetCompareConfiguration {
private SyncInfoSet set;
private String menuId;
- private boolean acceptParticipantMenuContributions = false;
+
+ private StructuredViewer viewer;
// fields that are tied to a single viewer
private SyncInfoDiffTreeNavigator navigator;
@@ -114,6 +116,10 @@ public class SyncInfoSetCompareConfiguration {
* @param viewer the viewer being initialized
*/
public void initializeViewer(Composite parent, final StructuredViewer viewer) {
+ Assert.isTrue(this.viewer == null, "A SyncInfoSetCompareConfiguration can only be used with a single viewer."); //$NON-NLS-1$
+ this.viewer = viewer;
+
+ // Use a logical view to set the content provider, label provider and sorter
ILogicalView view = getDefaultLogicalView();
setLogicalViewProvider(viewer, view);
logicalViews = new LogicalViewActionGroup();
@@ -121,21 +127,25 @@ public class SyncInfoSetCompareConfiguration {
GridData data = new GridData(GridData.FILL_BOTH);
viewer.getControl().setLayoutData(data);
+
+ // Listen to the glocal prefernce for content provider changes
+ // TODO: Related to logocal view
propertyListener = getPropertyListener(viewer);
getStore().addPropertyChangeListener(propertyListener);
initializeListeners(viewer);
-
+ initializeNavigator(viewer);
+ hookContextMenu(viewer);
+ createToolBarActions(parent);
+ viewer.setInput(getInput());
+ }
+
+ protected void initializeNavigator(final StructuredViewer viewer) {
viewer.getControl().setData(CompareUI.COMPARE_VIEWER_TITLE, getTitle());
if (viewer instanceof INavigableTree) {
initializeNavigation(viewer.getControl(), (INavigableTree)viewer);
navigator.createActions(viewer);
}
- hookContextMenu(viewer);
-
- createToolBarActions(parent);
- // TODO: This relates to the content provider (i.e. the use of SyncInfoDiffNode)
- viewer.setInput(getInput());
}
/**
@@ -184,9 +194,7 @@ public class SyncInfoSetCompareConfiguration {
ToolBarManager tbm= CompareViewerPane.getToolBarManager(parent);
if (tbm != null) {
tbm.removeAll();
-
tbm.add(new Separator("navigation")); //$NON-NLS-1$
-
navigator.createToolItems(tbm);
tbm.update(true);
}
@@ -200,8 +208,8 @@ public class SyncInfoSetCompareConfiguration {
return new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
if (event.getProperty().equals(IPreferenceIds.SYNCVIEW_COMPRESS_FOLDERS)) {
- // TODO:
- //viewer.setContentProvider(getContentProvider());
+ ILogicalView view = getDefaultLogicalView();
+ setLogicalViewProvider(viewer, view);
}
}
};
@@ -305,7 +313,7 @@ public class SyncInfoSetCompareConfiguration {
}
}
if (view == null) {
- viewer.setContentProvider(new SyncSetTreeContentProvider());
+ viewer.setContentProvider(new SyncInfoSetTreeContentProvider());
viewer.setLabelProvider(getLabelProvider(new SyncInfoLabelProvider()));
viewer.setSorter(new SyncViewerSorter(ResourceSorter.NAME));
}
@@ -349,8 +357,8 @@ public class SyncInfoSetCompareConfiguration {
Object curr = changed[i];
if (curr instanceof IResource) {
IContentProvider provider = viewer.getContentProvider();
- if (provider != null && provider instanceof SyncSetContentProvider) {
- curr = ((SyncSetContentProvider)provider).getModelObject((IResource)curr);
+ if (provider != null && provider instanceof SyncInfoSetContentProvider) {
+ curr = ((SyncInfoSetContentProvider)provider).getModelObject((IResource)curr);
}
}
others.add(curr);
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/TeamSubscriberParticipantLabelProvider.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/TeamSubscriberParticipantLabelProvider.java
index 5cb9a27ff..31b43fbe8 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/TeamSubscriberParticipantLabelProvider.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/TeamSubscriberParticipantLabelProvider.java
@@ -23,9 +23,9 @@ import org.eclipse.swt.widgets.Display;
import org.eclipse.team.core.subscribers.*;
import org.eclipse.team.internal.core.Assert;
import org.eclipse.team.internal.ui.*;
-import org.eclipse.team.internal.ui.synchronize.views.SyncSetContentProvider;
import org.eclipse.team.ui.ISharedImages;
import org.eclipse.team.ui.synchronize.content.SyncInfoLabelProvider;
+import org.eclipse.team.ui.synchronize.content.SyncInfoSetContentProvider;
import org.eclipse.ui.internal.WorkbenchColors;
/**
@@ -63,6 +63,7 @@ public class TeamSubscriberParticipantLabelProvider extends LabelProvider implem
working = true;
Display.getDefault().asyncExec(new Runnable() {
public void run() {
+ // TODO: What this is this supposed to be?
synchronized (this) {
fireLabelProviderChanged(new LabelProviderChangedEvent(TeamSubscriberParticipantLabelProvider.this));
}
@@ -98,7 +99,7 @@ public class TeamSubscriberParticipantLabelProvider extends LabelProvider implem
public String getText(Object element) {
String name = syncInfoLabelProvider.getText(element);
if (TeamUIPlugin.getPlugin().getPreferenceStore().getBoolean(IPreferenceIds.SYNCVIEW_VIEW_SYNCINFO_IN_LABEL)) {
- SyncInfo info = SyncSetContentProvider.getSyncInfo(element);
+ SyncInfo info = SyncInfoSetContentProvider.getSyncInfo(element);
if (info != null && info.getKind() != SyncInfo.IN_SYNC) {
String syncKindString = SyncInfo.kindToString(info.getKind());
name = Policy.bind("TeamSubscriberSyncPage.labelWithSyncKind", name, syncKindString); //$NON-NLS-1$
@@ -115,7 +116,7 @@ public class TeamSubscriberParticipantLabelProvider extends LabelProvider implem
*/
public Image getImage(Object element) {
Image decoratedImage = null;
- IResource resource = SyncSetContentProvider.getResource(element);
+ IResource resource = SyncInfoSetContentProvider.getResource(element);
Image image = syncInfoLabelProvider.getImage(element);
decoratedImage = getCompareImage(image, element);
decoratedImage = propagateConflicts(decoratedImage, element, resource);
@@ -123,7 +124,7 @@ public class TeamSubscriberParticipantLabelProvider extends LabelProvider implem
}
private Image getCompareImage(Image base, Object element) {
- int kind = SyncSetContentProvider.getSyncKind(element);
+ int kind = SyncInfoSetContentProvider.getSyncKind(element);
switch (kind & SyncInfo.DIRECTION_MASK) {
case SyncInfo.OUTGOING:
kind = (kind &~ SyncInfo.OUTGOING) | SyncInfo.INCOMING;
@@ -138,12 +139,9 @@ public class TeamSubscriberParticipantLabelProvider extends LabelProvider implem
private Image propagateConflicts(Image base, Object element, IResource resource) {
if(element instanceof SyncInfoDiffNode && resource.getType() != IResource.FILE) {
// if the folder is already conflicting then don't bother propagating the conflict
- int kind = SyncSetContentProvider.getSyncKind(element);
+ int kind = SyncInfoSetContentProvider.getSyncKind(element);
if((kind & SyncInfo.DIRECTION_MASK) != SyncInfo.CONFLICTING) {
- SyncInfo[] infos = ((SyncInfoDiffNode)element).getDescendantSyncInfos();
- SyncInfoSet set = new SyncInfoSet(infos);
- long count = set.countFor(SyncInfo.CONFLICTING, SyncInfo.DIRECTION_MASK);
- if(count > 0) {
+ if(((SyncInfoDiffNode)element).hasDecendantConflicts()) {
ImageDescriptor overlay = new OverlayIcon(
base,
new ImageDescriptor[] { TeamUIPlugin.getImageDescriptor(ISharedImages.IMG_CONFLICT_OVR)},
@@ -188,7 +186,7 @@ public class TeamSubscriberParticipantLabelProvider extends LabelProvider implem
if (columnIndex == COL_RESOURCE) {
return getImage(element);
} else if (columnIndex == COL_PARENT) {
- IResource resource = SyncSetContentProvider.getResource(element);
+ IResource resource = SyncInfoSetContentProvider.getResource(element);
return null;
}
return null;
@@ -201,7 +199,7 @@ public class TeamSubscriberParticipantLabelProvider extends LabelProvider implem
if (columnIndex == COL_RESOURCE) {
return getText(element);
} else if (columnIndex == COL_PARENT) {
- IResource resource = SyncSetContentProvider.getResource(element);
+ IResource resource = SyncInfoSetContentProvider.getResource(element);
return resource.getParent().getFullPath().toString();
}
return null;
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/actions/RefreshAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/actions/RefreshAction.java
index 7aa01a96b..674014fd9 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/actions/RefreshAction.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/actions/RefreshAction.java
@@ -20,7 +20,7 @@ import org.eclipse.team.core.subscribers.*;
import org.eclipse.team.internal.ui.Policy;
import org.eclipse.team.internal.ui.Utils;
import org.eclipse.team.internal.ui.jobs.RefreshSubscriberJob;
-import org.eclipse.team.internal.ui.synchronize.views.SyncSetContentProvider;
+import org.eclipse.team.ui.synchronize.content.SyncInfoSetContentProvider;
/**
* A general refresh action that will refresh a subscriber in the background.
@@ -72,7 +72,7 @@ public class RefreshAction extends Action {
List resources = new ArrayList();
Iterator it = selection.iterator();
while(it.hasNext()) {
- IResource resource = SyncSetContentProvider.getResource(it.next());
+ IResource resource = SyncInfoSetContentProvider.getResource(it.next());
if(resource != null) {
resources.add(resource);
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/content/LogicalViewProvider.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/content/LogicalViewProvider.java
index b4a04b2eb..a279e45f5 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/content/LogicalViewProvider.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/content/LogicalViewProvider.java
@@ -10,8 +10,6 @@
*******************************************************************************/
package org.eclipse.team.ui.synchronize.content;
-import org.eclipse.team.internal.ui.synchronize.views.SyncSetContentProvider;
-import org.eclipse.team.internal.ui.synchronize.views.SyncViewerSorter;
import org.eclipse.ui.views.navigator.ResourceSorter;
/**
@@ -19,7 +17,7 @@ import org.eclipse.ui.views.navigator.ResourceSorter;
*/
public abstract class LogicalViewProvider {
- public abstract SyncSetContentProvider getContentProvider();
+ public abstract SyncInfoSetContentProvider getContentProvider();
public abstract SyncInfoLabelProvider getLabelProvider();
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/content/SyncInfoLabelProvider.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/content/SyncInfoLabelProvider.java
index 6b87ebc45..33f689fda 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/content/SyncInfoLabelProvider.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/content/SyncInfoLabelProvider.java
@@ -13,7 +13,6 @@ package org.eclipse.team.ui.synchronize.content;
import org.eclipse.core.resources.IResource;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;
-import org.eclipse.team.internal.ui.synchronize.views.SyncSetContentProvider;
import org.eclipse.ui.model.WorkbenchLabelProvider;
/**
@@ -36,7 +35,7 @@ public class SyncInfoLabelProvider extends LabelProvider {
* @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
*/
public Image getImage(Object element) {
- IResource resource = SyncSetContentProvider.getResource(element);
+ IResource resource = SyncInfoSetContentProvider.getResource(element);
if (resource != null) {
return workbenchLabelProvider.getImage(resource);
}
@@ -47,7 +46,7 @@ public class SyncInfoLabelProvider extends LabelProvider {
* @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
*/
public String getText(Object element) {
- IResource resource = SyncSetContentProvider.getResource(element);
+ IResource resource = SyncInfoSetContentProvider.getResource(element);
if (resource != null) {
return workbenchLabelProvider.getText(resource);
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/views/SyncSetContentProvider.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/content/SyncInfoSetContentProvider.java
index 67a33a05b..438db28b8 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/views/SyncSetContentProvider.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/content/SyncInfoSetContentProvider.java
@@ -8,30 +8,40 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.team.internal.ui.synchronize.views;
+package org.eclipse.team.ui.synchronize.content;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.viewers.*;
import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.swt.widgets.Control;
import org.eclipse.team.core.subscribers.*;
+import org.eclipse.team.internal.core.Assert;
import org.eclipse.team.ui.synchronize.SyncInfoDiffNode;
/**
- * This class provides the contents for a StructuredViewer using a SyncSet as the model
+ * This class provides the contents for a StructuredViewer using the <code>SyncInfo</code>
+ * contained in a <code>SyncInfoSet</code> as the model.
+ *
+ * @see SyncInfo
+ * @see SyncInfoSet
*/
-public abstract class SyncSetContentProvider implements IStructuredContentProvider, ISyncSetChangedListener {
-
- protected Viewer viewer;
+public abstract class SyncInfoSetContentProvider implements IStructuredContentProvider, ISyncSetChangedListener {
- // parents who need a label update accumulated while handling sync set changes
- private Set parentsToUpdate = new HashSet();
+ private Viewer viewer;
+ /**
+ * Return the <code>SyncInfoSet</code> associated with the given object.
+ * The default implementation will extract the set from a <code>SyncInfoDiffNode</code>.
+ * Objects that implement <code>IAdaptable</code> will be queried for an adapter
+ * for the <code>SyncInfoSet</code> class. Subclasses may override to extract
+ * a <code>SyncInfoSet</code> from other model object types but should invoke
+ * the inherited method if extraction for their type fails.
+ *
+ * @param input the object from which to obtain the <code>SyncInfoSet</code>
+ * @return the <code>SyncInfoSet</code> or <code>null</code> if no set could be obtained
+ */
protected SyncInfoSet getSyncInfoSet(Object input) {
if (input == null) {
return null;
@@ -42,9 +52,18 @@ public abstract class SyncSetContentProvider implements IStructuredContentProvid
if(input instanceof SyncInfoSet) {
return (SyncInfoSet)input;
}
+ if (input instanceof IAdaptable) {
+ IAdaptable adaptable = (IAdaptable)input;
+ return (SyncInfoSet)adaptable.getAdapter(SyncInfoSet.class);
+ }
return null;
}
+ /**
+ * Return the <code>SyncInfoSet</code> of the viewer associated with this
+ * content provider.
+ * @return the <code>SyncInfoSet</code> of the viewer
+ */
protected SyncInfoSet getSyncInfoSet() {
if(viewer == null || viewer.getControl().isDisposed()) {
return null;
@@ -56,11 +75,9 @@ public abstract class SyncSetContentProvider implements IStructuredContentProvid
* @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
*/
public void inputChanged(Viewer v, Object oldInput, Object newInput) {
-
this.viewer = v;
SyncInfoSet oldSyncSet = getSyncInfoSet(oldInput);
SyncInfoSet newSyncSet = getSyncInfoSet(newInput);
-
if (oldSyncSet != newSyncSet) {
if (oldSyncSet != null) {
oldSyncSet.removeSyncSetChangedListener(this);
@@ -72,11 +89,6 @@ public abstract class SyncSetContentProvider implements IStructuredContentProvid
}
/* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
- */
- public abstract Object[] getElements(Object inputElement);
-
- /* (non-Javadoc)
* @see org.eclipse.jface.viewers.IContentProvider#dispose()
*/
public void dispose() {
@@ -97,7 +109,7 @@ public abstract class SyncSetContentProvider implements IStructuredContentProvid
if (!ctrl.isDisposed()) {
BusyIndicator.showWhile(ctrl.getDisplay(), new Runnable() {
public void run() {
- handleSyncSetChanges(event);
+ syncSetChanged(event);
}
});
}
@@ -107,27 +119,46 @@ public abstract class SyncSetContentProvider implements IStructuredContentProvid
}
/**
- * Update the viewer with the sync-set changes, aditions and removals
- * in the given event. This method is invoked from within the UI thread.
- * @param event
+ * Callback that is invoked from within an <code>asyncExec</code> when
+ * the model <code>SyncInfoSet</code> has changed. This method
+ * disables redraw in the viewer and then either refreshes the
+ * viewer (if the event was a reset) or invokes the
+ * <code>handleChanges(ISyncInfoSetChangeEvent)</code> method.
+ * Subclasses not need to override this method to handle changes
+ * but should instead override <code>handleChanges(ISyncInfoSetChangeEvent)</code>.
+ * @param event the <code>SyncInfoSet</code> change event.
+ *
+ * @see handleChanges(ISyncInfoSetChangeEvent)
*/
- protected void handleSyncSetChanges(ISyncInfoSetChangeEvent event) {
+ protected void syncSetChanged(ISyncInfoSetChangeEvent event) {
viewer.getControl().setRedraw(false);
if (event.isReset()) {
// On a reset, refresh the entire view
((StructuredViewer) viewer).refresh();
} else {
- handleResourceChanges(event);
- handleResourceRemovals(event);
- handleResourceAdditions(event);
- updateParentLabels();
+ handleChanges(event);
}
viewer.getControl().setRedraw(true);
}
/**
+ * Handle the changes made to the viewer's <code>SyncInfoSet</code>.
+ * This method delegates the changes to the three methods
+ * <code>handleResourceChanges(ISyncInfoSetChangeEvent)</code>,
+ * <code>handleResourceRemovals(ISyncInfoSetChangeEvent)</code> and
+ * <code>handleResourceAdditions(ISyncInfoSetChangeEvent)</code>.
+ *
+ * @param event the event containing the changed resourcses.
+ */
+ protected void handleChanges(ISyncInfoSetChangeEvent event) {
+ handleResourceChanges(event);
+ handleResourceRemovals(event);
+ handleResourceAdditions(event);
+ }
+
+ /**
* Update the viewer for the sync set changes in the provided event.
- * This method is invoked by <code>handleSyncSetChanges</code>.
+ * This method is invoked by <code>handleChanges(ISyncInfoSetChangeEvent)</code>.
* Subclasses may override.
* @param event
* @see #handleSyncSetChanges(SyncSetChangedEvent)
@@ -138,13 +169,12 @@ public abstract class SyncSetContentProvider implements IStructuredContentProvid
for (int i = 0; i < infos.length; i++) {
IResource local = infos[i].getLocal();
((StructuredViewer) viewer).refresh(getModelObject(local), true);
- updateParentLabels(local);
}
}
/**
* Update the viewer for the sync set removals in the provided event.
- * This method is invoked by <code>handleSyncSetChanges</code>.
+ * This method is invoked by <code>handleChanges(ISyncInfoSetChangeEvent)</code>.
* Subclasses may override.
* @param event
*/
@@ -154,13 +184,12 @@ public abstract class SyncSetContentProvider implements IStructuredContentProvid
for (int i = 0; i < removed.length; i++) {
IResource resource = removed[i];
((StructuredViewer) viewer).refresh(getModelObject(resource));
- updateParentLabels(resource);
}
}
/**
* Update the viewer for the sync set additions in the provided event.
- * This method is invoked by <code>handleSyncSetChanges</code>.
+ * This method is invoked by <code>handleChanges(ISyncInfoSetChangeEvent)</code>.
* Subclasses may override.
* @param event
*/
@@ -170,70 +199,93 @@ public abstract class SyncSetContentProvider implements IStructuredContentProvid
for (int i = 0; i < added.length; i++) {
IResource resource = added[i];
((StructuredViewer) viewer).refresh(getModelObject(resource.getParent()));
- updateParentLabels(resource);
}
}
+ /**
+ * Return the viewer to which this content provider is associated.
+ * @return the content provider's viewer
+ */
public StructuredViewer getViewer() {
return (StructuredViewer)viewer;
}
/**
- * Return the children of the given container who are either out-of-sync or contain
- * out-of-sync resources.
+ * Return the model object (i.e. an instance of <code>SyncInfoDiffNode</code> or one of its subclasses)
+ * for the given IResource.
+ *
+ * @param resource the resource
+ * @return the <code>SyncInfoDiffNode</code> for the given resource
*/
- public Object[] members(IResource resource) {
- IResource[] resources = getSyncInfoSet().members(resource);
+ public Object getModelObject(IResource resource) {
+ return new SyncInfoDiffNode(getSyncInfoSet(), resource);
+ }
+
+ /**
+ * Invokes <code>getModelObject(Object)</code> on an array of resources.
+ *
+ * @param resources the resources
+ * @return the model objects for the resources
+ */
+ protected Object[] getModelObjects(IResource[] resources) {
Object[] result = new Object[resources.length];
for (int i = 0; i < resources.length; i++) {
- IResource child = resources[i];
- result[i] = getModelObject(child);
+ result[i] = getModelObject(resources[i]);
}
return result;
}
/**
- * Return the SyncInfo for the given model object that was returned by
- * SyncSet#members(IResource). If syncSet is null, then the
- * sync info will also be null.
+ * Return the SyncInfo for the given model object
+ * (i.e. <code>SyncInfoDiffNode</code>). This method wiull return <code>null</code>
+ * if the <code>SuncInfo</code> associated with the given object is null. However,
+ * it is an error to invoke this method with <code>null</code> as an argument or with an object
+ * that does not have an associated <code>SyncInfo</code> as an argument.
*
- * @param element
- * @return
+ * @param element the model object
+ * @return the <code>SyncInfo</code> associated with the modle object or <code>null</code>
*/
public static SyncInfo getSyncInfo(Object element) {
if (element instanceof SyncInfo) {
return ((SyncInfo) element);
- } else if (element instanceof SyncInfoDiffNode) {
- SyncInfoDiffNode syncResource = (SyncInfoDiffNode)element;
- return syncResource.getSyncInfo();
}
- throw new NullPointerException();
+ if (element instanceof SyncInfoDiffNode) {
+ return ((SyncInfoDiffNode)element).getSyncInfo();
+ }
+ if (element instanceof IAdaptable) {
+ IAdaptable adaptable = (IAdaptable)element;
+ return (SyncInfo)adaptable.getAdapter(SyncInfo.class);
+ }
+ Assert.isTrue(false, "Provided object must have an associated SyncInfo"); //$NON-NLS-1$
+ // This point is never reached
+ return null;
}
/**
- * Return the IResource for the given model object that was returned by
- * SyncSet#members(IResource). Return <code>null</code> if the given
+ * Return the IResource for the given model object (i.e. <code>SyncInfoDiffNode</code>).
+ * Return <code>null</code> if the given
* object does not have a corresponding IResource.
*
- * @param element
- * @return
+ * @param element the modle object
+ * @return the corresponding <code>IResource</code>
*/
- public static IResource getResource(Object obj) {
- if (obj instanceof SyncInfo) {
- return ((SyncInfo) obj).getLocal();
- } else if (obj instanceof SyncInfoDiffNode) {
- return ((SyncInfoDiffNode)obj).getResource();
+ public static IResource getResource(Object element) {
+ if (element instanceof SyncInfo) {
+ return ((SyncInfo) element).getLocal();
+ } else if (element instanceof SyncInfoDiffNode) {
+ return ((SyncInfoDiffNode)element).getResource();
}
return null;
}
/**
- * Return the sync kind for the given model object that was returned by
- * SyncSet#members(IResource). If syncSet is null, then the
- * sync kind for SyncContainers will always be 0.
+ * Return the sync kind for the given model object (i.e. <code>SyncInfoDiffNode</code>).
+ * This method uses <code>getSyncInfo(Object)</code> to obtain the sync info for the object.
+ * The kind associated with the sync info is returned unless he sync info is <code>null</code>
+ * in which case <code>SyncInfo.IN_SYNC</code> is eturned.
*
- * @param element
- * @return
+ * @param element the model object
+ * @return the sync kind of the object
*/
public static int getSyncKind(Object element) {
SyncInfo info = getSyncInfo(element);
@@ -242,66 +294,4 @@ public abstract class SyncSetContentProvider implements IStructuredContentProvid
}
return SyncInfo.IN_SYNC;
}
-
- /**
- * Get the model object (SyncSet, SyncInfo or SyncContainer) that is the
- * parent of the given model object.
- *
- * @param syncSet
- * @param object
- * @return
- */
- public Object getParent(Object object) {
- IResource resource = getResource(object);
- if (resource == null) return null;
- IContainer parent = resource.getParent();
- return getModelObject(parent);
- }
-
- /**
- * Return the model object for the given IResource.
- * @param resource
- */
- public Object getModelObject(IResource resource) {
- return new SyncInfoDiffNode(getSyncInfoSet(), resource);
- }
-
- protected Object[] getModelObjects(IResource[] resources) {
- Object[] result = new Object[resources.length];
- for (int i = 0; i < resources.length; i++) {
- result[i] = getModelObject(resources[i]);
- }
- return result;
- }
-
- /**
- * Forces the viewer to update the labels for parents whose children have changed
- * during this round of sync set changes.
- */
- protected void updateParentLabels() {
- try {
- getViewer().update(
- parentsToUpdate.toArray(new Object[parentsToUpdate.size()]),
- null
- );
- } finally {
- parentsToUpdate.clear();
- }
- }
-
- /**
- * Forces the viewer to update the labels for parents of this element. This
- * can be useful when parents labels include information about their children
- * that needs updating when a child changes.
- * <p>
- * This method should only be called while processing sync set changes.
- * Changed parents are accumulated and updated at the end of the change processing
- */
- protected void updateParentLabels(IResource resource) {
- IResource parent = resource.getParent();
- while(parent.getType() != IResource.ROOT) {
- parentsToUpdate.add(getModelObject(parent));
- parent = parent.getParent();
- }
- }
} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/views/SyncSetTreeContentProvider.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/content/SyncInfoSetTreeContentProvider.java
index 8fae7f16b..79c627e8b 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/views/SyncSetTreeContentProvider.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/content/SyncInfoSetTreeContentProvider.java
@@ -8,18 +8,25 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.team.internal.ui.synchronize.views;
+package org.eclipse.team.ui.synchronize.content;
+
+import java.util.HashSet;
+import java.util.Set;
import org.eclipse.core.resources.*;
-import org.eclipse.jface.viewers.AbstractTreeViewer;
-import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.*;
import org.eclipse.team.core.subscribers.ISyncInfoSetChangeEvent;
+import org.eclipse.team.core.subscribers.SyncInfo;
/**
- * This class provides the contents for a AbstractTreeViewer using a SyncSet as the model
+ * This class provides the contents for a <code>AbstractTreeViewer</code> using the
+ * <code>SyncInfo</code> contained in a <code>SyncInfoSet</code> as the model
*/
-public class SyncSetTreeContentProvider extends SyncSetContentProvider implements ITreeContentProvider {
-
+public class SyncInfoSetTreeContentProvider extends SyncInfoSetContentProvider implements ITreeContentProvider {
+
+ // parents who need a label update accumulated while handling sync set changes
+ private Set parentsToUpdate = new HashSet();
+
/* (non-Javadoc)
* @see org.eclipse.team.ccvs.syncviews.views.SyncSetContentProvider#getElements(java.lang.Object)
*/
@@ -32,11 +39,14 @@ public class SyncSetTreeContentProvider extends SyncSetContentProvider implement
*/
public Object[] getChildren(Object element) {
IResource resource = getResource(element);
+ IResource[] children;
if (resource != null) {
- return members(resource);
+ children = getSyncInfoSet().members(resource);
} else {
- return members(ResourcesPlugin.getWorkspace().getRoot());
+ // TODO: This doesn't make sense!
+ children = getSyncInfoSet().members(ResourcesPlugin.getWorkspace().getRoot());
}
+ return getModelObjects(children);
}
/* (non-Javadoc)
@@ -56,7 +66,13 @@ public class SyncSetTreeContentProvider extends SyncSetContentProvider implement
return getModelObject(parent);
}
+ /**
+ * Return the <code>AbstractTreeViewer</code> asociated with this content provider
+ * or <code>null</code> if the viewer is not of the proper type.
+ * @return
+ */
public AbstractTreeViewer getTreeViewer() {
+ StructuredViewer viewer = getViewer();
if (viewer instanceof AbstractTreeViewer) {
return (AbstractTreeViewer)viewer;
}
@@ -64,6 +80,29 @@ public class SyncSetTreeContentProvider extends SyncSetContentProvider implement
}
/* (non-Javadoc)
+ * @see org.eclipse.team.internal.ui.synchronize.views.SyncSetContentProvider#handleChanges(org.eclipse.team.core.subscribers.ISyncInfoSetChangeEvent)
+ */
+ protected void handleChanges(ISyncInfoSetChangeEvent event) {
+ super.handleChanges(event);
+ updateParentLabels();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.internal.ui.synchronize.views.SyncSetContentProvider#handleResourceChanges(org.eclipse.team.core.subscribers.ISyncInfoSetChangeEvent)
+ */
+ protected void handleResourceChanges(ISyncInfoSetChangeEvent event) {
+ super.handleResourceChanges(event);
+ AbstractTreeViewer tree = getTreeViewer();
+ if (tree != null) {
+ SyncInfo[] infos = event.getChangedResources();
+ for (int i = 0; i < infos.length; i++) {
+ SyncInfo info = infos[i];
+ updateParentLabels(info.getLocal());
+ }
+ }
+ }
+
+ /* (non-Javadoc)
* @see org.eclipse.team.ccvs.syncviews.views.SyncSetContentProvider#handleResourceAdditions(org.eclipse.team.ccvs.syncviews.views.SyncSetChangedEvent)
*/
protected void handleResourceAdditions(ISyncInfoSetChangeEvent event) {
@@ -73,7 +112,7 @@ public class SyncSetTreeContentProvider extends SyncSetContentProvider implement
// TODO: Should group added roots by their parent
for (int i = 0; i < added.length; i++) {
IResource resource = added[i];
- Object parent = getModelParent(resource);
+ Object parent = getModelObject(resource.getParent());
Object element = getModelObject(resource);
tree.add(parent, element);
updateParentLabels(resource);
@@ -102,7 +141,34 @@ public class SyncSetTreeContentProvider extends SyncSetContentProvider implement
}
}
- protected Object getModelParent(IResource resource) {
- return getModelObject(resource.getParent());
+ /**
+ * Forces the viewer to update the labels for parents whose children have changed
+ * during this round of sync set changes.
+ */
+ protected void updateParentLabels() {
+ try {
+ getViewer().update(
+ parentsToUpdate.toArray(new Object[parentsToUpdate.size()]),
+ null
+ );
+ } finally {
+ parentsToUpdate.clear();
+ }
+ }
+
+ /**
+ * Forces the viewer to update the labels for parents of this element. This
+ * can be useful when parents labels include information about their children
+ * that needs updating when a child changes.
+ * <p>
+ * This method should only be called while processing sync set changes.
+ * Changed parents are accumulated and updated at the end of the change processing
+ */
+ protected void updateParentLabels(IResource resource) {
+ IResource parent = resource.getParent();
+ while(parent.getType() != IResource.ROOT) {
+ parentsToUpdate.add(getModelObject(parent));
+ parent = parent.getParent();
+ }
}
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/views/SyncViewerSorter.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/content/SyncViewerSorter.java
index 8a41e8042..323c31632 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/views/SyncViewerSorter.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/content/SyncViewerSorter.java
@@ -8,7 +8,7 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.team.internal.ui.synchronize.views;
+package org.eclipse.team.ui.synchronize.content;
import org.eclipse.core.resources.IResource;
import org.eclipse.jface.viewers.Viewer;
@@ -65,6 +65,6 @@ public class SyncViewerSorter extends ResourceSorter {
}
protected IResource getResource(Object obj) {
- return SyncSetContentProvider.getResource(obj);
+ return SyncInfoSetContentProvider.getResource(obj);
}
}
diff --git a/tests/org.eclipse.team.tests.cvs.core/launchConfigurations/One CVS Test.launch b/tests/org.eclipse.team.tests.cvs.core/launchConfigurations/One CVS Test.launch
index a7e192ca2..1bc7f7908 100644
--- a/tests/org.eclipse.team.tests.cvs.core/launchConfigurations/One CVS Test.launch
+++ b/tests/org.eclipse.team.tests.cvs.core/launchConfigurations/One CVS Test.launch
@@ -1,17 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<launchConfiguration type="org.eclipse.pde.ui.JunitLaunchConfig">
<booleanAttribute key="clearws" value="true"/>
-<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.team.tests.ccvs.core.subscriber.AllTestsTeamSubscriber"/>
-<stringAttribute key="vmargs" value="-Declipse.cvs.properties=c:\eclipse\repository.properties -Declipse.cvs.testName2=testIncomingChanges"/>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.team.tests.ccvs.core.subscriber.CVSWorkspaceSubscriberTest"/>
+<booleanAttribute key="tracing" value="false"/>
<booleanAttribute key="default" value="true"/>
+<stringAttribute key="vmargs" value="-Declipse.cvs.properties=c:\eclipse\repository.properties -Declipse.cvs.testName=testUpdateBinaryConflict"/>
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
+<stringAttribute key="onePluginID" value=""/>
<stringAttribute key="progargs" value="-os win32 -ws win32 -arch x86 -nl en_CA"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.team.tests.cvs.core"/>
<booleanAttribute key="askclear" value="false"/>
-<stringAttribute key="location0" value="C:\Eclipse\Latest-Eclipse-Drop\eclipse\runtime-test-workspace"/>
+<booleanAttribute key="onePlugin" value="false"/>
<stringAttribute key="application" value="org.eclipse.pde.junit.runtime.uitestapplication"/>
+<stringAttribute key="location0" value="C:\Eclipse\Latest-Eclipse-Drop\eclipse\runtime-test-workspace"/>
<stringAttribute key="org.eclipse.debug.core.source_locator_id" value="org.eclipse.jdt.debug.ui.javaSourceLocator"/>
</launchConfiguration>

Back to the top