diff options
author | Jean Michel-Lemieux | 2004-02-18 04:58:08 +0000 |
---|---|---|
committer | Jean Michel-Lemieux | 2004-02-18 04:58:08 +0000 |
commit | 779c760df978c562b930f927724ba538231bb263 (patch) | |
tree | 517185f5a18252ebace411e057622e4b0a14474b | |
parent | 916adfdbfef240547bddabc412e5939d45c68031 (diff) | |
download | eclipse.platform.team-779c760df978c562b930f927724ba538231bb263.tar.gz eclipse.platform.team-779c760df978c562b930f927724ba538231bb263.tar.xz eclipse.platform.team-779c760df978c562b930f927724ba538231bb263.zip |
*** empty log message ***
30 files changed, 455 insertions, 343 deletions
diff --git a/bundles/org.eclipse.team.cvs.ui/plugin.xml b/bundles/org.eclipse.team.cvs.ui/plugin.xml index 7b09f1b8d..6f8cbfc89 100644 --- a/bundles/org.eclipse.team.cvs.ui/plugin.xml +++ b/bundles/org.eclipse.team.cvs.ui/plugin.xml @@ -923,26 +923,6 @@ <projectSet id="org.eclipse.team.cvs.core.cvsnature" class="org.eclipse.team.internal.ccvs.ui.CVSProjectSetSerializer"/> </extension> - - <!-- ************ Editor Actions ************** --> - <extension point="org.eclipse.ui.editorActions"> - <editorContribution - id="org.eclipse.team.cvs.ui.contentCompare" - targetID="org.eclipse.compare.CompareEditor"> - <action - id="org.eclipse.team.cvs.ui.ContentAction" - state="false" - toolbarPath="Normal/additions" - icon="icons/full/etool16/contents.gif" - disabledIcon="icons/full/dtool16/contents.gif" - hoverIcon="icons/full/ctool16/contents.gif" - label="%ContentAction.label" - tooltip="%ContentAction.tooltip" - class="org.eclipse.team.internal.ccvs.ui.actions.ContentAction"> - </action> - </editorContribution> - </extension> - <!-- ********** Action Sets ************** --> <extension point="org.eclipse.ui.actionSets"> <actionSet 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 2ef56e542..17315c431 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 @@ -31,7 +31,6 @@ import org.eclipse.team.internal.ccvs.ui.Policy; import org.eclipse.team.internal.ccvs.ui.repo.RepositoryManager; import org.eclipse.team.internal.ui.actions.TeamAction; import org.eclipse.team.internal.ui.dialogs.IPromptCondition; -import org.eclipse.team.ui.synchronize.viewers.SyncInfoDiffNode; import org.eclipse.ui.*; /** @@ -469,17 +468,11 @@ abstract public class CVSAction extends TeamAction implements IEditorActionDeleg List resources = new ArrayList(); while(it.hasNext()) { Object element = it.next(); - if(element instanceof SyncInfoDiffNode) { - IResource resource = ((SyncInfoDiffNode)element).getResource(); - if (resource != null && resource.getType() != IResource.ROOT) { - resources.add(resource); - } - } else { - Object adapter = getAdapter(element, IResource.class); - if (adapter instanceof IResource) { - resources.add(adapter); - } + Object adapter = getAdapter(element, IResource.class); + if (adapter instanceof IResource) { + resources.add(adapter); } + } return (IResource[]) resources.toArray(new IResource[resources.size()]); } 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 2c4051e35..6f6b49647 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 @@ -16,9 +16,9 @@ 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.ISynchronizeView; +import org.eclipse.team.ui.synchronize.presentation.SyncInfoDiffNode; import org.eclipse.team.ui.synchronize.subscriber.SubscriberPageDiffTreeViewerConfiguration; import org.eclipse.team.ui.synchronize.subscriber.SubscriberParticipant; -import org.eclipse.team.ui.synchronize.viewers.SyncInfoDiffNode; import org.eclipse.team.ui.synchronize.viewers.SyncInfoLabelProvider; public class CVSSynchronizeViewCompareConfiguration extends SubscriberPageDiffTreeViewerConfiguration { diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/ChangeLogDiffNode.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/ChangeLogDiffNode.java index bb65cb332..94e0959f2 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/ChangeLogDiffNode.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/ChangeLogDiffNode.java @@ -13,24 +13,20 @@ package org.eclipse.team.internal.ccvs.ui.subscriber; import java.text.DateFormat; import org.eclipse.compare.structuremergeviewer.DiffNode; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.IAdaptable; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.team.core.synchronize.SyncInfo; -import org.eclipse.team.core.synchronize.SyncInfoTree; import org.eclipse.team.internal.ccvs.core.ILogEntry; import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants; -import org.eclipse.team.internal.core.subscribers.SubscriberSyncInfoSet; -import org.eclipse.team.ui.synchronize.viewers.SyncInfoDiffNode; -import org.eclipse.ui.model.IWorkbenchAdapter; +import org.eclipse.team.ui.synchronize.presentation.SyncInfoDiffNode; -public class ChangeLogDiffNode extends SyncInfoDiffNode implements IAdaptable, IWorkbenchAdapter { +public class ChangeLogDiffNode extends SyncInfoDiffNode { private ILogEntry logEntry; public ChangeLogDiffNode(DiffNode parent, ILogEntry logEntry) { - super(parent, new SyncInfoTree(), ResourcesPlugin.getWorkspace().getRoot()); + //super(parent, new SyncInfoTree(), ResourcesPlugin.getWorkspace().getRoot()); + super(null, null); this.logEntry = logEntry; } @@ -60,7 +56,7 @@ public class ChangeLogDiffNode extends SyncInfoDiffNode implements IAdaptable, I } public void add(SyncInfo info) { - ((SubscriberSyncInfoSet)getSyncInfoTree()).add(info); + //((SubscriberSyncInfoSet)getSyncInfoTree()).add(info); } /* (non-Javadoc) diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/ChangeLogViewerInput.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/ChangeLogViewerInput.java index 40c99cd8c..b085e4fe1 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/ChangeLogViewerInput.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/ChangeLogViewerInput.java @@ -25,8 +25,8 @@ import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; import org.eclipse.team.internal.ccvs.core.resources.RemoteFile; import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo; import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; -import org.eclipse.team.ui.synchronize.viewers.SyncInfoDiffNode; -import org.eclipse.team.ui.synchronize.viewers.DiffNodeControllerHierarchical; +import org.eclipse.team.ui.synchronize.presentation.DiffNodeControllerHierarchical; +import org.eclipse.team.ui.synchronize.presentation.SyncInfoDiffNode; import org.eclipse.ui.model.IWorkbenchAdapter; import org.eclipse.ui.progress.UIJob; diff --git a/bundles/org.eclipse.team.ui/TODO-syncview.txt b/bundles/org.eclipse.team.ui/TODO-syncview.txt index 9ddbfd352..9eb13bb68 100644 --- a/bundles/org.eclipse.team.ui/TODO-syncview.txt +++ b/bundles/org.eclipse.team.ui/TODO-syncview.txt @@ -155,4 +155,10 @@ needs to walk the diff node tree for this case. ====================================================================== - cvs merge participant doesn't get view progress support because participant is added before viewer is created. But this should be solvable by ensuring that showInActivePerspective forces -viewer creation.
\ No newline at end of file +viewer creation. + + +============================== +- initialize case doesn't work because main page is shown as empty but mode is correct +- how do we handle changes to sync: re-create new nodes or update the nodes with new sync kind? +- new projects don't show up?
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamAdapterFactory.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamAdapterFactory.java new file mode 100644 index 000000000..315c9dcc1 --- /dev/null +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamAdapterFactory.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * 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; + +import org.eclipse.compare.structuremergeviewer.DiffNode; +import org.eclipse.core.runtime.IAdapterFactory; +import org.eclipse.team.internal.ui.synchronize.DiffNodeWorkbenchAdapter; +import org.eclipse.ui.model.IWorkbenchAdapter; + + +public class TeamAdapterFactory implements IAdapterFactory { + + private DiffNodeWorkbenchAdapter diffNodeAdapter = new DiffNodeWorkbenchAdapter(); + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class) + */ + public Object getAdapter(Object adaptableObject, Class adapterType) { + if(adaptableObject instanceof DiffNode && adapterType == IWorkbenchAdapter.class) { + return diffNodeAdapter; + } + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList() + */ + public Class[] getAdapterList() { + // TODO Auto-generated method stub + return new Class[] {IWorkbenchAdapter.class}; + } +} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamUIPlugin.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamUIPlugin.java index 10a847914..daece01fe 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamUIPlugin.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamUIPlugin.java @@ -16,6 +16,7 @@ import java.net.MalformedURLException; import java.net.URL; import java.util.*; +import org.eclipse.compare.structuremergeviewer.DiffNode; import org.eclipse.core.runtime.*; import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.preference.IPreferenceStore; @@ -179,6 +180,8 @@ public class TeamUIPlugin extends AbstractUIPlugin { public void startup() throws CoreException { Policy.localize("org.eclipse.team.internal.ui.messages"); //$NON-NLS-1$ initializePreferences(); + IAdapterFactory factory = new TeamAdapterFactory(); + Platform.getAdapterManager().registerAdapters(factory, DiffNode.class); ((SynchronizeManager)TeamUI.getSynchronizeManager()).init(); } diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/Utils.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/Utils.java index 2d1eb24af..c32f74d7e 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/Utils.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/Utils.java @@ -26,10 +26,10 @@ import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.swt.custom.BusyIndicator; import org.eclipse.swt.widgets.*; import org.eclipse.team.core.TeamException; -import org.eclipse.team.core.synchronize.*; +import org.eclipse.team.core.synchronize.IRemoteResource; +import org.eclipse.team.core.synchronize.SyncInfo; import org.eclipse.team.ui.TeamImages; import org.eclipse.team.ui.synchronize.subscriber.SubscriberParticipant; -import org.eclipse.team.ui.synchronize.viewers.SyncInfoDiffNode; import org.eclipse.ui.*; public class Utils { @@ -391,10 +391,8 @@ public class Utils { IResource resource = null; if (element instanceof IResource) { resource = (IResource)element; - } else if (element instanceof SyncInfoDiffNode) { - resource = ((SyncInfoDiffNode) element).getResource(); - } else if (element instanceof IAdaptable) { - resource = (IResource) ((IAdaptable) element).getAdapter(IResource.class); + } else { + resource = (IResource) getAdapter(element, IResource.class); } if (resource != null) { resources.add(resource); @@ -403,33 +401,11 @@ public class Utils { return (IResource[]) resources.toArray(new IResource[resources.size()]); } - /** - * This method returns all out-of-sync SyncInfos that are in the current - * selection. - * - * @return the list of selected sync infos - */ - public static SyncInfo[] getSyncInfos(Object[] selected) { - Set result = new HashSet(); - for (int i = 0; i < selected.length; i++) { - Object object = selected[i]; - if (object instanceof SyncInfoDiffNode) { - SyncInfoDiffNode syncResource = (SyncInfoDiffNode) object; - if(syncResource.hasChildren()) { - SyncInfoTree set = syncResource.getSyncInfoTree(); - SyncInfo[] infos = set.getSyncInfos(syncResource.getResource(), IResource.DEPTH_INFINITE); - result.addAll(Arrays.asList(infos)); - } else { - SyncInfo info = syncResource.getSyncInfo(); - if(info != null && info.getKind() != SyncInfo.IN_SYNC) { - result.add(info); - } - } - } else if(object instanceof SyncInfo) { - result.add(object); - } - } - return (SyncInfo[]) result.toArray(new SyncInfo[result.size()]); + public static Object getAdapter(Object element, Class adapter) { + if (element instanceof IAdaptable) { + return ((IAdaptable) element).getAdapter(adapter); + } + return null; } /** diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/SubscriberAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/SubscriberAction.java index b0ad0038a..86e9bd2e3 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/SubscriberAction.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/SubscriberAction.java @@ -27,7 +27,7 @@ import org.eclipse.team.core.synchronize.*; import org.eclipse.team.internal.core.TeamPlugin; import org.eclipse.team.internal.ui.TeamUIPlugin; import org.eclipse.team.internal.ui.Utils; -import org.eclipse.team.ui.synchronize.viewers.SyncInfoDiffNode; +import org.eclipse.team.ui.synchronize.presentation.SyncInfoDiffNode; import org.eclipse.ui.*; /** diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/DiffNodeWorkbenchAdapter.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/DiffNodeWorkbenchAdapter.java new file mode 100644 index 000000000..15b53730f --- /dev/null +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/DiffNodeWorkbenchAdapter.java @@ -0,0 +1,75 @@ +/******************************************************************************* + * 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; + +import org.eclipse.compare.structuremergeviewer.DiffNode; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.team.internal.ui.Utils; +import org.eclipse.team.ui.synchronize.presentation.AdaptableDiffNode; +import org.eclipse.ui.model.IWorkbenchAdapter; + +public class DiffNodeWorkbenchAdapter implements IWorkbenchAdapter { + + /* (non-Javadoc) + * @see org.eclipse.ui.model.IWorkbenchAdapter#getChildren(java.lang.Object) + */ + public Object[] getChildren(Object o) { + DiffNode node = getDiffNode(o); + return node != null ? node.getChildren() : new Object[0]; + } + + /* (non-Javadoc) + * @see org.eclipse.ui.model.IWorkbenchAdapter#getImageDescriptor(java.lang.Object) + */ + public ImageDescriptor getImageDescriptor(Object o) { + DiffNode node = getDiffNode(o); + if(node instanceof AdaptableDiffNode) { + ImageDescriptor imd = ((AdaptableDiffNode)node).getImageDescriptor(o); + if(imd != null) { + return imd; + } + } + IResource resource = (IResource)Utils.getAdapter(o, IResource.class); + if (resource == null) { + return null; + } + 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) { + DiffNode node = getDiffNode(o); + return node != null ? node.getName() : ""; + } + + /* (non-Javadoc) + * @see org.eclipse.ui.model.IWorkbenchAdapter#getParent(java.lang.Object) + */ + public Object getParent(Object o) { + DiffNode node = getDiffNode(o); + return node != null ? node.getParent() : null; + } + + /* + * Return a diff node if the input object is a diff node or null otherwise. + */ + private DiffNode getDiffNode(Object element) { + if(element instanceof DiffNode) { + return (DiffNode)element; + } + return null; + } +} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/NavigateAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/NavigateAction.java index cb776c03a..18da6169d 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/NavigateAction.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/NavigateAction.java @@ -19,7 +19,7 @@ import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.team.core.synchronize.SyncInfo; import org.eclipse.team.internal.ui.Utils; import org.eclipse.team.ui.synchronize.ISynchronizeView; -import org.eclipse.team.ui.synchronize.viewers.SyncInfoDiffNode; +import org.eclipse.team.ui.synchronize.presentation.SyncInfoDiffNode; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IKeyBindingService; import org.eclipse.ui.actions.ActionFactory; diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/OpenInCompareAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/OpenInCompareAction.java index 4d9b122a1..2f8ade7e7 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/OpenInCompareAction.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/OpenInCompareAction.java @@ -20,8 +20,8 @@ import org.eclipse.team.core.synchronize.SyncInfo; import org.eclipse.team.internal.ui.Utils; import org.eclipse.team.ui.synchronize.ISynchronizeParticipant; import org.eclipse.team.ui.synchronize.ISynchronizeView; +import org.eclipse.team.ui.synchronize.presentation.SyncInfoDiffNode; import org.eclipse.team.ui.synchronize.viewers.SyncInfoCompareInput; -import org.eclipse.team.ui.synchronize.viewers.SyncInfoDiffNode; import org.eclipse.ui.*; /** diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/presentation/AdaptableDiffNode.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/presentation/AdaptableDiffNode.java new file mode 100644 index 000000000..0eb402197 --- /dev/null +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/presentation/AdaptableDiffNode.java @@ -0,0 +1,42 @@ +/******************************************************************************* + * 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.presentation; + +import org.eclipse.compare.structuremergeviewer.DiffNode; +import org.eclipse.compare.structuremergeviewer.IDiffContainer; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.Platform; +import org.eclipse.jface.resource.ImageDescriptor; + +public class AdaptableDiffNode extends DiffNode implements IAdaptable { + + public AdaptableDiffNode(IDiffContainer parent, int kind) { + super(parent, kind); + } + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) + */ + public Object getAdapter(Class adapter) { + return Platform.getAdapterManager().getAdapter(this, adapter); + } + + public ImageDescriptor getImageDescriptor(Object object) { + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.compare.structuremergeviewer.DiffContainer#hasChildren() + */ + public boolean hasChildren() { + return true; + } +} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/DiffNodeController.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/presentation/DiffNodeController.java index d41cc65cb..29bf3b072 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/DiffNodeController.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/presentation/DiffNodeController.java @@ -8,7 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.team.ui.synchronize.viewers; +package org.eclipse.team.ui.synchronize.presentation; import org.eclipse.compare.structuremergeviewer.DiffNode; import org.eclipse.core.runtime.IProgressMonitor; diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/DiffNodeControllerCompressedFolders.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/presentation/DiffNodeControllerCompressedFolders.java index 27720fcde..af90af5b2 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/DiffNodeControllerCompressedFolders.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/presentation/DiffNodeControllerCompressedFolders.java @@ -8,19 +8,68 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.team.ui.synchronize.viewers; +package org.eclipse.team.ui.synchronize.presentation; import java.util.*; -import org.eclipse.compare.structuremergeviewer.DiffNode; -import org.eclipse.compare.structuremergeviewer.IDiffElement; +import org.eclipse.compare.structuremergeviewer.*; import org.eclipse.core.resources.*; +import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.viewers.AbstractTreeViewer; import org.eclipse.jface.viewers.ViewerSorter; import org.eclipse.team.core.synchronize.*; +import org.eclipse.team.internal.ui.TeamUIPlugin; +import org.eclipse.team.internal.ui.Utils; +import org.eclipse.team.ui.ISharedImages; public class DiffNodeControllerCompressedFolders extends DiffNodeControllerHierarchical { + protected class UnchangedCompressedDiffNode extends UnchangedResourceDiffNode { + public UnchangedCompressedDiffNode(IDiffContainer parent, IResource resource) { + super(parent, resource); + } + + /* (non-Javadoc) + * @see org.eclipse.compare.structuremergeviewer.DiffNode#getName() + */ + public String getName() { + 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); + } + } + + /** + * A compressed folder appears under a project and contains out-of-sync resources + */ + public class CompressedFolderDiffNode extends SyncInfoDiffNode { + + public CompressedFolderDiffNode(IDiffContainer parent, SyncInfo info) { + super(parent, info); + } + + /* (non-Javadoc) + * @see org.eclipse.compare.structuremergeviewer.DiffNode#getName() + */ + public String getName() { + 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); + } + } + public DiffNodeControllerCompressedFolders(SyncInfoTree set) { super(set); } @@ -38,22 +87,23 @@ public class DiffNodeControllerCompressedFolders extends DiffNodeControllerHiera } }; } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.views.DiffNodeControllerHierarchical#createChildren(org.eclipse.compare.structuremergeviewer.IDiffContainer) - */ - + /* (non-Javadoc) * @see org.eclipse.team.ui.synchronize.viewers.DiffNodeControllerHierarchical#createModelObjects(org.eclipse.compare.structuremergeviewer.DiffNode) - */ + */ protected IDiffElement[] createModelObjects(DiffNode container) { - if (container instanceof SyncInfoDiffNode) { - SyncInfoDiffNode node = (SyncInfoDiffNode)container; - if (node.getResource().getType() == IResource.PROJECT) { - return getProjectChildren(container, (IProject)node.getResource()); + IResource resource = null; + if (container == getRoot()) { + resource = ResourcesPlugin.getWorkspace().getRoot(); + } else { + resource = (IResource)Utils.getAdapter(container, IResource.class); + } + if(resource != null) { + if (resource.getType() == IResource.PROJECT) { + return getProjectChildren(container, (IProject)resource); } - if (container instanceof CompressedFolderDiffNode) { - return getFolderChildren(container, node.getResource()); + if (resource.getType() == IResource.FOLDER) { + return getFolderChildren(container, resource); } } return super.createModelObjects(container); @@ -106,12 +156,18 @@ public class DiffNodeControllerCompressedFolders extends DiffNodeControllerHiera /* (non-Javadoc) * @see org.eclipse.team.ui.synchronize.viewers.DiffNodeControllerHierarchical#createModelObject(org.eclipse.compare.structuremergeviewer.DiffNode, org.eclipse.core.resources.IResource) */ - protected SyncInfoDiffNode createModelObject(DiffNode parent, IResource resource) { + protected DiffNode createModelObject(DiffNode parent, IResource resource) { if (resource.getType() == IResource.FOLDER) { - SyncInfoDiffNode node = new CompressedFolderDiffNode(parent, getSyncInfoTree(), resource); - associateDiffNode(resource, node); - addToViewer(node); - return node; + SyncInfo info = getSyncInfoTree().getSyncInfo(resource); + DiffNode newNode; + if(info != null) { + newNode = new CompressedFolderDiffNode(parent, info); + } else { + newNode = new UnchangedCompressedDiffNode(parent, resource); + } + associateDiffNode(newNode); + addToViewer(newNode); + return newNode; } return super.createModelObject(parent, resource); } diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/DiffNodeControllerHierarchical.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/presentation/DiffNodeControllerHierarchical.java index b55816413..c3abdad81 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/DiffNodeControllerHierarchical.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/presentation/DiffNodeControllerHierarchical.java @@ -8,15 +8,14 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.team.ui.synchronize.viewers; +package org.eclipse.team.ui.synchronize.presentation; 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.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.*; import org.eclipse.jface.viewers.AbstractTreeViewer; import org.eclipse.jface.viewers.ViewerSorter; import org.eclipse.swt.custom.BusyIndicator; @@ -26,10 +25,11 @@ import org.eclipse.team.core.synchronize.*; import org.eclipse.team.internal.core.Assert; import org.eclipse.team.internal.core.TeamPlugin; import org.eclipse.team.internal.ui.TeamUIPlugin; +import org.eclipse.team.internal.ui.Utils; /** - * An input that can be used with both {@link DiffTreeViewerConfiguration} and - * {@link CompareEditorInput}. The + * An input that can be used with both {@link } and + * {@link }. The * job of this input is to create the logical model of the contents of the * sync set for displaying to the user. The created logical model must diff * nodes. @@ -62,7 +62,7 @@ public class DiffNodeControllerHierarchical implements ISyncInfoSetChangeListene // building the model. private boolean refreshViewer; - private SyncInfoDiffNode root; + private AdaptableDiffNode root; private SyncInfoTree set; @@ -74,7 +74,7 @@ public class DiffNodeControllerHierarchical implements ISyncInfoSetChangeListene */ public DiffNodeControllerHierarchical(SyncInfoTree set) { Assert.isNotNull(set); - this.root = new SyncInfoDiffNode(null, set, ResourcesPlugin.getWorkspace().getRoot()); + this.root = new AdaptableDiffNode(null, SyncInfo.IN_SYNC); this.set = set; } @@ -191,26 +191,34 @@ public class DiffNodeControllerHierarchical implements ISyncInfoSetChangeListene * @return */ protected IDiffElement[] createModelObjects(DiffNode container) { - if (container instanceof SyncInfoDiffNode) { - SyncInfoDiffNode parentNode = (SyncInfoDiffNode) container; - IResource resource = parentNode.getResource(); - if (resource == null) { - resource = ResourcesPlugin.getWorkspace().getRoot(); - } - IResource[] children = getSyncInfoTree().members(resource); - SyncInfoDiffNode[] nodes = new SyncInfoDiffNode[children.length]; + IResource resource = null; + if (container == getRoot()) { + resource = ResourcesPlugin.getWorkspace().getRoot(); + } else { + resource = (IResource)Utils.getAdapter(container, IResource.class); + } + if(resource != null) { + SyncInfoTree infoTree = getSyncInfoTree(); + IResource[] children = infoTree.members(resource); + DiffNode[] nodes = new DiffNode[children.length]; for (int i = 0; i < children.length; i++) { - nodes[i] = createModelObject(parentNode, children[i]); + nodes[i] = createModelObject(container, children[i]); } - return nodes; + return nodes; } return new IDiffElement[0]; } - protected SyncInfoDiffNode createModelObject(DiffNode parent, IResource resource) { - SyncInfoDiffNode node = new SyncInfoDiffNode(parent, getSyncInfoTree(), resource); - addToViewer(node); - return node; + protected DiffNode createModelObject(DiffNode parent, IResource resource) { + SyncInfo info = getSyncInfoTree().getSyncInfo(resource); + DiffNode newNode; + if(info != null) { + newNode = new SyncInfoDiffNode(parent, info); + } else { + newNode = new UnchangedResourceDiffNode(parent, resource); + } + addToViewer(newNode); + return newNode; } /** @@ -223,13 +231,13 @@ public class DiffNodeControllerHierarchical implements ISyncInfoSetChangeListene */ protected void clearModelObjects(DiffNode node) { IDiffElement[] children = node.getChildren(); - IResource resource = getResource(node); for (int i = 0; i < children.length; i++) { IDiffElement element = children[i]; if (element instanceof DiffNode) { clearModelObjects((DiffNode) element); } } + IResource resource = (IResource)Utils.getAdapter(node, IResource.class); if (resource != null) { unassociateDiffNode(resource); } @@ -253,26 +261,17 @@ public class DiffNodeControllerHierarchical implements ISyncInfoSetChangeListene return result; } - protected void associateDiffNode(IResource childResource, DiffNode childNode) { - resourceMap.put(childResource, childNode); - } - - protected void unassociateDiffNode(IResource childResource) { - resourceMap.remove(childResource); + protected void associateDiffNode(DiffNode node) { + if(node instanceof IAdaptable) { + IResource resource = (IResource)((IAdaptable)node).getAdapter(IResource.class); + if(resource != null) { + resourceMap.put(resource, node); + } + } } - /** - * Return the resource associated with the node or <code>null</code> if - * the node is not directly associated with a resource. - * @param node - * a diff node - * @return a resource or <code>null</code> - */ - protected IResource getResource(DiffNode node) { - if (node instanceof SyncInfoDiffNode) { - return ((SyncInfoDiffNode) node).getResource(); - } - return null; + protected void unassociateDiffNode(IResource resource) { + resourceMap.remove(resource); } /** @@ -364,8 +363,10 @@ public class DiffNodeControllerHierarchical implements ISyncInfoSetChangeListene for (int i = 0; i < elements.length; i++) { viewer.remove(elements[i]); } - associateDiffNode(ResourcesPlugin.getWorkspace().getRoot(), getRoot()); + associateDiffNode(getRoot()); buildModelObjects(getRoot()); + } catch(Exception e) { + e.printStackTrace(); } finally { refreshViewer = true; } @@ -411,8 +412,8 @@ public class DiffNodeControllerHierarchical implements ISyncInfoSetChangeListene } } - protected void addToViewer(SyncInfoDiffNode node) { - associateDiffNode(node.getResource(), node); + protected void addToViewer(DiffNode node) { + associateDiffNode(node); if (canUpdateViewer()) { AbstractTreeViewer tree = getTreeViewer(); tree.add(node.getParent(), node); diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/SyncInfoDiffNode.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/presentation/SyncInfoDiffNode.java index f09681c03..5d35f6db6 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/SyncInfoDiffNode.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/presentation/SyncInfoDiffNode.java @@ -8,23 +8,18 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.team.ui.synchronize.viewers; +package org.eclipse.team.ui.synchronize.presentation; import org.eclipse.compare.ITypedElement; import org.eclipse.compare.ResourceNode; import org.eclipse.compare.structuremergeviewer.*; 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.synchronize.*; -import org.eclipse.team.internal.core.Assert; import org.eclipse.team.internal.ui.Policy; -import org.eclipse.team.internal.ui.TeamUIPlugin; import org.eclipse.team.internal.ui.synchronize.compare.LocalResourceTypedElement; import org.eclipse.team.internal.ui.synchronize.compare.RemoteResourceTypedElement; -import org.eclipse.ui.model.IWorkbenchAdapter; /** * A diff node used to display the synchronization state for resources described by @@ -43,91 +38,10 @@ import org.eclipse.ui.model.IWorkbenchAdapter; * @see DiffTreeViewer * @see Differencer */ -public class SyncInfoDiffNode extends DiffNode implements IAdaptable, IWorkbenchAdapter { - - private SyncInfoTree syncSet; - private IResource resource; - - private ITypedElement base; - - /** - * Property constant indicating the mode of a page has changed. - */ - public static final String P_BUSY_ELEMENT = TeamUIPlugin.ID + ".P_NODE_ISBUSY"; //$NON-NLS-1$ - - /** - * Create an ITypedElement for the given local resource. The returned ITypedElement - * will prevent editing of outgoing deletions. - */ - private static ITypedElement createTypeElement(IResource resource, final int kind) { - if(resource != null && resource.exists()) { - return new LocalResourceTypedElement(resource) { - public boolean isEditable() { - if(SyncInfo.getDirection(kind) == SyncInfo.OUTGOING && SyncInfo.getChange(kind) == SyncInfo.DELETION) { - return false; - } - return super.isEditable(); - } - }; - } - return null; - } - - /** - * Create an ITypedElement for the given remote resource. The contents for the remote resource - * will be retrieved from the given IStorage which is a local cache used to buffer the remote contents - */ - private static ITypedElement createTypeElement(IRemoteResource remoteResource) { - return new RemoteResourceTypedElement(remoteResource); - } - - private static ITypedElement createRemoteTypeElement(SyncInfoSet set, IResource resource) { - return createRemoteTypeElement(set.getSyncInfo(resource)); - } - - private static ITypedElement createLocalTypeElement(SyncInfoSet set, IResource resource) { - return createLocalTypeElement(set.getSyncInfo(resource)); - } - - private static ITypedElement createBaseTypeElement(SyncInfoSet set, IResource resource) { - return createBaseTypeElement(set.getSyncInfo(resource)); - } - - private static ITypedElement createRemoteTypeElement(SyncInfo info) { - if(info != null && info.getRemote() != null) { - return createTypeElement(info.getRemote()); - } - return null; - } - - private static ITypedElement createLocalTypeElement(SyncInfo info) { - if(info != null && info.getLocal() != null) { - return createTypeElement(info.getLocal(), info.getKind()); - } - return null; - } - - private static ITypedElement createBaseTypeElement(SyncInfo info) { - if(info != null && info.getBase() != null) { - return createTypeElement(info.getBase()); - } - return null; - } - - private static int getSyncKind(SyncInfoSet set, IResource resource) { - SyncInfo info = set.getSyncInfo(resource); - if(info != null) { - return info.getKind(); - } - return SyncInfo.IN_SYNC; - } - - /** - * Creates a new diff node. - */ - private SyncInfoDiffNode(IDiffContainer parent, ITypedElement base, ITypedElement local, ITypedElement remote, int syncKind) { - super(parent, syncKind, base, local, remote); - } +public class SyncInfoDiffNode extends AdaptableDiffNode { + + private ITypedElement ancestor; + private SyncInfo info; /** * Construct a <code>SyncInfoDiffNode</code> for the given resource. The {@link SyncInfoSet} @@ -138,14 +52,21 @@ public class SyncInfoDiffNode extends DiffNode implements IAdaptable, IWorkbench * @param set The set associated with the diff tree veiwer * @param resource The resource for the node */ - public SyncInfoDiffNode(IDiffContainer parent, SyncInfoTree set, IResource resource) { - this(parent, createBaseTypeElement(set, resource), createLocalTypeElement(set, resource), createRemoteTypeElement(set, resource), getSyncKind(set, resource)); - Assert.isNotNull(resource); - Assert.isNotNull(set); - this.syncSet = set; - this.resource = resource; + public SyncInfoDiffNode(IDiffContainer parent, SyncInfo info) { + super(parent, info.getKind()); + update(info); } + public void update(SyncInfo info) { + this.info = info; + // local + setLeft(createLocalTypeElement(info)); + // remote + setRight(createRemoteTypeElement(info)); + // base + setAncestor(createBaseTypeElement(info)); + } + /* (non-Javadoc) * @see org.eclipse.compare.structuremergeviewer.DiffElement#getKind() */ @@ -158,6 +79,22 @@ public class SyncInfoDiffNode extends DiffNode implements IAdaptable, IWorkbench } } + /** + * We have to track the base because <code>DiffNode</code> doesn't provide a + * setter. See: + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=52261 + */ + public void setAncestor(ITypedElement ancestor) { + this.ancestor = ancestor; + } + + /* (non-Javadoc) + * @see org.eclipse.compare.structuremergeviewer.DiffNode#getAncestor() + */ + public ITypedElement getAncestor() { + return this.ancestor; + } + /* (non-Javadoc) * @see org.eclipse.compare.structuremergeviewer.DiffNode#getName() */ @@ -174,21 +111,14 @@ public class SyncInfoDiffNode extends DiffNode implements IAdaptable, IWorkbench * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) */ public Object getAdapter(Class adapter) { - if(adapter == IWorkbenchAdapter.class) { - return this; + if(adapter == IResource.class) { + return getResource(); + } else if(adapter == SyncInfo.class) { + return getSyncInfo(); } - return null; - } - - /** - * Return the <code>SyncInfoSet</code> from which this diff node was derived. - * @return a <code>SyncInfoSet</code> - */ - public SyncInfoTree getSyncInfoTree() { - return syncSet; + return super.getAdapter(adapter); } - /** * Helper method that returns the resource associated with this node. A node is not * required to have an associated local resource. @@ -197,9 +127,7 @@ public class SyncInfoDiffNode extends DiffNode implements IAdaptable, IWorkbench */ public IResource getResource() { ITypedElement element = getLeft(); - if(resource != null) { - return resource; - } else if(element instanceof ResourceNode) { + if(element instanceof ResourceNode) { return ((ResourceNode)element).getResource(); } return null; @@ -254,45 +182,53 @@ public class SyncInfoDiffNode extends DiffNode implements IAdaptable, IWorkbench } public SyncInfo getSyncInfo() { - IResource resource = getResource(); + return info; + } + + /** + * Create an ITypedElement for the given local resource. The returned ITypedElement + * will prevent editing of outgoing deletions. + */ + private static ITypedElement createTypeElement(final IResource resource, final int kind) { if(resource != null) { - return syncSet.getSyncInfo(resource); + return new LocalResourceTypedElement(resource) { + public boolean isEditable() { + if(! resource.exists() && SyncInfo.getDirection(kind) == SyncInfo.OUTGOING && SyncInfo.getChange(kind) == SyncInfo.DELETION) { + return false; + } + return super.isEditable(); + } + }; } return null; } - - /** WorkbenchAdapter methods **/ - /* (non-Javadoc) - * @see org.eclipse.ui.model.IWorkbenchAdapter#getChildren(java.lang.Object) + /** + * Create an ITypedElement for the given remote resource. The contents for the remote resource + * will be retrieved from the given IStorage which is a local cache used to buffer the remote contents */ - public Object[] getChildren(Object o) { - return getChildren(); + private static ITypedElement createTypeElement(IRemoteResource remoteResource) { + return new RemoteResourceTypedElement(remoteResource); } - /* (non-Javadoc) - * @see org.eclipse.ui.model.IWorkbenchAdapter#getImageDescriptor(java.lang.Object) - */ - public ImageDescriptor getImageDescriptor(Object object) { - IResource resource = getResource(); - if (resource == null) { - return null; + private static ITypedElement createRemoteTypeElement(SyncInfo info) { + if(info != null && info.getRemote() != null) { + return createTypeElement(info.getRemote()); } - IWorkbenchAdapter adapter = (IWorkbenchAdapter)((IAdaptable) resource).getAdapter(IWorkbenchAdapter.class); - return adapter.getImageDescriptor(resource); + return null; } - /* (non-Javadoc) - * @see org.eclipse.ui.model.IWorkbenchAdapter#getLabel(java.lang.Object) - */ - public String getLabel(Object o) { - return getName(); + private static ITypedElement createLocalTypeElement(SyncInfo info) { + if(info != null && info.getLocal() != null) { + return createTypeElement(info.getLocal(), info.getKind()); + } + return null; } - /* (non-Javadoc) - * @see org.eclipse.ui.model.IWorkbenchAdapter#getParent(java.lang.Object) - */ - public Object getParent(Object o) { - return getParent(); + private static ITypedElement createBaseTypeElement(SyncInfo info) { + if(info != null && info.getBase() != null) { + return createTypeElement(info.getBase()); + } + return null; } }
\ No newline at end of file diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/SyncInfoDiffNodeSorter.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/presentation/SyncInfoDiffNodeSorter.java index aecaa6d1a..fa2a2f0c9 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/SyncInfoDiffNodeSorter.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/presentation/SyncInfoDiffNodeSorter.java @@ -8,7 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.team.ui.synchronize.viewers; +package org.eclipse.team.ui.synchronize.presentation; import org.eclipse.core.resources.IResource; import org.eclipse.jface.viewers.Viewer; diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/presentation/UnchangedResourceDiffNode.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/presentation/UnchangedResourceDiffNode.java new file mode 100644 index 000000000..f4a5ac181 --- /dev/null +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/presentation/UnchangedResourceDiffNode.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * 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.presentation; + +import org.eclipse.compare.structuremergeviewer.IDiffContainer; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.team.core.synchronize.SyncInfo; + +/** + * DiffNode that represents a resource that is in sync. + */ +public class UnchangedResourceDiffNode extends AdaptableDiffNode implements IAdaptable { + + private IResource resource; + + public UnchangedResourceDiffNode(IDiffContainer parent, IResource resource) { + super(parent, SyncInfo.IN_SYNC); + this.resource = resource; + } + + /** + * @return Returns the resource. + */ + public IResource getResource() { + return resource; + } + + /* (non-Javadoc) + * @see org.eclipse.compare.structuremergeviewer.DiffNode#getName() + */ + public String getName() { + return resource.getName(); + } + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) + */ + public Object getAdapter(Class adapter) { + if(adapter == IResource.class) { + return this.resource; + } + return super.getAdapter(adapter); + } +} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscriber/SubscriberPageDiffTreeViewerConfiguration.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscriber/SubscriberPageDiffTreeViewerConfiguration.java index e3975a74c..107de00d5 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscriber/SubscriberPageDiffTreeViewerConfiguration.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscriber/SubscriberPageDiffTreeViewerConfiguration.java @@ -18,6 +18,7 @@ import org.eclipse.jface.viewers.*; import org.eclipse.team.internal.ui.Policy; import org.eclipse.team.internal.ui.synchronize.actions.*; import org.eclipse.team.ui.synchronize.ISynchronizeView; +import org.eclipse.team.ui.synchronize.presentation.*; import org.eclipse.team.ui.synchronize.viewers.*; /** diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/CompressedFolderDiffNode.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/CompressedFolderDiffNode.java deleted file mode 100644 index 6930906aa..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/CompressedFolderDiffNode.java +++ /dev/null @@ -1,50 +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.viewers; - -import org.eclipse.compare.structuremergeviewer.IDiffContainer; -import org.eclipse.core.resources.IResource; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.team.core.synchronize.SyncInfoTree; -import org.eclipse.team.internal.ui.TeamUIPlugin; -import org.eclipse.team.ui.ISharedImages; - -/** - * A compressed folder appears under a project and contains out-of-sync resources - */ -public class CompressedFolderDiffNode extends SyncInfoDiffNode { - - public CompressedFolderDiffNode(IDiffContainer parent, SyncInfoTree input, IResource resource) { - super(parent, input, resource); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.SyncInfoDiffNode#isResourcePath() - */ - public boolean isResourcePath() { - return true; - } - - /* (non-Javadoc) - * @see org.eclipse.compare.structuremergeviewer.DiffNode#getName() - */ - public String getName() { - 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/viewers/DiffTreeViewerConfiguration.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/DiffTreeViewerConfiguration.java index 878ef3f64..2a897a1cb 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/DiffTreeViewerConfiguration.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/DiffTreeViewerConfiguration.java @@ -25,6 +25,7 @@ import org.eclipse.team.internal.core.Assert; import org.eclipse.team.internal.ui.*; import org.eclipse.team.internal.ui.synchronize.actions.ExpandAllAction; import org.eclipse.team.internal.ui.synchronize.views.TreeViewerUtils; +import org.eclipse.team.ui.synchronize.presentation.*; import org.eclipse.ui.IWorkbenchActionConstants; import org.eclipse.ui.IWorkbenchPartSite; import org.eclipse.ui.internal.PluginAction; diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/SyncInfoCompareInput.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/SyncInfoCompareInput.java index 3d6924f7d..f4bbf6fe7 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/SyncInfoCompareInput.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/SyncInfoCompareInput.java @@ -20,11 +20,11 @@ import org.eclipse.jface.resource.ImageRegistry; import org.eclipse.swt.graphics.Image; import org.eclipse.team.core.TeamException; import org.eclipse.team.core.synchronize.SyncInfo; -import org.eclipse.team.core.synchronize.SyncInfoTree; import org.eclipse.team.internal.core.Assert; import org.eclipse.team.internal.ui.*; import org.eclipse.team.internal.ui.synchronize.compare.LocalResourceTypedElement; import org.eclipse.team.ui.ISharedImages; +import org.eclipse.team.ui.synchronize.presentation.*; /** * A {@link SyncInfo} editor input used as input to a two-way or three-way @@ -49,7 +49,7 @@ public class SyncInfoCompareInput extends CompareEditorInput { public SyncInfoCompareInput(SyncInfo sync) { super(new CompareConfiguration()); Assert.isNotNull(sync); - this.node = new SyncInfoDiffNode(null, new SyncInfoTree(new SyncInfo[] {sync}), sync.getLocal()); + this.node = new SyncInfoDiffNode(null, sync); initializeContentChangeListeners(); } diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/SyncInfoLabelProvider.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/SyncInfoLabelProvider.java index e272b19f9..71e74e00a 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/SyncInfoLabelProvider.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/SyncInfoLabelProvider.java @@ -14,14 +14,13 @@ import java.util.*; import org.eclipse.compare.CompareConfiguration; import org.eclipse.compare.structuremergeviewer.DiffNode; -import org.eclipse.core.resources.IResource; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.viewers.*; import org.eclipse.swt.graphics.*; import org.eclipse.team.core.synchronize.SyncInfo; -import org.eclipse.team.core.synchronize.SyncInfoTree; import org.eclipse.team.internal.ui.*; import org.eclipse.team.ui.ISharedImages; +import org.eclipse.team.ui.synchronize.presentation.*; import org.eclipse.ui.model.WorkbenchLabelProvider; /** @@ -176,7 +175,7 @@ public class SyncInfoLabelProvider extends LabelProvider implements IColorProvid */ private boolean hasDecendantConflicts(DiffNode node) { if(node instanceof SyncInfoDiffNode) { - SyncInfoDiffNode diffNode = (SyncInfoDiffNode)node; + /*SyncInfoDiffNode diffNode = (SyncInfoDiffNode)node; IResource resource = diffNode.getResource(); // If this node has no resource, we can't tell // The subclass which created the node with no resource should have overridden this method @@ -191,7 +190,7 @@ public class SyncInfoLabelProvider extends LabelProvider implements IColorProvid return true; } } - } + }*/ } return false; } diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/SyncInfoSetCheckboxCompareInput.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/SyncInfoSetCheckboxCompareInput.java index 22cfcc1d9..362396def 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/SyncInfoSetCheckboxCompareInput.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/SyncInfoSetCheckboxCompareInput.java @@ -16,6 +16,7 @@ import org.eclipse.core.resources.IResource; import org.eclipse.jface.viewers.*; import org.eclipse.swt.widgets.Composite; import org.eclipse.team.core.synchronize.SyncInfo; +import org.eclipse.team.ui.synchronize.presentation.*; /** * This compare input supports selection of multiple sync info using * checkboxes. diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/SyncInfoSetCompareInput.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/SyncInfoSetCompareInput.java index 5e45fc213..774b3349f 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/SyncInfoSetCompareInput.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/SyncInfoSetCompareInput.java @@ -22,6 +22,7 @@ import org.eclipse.jface.viewers.*; import org.eclipse.swt.widgets.Composite; import org.eclipse.team.core.TeamException; import org.eclipse.team.internal.ui.Utils; +import org.eclipse.team.ui.synchronize.presentation.*; /** * A <code>CompareEditorInput</code> whose diff viewer shows the resources contained @@ -29,6 +30,8 @@ import org.eclipse.team.internal.ui.Utils; * <code>SyncInfoSetCompareConfiguration</code> that is used to create the * <code>SyncInfoSetCompareInput</code>. * + * uses the presentation model defined by the configuration. + * * @since 3.0 */ public class SyncInfoSetCompareInput extends CompareEditorInput { 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 5daeb2c34..51aafb212 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 @@ -26,7 +26,7 @@ import org.eclipse.team.internal.core.subscribers.SubscriberSyncInfoSet; 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.viewers.SyncInfoDiffNode; +import org.eclipse.team.ui.synchronize.presentation.SyncInfoDiffNode; /** * Tests for the SyncInfoSet content providers. 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 29bf92d6b..29226b221 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 @@ -14,7 +14,7 @@ import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Composite; import org.eclipse.team.core.synchronize.SyncInfoTree; import org.eclipse.team.internal.ui.TeamUIPlugin; -import org.eclipse.team.ui.synchronize.viewers.DiffNodeControllerCompressedFolders; +import org.eclipse.team.ui.synchronize.presentation.DiffNodeControllerCompressedFolders; import org.eclipse.team.ui.synchronize.viewers.SyncInfoLabelProvider; import org.eclipse.ui.*; import org.eclipse.ui.model.BaseWorkbenchContentProvider; diff --git a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/views/TestTreeViewer.java b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/views/TestTreeViewer.java index cd5fb48b2..1860f82f5 100644 --- a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/views/TestTreeViewer.java +++ b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/views/TestTreeViewer.java @@ -12,7 +12,7 @@ package org.eclipse.team.tests.ui.views; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.swt.widgets.*; -import org.eclipse.team.ui.synchronize.viewers.SyncInfoDiffNode; +import org.eclipse.team.ui.synchronize.presentation.SyncInfoDiffNode; public class TestTreeViewer extends TreeViewer { |