Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Michel-Lemieux2004-01-30 08:28:30 -0500
committerJean Michel-Lemieux2004-01-30 08:28:30 -0500
commit6ee63155d67e693147ef46438ad3ce28a3ebf7ff (patch)
tree95402d95c0f41a3a1a0a56af0ba965ac2e5a43c7
parent512036a9589c87d541e4f9a2aa661fc275b3a539 (diff)
downloadeclipse.platform.team-6ee63155d67e693147ef46438ad3ce28a3ebf7ff.tar.gz
eclipse.platform.team-6ee63155d67e693147ef46438ad3ce28a3ebf7ff.tar.xz
eclipse.platform.team-6ee63155d67e693147ef46438ad3ce28a3ebf7ff.zip
*** empty log message ***
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSSynchronizeViewCompareConfiguration.java30
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/registry/LogicalViewDescriptor.java93
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/registry/LogicalViewRegistry.java52
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeManager.java22
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/views/CompressedFolderLabelProvider.java65
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/views/DefaultLogicalView.java66
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/views/ILogicalView.java38
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/views/LogicalViewProvider.java64
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/views/TreeViewerUtils.java4
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/DiffTreeViewerConfiguration.java99
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoDiffCheckboxTreeViewer.java2
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoDiffNode.java55
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoDiffTreeViewer.java2
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoSetCompareInput.java2
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/views/CompressedFolderContentProvider.java (renamed from bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/views/CompressedFolderContentProvider.java)9
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/views/CompressedFolderDiffNode.java (renamed from bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/views/CompressedFolder.java)23
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/views/DecoratingColorLabelProvider.java46
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/views/SyncInfoLabelDecorator.java (renamed from bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/views/SyncInfoDecoratingLabelProvider.java)124
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/views/SyncInfoLabelProvider.java64
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/views/SyncInfoSetContentProvider.java10
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/views/SyncInfoSetTreeContentProvider.java41
-rw-r--r--tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/SyncInfoSetContentProviderTest.java6
-rw-r--r--tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/views/ContentProviderTestView.java6
23 files changed, 247 insertions, 676 deletions
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSSynchronizeViewCompareConfiguration.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSSynchronizeViewCompareConfiguration.java
index b346bb2bb..cf97ca897 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSSynchronizeViewCompareConfiguration.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSSynchronizeViewCompareConfiguration.java
@@ -11,20 +11,17 @@
package org.eclipse.team.internal.ccvs.ui.subscriber;
import org.eclipse.core.resources.IResource;
-import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.*;
import org.eclipse.swt.graphics.Image;
import org.eclipse.team.internal.ccvs.ui.CVSLightweightDecorator;
import org.eclipse.team.ui.synchronize.*;
-import org.eclipse.team.ui.synchronize.views.*;
-import org.eclipse.team.ui.synchronize.views.SyncInfoLabelProvider;
+import org.eclipse.team.ui.synchronize.views.DecoratingColorLabelProvider;
+import org.eclipse.team.ui.synchronize.views.SyncInfoLabelDecorator;
public class CVSSynchronizeViewCompareConfiguration extends TeamSubscriberPageDiffTreeViewerConfiguration {
- private static class CVSLabelProvider extends SyncInfoDecoratingLabelProvider {
- protected CVSLabelProvider(SyncInfoLabelProvider syncInfoLabelProvider) {
- super(syncInfoLabelProvider);
- }
- protected String decorateText(String input, Object element) {
+ private static class CVSLabelDecorator extends LabelProvider implements ILabelDecorator {
+ public String decorateText(String input, Object element) {
String text = input;
if (element instanceof SyncInfoDiffNode) {
IResource resource = ((SyncInfoDiffNode)element).getResource();
@@ -46,15 +43,8 @@ public class CVSSynchronizeViewCompareConfiguration extends TeamSubscriberPageDi
}
return text;
}
-
- /* (non-Javadoc)
- * @see org.eclipse.team.ui.synchronize.TeamSubscriberParticipantLabelProvider#decorateImage(org.eclipse.swt.graphics.Image, java.lang.Object)
- */
- protected Image decorateImage(Image base, Object element) {
- if(element instanceof ChangeLogDiffNode) {
- //TODO: return getCompressedFolderImage();
- }
- return super.decorateImage(base, element);
+ public Image decorateImage(Image base, Object element) {
+ return base;
}
}
@@ -63,9 +53,9 @@ public class CVSSynchronizeViewCompareConfiguration extends TeamSubscriberPageDi
}
/* (non-Javadoc)
- * @see org.eclipse.team.ui.synchronize.SyncInfoSetCompareConfiguration#getLabelProvider(org.eclipse.team.ui.synchronize.content.SyncInfoLabelProvider)
+ * @see org.eclipse.team.ui.synchronize.DiffTreeViewerConfiguration#getLabelProvider()
*/
- protected ILabelProvider getLabelProvider(SyncInfoLabelProvider logicalProvider) {
- return new CVSLabelProvider(logicalProvider);
+ protected ILabelProvider getLabelProvider() {
+ return new DecoratingColorLabelProvider(new SyncInfoLabelDecorator(), new CVSLabelDecorator());
}
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/registry/LogicalViewDescriptor.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/registry/LogicalViewDescriptor.java
deleted file mode 100644
index c242be86c..000000000
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/registry/LogicalViewDescriptor.java
+++ /dev/null
@@ -1,93 +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.internal.ui.registry;
-
-import org.eclipse.core.runtime.*;
-import org.eclipse.team.internal.ui.synchronize.views.ILogicalView;
-import org.eclipse.team.internal.ui.synchronize.views.LogicalViewProvider;
-import org.eclipse.ui.internal.WorkbenchPlugin;
-
-/**
- *
- * TODO: Should have an icon
- */
-public class LogicalViewDescriptor implements ILogicalView {
-
- public static final String ATT_ID = "id"; //$NON-NLS-1$
- public static final String ATT_NAME = "name"; //$NON-NLS-1$
- public static final String ATT_CLASS = "class"; //$NON-NLS-1$
-
- private IConfigurationElement element;
- private String label;
- private String description;
- private String className;
- private String id;
- private LogicalViewProvider provider;
-
- public LogicalViewDescriptor(IConfigurationElement element, String descText) throws CoreException {
- this.element = element;
- this.description = descText;
- loadFromExtension();
- }
-
- /**
- * load a view descriptor from the registry.
- */
- private void loadFromExtension() throws CoreException {
- String identifier = element.getAttribute(ATT_ID);
- label = element.getAttribute(ATT_NAME);
- className = element.getAttribute(ATT_CLASS);
-
- // Sanity check.
- if ((label == null) || (className == null) || (identifier == null)) {
- throw new CoreException(new Status(IStatus.ERROR, element.getDeclaringExtension().getDeclaringPluginDescriptor().getUniqueIdentifier(), 0, "Invalid extension (missing label or class name): " + identifier, //$NON-NLS-1$
- null));
- }
-
- id = identifier;
- }
-
- private LogicalViewProvider createProvider() throws CoreException {
- Object obj = WorkbenchPlugin.createExtension(element, ATT_CLASS);
- return (LogicalViewProvider) obj;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.ui.synchronize.content.ILogicalView#getId()
- */
- public String getId() {
- return id;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.ui.synchronize.content.ILogicalView#getLabel()
- */
- public String getLabel() {
- return label;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.ui.synchronize.content.ILogicalView#getDescription()
- */
- public String getDescription() {
- return description;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.ui.synchronize.content.ILogicalView#getLogicalViewProvider()
- */
- public LogicalViewProvider getLogicalViewProvider() throws CoreException {
- if (provider == null) {
- provider = createProvider();
- }
- return provider;
- }
-}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/registry/LogicalViewRegistry.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/registry/LogicalViewRegistry.java
deleted file mode 100644
index e40aacb5a..000000000
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/registry/LogicalViewRegistry.java
+++ /dev/null
@@ -1,52 +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.internal.ui.registry;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.team.internal.ui.TeamUIPlugin;
-import org.eclipse.team.internal.ui.synchronize.views.ILogicalView;
-
-public class LogicalViewRegistry extends RegistryReader {
-
- private static final String TAG_LOGICAL_VIEW = "logicalView"; //$NON-NLS-1$
- private Map views = new HashMap();
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ui.registry.RegistryReader#readElement(org.eclipse.core.runtime.IConfigurationElement)
- */
- protected boolean readElement(IConfigurationElement element) {
- if (element.getName().equals(TAG_LOGICAL_VIEW)) {
- String descText = getDescription(element);
- LogicalViewDescriptor desc;
- try {
- desc = new LogicalViewDescriptor(element, descText);
- views.put(desc.getId(), desc);
- } catch (CoreException e) {
- TeamUIPlugin.log(e);
- }
- return true;
- }
- return false;
- }
-
- public ILogicalView[] getLogicalViews() {
- return (ILogicalView[])views.values().toArray(new ILogicalView[views.size()]);
- }
-
- public ILogicalView getLogicalView(String id) {
- return (ILogicalView)views.get(id);
- }
-
-}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeManager.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeManager.java
index e5c9432d4..70550813a 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeManager.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeManager.java
@@ -17,8 +17,8 @@ import org.eclipse.core.runtime.*;
import org.eclipse.jface.util.ListenerList;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.internal.ui.*;
-import org.eclipse.team.internal.ui.registry.*;
-import org.eclipse.team.internal.ui.synchronize.views.ILogicalView;
+import org.eclipse.team.internal.ui.registry.SynchronizeParticipantDescriptor;
+import org.eclipse.team.internal.ui.registry.SynchronizeParticipantRegistry;
import org.eclipse.team.ui.ITeamUIConstants;
import org.eclipse.team.ui.synchronize.*;
import org.eclipse.ui.*;
@@ -57,8 +57,6 @@ public class SynchronizeManager implements ISynchronizeManager {
private final static String CTX_PARTICIPANT_DATA = "data"; //$NON-NLS-1$
private final static String FILENAME = "syncParticipants.xml"; //$NON-NLS-1$
- private LogicalViewRegistry logicalViewRegistry;
-
/**
* Notifies a participant listeners of additions or removals
*/
@@ -505,20 +503,4 @@ public class SynchronizeManager implements ISynchronizeManager {
private void fireUpdate(ISynchronizeParticipant[] participants, int type) {
new SynchronizeViewPageNotifier().notify(participants, type);
}
-
- private synchronized LogicalViewRegistry getLogicalViewRegistry() {
- if (logicalViewRegistry == null) {
- logicalViewRegistry = new LogicalViewRegistry();
- logicalViewRegistry.readRegistry(Platform.getPluginRegistry(), TeamUIPlugin.ID, ITeamUIConstants.PT_LOGICAL_VIEWS);
- }
- return logicalViewRegistry;
- }
-
- public ILogicalView[] getLogicalViews() {
- return getLogicalViewRegistry().getLogicalViews();
- }
-
- public ILogicalView getLogicalView(String id) {
- return getLogicalViewRegistry().getLogicalView(id);
- }
} \ No newline at end of file
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
deleted file mode 100644
index 3ade5ab60..000000000
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/views/CompressedFolderLabelProvider.java
+++ /dev/null
@@ -1,65 +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.internal.ui.synchronize.views;
-
-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.views.*;
-import org.eclipse.team.ui.synchronize.views.SyncInfoLabelProvider;
-
-/**
- * Label provider for compressed folders
- */
-public class CompressedFolderLabelProvider extends SyncInfoLabelProvider {
-
- private Image compressedFolderImage;
-
- public Image getCompressedFolderImage() {
- if (compressedFolderImage == null) {
- compressedFolderImage = TeamUIPlugin.getImageDescriptor(ISharedImages.IMG_COMPRESSED_FOLDER).createImage();
- }
- return compressedFolderImage;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose()
- */
- public void dispose() {
- if (compressedFolderImage != null) {
- compressedFolderImage.dispose();
- }
- super.dispose();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
- */
- public Image getImage(Object element) {
- if (element instanceof CompressedFolder) {
- return getCompressedFolderImage();
- }
- return super.getImage(element);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
- */
- public String getText(Object element) {
- if (element instanceof CompressedFolder) {
- 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/internal/ui/synchronize/views/DefaultLogicalView.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/views/DefaultLogicalView.java
deleted file mode 100644
index e06c4d10f..000000000
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/views/DefaultLogicalView.java
+++ /dev/null
@@ -1,66 +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.internal.ui.synchronize.views;
-
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.team.internal.ui.IPreferenceIds;
-import org.eclipse.team.internal.ui.TeamUIPlugin;
-import org.eclipse.team.ui.synchronize.DiffTreeViewerConfiguration;
-import org.eclipse.team.ui.synchronize.views.SyncInfoLabelProvider;
-import org.eclipse.team.ui.synchronize.views.SyncInfoSetTreeContentProvider;
-
-public class DefaultLogicalView extends LogicalViewProvider implements IPropertyChangeListener {
-
- public DefaultLogicalView(DiffTreeViewerConfiguration configuration) {
- super(configuration);
- TeamUIPlugin.getPlugin().getPreferenceStore().addPropertyChangeListener(this);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ui.synchronize.views.LogicalViewProvider#getContentProvider()
- */
- public SyncInfoSetTreeContentProvider getContentProvider() {
- if(getShowCompressedFolders()) {
- return new CompressedFolderContentProvider();
- } else {
- return new SyncInfoSetTreeContentProvider();
- }
- }
-
- private boolean getShowCompressedFolders() {
- return TeamUIPlugin.getPlugin().getPreferenceStore().getBoolean(IPreferenceIds.SYNCVIEW_COMPRESS_FOLDERS);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ui.synchronize.views.LogicalViewProvider#getLabelProvider()
- */
- public SyncInfoLabelProvider getLabelProvider() {
- if(getShowCompressedFolders()) {
- return new CompressedFolderLabelProvider();
- } else {
- return new SyncInfoLabelProvider();
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
- */
- public void propertyChange(PropertyChangeEvent event) {
- if (event.getProperty().equals(IPreferenceIds.SYNCVIEW_COMPRESS_FOLDERS)) {
- getConfiguration().setLogicalViewProvider(this);
- }
- }
-
- public void dispose() {
- TeamUIPlugin.getPlugin().getPreferenceStore().removePropertyChangeListener(this);
- }
-}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/views/ILogicalView.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/views/ILogicalView.java
deleted file mode 100644
index d216ef333..000000000
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/views/ILogicalView.java
+++ /dev/null
@@ -1,38 +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.internal.ui.synchronize.views;
-
-import org.eclipse.core.runtime.CoreException;
-
-/**
- * This interface provides access to the information about a logical view that
- * can be used to display <code>SyncInfoDiffNode</code> instances in a
- * tree viewer.
- *
- * <p>
- * This interface is not intended to be implemented by clients. Clients who
- * want to provide a logical view should implement a <code>LogicalViewProvider</code>.
- *
- * @see LogicalViewProvider
- *
- * @since 3.0
- */
-public interface ILogicalView {
-
- String getId();
-
- String getLabel();
-
- String getDescription();
-
- LogicalViewProvider getLogicalViewProvider() throws CoreException;
-
-}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/views/LogicalViewProvider.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/views/LogicalViewProvider.java
deleted file mode 100644
index e49374ba4..000000000
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/views/LogicalViewProvider.java
+++ /dev/null
@@ -1,64 +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.internal.ui.synchronize.views;
-
-import org.eclipse.team.ui.synchronize.DiffTreeViewerConfiguration;
-import org.eclipse.team.ui.synchronize.views.*;
-import org.eclipse.ui.views.navigator.ResourceSorter;
-
-/**
- * Implementations can be contributed via extension point and used by team participants.
- * Logical Providers can be of two types:
- * 1. nature based (are applied directly to projects
- * 2. global based
- *
- * TODO: Add project nature filter to extension point
- *
- * @since 3.0
- */
-public abstract class LogicalViewProvider {
-
- private DiffTreeViewerConfiguration configuration;
-
- public LogicalViewProvider(DiffTreeViewerConfiguration configuration) {
- this.configuration = configuration;
- }
-
- /**
- * Return a content provider that can be used in a <code>TreeViewer</code>
- * to show the hiearchical structure appropriate for this provider.
- * @return a <code>SyncInfoSetTreeContentProvider</code>
- */
- public abstract SyncInfoSetTreeContentProvider getContentProvider();
-
- /**
- * Return a label provider that provides the text and image labels for
- * the logical elements associated with this provider.
- * @return
- */
- public abstract SyncInfoLabelProvider getLabelProvider();
-
- /**
- * Return the sorter to be used to sort elements from the logical view's
- * content provider.
- * @return a <code>SyncViewerSorter</code>
- */
- public SyncViewerSorter getSorter() {
- return new SyncViewerSorter(ResourceSorter.NAME);
- }
-
- protected DiffTreeViewerConfiguration getConfiguration() {
- return configuration;
- }
-
- public void dispose() {
- }
-}
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 f5c898979..88df62aab 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
@@ -24,8 +24,8 @@ public class TreeViewerUtils {
*
* @param next if <code>true</code> the next node is selected, otherwise the previous node
*/
- public static boolean gotoDifference(TreeViewer viewer, boolean next) {
- return navigate(viewer, next, false);
+ public static boolean gotoDifference(TreeViewer viewer, boolean next, boolean fireOpen) {
+ return navigate(viewer, next, fireOpen);
}
/**
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 7b7a5aafa..be9d3db1e 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
@@ -15,6 +15,8 @@ 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;
+import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.*;
import org.eclipse.swt.events.MenuEvent;
import org.eclipse.swt.events.MenuListener;
@@ -23,38 +25,26 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.team.core.subscribers.SyncInfoSet;
import org.eclipse.team.internal.core.Assert;
-import org.eclipse.team.internal.ui.Utils;
-import org.eclipse.team.internal.ui.synchronize.views.DefaultLogicalView;
-import org.eclipse.team.internal.ui.synchronize.views.LogicalViewProvider;
+import org.eclipse.team.internal.ui.*;
import org.eclipse.team.ui.synchronize.actions.ExpandAllAction;
import org.eclipse.team.ui.synchronize.views.*;
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.IWorkbenchPartSite;
import org.eclipse.ui.internal.PluginAction;
+import org.eclipse.ui.views.navigator.ResourceSorter;
/**
- * This class provides the configurability of diff viewers that contain <code>SyncInfo</code>
- * (e.g. <code>SyncInfoDiffTreeViewer</code> and <code>SyncInfoDiffCheckboxTreeViewer</code>
- * as well as instance of <code>SyncInfoSetCompareInput</code>.
- * A configuration can only be used to configure a single viewer and the lifecycle of the
- * configuration
- *
- * 1. contents diff nodes (labels, content provider, sorter)
- * 2. menus
- * 3. title
- * 4. navigation
- *
- * @see SyncInfoSetCompareInput
- * @see SyncInfoDiffTreeViewer
- * @see SyncInfoDiffCheckboxTreeViewer
+ * Configures the following behavior of a SyncInfoDiffTreeViewer:
+ * <ul>
+ * <li>context menus
+ * <li>
* @since 3.0
*/
-public class DiffTreeViewerConfiguration {
+public class DiffTreeViewerConfiguration implements IPropertyChangeListener {
private SyncInfoSet set;
private String menuId;
private StructuredViewer viewer;
- private LogicalViewProvider logicalView;
private ExpandAllAction expandAllAction;
@@ -79,6 +69,7 @@ public class DiffTreeViewerConfiguration {
public DiffTreeViewerConfiguration(String menuId, SyncInfoSet set) {
this.menuId = menuId;
this.set = set;
+ TeamUIPlugin.getPlugin().getPreferenceStore().addPropertyChangeListener(this);
}
/**
@@ -99,9 +90,10 @@ public class DiffTreeViewerConfiguration {
initializeListeners(viewer);
hookContextMenu(viewer);
initializeActions(viewer);
- logicalView = getDefaultLogicalViewProvider();
- setLogicalViewProvider(logicalView);
+ viewer.setLabelProvider(getLabelProvider());
+ viewer.setSorter(getViewSorter());
+ viewer.setContentProvider(getContentProvider());
viewer.setInput(getInput());
}
@@ -123,10 +115,21 @@ public class DiffTreeViewerConfiguration {
* subclass of <code>TeamSubscriberParticipantLabelProvider</code>.
* @param logicalProvider the label provider for the selected logical view
* @return a label provider
- * @see SyncInfoDecoratingLabelProvider
+ * @see SyncInfoLabelDecorator
*/
- protected ILabelProvider getLabelProvider(SyncInfoLabelProvider logicalProvider) {
- return new SyncInfoDecoratingLabelProvider(logicalProvider);
+ protected ILabelProvider getLabelProvider() {
+ return new SyncInfoLabelDecorator();
+ }
+
+ protected IStructuredContentProvider getContentProvider() {
+ if(getShowCompressedFolders()) {
+ return new CompressedFolderContentProvider();
+ }
+ return new SyncInfoSetTreeContentProvider();
+ }
+
+ protected ViewerSorter getViewSorter() {
+ return new SyncViewerSorter(ResourceSorter.NAME);
}
/**
@@ -166,8 +169,6 @@ public class DiffTreeViewerConfiguration {
return set;
}
-
-
/**
* Method invoked from <code>initializeViewer(Composite, StructuredViewer)</code> in order
* to configure the viewer to call <code>fillContextMenu(StructuredViewer, IMenuManager)</code>
@@ -227,40 +228,15 @@ public class DiffTreeViewerConfiguration {
manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
}
- public void contributeToToolBar(IToolBarManager tbm) {
- }
-
- protected LogicalViewProvider getDefaultLogicalViewProvider() {
- return new DefaultLogicalView(this);
- }
-
- /**
- * Return the title of the diff viewer. This title is used by the <code>SyncInfoCompareInput</code>.
- * @return a title string
- */
- public String getTitle() {
- return "Synchronization Changes";
+ protected StructuredViewer getViewer() {
+ return viewer;
}
/**
* Cleanup listeners
*/
public void dispose() {
- logicalView.dispose();
- }
-
- /**
- * Set the logical view to be used in the diff tree viewer. Passing <code>null</code>
- * will remove any logical view and use the standard resource hierarchy view.
- * @param viewer the viewer
- * @param view the logical view to be used
- */
- public void setLogicalViewProvider(LogicalViewProvider provider) {
- if (viewer != null) {
- viewer.setLabelProvider(getLabelProvider(provider.getLabelProvider()));
- viewer.setSorter(provider.getSorter());
- viewer.setContentProvider(provider.getContentProvider());
- }
+ TeamUIPlugin.getPlugin().getPreferenceStore().removePropertyChangeListener(this);
}
/**
@@ -327,4 +303,17 @@ public class DiffTreeViewerConfiguration {
protected boolean allowParticipantMenuContributions() {
return getMenuId() != null;
}
-}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
+ */
+ public void propertyChange(PropertyChangeEvent event) {
+ if (viewer != null && event.getProperty().equals(IPreferenceIds.SYNCVIEW_COMPRESS_FOLDERS)) {
+ viewer.setContentProvider(getContentProvider());
+ }
+ }
+
+ private boolean getShowCompressedFolders() {
+ return TeamUIPlugin.getPlugin().getPreferenceStore().getBoolean(IPreferenceIds.SYNCVIEW_COMPRESS_FOLDERS);
+ }
+} \ No newline at end of file
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 43c36a827..08a6bdc4e 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
@@ -61,7 +61,7 @@ public class SyncInfoDiffCheckboxTreeViewer extends ContainerCheckedTreeViewer i
* @see org.eclipse.team.ui.synchronize.actions.INavigableControl#gotoDifference(int)
*/
public boolean gotoDifference(boolean next) {
- return TreeViewerUtils.gotoDifference(this, next);
+ return TreeViewerUtils.gotoDifference(this, next, true);
}
/* (non-Javadoc)
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 603664f34..4a31b1621 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,20 +12,22 @@ 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.core.resources.IResource;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.subscribers.*;
import org.eclipse.team.internal.ui.Policy;
import org.eclipse.team.internal.ui.synchronize.compare.LocalResourceTypedElement;
import org.eclipse.team.internal.ui.synchronize.compare.RemoteResourceTypedElement;
+import org.eclipse.ui.model.IWorkbenchAdapter;
-public class SyncInfoDiffNode extends DiffNode implements IAdaptable {
+public class SyncInfoDiffNode extends DiffNode implements IAdaptable, IWorkbenchAdapter {
private IResource resource;
private SyncInfoSet input;
- // TODO: Create subclass for SyncInfoCompareInput
private SyncInfo info;
/**
@@ -133,7 +135,10 @@ public class SyncInfoDiffNode extends DiffNode implements IAdaptable {
public Object getAdapter(Class adapter) {
if (adapter == SyncInfo.class) {
return getSyncInfo();
- }
+ }
+ if(adapter == IWorkbenchAdapter.class) {
+ return this;
+ }
return null;
}
@@ -193,7 +198,7 @@ public class SyncInfoDiffNode extends DiffNode implements IAdaptable {
* @see java.lang.Object#toString()
*/
public String toString() {
- return "SynchronizeViewNode for " + getResource().getFullPath().toString(); //$NON-NLS-1$
+ return "SyncInfoDiffNode for " + getResource().getFullPath().toString(); //$NON-NLS-1$
}
/**
@@ -269,4 +274,46 @@ public class SyncInfoDiffNode extends DiffNode implements IAdaptable {
}
return false;
}
+
+ /* (non-Javadoc)
+ * @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];
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.model.IWorkbenchAdapter#getImageDescriptor(java.lang.Object)
+ */
+ public ImageDescriptor getImageDescriptor(Object object) {
+ IResource resource = getResource();
+ IWorkbenchAdapter adapter = (IWorkbenchAdapter)((IAdaptable) resource).getAdapter(IWorkbenchAdapter.class);
+ return adapter.getImageDescriptor(resource);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.model.IWorkbenchAdapter#getLabel(java.lang.Object)
+ */
+ public String getLabel(Object o) {
+ return getResource().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;
+ }
} \ No newline at end of file
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 e39cabeab..45213c3be 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
@@ -59,7 +59,7 @@ public class SyncInfoDiffTreeViewer extends TreeViewer implements INavigatable,
* @see org.eclipse.team.ui.synchronize.actions.INavigableControl#gotoDifference(int)
*/
public boolean gotoDifference(boolean direction) {
- return TreeViewerUtils.gotoDifference(this, direction);
+ return TreeViewerUtils.gotoDifference(this, direction, true);
}
/* (non-Javadoc)
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoSetCompareInput.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoSetCompareInput.java
index 88eb5130b..cac1306d5 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoSetCompareInput.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoSetCompareInput.java
@@ -50,7 +50,7 @@ public class SyncInfoSetCompareInput extends CompareEditorInput {
public final Viewer createDiffViewer(Composite parent) {
final StructuredViewer viewer = internalCreateDiffViewer(parent, diffViewerConfiguration);
- viewer.getControl().setData(CompareUI.COMPARE_VIEWER_TITLE, diffViewerConfiguration.getTitle());
+ viewer.getControl().setData(CompareUI.COMPARE_VIEWER_TITLE, getTitle());
if(viewer instanceof INavigatable) {
INavigatable nav= new INavigatable() {
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/ui/synchronize/views/CompressedFolderContentProvider.java
index 1a3abed17..c250027d0 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/ui/synchronize/views/CompressedFolderContentProvider.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.views;
import java.util.*;
@@ -18,7 +18,6 @@ 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.views.*;
/**
* The contents provider compressed in-sync folder paths
@@ -169,7 +168,7 @@ public class CompressedFolderContentProvider extends SyncInfoSetTreeContentProvi
}
public Object getParent(Object element) {
- if (element instanceof CompressedFolder) {
+ if (element instanceof CompressedFolderDiffNode) {
// The parent of a compressed folder is always the project
return getModelObject(getResource(element).getProject());
}
@@ -180,7 +179,7 @@ public class CompressedFolderContentProvider extends SyncInfoSetTreeContentProvi
// The resource is in-sync so return a compressed folder
IResource resource = ((SyncInfoDiffNode)parent).getResource();
if (resource.getType() == IResource.FOLDER) {
- return new CompressedFolder(((SyncInfoDiffNode)parent).getSyncInfoSet(), resource);
+ return new CompressedFolderDiffNode(((SyncInfoDiffNode)parent).getSyncInfoSet(), resource);
}
}
@@ -241,7 +240,7 @@ public class CompressedFolderContentProvider extends SyncInfoSetTreeContentProvi
*/
public Object getModelObject(IResource resource) {
if (resource.getType() == IResource.FOLDER && getSyncInfoSet().getSyncInfo(resource) == null) {
- return new CompressedFolder(getSyncInfoSet(), resource);
+ return new CompressedFolderDiffNode(getSyncInfoSet(), resource);
}
return super.getModelObject(resource);
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/views/CompressedFolder.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/views/CompressedFolderDiffNode.java
index cb18aefb9..6ebed654a 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/views/CompressedFolder.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/views/CompressedFolderDiffNode.java
@@ -8,21 +8,24 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.team.internal.ui.synchronize.views;
+package org.eclipse.team.ui.synchronize.views;
import java.util.*;
import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.team.core.subscribers.SyncInfo;
import org.eclipse.team.core.subscribers.SyncInfoSet;
+import org.eclipse.team.internal.ui.TeamUIPlugin;
+import org.eclipse.team.ui.ISharedImages;
import org.eclipse.team.ui.synchronize.SyncInfoDiffNode;
/**
* A compressed folder appears under a project and contains out-of-sync resources
*/
-public class CompressedFolder extends SyncInfoDiffNode {
+public class CompressedFolderDiffNode extends SyncInfoDiffNode {
- public CompressedFolder(SyncInfoSet input, IResource resource) {
+ public CompressedFolderDiffNode(SyncInfoSet input, IResource resource) {
super(input, resource);
}
@@ -56,4 +59,18 @@ public class CompressedFolder extends SyncInfoDiffNode {
return true;
}
+ /* (non-Javadoc)
+ * @see org.eclipse.compare.structuremergeviewer.DiffNode#getName()
+ */
+ public String getLabel(Object o) {
+ IResource resource = getResource();
+ return resource.getProjectRelativePath().toString();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.ui.synchronize.SyncInfoDiffNode#getImageDescriptor(java.lang.Object)
+ */
+ public ImageDescriptor getImageDescriptor(Object object) {
+ return TeamUIPlugin.getImageDescriptor(ISharedImages.IMG_COMPRESSED_FOLDER);
+ }
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/views/DecoratingColorLabelProvider.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/views/DecoratingColorLabelProvider.java
new file mode 100644
index 000000000..18147ec78
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/views/DecoratingColorLabelProvider.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * 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.jface.viewers.*;
+import org.eclipse.swt.graphics.Color;
+
+/**
+ * Should PR UI to fix their decorating provider!!!
+ */
+public class DecoratingColorLabelProvider extends DecoratingLabelProvider implements IColorProvider {
+
+ public DecoratingColorLabelProvider(ILabelProvider provider, ILabelDecorator decorator) {
+ super(provider, decorator);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object)
+ */
+ public Color getForeground(Object element) {
+ ILabelProvider p = getLabelProvider();
+ if(p instanceof IColorProvider) {
+ return ((IColorProvider)p).getForeground(element);
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IColorProvider#getBackground(java.lang.Object)
+ */
+ public Color getBackground(Object element) {
+ ILabelProvider p = getLabelProvider();
+ if(p instanceof IColorProvider) {
+ return ((IColorProvider)p).getBackground(element);
+ }
+ return null;
+ }
+}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/views/SyncInfoDecoratingLabelProvider.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/views/SyncInfoLabelDecorator.java
index 632e0d76f..73184adfb 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/views/SyncInfoDecoratingLabelProvider.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/views/SyncInfoLabelDecorator.java
@@ -14,50 +14,34 @@ import java.util.*;
import org.eclipse.compare.CompareConfiguration;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.*;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.LabelProviderChangedEvent;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.*;
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.ui.ISharedImages;
import org.eclipse.team.ui.synchronize.SyncInfoDiffNode;
import org.eclipse.ui.internal.WorkbenchColors;
+import org.eclipse.ui.model.WorkbenchLabelProvider;
/**
- * Decorates the text and labels from a <code>SyncInfoLabelProvider</code>
- * with the proper sync kind indications.
- * This class provides a facility for subclasses to define annotations
- * on the labels and icons of adaptable objects by overriding
- * <code>decorateText()</code> and <code>decorateImage</code>.
- *
- * @see DiffTreeViewerConfiguration#getLabelProvider(SyncInfoLabelProvider)
* @since 3.0
*/
-public class SyncInfoDecoratingLabelProvider extends LabelProvider implements IColorProvider {
+public class SyncInfoLabelDecorator extends LabelProvider implements IColorProvider {
- //column constants
- private static final int COL_RESOURCE = 0;
- private static final int COL_PARENT = 1;
private boolean working = false;
-
// cache for folder images that have been overlayed with conflict icon
- private Map fgImageCache;
-
- // Keep track of the compare provider and sync info label provider
- // so they can be properly disposed
+ private Map fgImageCache;
CompareConfiguration compareConfig = new CompareConfiguration();
- SyncInfoLabelProvider syncInfoLabelProvider;
-
- public SyncInfoDecoratingLabelProvider() {
- this(new SyncInfoLabelProvider());
- }
+ private WorkbenchLabelProvider workbenchLabelProvider = new WorkbenchLabelProvider();
- public SyncInfoDecoratingLabelProvider(SyncInfoLabelProvider syncInfoLabelProvider) {
- Assert.isNotNull(syncInfoLabelProvider);
+ public SyncInfoLabelDecorator() {
JobStatusHandler.addJobListener(new IJobListener() {
public void started(QualifiedName jobType) {
working = true;
@@ -65,7 +49,7 @@ public class SyncInfoDecoratingLabelProvider extends LabelProvider implements IC
public void run() {
// TODO: What this is this supposed to be?
synchronized (this) {
- fireLabelProviderChanged(new LabelProviderChangedEvent(SyncInfoDecoratingLabelProvider.this));
+ fireLabelProviderChanged(new LabelProviderChangedEvent(SyncInfoLabelDecorator.this));
}
}
});
@@ -75,7 +59,7 @@ public class SyncInfoDecoratingLabelProvider extends LabelProvider implements IC
Display.getDefault().asyncExec(new Runnable() {
public void run() {
synchronized (this) {
- fireLabelProviderChanged(new LabelProviderChangedEvent(SyncInfoDecoratingLabelProvider.this));
+ fireLabelProviderChanged(new LabelProviderChangedEvent(SyncInfoLabelDecorator.this));
}
}
});
@@ -85,46 +69,58 @@ public class SyncInfoDecoratingLabelProvider extends LabelProvider implements IC
// The label provider may of been created after the subscriber job has been
// started.
this.working = JobStatusHandler.hasRunningJobs(TeamSubscriber.SUBSCRIBER_JOB_TYPE);
- this.syncInfoLabelProvider = syncInfoLabelProvider;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object)
+ */
+ public Color getForeground(Object element) {
+ if (working) {
+ return WorkbenchColors.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW);
+ } else {
+ return null;
+ }
}
- protected String decorateText(String input, Object element) {
- return input;
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IColorProvider#getBackground(java.lang.Object)
+ */
+ public Color getBackground(Object element) {
+ return null;
}
- protected Image decorateImage(Image base, Object element) {
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
+ */
+ public Image getImage(Object element) {
+ Image base = workbenchLabelProvider.getImage(element);
+ if(base != null) {
+ SyncInfo info = getSyncInfo(element);
+ if(info == null) {
+ return getCompareImage(base, SyncInfo.IN_SYNC);
+ }
+ Image decoratedImage = getCompareImage(base, info.getKind());
+ return propagateConflicts(decoratedImage, element, info.getLocal());
+ }
return base;
}
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
+ */
public String getText(Object element) {
- String name = syncInfoLabelProvider.getText(element);
+ String base = workbenchLabelProvider.getText(element);
if (TeamUIPlugin.getPlugin().getPreferenceStore().getBoolean(IPreferenceIds.SYNCVIEW_VIEW_SYNCINFO_IN_LABEL)) {
- SyncInfo info = syncInfoLabelProvider.getSyncInfo(element);
+ SyncInfo info = 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$
+ return Policy.bind("TeamSubscriberSyncPage.labelWithSyncKind", base, syncKindString); //$NON-NLS-1$
}
}
- return decorateText(name, element);
- }
-
- /**
- * An image is decorated by at most 3 different plugins.
- * 1. ask the sync info label decorator for the default icon for the resource
- * 2. ask the compare plugin for the sync kind overlay
- * 3. overlay the conflicting image on folders/projects containing conflicts
- */
- public Image getImage(Object element) {
- Image decoratedImage = null;
- IResource resource = syncInfoLabelProvider.getResource(element);
- Image image = syncInfoLabelProvider.getImage(element);
- decoratedImage = getCompareImage(image, element);
- decoratedImage = propagateConflicts(decoratedImage, element, resource);
- return decorateImage(decoratedImage, element);
+ return base;
}
- private Image getCompareImage(Image base, Object element) {
- int kind = getSyncKind(element);
+ protected Image getCompareImage(Image base, int kind) {
switch (kind & SyncInfo.DIRECTION_MASK) {
case SyncInfo.OUTGOING:
kind = (kind &~ SyncInfo.OUTGOING) | SyncInfo.INCOMING;
@@ -164,7 +160,7 @@ public class SyncInfoDecoratingLabelProvider extends LabelProvider implements IC
}
private int getSyncKind(Object element) {
- SyncInfo info = syncInfoLabelProvider.getSyncInfo(element);
+ SyncInfo info = getSyncInfo(element);
if (info != null) {
return info.getKind();
}
@@ -175,8 +171,6 @@ public class SyncInfoDecoratingLabelProvider extends LabelProvider implements IC
* @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose()
*/
public void dispose() {
- super.dispose();
- syncInfoLabelProvider.dispose();
compareConfig.dispose();
if(fgImageCache != null) {
Iterator it = fgImageCache.values().iterator();
@@ -186,22 +180,16 @@ public class SyncInfoDecoratingLabelProvider extends LabelProvider implements IC
}
}
}
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object)
+
+ /**
+ * 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 Color getForeground(Object element) {
- if (working) {
- return WorkbenchColors.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW);
- } else {
+ protected final SyncInfo getSyncInfo(Object o) {
+ if (!(o instanceof IAdaptable)) {
return null;
}
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IColorProvider#getBackground(java.lang.Object)
- */
- public Color getBackground(Object element) {
- return null;
+ return (SyncInfo) ((IAdaptable) o).getAdapter(SyncInfo.class);
}
} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/views/SyncInfoLabelProvider.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/views/SyncInfoLabelProvider.java
deleted file mode 100644
index bc0879ac9..000000000
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/views/SyncInfoLabelProvider.java
+++ /dev/null
@@ -1,64 +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 org.eclipse.core.resources.IResource;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.team.core.subscribers.SyncInfo;
-import org.eclipse.ui.model.WorkbenchLabelProvider;
-
-/**
- * Provides text and image labels for <code>SyncInfo</code> and <code>SyncInfoDiffNode</code>
- * instances by delegating to a <code>WorkbenchLabelProvider</code>.
- */
-public class SyncInfoLabelProvider extends LabelProvider {
-
- WorkbenchLabelProvider workbenchLabelProvider = new WorkbenchLabelProvider();
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose()
- */
- public void dispose() {
- super.dispose();
- workbenchLabelProvider.dispose();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
- */
- public Image getImage(Object element) {
- IResource resource = SyncInfoSetContentProvider.getResource(element);
- if (resource != null) {
- return workbenchLabelProvider.getImage(resource);
- }
- return super.getImage(element);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
- */
- public String getText(Object element) {
- IResource resource = SyncInfoSetContentProvider.getResource(element);
- if (resource != null) {
- return workbenchLabelProvider.getText(resource);
- }
- return super.getText(element);
- }
-
- public SyncInfo getSyncInfo(Object element) {
- return SyncInfoSetContentProvider.getSyncInfo(element);
- }
-
- public IResource getResource(Object element) {
- return SyncInfoSetContentProvider.getResource(element);
- }
-}
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 6c6886779..d179fd5fe 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
@@ -19,6 +19,7 @@ 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.ui.model.BaseWorkbenchContentProvider;
/**
* This class provides the contents for a StructuredViewer using the <code>SyncInfo</code>
@@ -27,7 +28,7 @@ import org.eclipse.team.ui.synchronize.SyncInfoDiffNode;
* @see SyncInfo
* @see SyncInfoSet
*/
-public abstract class SyncInfoSetContentProvider implements IStructuredContentProvider, ISyncSetChangedListener {
+public abstract class SyncInfoSetContentProvider extends BaseWorkbenchContentProvider implements IStructuredContentProvider, ISyncSetChangedListener {
private Viewer viewer;
@@ -49,13 +50,6 @@ public abstract class SyncInfoSetContentProvider implements IStructuredContentPr
if(input instanceof SyncInfoDiffNode) {
return ((SyncInfoDiffNode)input).getSyncInfoSet();
}
- if(input instanceof SyncInfoSet) {
- return (SyncInfoSet)input;
- }
- if (input instanceof IAdaptable) {
- IAdaptable adaptable = (IAdaptable)input;
- return (SyncInfoSet)adaptable.getAdapter(SyncInfoSet.class);
- }
return null;
}
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
index 672e160a8..f519de114 100644
--- 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
@@ -13,7 +13,7 @@ package org.eclipse.team.ui.synchronize.views;
import java.util.HashSet;
import java.util.Set;
-import org.eclipse.core.resources.*;
+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;
@@ -27,45 +27,6 @@ public class SyncInfoSetTreeContentProvider extends SyncInfoSetContentProvider i
// 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)
- */
- public Object[] getElements(Object inputElement) {
- return getChildren(inputElement);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
- */
- public Object[] getChildren(Object element) {
- IResource resource = getResource(element);
- IResource[] children;
- if (resource != null) {
- children = getSyncInfoSet().members(resource);
- } else {
- // TODO: This doesn't make sense!
- children = getSyncInfoSet().members(ResourcesPlugin.getWorkspace().getRoot());
- }
- return getModelObjects(children);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
- */
- public boolean hasChildren(Object element) {
- return getChildren(element).length > 0;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
- */
- public Object getParent(Object element) {
- IResource resource = getResource(element);
- if (resource == null) return null;
- IContainer parent = resource.getParent();
- 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.
diff --git a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/SyncInfoSetContentProviderTest.java b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/SyncInfoSetContentProviderTest.java
index 4e8de8caf..4e777f9e0 100644
--- a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/SyncInfoSetContentProviderTest.java
+++ b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/SyncInfoSetContentProviderTest.java
@@ -20,11 +20,11 @@ import org.eclipse.swt.widgets.Item;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.subscribers.MutableSyncInfoSet;
import org.eclipse.team.core.subscribers.SyncInfo;
-import org.eclipse.team.internal.ui.synchronize.views.CompressedFolder;
import org.eclipse.team.tests.core.TeamTest;
import org.eclipse.team.tests.ui.views.ContentProviderTestView;
import org.eclipse.team.tests.ui.views.TestTreeViewer;
import org.eclipse.team.ui.synchronize.SyncInfoDiffNode;
+import org.eclipse.team.ui.synchronize.views.CompressedFolderDiffNode;
/**
* Tests for the SyncInfoSet content providers.
@@ -140,7 +140,7 @@ public class SyncInfoSetContentProviderTest extends TeamTest {
if (set.getSyncInfo(parent) == null) {
assertTrue(
"Compressed parent for " + resource.getFullPath() + " is missing",
- viewer.hasItemFor(new CompressedFolder(set, parent)));
+ viewer.hasItemFor(new CompressedFolderDiffNode(set, parent)));
}
}
}
@@ -155,7 +155,7 @@ public class SyncInfoSetContentProviderTest extends TeamTest {
if (resource.getType() == IResource.PROJECT) {
assertProjectPresent((IProject)resource, resources);
} else if (resource.getType() == IResource.FOLDER) {
- if (data instanceof CompressedFolder) {
+ if (data instanceof CompressedFolderDiffNode) {
assertParentOfResource((IFolder)resource, resources);
} else {
assertResourcePresent(resource, resources);
diff --git a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/views/ContentProviderTestView.java b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/views/ContentProviderTestView.java
index 12ef4f43f..b7285ca6a 100644
--- a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/views/ContentProviderTestView.java
+++ b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/views/ContentProviderTestView.java
@@ -16,9 +16,9 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.team.core.subscribers.SyncInfo;
import org.eclipse.team.core.subscribers.SyncInfoSet;
import org.eclipse.team.internal.ui.TeamUIPlugin;
-import org.eclipse.team.internal.ui.synchronize.views.CompressedFolderContentProvider;
import org.eclipse.team.ui.synchronize.SyncInfoDiffNode;
-import org.eclipse.team.ui.synchronize.views.SyncInfoDecoratingLabelProvider;
+import org.eclipse.team.ui.synchronize.views.CompressedFolderContentProvider;
+import org.eclipse.team.ui.synchronize.views.SyncInfoLabelDecorator;
import org.eclipse.ui.*;
import org.eclipse.ui.part.ViewPart;
@@ -49,7 +49,7 @@ public class ContentProviderTestView extends ViewPart {
public void createPartControl(Composite parent) {
viewer = new TestTreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
viewer.setContentProvider(new CompressedFolderContentProvider());
- viewer.setLabelProvider(new SyncInfoDecoratingLabelProvider());
+ viewer.setLabelProvider(new SyncInfoLabelDecorator());
setInput(new SyncInfoSet(new SyncInfo[0]));
}

Back to the top