Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2004-01-30 16:25:21 -0500
committerMichael Valenta2004-01-30 16:25:21 -0500
commit51212d62503bd84adb3d9920d0a8e3301e222c22 (patch)
tree21d45537a59e60f71bf813b9c1f27a29e1c5c4a7
parent8179153a3bb8af7e406e4009d56b07e41f2ef7b8 (diff)
downloadeclipse.platform.team-51212d62503bd84adb3d9920d0a8e3301e222c22.tar.gz
eclipse.platform.team-51212d62503bd84adb3d9920d0a8e3301e222c22.tar.xz
eclipse.platform.team-51212d62503bd84adb3d9920d0a8e3301e222c22.zip
*** empty log message ***
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CVSAction.java5
-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/src/org/eclipse/team/internal/ui/synchronize/actions/OpenFileInSystemEditorAction.java9
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/OpenWithActionGroup.java8
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/RefactorActionGroup.java23
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/views/TreeViewerUtils.java22
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/DiffTreeViewerConfiguration.java42
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoDiffCheckboxTreeViewer.java11
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoDiffNode.java83
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoDiffNodeRoot.java59
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoDiffTreeViewer.java11
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoSetCheckboxCompareInput.java5
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/actions/RefreshAction.java6
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/views/CompressedFolderContentProvider.java256
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/views/CompressedFolderDiffNode.java5
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/views/CompressedFolderDiffNodeBuilder.java203
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/views/CompressedFolderDiffNodeRoot.java29
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/views/SyncInfoDiffNodeBuilder.java330
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/views/SyncInfoSetContentProvider.java265
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/views/SyncInfoSetTreeContentProvider.java135
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/views/SyncViewerSorter.java3
21 files changed, 729 insertions, 785 deletions
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CVSAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CVSAction.java
index 258c8f214..00d737c59 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CVSAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CVSAction.java
@@ -470,7 +470,10 @@ abstract public class CVSAction extends TeamAction implements IEditorActionDeleg
while(it.hasNext()) {
Object element = it.next();
if(element instanceof SyncInfoDiffNode) {
- resources.add(((SyncInfoDiffNode)element).getResource());
+ IResource resource = ((SyncInfoDiffNode)element).getResource();
+ if (resource != null) {
+ resources.add(resource);
+ }
} else {
Object adapter = getAdapter(element, IResource.class);
if (adapter instanceof IResource) {
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 2e7e087a6..5e79c3946 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,12 +20,12 @@ import org.eclipse.team.core.subscribers.*;
import org.eclipse.team.internal.ccvs.core.CVSSyncInfo;
import org.eclipse.team.internal.ccvs.core.ICVSRemoteResource;
import org.eclipse.team.ui.synchronize.SyncInfoDiffNode;
-import org.eclipse.team.ui.synchronize.views.SyncInfoSetTreeContentProvider;
+import org.eclipse.team.ui.synchronize.views.SyncInfoSetContentProvider;
/**
* Seeing change comments makes sense it two ways.
*/
-public class ChangeLogContentProvider extends SyncInfoSetTreeContentProvider {
+public class ChangeLogContentProvider extends SyncInfoSetContentProvider {
private Map commentRoots = new HashMap();
// private SyncInfoSetContentProvider oldProvider;
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 691bfebfa..2a5efc2a2 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
@@ -10,14 +10,11 @@
*******************************************************************************/
package org.eclipse.team.internal.ui.synchronize.actions;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
+import java.util.*;
import org.eclipse.core.resources.IResource;
import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.team.ui.synchronize.views.SyncInfoSetContentProvider;
+import org.eclipse.team.internal.ui.synchronize.views.TreeViewerUtils;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.actions.OpenFileAction;
@@ -35,7 +32,7 @@ public class OpenFileInSystemEditorAction extends OpenFileAction {
IStructuredSelection selection = getStructuredSelection();
for (Iterator e = selection.iterator(); e.hasNext();) {
Object next = e.next();
- IResource resource = SyncInfoSetContentProvider.getResource(next);
+ IResource resource = TreeViewerUtils.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 62432668a..e34a484cc 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.TreeViewerUtils;
import org.eclipse.team.ui.synchronize.*;
-import org.eclipse.team.ui.synchronize.views.SyncInfoSetContentProvider;
import org.eclipse.ui.actions.ActionGroup;
import org.eclipse.ui.actions.OpenWithMenu;
import org.eclipse.ui.views.navigator.ResourceNavigatorMessages;
@@ -60,7 +60,7 @@ public class OpenWithActionGroup extends ActionGroup {
if (selection == null || selection.size() != 1)
return;
Object element = selection.getFirstElement();
- IResource resource = getResource(element);
+ IResource resource = TreeViewerUtils.getResource(element);
if (!(resource instanceof IFile)) {
return;
}
@@ -90,10 +90,6 @@ public class OpenWithActionGroup extends ActionGroup {
openFileAction.run();
}
}
-
- private IResource getResource(Object obj) {
- return SyncInfoSetContentProvider.getResource(obj);
- }
public void openInCompareEditor() {
openInCompareAction.run();
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 242cb47c6..ebca84301 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
@@ -10,9 +10,7 @@
*******************************************************************************/
package org.eclipse.team.internal.ui.synchronize.actions;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
+import java.util.*;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IAdaptable;
@@ -22,18 +20,9 @@ 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.ui.synchronize.views.SyncInfoSetContentProvider;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IKeyBindingService;
-import org.eclipse.ui.ISharedImages;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchPartSite;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.actions.ActionGroup;
-import org.eclipse.ui.actions.DeleteResourceAction;
-import org.eclipse.ui.actions.MoveResourceAction;
-import org.eclipse.ui.actions.RenameResourceAction;
-import org.eclipse.ui.actions.TextActionHandler;
+import org.eclipse.team.internal.ui.synchronize.views.TreeViewerUtils;
+import org.eclipse.ui.*;
+import org.eclipse.ui.actions.*;
/**
* This action group is modeled after the class of the same name in
@@ -80,7 +69,7 @@ public class RefactorActionGroup extends ActionGroup {
List resources = new ArrayList();
Iterator it = selection.iterator();
while(it.hasNext()) {
- IResource resource = SyncInfoSetContentProvider.getResource(it.next());
+ IResource resource = TreeViewerUtils.getResource(it.next());
if(resource != null) {
resources.add(resource);
}
@@ -140,7 +129,7 @@ public class RefactorActionGroup extends ActionGroup {
resource = (IResource)adaptable.getAdapter(IResource.class);
}
if(resource == null) {
- resource = SyncInfoSetContentProvider.getResource(next);
+ resource = TreeViewerUtils.getResource(next);
}
if (resource == null || (resource.getType() & resourceMask) == 0) {
return false;
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/views/TreeViewerUtils.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/views/TreeViewerUtils.java
index 88df62aab..e00abc34c 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/views/TreeViewerUtils.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/views/TreeViewerUtils.java
@@ -10,9 +10,12 @@
*******************************************************************************/
package org.eclipse.team.internal.ui.synchronize.views;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.viewers.*;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.team.core.subscribers.SyncInfo;
public class TreeViewerUtils {
@@ -173,4 +176,23 @@ public class TreeViewerUtils {
return item;
}
+ /**
+ * Returns the implementation of SyncInfo for the given
+ * object. Returns <code>null</code> if the adapter is not defined or the
+ * object is not adaptable.
+ */
+ public static SyncInfo getSyncInfo(Object o) {
+ if (!(o instanceof IAdaptable)) {
+ return null;
+ }
+ return (SyncInfo) ((IAdaptable) o).getAdapter(SyncInfo.class);
+ }
+
+ public static IResource getResource(Object obj) {
+ SyncInfo info = getSyncInfo(obj);
+ if (info != null) {
+ return info.getLocal();
+ }
+ return null;
+ }
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/DiffTreeViewerConfiguration.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/DiffTreeViewerConfiguration.java
index be9d3db1e..212ca58e1 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/DiffTreeViewerConfiguration.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/DiffTreeViewerConfiguration.java
@@ -10,9 +10,6 @@
*******************************************************************************/
package org.eclipse.team.ui.synchronize;
-import java.util.ArrayList;
-
-import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.jface.action.*;
import org.eclipse.jface.util.IPropertyChangeListener;
@@ -104,7 +101,10 @@ public class DiffTreeViewerConfiguration implements IPropertyChangeListener {
* @return the viewer input
*/
protected SyncInfoDiffNode getInput() {
- return new SyncInfoDiffNode(getSyncSet(), ResourcesPlugin.getWorkspace().getRoot());
+ if (getShowCompressedFolders()) {
+ return new CompressedFolderDiffNodeRoot(getSyncSet(), ResourcesPlugin.getWorkspace().getRoot());
+ }
+ return new SyncInfoDiffNodeRoot(getSyncSet(), ResourcesPlugin.getWorkspace().getRoot());
}
/**
@@ -122,10 +122,7 @@ public class DiffTreeViewerConfiguration implements IPropertyChangeListener {
}
protected IStructuredContentProvider getContentProvider() {
- if(getShowCompressedFolders()) {
- return new CompressedFolderContentProvider();
- }
- return new SyncInfoSetTreeContentProvider();
+ return new SyncInfoSetContentProvider();
}
protected ViewerSorter getViewSorter() {
@@ -260,33 +257,6 @@ public class DiffTreeViewerConfiguration implements IPropertyChangeListener {
}
/**
- * Callback that is used to convert resource label change events into
- * label change events on the model objects (namely <code>SyncInfoDiffNode</code>
- * instances. Any provided objects that cannot be converted to resources are
- * returned as-is in the resulting array.
- * @param viewer the viewer
- * @param changed the changed objects
- * @return the changed objects converted to diff model objects if possible
- */
- protected Object[] asModelObjects(StructuredViewer viewer, Object[] changed) {
- if (changed != null && viewer.getInput() != null) {
- ArrayList others= new ArrayList();
- for (int i= 0; i < changed.length; i++) {
- Object curr = changed[i];
- if (curr instanceof IResource) {
- IContentProvider provider = viewer.getContentProvider();
- if (provider != null && provider instanceof SyncInfoSetContentProvider) {
- curr = ((SyncInfoSetContentProvider)provider).getModelObject((IResource)curr);
- }
- }
- others.add(curr);
- }
- return others.toArray();
- }
- return null;
- }
-
- /**
* Return the menu id that is used to obtain context menu items from the workbench.
* @return the menuId.
*/
@@ -309,7 +279,7 @@ public class DiffTreeViewerConfiguration implements IPropertyChangeListener {
*/
public void propertyChange(PropertyChangeEvent event) {
if (viewer != null && event.getProperty().equals(IPreferenceIds.SYNCVIEW_COMPRESS_FOLDERS)) {
- viewer.setContentProvider(getContentProvider());
+ viewer.setInput(getInput());
}
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoDiffCheckboxTreeViewer.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoDiffCheckboxTreeViewer.java
index 08a6bdc4e..74a81f4ad 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoDiffCheckboxTreeViewer.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoDiffCheckboxTreeViewer.java
@@ -31,17 +31,6 @@ public class SyncInfoDiffCheckboxTreeViewer extends ContainerCheckedTreeViewer i
configuration.initializeViewer(parent, this);
}
- protected void handleLabelProviderChanged(LabelProviderChangedEvent event) {
- Object[] changed = configuration.asModelObjects(this, event.getElements());
- if (changed != null) {
- if (changed.length == 0) {
- return;
- }
- event= new LabelProviderChangedEvent((IBaseLabelProvider) event.getSource(), changed);
- }
- super.handleLabelProviderChanged(event);
- }
-
/**
* Cleanup listeners and call super for content provider and label provider disposal.
*/
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 4a31b1621..11ea82f3c 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
@@ -12,7 +12,7 @@ package org.eclipse.team.ui.synchronize;
import org.eclipse.compare.ITypedElement;
import org.eclipse.compare.structuremergeviewer.DiffNode;
-import org.eclipse.core.resources.IContainer;
+import org.eclipse.compare.structuremergeviewer.IDiffContainer;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -29,6 +29,7 @@ public class SyncInfoDiffNode extends DiffNode implements IAdaptable, IWorkbench
private IResource resource;
private SyncInfoSet input;
private SyncInfo info;
+ private DiffNode parent;
/**
* Create an ITypedElement for the given local resource. The returned ITypedElement
@@ -55,13 +56,6 @@ public class SyncInfoDiffNode extends DiffNode implements IAdaptable, IWorkbench
private static ITypedElement createTypeElement(ISubscriberResource remoteResource) {
return new RemoteResourceTypedElement(remoteResource);
}
-
- /**
- * Creates a new diff node.
- */
- private SyncInfoDiffNode(ITypedElement base, ITypedElement local, ITypedElement remote, int syncKind) {
- super(syncKind, base, local, remote);
- }
private static ITypedElement createRemoteTypeElement(SyncInfoSet set, IResource resource) {
return createRemoteTypeElement(set.getSyncInfo(resource));
@@ -105,12 +99,19 @@ public class SyncInfoDiffNode extends DiffNode implements IAdaptable, IWorkbench
}
/**
+ * Creates a new diff node.
+ */
+ private SyncInfoDiffNode(IDiffContainer parent, ITypedElement base, ITypedElement local, ITypedElement remote, int syncKind) {
+ super(parent, syncKind, base, local, remote);
+ }
+
+ /**
* Construct a <code>SyncInfoDiffNode</code> for a resource for use in a diff tree viewer.
* @param set The set associated with the diff tree veiwer
* @param resource The resource for the node
*/
- public SyncInfoDiffNode(SyncInfoSet set, IResource resource) {
- this(createBaseTypeElement(set, resource), createLocalTypeElement(set, resource), createRemoteTypeElement(set, resource), getSyncKind(set, resource));
+ public SyncInfoDiffNode(IDiffContainer parent, SyncInfoSet set, IResource resource) {
+ this(parent, createBaseTypeElement(set, resource), createLocalTypeElement(set, resource), createRemoteTypeElement(set, resource), getSyncKind(set, resource));
this.input = set;
this.resource = resource;
this.info = null;
@@ -123,12 +124,12 @@ public class SyncInfoDiffNode extends DiffNode implements IAdaptable, IWorkbench
* @param info The <code>SyncInfo</code> for a resource
*/
public SyncInfoDiffNode(SyncInfo info) {
- this(createBaseTypeElement(info), createLocalTypeElement(info), createRemoteTypeElement(info), info.getKind());
+ this(null, createBaseTypeElement(info), createLocalTypeElement(info), createRemoteTypeElement(info), info.getKind());
this.info = info;
this.input = null;
this.resource = info.getLocal();
}
-
+
/* (non-Javadoc)
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
*/
@@ -159,7 +160,7 @@ public class SyncInfoDiffNode extends DiffNode implements IAdaptable, IWorkbench
* that are descendants of this node in the diff viewer.
*/
public SyncInfo[] getDescendantSyncInfos() {
- if(input != null) {
+ if(input != null && getResource() != null) {
return input.getOutOfSyncDescendants(resource);
} else if(info != null) {
return new SyncInfo[] {info};
@@ -173,9 +174,11 @@ public class SyncInfoDiffNode extends DiffNode implements IAdaptable, IWorkbench
* @return true has the same subsriber and resource
*/
public boolean equals(Object object) {
- if (object instanceof SyncInfoDiffNode) {
- SyncInfoDiffNode syncViewNode = (SyncInfoDiffNode) object;
- return getResource().equals(syncViewNode.getResource());
+ if (object == this) {
+ return true;
+ }
+ if (!object.getClass().equals(this.getClass())) {
+ return false;
}
return super.equals(object);
}
@@ -184,7 +187,11 @@ public class SyncInfoDiffNode extends DiffNode implements IAdaptable, IWorkbench
* @see java.lang.Object#hashCode()
*/
public int hashCode() {
- return getResource().hashCode();
+ IResource resource = getResource();
+ if (resource == null) {
+ return super.hashCode();
+ }
+ return resource.hashCode();
}
/**
@@ -198,7 +205,7 @@ public class SyncInfoDiffNode extends DiffNode implements IAdaptable, IWorkbench
* @see java.lang.Object#toString()
*/
public String toString() {
- return "SyncInfoDiffNode for " + getResource().getFullPath().toString(); //$NON-NLS-1$
+ return getName();
}
/**
@@ -230,19 +237,6 @@ public class SyncInfoDiffNode extends DiffNode implements IAdaptable, IWorkbench
return input;
}
- /* (non-Javadoc)
- * @see org.eclipse.compare.structuremergeviewer.IDiffContainer#hasChildren()
- */
- public boolean hasChildren() {
- if(input != null) {
- if(getResource().getType() == IResource.ROOT) return true;
- SyncInfo[] info = input.getOutOfSyncDescendants(getResource());
- if(info != null && info.length > 0)
- return true;
- }
- return false;
- }
-
/**
* Indicates whether the diff node represents a resource path or a single level.
* This is used by the <code>SyncViewerSorter</code> to determine whether to compare
@@ -260,7 +254,7 @@ public class SyncInfoDiffNode extends DiffNode implements IAdaptable, IWorkbench
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 (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;
@@ -279,15 +273,7 @@ public class SyncInfoDiffNode extends DiffNode implements IAdaptable, IWorkbench
* @see org.eclipse.ui.model.IWorkbenchAdapter#getChildren(java.lang.Object)
*/
public Object[] getChildren(Object o) {
- if(input != null) {
- IResource[] children = input.members(getResource());
- SyncInfoDiffNode[] nodes = new SyncInfoDiffNode[children.length];
- for (int i = 0; i < children.length; i++) {
- nodes[i] = new SyncInfoDiffNode(getSyncInfoSet(), children[i]);
- }
- return nodes;
- }
- return new SyncInfo[0];
+ return getChildren();
}
/* (non-Javadoc)
@@ -295,6 +281,9 @@ public class SyncInfoDiffNode extends DiffNode implements IAdaptable, IWorkbench
*/
public ImageDescriptor getImageDescriptor(Object object) {
IResource resource = getResource();
+ if (resource == null) {
+ return null;
+ }
IWorkbenchAdapter adapter = (IWorkbenchAdapter)((IAdaptable) resource).getAdapter(IWorkbenchAdapter.class);
return adapter.getImageDescriptor(resource);
}
@@ -303,17 +292,17 @@ public class SyncInfoDiffNode extends DiffNode implements IAdaptable, IWorkbench
* @see org.eclipse.ui.model.IWorkbenchAdapter#getLabel(java.lang.Object)
*/
public String getLabel(Object o) {
- return getResource().getName();
+ IResource resource = getResource();
+ if (resource == null) {
+ return toString();
+ }
+ return resource.getName();
}
/* (non-Javadoc)
* @see org.eclipse.ui.model.IWorkbenchAdapter#getParent(java.lang.Object)
*/
public Object getParent(Object o) {
- IContainer parent = getResource().getParent();
- if(parent != null) {
- return new SyncInfoDiffNode(getSyncInfoSet(), parent);
- }
- return null;
+ return getParent();
}
} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoDiffNodeRoot.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoDiffNodeRoot.java
new file mode 100644
index 000000000..9a1f5ce07
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoDiffNodeRoot.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.team.ui.synchronize;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.viewers.AbstractTreeViewer;
+import org.eclipse.team.core.subscribers.SyncInfoSet;
+import org.eclipse.team.ui.synchronize.views.SyncInfoDiffNodeBuilder;
+
+/**
+ * @author Administrator
+ *
+ * To change the template for this generated type comment go to
+ * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
+ */
+public class SyncInfoDiffNodeRoot extends SyncInfoDiffNode {
+
+ SyncInfoDiffNodeBuilder builder;
+
+ /**
+ * @param set
+ * @param resource
+ */
+ public SyncInfoDiffNodeRoot(SyncInfoSet set, IResource resource) {
+ super(null, set, resource);
+ builder = createBuilder();
+ builder.buildTree();
+ }
+
+ /**
+ * @return
+ */
+ protected SyncInfoDiffNodeBuilder createBuilder() {
+ return new SyncInfoDiffNodeBuilder(this);
+ }
+
+ /**
+ *
+ */
+ public void dispose() {
+ builder.dispose();
+ }
+
+ /**
+ * @param viewer
+ */
+ public void setViewer(AbstractTreeViewer viewer) {
+ builder.setViewer(viewer);
+ }
+
+}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoDiffTreeViewer.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoDiffTreeViewer.java
index 45213c3be..3c1c36ce7 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoDiffTreeViewer.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoDiffTreeViewer.java
@@ -29,17 +29,6 @@ public class SyncInfoDiffTreeViewer extends TreeViewer implements INavigatable,
configuration.initializeViewer(parent, this);
}
- protected void handleLabelProviderChanged(LabelProviderChangedEvent event) {
- Object[] changed = configuration.asModelObjects(this, event.getElements());
- if (changed != null) {
- if (changed.length == 0) {
- return;
- }
- event= new LabelProviderChangedEvent((IBaseLabelProvider) event.getSource(), changed);
- }
- super.handleLabelProviderChanged(event);
- }
-
/**
* Cleanup listeners and call super for content provider and label provider disposal.
*/
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoSetCheckboxCompareInput.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoSetCheckboxCompareInput.java
index 2ff235d7b..00a2e411c 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoSetCheckboxCompareInput.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoSetCheckboxCompareInput.java
@@ -74,7 +74,10 @@ public class SyncInfoSetCheckboxCompareInput extends SyncInfoSetCompareInput {
SyncInfoDiffNode node = (SyncInfoDiffNode) element;
SyncInfo syncInfo = node.getSyncInfo();
if (syncInfo != null && syncInfo.getKind() != 0) {
- result.add(node.getResource());
+ IResource resource = node.getResource();
+ if (resource != null) {
+ result.add(resource);
+ }
}
}
}
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 deb199fd5..072afcb68 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,8 +20,8 @@ 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.*;
-import org.eclipse.team.ui.synchronize.views.SyncInfoSetContentProvider;
+import org.eclipse.team.internal.ui.synchronize.IRefreshSubscriberListener;
+import org.eclipse.team.internal.ui.synchronize.views.TreeViewerUtils;
/**
* A general refresh action that will refresh a subscriber in the background.
@@ -73,7 +73,7 @@ public class RefreshAction extends Action {
List resources = new ArrayList();
Iterator it = selection.iterator();
while(it.hasNext()) {
- IResource resource = SyncInfoSetContentProvider.getResource(it.next());
+ IResource resource = TreeViewerUtils.getResource(it.next());
if(resource != null) {
resources.add(resource);
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/views/CompressedFolderContentProvider.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/views/CompressedFolderContentProvider.java
deleted file mode 100644
index c250027d0..000000000
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/views/CompressedFolderContentProvider.java
+++ /dev/null
@@ -1,256 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.ui.synchronize.views;
-
-import java.util.*;
-
-import org.eclipse.core.resources.*;
-import org.eclipse.jface.viewers.AbstractTreeViewer;
-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;
-
-/**
- * The contents provider compressed in-sync folder paths
- */
-public class CompressedFolderContentProvider extends SyncInfoSetTreeContentProvider {
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ui.synchronize.views.SyncSetContentProvider#handleResourceChanges(org.eclipse.team.core.subscribers.ISyncInfoSetChangeEvent)
- */
- protected void handleResourceChanges(ISyncInfoSetChangeEvent event) {
- AbstractTreeViewer tree = getTreeViewer();
- if (tree != null) {
- SyncInfo[] infos = event.getChangedResources();
-
- // Determine if any folders changed sync state
- Set projectsToRefresh = new HashSet();
- for (int i = 0; i < infos.length; i++) {
- SyncInfo info = infos[i];
- if (info.getLocal().getType() != IResource.FILE) {
- // For folder sync changes, we refresh the whole project
- // so that any compressed folders are adjusted properly
- // (as rebalancing is tricky)
- // TODO: Perhaps this could be optimized
- projectsToRefresh.add(info.getLocal().getProject());
- }
- }
- if (!projectsToRefresh.isEmpty()) {
-
- // Exclude any resources whose project will be refreshed
- // Create a new event
- SyncSetChangedEvent remainingChanges = new SyncSetChangedEvent(event.getSet());
- for (int i = 0; i < infos.length; i++) {
- SyncInfo info = infos[i];
- if (!projectsToRefresh.contains(info.getLocal().getProject())) {
- remainingChanges.changed(info);
- }
- }
- // Refresh the projects
- for (Iterator iter = projectsToRefresh.iterator(); iter.hasNext();) {
- IResource resource = (IResource) iter.next();
- tree.refresh(getModelObject(resource), true);
- }
- event = remainingChanges;
- }
- }
- super.handleResourceChanges(event);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ui.sync.views.SyncSetContentProvider#handleResourceAdditions(org.eclipse.team.internal.ui.sync.views.SyncSetChangedEvent)
- */
- protected void handleResourceAdditions(ISyncInfoSetChangeEvent event) {
- AbstractTreeViewer tree = getTreeViewer();
- if (tree != null) {
- IResource[] roots = event.getAddedRoots();
- for (int i = 0; i < roots.length; i++) {
- IResource resource = roots[i];
- if (resource.getType() == IResource.PROJECT) {
- // Add the project
- tree.add(getModelObject(resource.getParent()), getModelObject(resource));
- updateParentLabels(resource);
- } else {
- // TODO: Refresh the resources project for now
- // because trying to rebalance compressed folder may be tricky
- // perhaps we could be smarter
- tree.refresh(getModelObject(resource.getProject()), true);
- }
- }
- } else {
- super.handleResourceAdditions(event);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ui.sync.views.SyncSetContentProvider#handleResourceRemovals(org.eclipse.team.internal.ui.sync.views.SyncSetChangedEvent)
- */
- protected void handleResourceRemovals(ISyncInfoSetChangeEvent event) {
- AbstractTreeViewer tree = getTreeViewer();
- if (tree != null) {
- IResource[] roots = event.getRemovedRoots();
- IResource[] resources = event.getRemovedResources();
- Set removals = new HashSet();
-
- // First, deal with any projects that have been removed
- List remainingRoots = new ArrayList();
- for (int i = 0; i < roots.length; i++) {
- IResource resource = roots[i];
- if (resource.getType() == IResource.PROJECT) {
- removals.add(getModelObject(resource));
- } else {
- remainingRoots.add(resource);
- }
- }
- roots = (IResource[]) remainingRoots.toArray(new IResource[remainingRoots.size()]);
-
- // Then determine the other model objects that must be removed
- if (roots.length > 0) {
- for (int i = 0; i < resources.length; i++) {
- IResource resource = resources[i];
- if (isChildOfRoot(resource, roots) || isCompressedParentEmpty(resource)) {
- // A root of the resource has also been removed.
- // However, the resource's model parent would be a
- // compressed folder on the resource's parent folder.
- removals.add(getModelObject(resource.getParent()));
- updateParentLabels(resource);
- } else {
- // The resources parent still has children so just remove
- // the resource's model object
- removals.add(getModelObject(resource));
- updateParentLabels(resource);
- }
- }
- }
- tree.remove(removals.toArray(new Object[removals.size()]));
- } else {
- super.handleResourceRemovals(event);
- }
- }
-
- private boolean isCompressedParentEmpty(IResource resource) {
- IContainer parent = resource.getParent();
- if (parent == null
- || parent.getType() == IResource.ROOT
- || parent.getType() == IResource.PROJECT) {
- return false;
- }
- // Check if the sync set has any file children of the parent
- IResource[] members = getSyncInfoSet().members(parent);
- for (int i = 0; i < members.length; i++) {
- IResource member = members[i];
- if (member.getType() == IResource.FILE) {
- return false;
- }
- }
- // The parent does not contain any files
- return true;
- }
-
- private boolean isChildOfRoot(IResource resource, IResource[] roots) {
- for (int i = 0; i < roots.length; i++) {
- IResource root = roots[i];
- if (!root.equals(resource)
- && root.getFullPath().isPrefixOf(resource.getFullPath())) {
- return true;
- }
- }
- return false;
- }
-
- public Object getParent(Object element) {
- if (element instanceof CompressedFolderDiffNode) {
- // The parent of a compressed folder is always the project
- return getModelObject(getResource(element).getProject());
- }
- Object parent = super.getParent(element);
- if (parent instanceof SyncInfoDiffNode) {
- SyncInfo info = ((SyncInfoDiffNode)parent).getSyncInfo();
- if (info == null) {
- // The resource is in-sync so return a compressed folder
- IResource resource = ((SyncInfoDiffNode)parent).getResource();
- if (resource.getType() == IResource.FOLDER) {
- return new CompressedFolderDiffNode(((SyncInfoDiffNode)parent).getSyncInfoSet(), resource);
-
- }
- }
- }
- return parent;
- }
-
- public Object[] getChildren(Object element) {
- IResource resource = getResource(element);
- if (resource != null) {
- if (resource.getType() == IResource.PROJECT) {
- return getProjectChildren((IProject)resource);
- } else if (resource.getType() == IResource.FOLDER) {
- return getFolderChildren(resource);
- }
- }
- return super.getChildren(element);
- }
-
- private Object[] getFolderChildren(IResource resource) {
- // Folders will only contain out-of-sync children
- IResource[] children = getSyncInfoSet().members(resource);
- List result = new ArrayList();
- for (int i = 0; i < children.length; i++) {
- IResource child = children[i];
- SyncInfo info = getSyncInfoSet().getSyncInfo(child);
- if (info != null) {
- result.add(getModelObject(info.getLocal()));
- }
- }
- return result.toArray(new Object[result.size()]);
- }
-
- private Object[] getProjectChildren(IProject project) {
- SyncInfo[] outOfSync = getSyncInfoSet().getOutOfSyncDescendants(project);
- Set result = new HashSet();
- for (int i = 0; i < outOfSync.length; i++) {
- SyncInfo info = outOfSync[i];
- IResource local = info.getLocal();
- if (local.getProjectRelativePath().segmentCount() == 1) {
- // If the resource is a child of the project, include it uncompressed
- result.add(getModelObject(local));
- } else {
- IContainer container = getLowestInSyncParent(local);
- if (container.getType() == IResource.FOLDER) {
- result.add(getModelObject(container));
- }
- }
- }
- return result.toArray(new Object[result.size()]);
- }
-
- /**
- * Return a compressed folder if the provided resource is an in-sync folder.
- * Warning: This method will return a compressed folder for any in-sync
- * folder, even those that do not contain out-of-sync resources (i.e. those that
- * are not visible in the view).
- */
- public Object getModelObject(IResource resource) {
- if (resource.getType() == IResource.FOLDER && getSyncInfoSet().getSyncInfo(resource) == null) {
- return new CompressedFolderDiffNode(getSyncInfoSet(), resource);
- }
- return super.getModelObject(resource);
- }
-
- private IContainer getLowestInSyncParent(IResource resource) {
- if (resource.getType() == IResource.ROOT) return (IContainer)resource;
- IContainer parent = resource.getParent();
- if (getSyncInfoSet().getSyncInfo(parent) == null) {
- return parent;
- }
- return getLowestInSyncParent(parent);
- }
-}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/views/CompressedFolderDiffNode.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/views/CompressedFolderDiffNode.java
index 6ebed654a..a7e1ff2a9 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/views/CompressedFolderDiffNode.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/views/CompressedFolderDiffNode.java
@@ -12,6 +12,7 @@ package org.eclipse.team.ui.synchronize.views;
import java.util.*;
+import org.eclipse.compare.structuremergeviewer.IDiffContainer;
import org.eclipse.core.resources.IResource;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.team.core.subscribers.SyncInfo;
@@ -25,8 +26,8 @@ import org.eclipse.team.ui.synchronize.SyncInfoDiffNode;
*/
public class CompressedFolderDiffNode extends SyncInfoDiffNode {
- public CompressedFolderDiffNode(SyncInfoSet input, IResource resource) {
- super(input, resource);
+ public CompressedFolderDiffNode(IDiffContainer parent, SyncInfoSet input, IResource resource) {
+ super(parent, input, resource);
}
/* (non-Javadoc)
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/views/CompressedFolderDiffNodeBuilder.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/views/CompressedFolderDiffNodeBuilder.java
new file mode 100644
index 000000000..17aa12682
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/views/CompressedFolderDiffNodeBuilder.java
@@ -0,0 +1,203 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.team.ui.synchronize.views;
+
+import java.util.*;
+
+import org.eclipse.compare.structuremergeviewer.DiffNode;
+import org.eclipse.compare.structuremergeviewer.IDiffElement;
+import org.eclipse.core.resources.*;
+import org.eclipse.jface.viewers.AbstractTreeViewer;
+import org.eclipse.team.core.subscribers.ISyncInfoSetChangeEvent;
+import org.eclipse.team.core.subscribers.SyncInfo;
+import org.eclipse.team.ui.synchronize.SyncInfoDiffNode;
+import org.eclipse.team.ui.synchronize.SyncInfoDiffNodeRoot;
+
+public class CompressedFolderDiffNodeBuilder extends SyncInfoDiffNodeBuilder {
+
+ public CompressedFolderDiffNodeBuilder(SyncInfoDiffNodeRoot root) {
+ super(root);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.ui.synchronize.views.SyncInfoDiffNodeBuilder#createChildren(org.eclipse.compare.structuremergeviewer.IDiffContainer)
+ */
+ protected IDiffElement[] createChildren(DiffNode container) {
+ if (container instanceof SyncInfoDiffNode) {
+ SyncInfoDiffNode node = (SyncInfoDiffNode)container;
+ if (node.getResource().getType() == IResource.PROJECT) {
+ return getProjectChildren(container, (IProject)node.getResource());
+ }
+ if (container instanceof CompressedFolderDiffNode) {
+ return getFolderChildren(container, node.getResource());
+ }
+ }
+ return super.createChildren(container);
+ }
+
+ private IDiffElement[] getFolderChildren(DiffNode parent, IResource resource) {
+ // Folders will only contain out-of-sync children
+ IResource[] children = getRoot().getSyncInfoSet().members(resource);
+ List result = new ArrayList();
+ for (int i = 0; i < children.length; i++) {
+ IResource child = children[i];
+ if (child.getType() == IResource.FILE) {
+ result.add(createChildNode(parent, child));
+ }
+ }
+ return (IDiffElement[])result.toArray(new IDiffElement[result.size()]);
+ }
+
+ private IDiffElement[] getProjectChildren(DiffNode parent, IProject project) {
+ SyncInfo[] outOfSync = getRoot().getSyncInfoSet().getOutOfSyncDescendants(project);
+ Set result = new HashSet();
+ Set resourcesToShow = new HashSet();
+ for (int i = 0; i < outOfSync.length; i++) {
+ SyncInfo info = outOfSync[i];
+ IResource local = info.getLocal();
+ if (local.getProjectRelativePath().segmentCount() == 1 && local.getType() == IResource.FILE) {
+ resourcesToShow.add(local);
+ } else {
+ if (local.getType() == IResource.FILE) {
+ resourcesToShow.add(local.getParent());
+ } else {
+ resourcesToShow.add(local);
+ }
+ }
+ }
+ for (Iterator iter = resourcesToShow.iterator(); iter.hasNext();) {
+ IResource resource = (IResource) iter.next();
+ result.add(createChildNode(parent, resource));
+ }
+
+ return (IDiffElement[])result.toArray(new IDiffElement[result.size()]);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.ui.synchronize.views.SyncInfoDiffNodeBuilder#createChildNode(org.eclipse.compare.structuremergeviewer.DiffNode, org.eclipse.core.resources.IResource)
+ */
+ protected SyncInfoDiffNode createChildNode(DiffNode parent, IResource resource) {
+ if (resource.getType() == IResource.FOLDER) {
+ SyncInfoDiffNode node = new CompressedFolderDiffNode(parent, getRoot().getSyncInfoSet(), resource);
+ associateDiffNode(resource, node);
+ addToViewer(node);
+ return node;
+ }
+ return super.createChildNode(parent, resource);
+ }
+
+ /**
+ * Update the viewer for the sync set additions in the provided event.
+ * This method is invoked by <code>handleChanges(ISyncInfoSetChangeEvent)</code>.
+ * Subclasses may override.
+ * @param event
+ */
+ protected void handleResourceAdditions(ISyncInfoSetChangeEvent event) {
+ SyncInfo[] infos = event.getAddedResources();
+ for (int i = 0; i < infos.length; i++) {
+ SyncInfo info = infos[i];
+ IResource local = info.getLocal();
+ if (local.getType() == IResource.FILE) {
+ DiffNode compressedNode = getModelObject(local.getParent());
+ if (compressedNode == null) {
+ DiffNode projectNode = getModelObject(local.getProject());
+ if (projectNode == null) {
+ projectNode = createChildNode(getRoot(), local.getProject());
+ }
+ compressedNode = createChildNode(projectNode, local.getParent());
+ }
+ createChildNode(compressedNode, local);
+ } else {
+ DiffNode projectNode = getModelObject(local.getProject());
+ if (projectNode == null) {
+ projectNode = createChildNode(getRoot(), local.getProject());
+ }
+ createChildNode(projectNode, local);
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.internal.ui.sync.views.SyncSetContentProvider#handleResourceRemovals(org.eclipse.team.internal.ui.sync.views.SyncSetChangedEvent)
+ */
+ protected void handleResourceRemovals(ISyncInfoSetChangeEvent event) {
+
+ IResource[] roots = event.getRemovedRoots();
+ Set removals = new HashSet();
+
+ // First, deal with any projects that have been removed
+ List remainingRoots = new ArrayList();
+ for (int i = 0; i < roots.length; i++) {
+ IResource resource = roots[i];
+ if (resource.getType() == IResource.PROJECT) {
+ removals.add(getModelObject(resource));
+// TODO: clean up hash table
+ } else {
+ remainingRoots.add(resource);
+ }
+ }
+ roots = (IResource[]) remainingRoots.toArray(new IResource[remainingRoots.size()]);
+
+ // Then determine the other model objects that must be removed
+ if (roots.length > 0) {
+ IResource[] resources = event.getRemovedResources();
+ for (int i = 0; i < resources.length; i++) {
+ IResource resource = resources[i];
+ if (isChildOfRoot(resource, roots) || isCompressedParentEmpty(resource)) {
+ // A root of the resource has also been removed.
+ // However, the resource's model parent would be a
+ // compressed folder on the resource's parent folder.
+ unassociateDiffNode(resource);
+ resource = resource.getParent();
+ }
+ DiffNode modelObject = getModelObject(resource);
+ removals.add(modelObject);
+ modelObject.getParent().removeToRoot(modelObject);
+ unassociateDiffNode(resource);
+ updateParentLabels(modelObject);
+ }
+ }
+ AbstractTreeViewer tree = getTreeViewer();
+ if (tree != null) {
+ tree.remove(removals.toArray(new Object[removals.size()]));
+ }
+ }
+
+ private boolean isCompressedParentEmpty(IResource resource) {
+ IContainer parent = resource.getParent();
+ if (parent == null
+ || parent.getType() == IResource.ROOT
+ || parent.getType() == IResource.PROJECT) {
+ return false;
+ }
+ // Check if the sync set has any file children of the parent
+ IResource[] members = getRoot().getSyncInfoSet().members(parent);
+ for (int i = 0; i < members.length; i++) {
+ IResource member = members[i];
+ if (member.getType() == IResource.FILE) {
+ return false;
+ }
+ }
+ // The parent does not contain any files
+ return true;
+ }
+
+ private boolean isChildOfRoot(IResource resource, IResource[] roots) {
+ for (int i = 0; i < roots.length; i++) {
+ IResource root = roots[i];
+ if (!root.equals(resource)
+ && root.getFullPath().isPrefixOf(resource.getFullPath())) {
+ return true;
+ }
+ }
+ return false;
+ }
+}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/views/CompressedFolderDiffNodeRoot.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/views/CompressedFolderDiffNodeRoot.java
new file mode 100644
index 000000000..c1e19e95f
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/views/CompressedFolderDiffNodeRoot.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.team.ui.synchronize.views;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.team.core.subscribers.SyncInfoSet;
+import org.eclipse.team.ui.synchronize.SyncInfoDiffNodeRoot;
+
+public class CompressedFolderDiffNodeRoot extends SyncInfoDiffNodeRoot {
+
+ public CompressedFolderDiffNodeRoot(SyncInfoSet set, IResource resource) {
+ super(set, resource);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.ui.synchronize.SyncInfoDiffNodeRoot#createBuilder()
+ */
+ protected SyncInfoDiffNodeBuilder createBuilder() {
+ return new CompressedFolderDiffNodeBuilder(this);
+ }
+}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/views/SyncInfoDiffNodeBuilder.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/views/SyncInfoDiffNodeBuilder.java
new file mode 100644
index 000000000..f704d8735
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/views/SyncInfoDiffNodeBuilder.java
@@ -0,0 +1,330 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.team.ui.synchronize.views;
+
+import java.util.*;
+
+import org.eclipse.compare.structuremergeviewer.*;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.viewers.AbstractTreeViewer;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.team.core.subscribers.*;
+import org.eclipse.team.ui.synchronize.SyncInfoDiffNode;
+import org.eclipse.team.ui.synchronize.SyncInfoDiffNodeRoot;
+
+/**
+ * @author Administrator
+ *
+ * To change the template for this generated type comment go to
+ * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
+ */
+public class SyncInfoDiffNodeBuilder implements ISyncSetChangedListener {
+
+ private AbstractTreeViewer viewer;
+ private SyncInfoDiffNodeRoot root;
+
+ // parents who need a label update accumulated while handling sync set changes
+ private Set parentsToUpdate = new HashSet();
+
+ private Map resourceMap = new HashMap();
+
+ public SyncInfoDiffNodeBuilder(SyncInfoDiffNodeRoot root) {
+ this.root = root;
+ }
+
+ /**
+ * Build the tree
+ */
+ public void buildTree() {
+ // TODO: need to ensure taht sync set doesn't change while in this method
+ buildTree(root);
+ associateDiffNode(ResourcesPlugin.getWorkspace().getRoot(), root);
+ root.getSyncInfoSet().addSyncSetChangedListener(this);
+ }
+
+ protected IDiffElement[] buildTree(DiffNode node) {
+ IDiffElement[] children = createChildren(node);
+ for (int i = 0; i < children.length; i++) {
+ IDiffElement element = children[i];
+ if (element instanceof DiffNode) {
+ buildTree((DiffNode)element);
+ }
+ }
+ return children;
+ }
+
+ protected IDiffElement[] createChildren(DiffNode container) {
+ if (container instanceof SyncInfoDiffNode) {
+ SyncInfoDiffNode parentNode = (SyncInfoDiffNode)container;
+ IResource resource = parentNode.getResource();
+ if (resource != null) {
+ IResource[] children = parentNode.getSyncInfoSet().members(resource);
+ SyncInfoDiffNode[] nodes = new SyncInfoDiffNode[children.length];
+ for (int i = 0; i < children.length; i++) {
+ nodes[i] = createChildNode(parentNode, children[i]);
+ }
+ return nodes;
+ }
+ }
+ return new IDiffElement[0];
+ }
+
+ protected void associateDiffNode(IResource childResource, SyncInfoDiffNode childNode) {
+ resourceMap.put(childResource, childNode);
+ }
+
+ protected void unassociateDiffNode(IResource childResource) {
+ resourceMap.remove(childResource);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.ccvs.syncviews.views.ISyncSetChangedListener#syncSetChanged(org.eclipse.team.ccvs.syncviews.views.SyncSetChangedEvent)
+ */
+ public void syncSetChanged(final ISyncInfoSetChangeEvent event, IProgressMonitor monitor) {
+ final Control ctrl = viewer.getControl();
+ if (ctrl != null && !ctrl.isDisposed()) {
+ ctrl.getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ if (!ctrl.isDisposed()) {
+ BusyIndicator.showWhile(ctrl.getDisplay(), new Runnable() {
+ public void run() {
+ syncSetChanged(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 syncSetChanged(ISyncInfoSetChangeEvent event) {
+ viewer.getControl().setRedraw(false);
+ if (event.isReset()) {
+ // On a reset, refresh the entire view
+ ((StructuredViewer) viewer).refresh();
+ } else {
+ 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);
+ updateParentLabels();
+ }
+
+ /**
+ * 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() {
+ return viewer;
+ }
+
+ /**
+ * Update the viewer for the sync set changes in the provided event.
+ * This method is invoked by <code>handleChanges(ISyncInfoSetChangeEvent)</code>.
+ * Subclasses may override.
+ * @param event
+ * @see #handleSyncSetChanges(SyncSetChangedEvent)
+ */
+ protected void handleResourceChanges(ISyncInfoSetChangeEvent event) {
+ // Refresh the viewer for each changed resource
+ SyncInfo[] infos = event.getChangedResources();
+ for (int i = 0; i < infos.length; i++) {
+ IResource local = infos[i].getLocal();
+ DiffNode diffNode = getModelObject(local);
+ if (diffNode != null) {
+ refreshInViewer(diffNode);
+ }
+ }
+ }
+
+ protected void refreshInViewer(DiffNode diffNode) {
+ AbstractTreeViewer tree = getTreeViewer();
+ if (tree != null) {
+ viewer.refresh(diffNode, true);
+ updateParentLabels(diffNode);
+ }
+ }
+
+ /**
+ * Update the viewer for the sync set removals in the provided event.
+ * This method is invoked by <code>handleChanges(ISyncInfoSetChangeEvent)</code>.
+ * Subclasses may override.
+ * @param event
+ */
+ protected void handleResourceRemovals(ISyncInfoSetChangeEvent event) {
+ IResource[] removedRoots = event.getRemovedRoots();
+ if (removedRoots.length == 0) return;
+ DiffNode[] nodes = new DiffNode[removedRoots.length];
+ for (int i = 0; i < nodes.length; i++) {
+ nodes[i] = getModelObject(removedRoots[i]);
+ DiffNode node = nodes[i];
+ node.getParent().removeToRoot(node);
+ //TODO: Clean up hashMap
+ updateParentLabels(node);
+ }
+ AbstractTreeViewer tree = getTreeViewer();
+ if (tree != null) {
+ tree.remove(nodes);
+ }
+ }
+
+ /**
+ * Update the viewer for the sync set additions in the provided event.
+ * This method is invoked by <code>handleChanges(ISyncInfoSetChangeEvent)</code>.
+ * Subclasses may override.
+ * @param event
+ */
+ protected void handleResourceAdditions(ISyncInfoSetChangeEvent event) {
+ IResource[] added = event.getAddedRoots();
+ for (int i = 0; i < added.length; i++) {
+ IResource resource = added[i];
+ buildSubTree(getModelObject(resource.getParent()), resource);
+ }
+ }
+
+ /**
+ * @param parent
+ * @param resource
+ * @return
+ */
+ protected DiffNode buildSubTree(DiffNode parent, IResource resource) {
+ SyncInfoDiffNode node = createChildNode(parent, resource);
+ buildTree(node);
+ return node;
+ }
+
+ protected SyncInfoDiffNode createChildNode(DiffNode parent, IResource resource) {
+ SyncInfoDiffNode node = new SyncInfoDiffNode(parent, root.getSyncInfoSet(), resource);
+ associateDiffNode(resource, node);
+ addToViewer(node);
+ return node;
+ }
+
+ protected void addToViewer(SyncInfoDiffNode node) {
+ AbstractTreeViewer tree = getTreeViewer();
+ if (tree != null) {
+ tree.add(node.getParent(), node);
+ updateParentLabels(node);
+ }
+ }
+
+ /**
+ * Forces the viewer to update the labels for parents whose children have changed
+ * during this round of sync set changes.
+ */
+ protected void updateParentLabels() {
+ try {
+ AbstractTreeViewer tree = getTreeViewer();
+ if (tree != null) {
+ tree.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(DiffNode diffNode) {
+ IDiffContainer parent = diffNode.getParent();
+ while(parent != null) {
+ parentsToUpdate.add(parent);
+ parent = parent.getParent();
+ }
+ }
+
+ /**
+ * 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 DiffNode getModelObject(IResource resource) {
+ return (DiffNode)resourceMap.get(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++) {
+ result[i] = getModelObject(resources[i]);
+ }
+ return result;
+ }
+
+ /**
+ * Associate a viewer with the builder.
+ * @param v the viewer
+ */
+ public void setViewer(AbstractTreeViewer v) {
+ this.viewer = v;
+ }
+
+ /**
+ * Dispose of the builder
+ */
+ public void dispose() {
+ resourceMap.clear();
+ root.getSyncInfoSet().removeSyncSetChangedListener(this);
+ }
+ /**
+ * @return Returns the root.
+ */
+ protected SyncInfoDiffNodeRoot getRoot() {
+ return root;
+ }
+}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/views/SyncInfoSetContentProvider.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/views/SyncInfoSetContentProvider.java
index d179fd5fe..24b9792ca 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/views/SyncInfoSetContentProvider.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/views/SyncInfoSetContentProvider.java
@@ -10,15 +10,9 @@
*******************************************************************************/
package org.eclipse.team.ui.synchronize.views;
-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;
+import org.eclipse.jface.viewers.AbstractTreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.team.ui.synchronize.SyncInfoDiffNodeRoot;
import org.eclipse.ui.model.BaseWorkbenchContentProvider;
/**
@@ -28,264 +22,35 @@ import org.eclipse.ui.model.BaseWorkbenchContentProvider;
* @see SyncInfo
* @see SyncInfoSet
*/
-public abstract class SyncInfoSetContentProvider extends BaseWorkbenchContentProvider implements IStructuredContentProvider, ISyncSetChangedListener {
+public class SyncInfoSetContentProvider extends BaseWorkbenchContentProvider {
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;
- }
- if(input instanceof SyncInfoDiffNode) {
- return ((SyncInfoDiffNode)input).getSyncInfoSet();
- }
- 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;
- }
- return getSyncInfoSet(viewer.getInput());
- }
-
/* (non-Javadoc)
* @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);
+ SyncInfoDiffNodeRoot oldNode = (SyncInfoDiffNodeRoot)oldInput;
+ SyncInfoDiffNodeRoot newNode = (SyncInfoDiffNodeRoot)newInput;
+ if (oldNode != newNode) {
+ if (oldNode != null) {
+ oldNode.dispose();
}
- if (newSyncSet != null) {
- newSyncSet.addSyncSetChangedListener(this);
+ if (newNode != null) {
+ newNode.setViewer((AbstractTreeViewer)v);
}
}
}
-
+
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.IContentProvider#dispose()
*/
public void dispose() {
- SyncInfoSet input = getSyncInfoSet();
- if (input != null) {
- input.removeSyncSetChangedListener(this);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.ccvs.syncviews.views.ISyncSetChangedListener#syncSetChanged(org.eclipse.team.ccvs.syncviews.views.SyncSetChangedEvent)
- */
- public void syncSetChanged(final ISyncInfoSetChangeEvent event, IProgressMonitor monitor) {
- final Control ctrl = viewer.getControl();
- if (ctrl != null && !ctrl.isDisposed()) {
- ctrl.getDisplay().asyncExec(new Runnable() {
- public void run() {
- if (!ctrl.isDisposed()) {
- BusyIndicator.showWhile(ctrl.getDisplay(), new Runnable() {
- public void run() {
- syncSetChanged(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 syncSetChanged(ISyncInfoSetChangeEvent event) {
- viewer.getControl().setRedraw(false);
- if (event.isReset()) {
- // On a reset, refresh the entire view
- ((StructuredViewer) viewer).refresh();
- } else {
- 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>handleChanges(ISyncInfoSetChangeEvent)</code>.
- * Subclasses may override.
- * @param event
- * @see #handleSyncSetChanges(SyncSetChangedEvent)
- */
- protected void handleResourceChanges(ISyncInfoSetChangeEvent event) {
- // Refresh the viewer for each changed resource
- SyncInfo[] infos = event.getChangedResources();
- for (int i = 0; i < infos.length; i++) {
- IResource local = infos[i].getLocal();
- ((StructuredViewer) viewer).refresh(getModelObject(local), true);
- }
- }
-
- /**
- * Update the viewer for the sync set removals in the provided event.
- * This method is invoked by <code>handleChanges(ISyncInfoSetChangeEvent)</code>.
- * Subclasses may override.
- * @param event
- */
- protected void handleResourceRemovals(ISyncInfoSetChangeEvent event) {
- // Update the viewer for each removed resource
- IResource[] removed = event.getRemovedRoots();
- for (int i = 0; i < removed.length; i++) {
- IResource resource = removed[i];
- ((StructuredViewer) viewer).refresh(getModelObject(resource));
- }
- }
-
- /**
- * Update the viewer for the sync set additions in the provided event.
- * This method is invoked by <code>handleChanges(ISyncInfoSetChangeEvent)</code>.
- * Subclasses may override.
- * @param event
- */
- protected void handleResourceAdditions(ISyncInfoSetChangeEvent event) {
- // Update the viewer for each of the added resource's parents
- IResource[] added = event.getAddedRoots();
- for (int i = 0; i < added.length; i++) {
- IResource resource = added[i];
- ((StructuredViewer) viewer).refresh(getModelObject(resource.getParent()));
+ Object input = viewer.getInput();
+ if (input instanceof SyncInfoDiffNodeRoot) {
+ ((SyncInfoDiffNodeRoot)input).dispose();
}
}
- /**
- * Return the viewer to which this content provider is associated.
- * @return the content provider's viewer
- */
- public StructuredViewer getViewer() {
- return (StructuredViewer)viewer;
- }
-
- /**
- * 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 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++) {
- result[i] = getModelObject(resources[i]);
- }
- return result;
- }
-
- /**
- * 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 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);
- }
- 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 (i.e. <code>SyncInfoDiffNode</code>).
- * Return <code>null</code> if the given
- * object does not have a corresponding IResource.
- *
- * @param element the modle object
- * @return the corresponding <code>IResource</code>
- */
- 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 (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 the model object
- * @return the sync kind of the object
- */
- public static int getSyncKind(Object element) {
- SyncInfo info = getSyncInfo(element);
- if (info != null) {
- return info.getKind();
- }
- return SyncInfo.IN_SYNC;
- }
} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/views/SyncInfoSetTreeContentProvider.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/views/SyncInfoSetTreeContentProvider.java
deleted file mode 100644
index f519de114..000000000
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/views/SyncInfoSetTreeContentProvider.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.ui.synchronize.views;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.eclipse.core.resources.IResource;
-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 <code>AbstractTreeViewer</code> using the
- * <code>SyncInfo</code> contained in a <code>SyncInfoSet</code> as the model
- */
-public class SyncInfoSetTreeContentProvider extends SyncInfoSetContentProvider implements ITreeContentProvider {
-
- // parents who need a label update accumulated while handling sync set changes
- private Set parentsToUpdate = new HashSet();
-
- /**
- * 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;
- }
- return null;
- }
-
- /* (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) {
- AbstractTreeViewer tree = getTreeViewer();
- if (tree != null) {
- IResource[] added = event.getAddedRoots();
- // TODO: Should group added roots by their parent
- for (int i = 0; i < added.length; i++) {
- IResource resource = added[i];
- Object parent = getModelObject(resource.getParent());
- Object element = getModelObject(resource);
- tree.add(parent, element);
- updateParentLabels(resource);
- }
- } else {
- super.handleResourceAdditions(event);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.ccvs.syncviews.views.SyncSetContentProvider#handleResourceRemovals(org.eclipse.team.ccvs.syncviews.views.SyncSetChangedEvent)
- */
- protected void handleResourceRemovals(ISyncInfoSetChangeEvent event) {
- AbstractTreeViewer tree = getTreeViewer();
- if (tree != null) {
- IResource[] roots = event.getRemovedRoots();
- if (roots.length == 0) return;
- Object[] modelRoots = new Object[roots.length];
- for (int i = 0; i < modelRoots.length; i++) {
- modelRoots[i] = getModelObject(roots[i]);
- updateParentLabels(roots[i]);
- }
- tree.remove(modelRoots);
- } else {
- super.handleResourceRemovals(event);
- }
- }
-
- /**
- * 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/ui/synchronize/views/SyncViewerSorter.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/views/SyncViewerSorter.java
index 67afe886c..3af53ff8c 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/views/SyncViewerSorter.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/views/SyncViewerSorter.java
@@ -12,6 +12,7 @@ package org.eclipse.team.ui.synchronize.views;
import org.eclipse.core.resources.IResource;
import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.team.internal.ui.synchronize.views.TreeViewerUtils;
import org.eclipse.team.ui.synchronize.SyncInfoDiffNode;
import org.eclipse.ui.views.navigator.ResourceSorter;
@@ -65,6 +66,6 @@ public class SyncViewerSorter extends ResourceSorter {
}
protected IResource getResource(Object obj) {
- return SyncInfoSetContentProvider.getResource(obj);
+ return TreeViewerUtils.getResource(obj);
}
}

Back to the top