Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSSynchronizeViewPage.java4
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CompareParticipantPage.java2
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangesSection.java4
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeView.java42
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscriber/SubscriberParticipantPage.java4
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/StructuredViewerAdvisor.java42
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/SynchronizeViewTestAdapter.java69
7 files changed, 135 insertions, 32 deletions
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSSynchronizeViewPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSSynchronizeViewPage.java
index 99d3ca7d0..39d87d1e5 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSSynchronizeViewPage.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSSynchronizeViewPage.java
@@ -77,7 +77,7 @@ public class CVSSynchronizeViewPage extends SubscriberParticipantPage implements
*/
public void dispose() {
super.dispose();
- getViewerConfiguration().removeInputChangedListener(this);
+ getViewerAdviser().removeInputChangedListener(this);
CVSUIPlugin.removePropertyChangeListener(this);
}
@@ -124,7 +124,7 @@ public class CVSSynchronizeViewPage extends SubscriberParticipantPage implements
super.createControl(parent);
// Sync changes are used to update the action state for the update/commit buttons.
- getViewerConfiguration().addInputChangedListener(this);
+ getViewerAdviser().addInputChangedListener(this);
// Listen for decorator changed to refresh the viewer's labels.
CVSUIPlugin.addPropertyChangeListener(this);
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CompareParticipantPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CompareParticipantPage.java
index 47e0cd2fb..0ffff4c62 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CompareParticipantPage.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CompareParticipantPage.java
@@ -51,7 +51,7 @@ public class CompareParticipantPage extends CVSSynchronizeViewPage {
public void run() {
groupByComment = ! groupByComment;
setChecked(groupByComment);
- CompareAdvisor advisor = ((CompareAdvisor)CompareParticipantPage.this.getViewerConfiguration());
+ CompareAdvisor advisor = ((CompareAdvisor)CompareParticipantPage.this.getViewerAdviser());
try {
advisor.prepareInput(new NullProgressMonitor());
} catch (TeamException e) {
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangesSection.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangesSection.java
index dbfc639cc..9ef961daa 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangesSection.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangesSection.java
@@ -153,7 +153,7 @@ public class ChangesSection extends Composite {
public void setViewer(Viewer viewer) {
this.changesViewer = viewer;
calculateDescription();
- page.getViewerConfiguration().addInputChangedListener(changedListener);
+ page.getViewerAdviser().addInputChangedListener(changedListener);
participant.getSubscriberSyncInfoCollector().getSubscriberSyncInfoSet().addSyncSetChangedListener(subscriberListener);
participant.getSubscriberSyncInfoCollector().getSyncInfoTree().addSyncSetChangedListener(outputSetListener);
}
@@ -288,7 +288,7 @@ public class ChangesSection extends Composite {
public void dispose() {
super.dispose();
- page.getViewerConfiguration().removeInputChangedListener(changedListener);
+ page.getViewerAdviser().removeInputChangedListener(changedListener);
participant.getSubscriberSyncInfoCollector().getSubscriberSyncInfoSet().removeSyncSetChangedListener(subscriberListener);
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeView.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeView.java
index e794f0106..43cdf7837 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeView.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeView.java
@@ -23,9 +23,16 @@ import org.eclipse.team.internal.ui.Policy;
import org.eclipse.team.internal.ui.TeamUIPlugin;
import org.eclipse.team.internal.ui.synchronize.actions.SynchronizePageDropDownAction;
import org.eclipse.team.ui.TeamUI;
-import org.eclipse.team.ui.synchronize.*;
+import org.eclipse.team.ui.synchronize.ISynchronizeManager;
+import org.eclipse.team.ui.synchronize.ISynchronizeParticipant;
+import org.eclipse.team.ui.synchronize.ISynchronizeParticipantListener;
+import org.eclipse.team.ui.synchronize.ISynchronizeView;
import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.part.*;
+import org.eclipse.ui.part.IPage;
+import org.eclipse.ui.part.IPageBookViewPage;
+import org.eclipse.ui.part.MessagePage;
+import org.eclipse.ui.part.PageBook;
+import org.eclipse.ui.part.PageBookView;
/**
* Implements a Synchronize View that contains multiple synchronize participants.
@@ -45,7 +52,7 @@ public class SynchronizeView extends PageBookView implements ISynchronizeView, I
/**
* Map of parts to participants
*/
- private Map fPartToPage;
+ private Map fPartToParticipant;
/**
* Drop down action to switch between participants
@@ -90,7 +97,7 @@ public class SynchronizeView extends PageBookView implements ISynchronizeView, I
*/
protected void showPageRec(PageRec pageRec) {
super.showPageRec(pageRec);
- activeParticipant = (ISynchronizeParticipant)fPartToPage.get(pageRec.part);
+ activeParticipant = (ISynchronizeParticipant)fPartToParticipant.get(pageRec.part);
updateTitle();
}
@@ -113,10 +120,10 @@ public class SynchronizeView extends PageBookView implements ISynchronizeView, I
IPage page = pageRecord.page;
page.dispose();
pageRecord.dispose();
- ISynchronizeParticipant participant = (ISynchronizeParticipant) fPartToPage.get(part);
+ ISynchronizeParticipant participant = (ISynchronizeParticipant) fPartToParticipant.get(part);
participant.removePropertyChangeListener(this);
// empty cross-reference cache
- fPartToPage.remove(part);
+ fPartToParticipant.remove(part);
fParticipantToPart.remove(participant);
}
@@ -188,7 +195,7 @@ public class SynchronizeView extends PageBookView implements ISynchronizeView, I
ISynchronizeParticipant participant = participants[i];
SynchronizeViewWorkbenchPart part = new SynchronizeViewWorkbenchPart(participant, getSite());
fParticipantToPart.put(participant, part);
- fPartToPage.put(part, participant);
+ fPartToParticipant.put(part, participant);
}
}
}
@@ -227,7 +234,7 @@ public class SynchronizeView extends PageBookView implements ISynchronizeView, I
public SynchronizeView() {
super();
fParticipantToPart = new HashMap();
- fPartToPage = new HashMap();
+ fPartToParticipant = new HashMap();
updateTitle();
}
@@ -333,4 +340,23 @@ public class SynchronizeView extends PageBookView implements ISynchronizeView, I
private boolean isAvailable() {
return getPageBook() != null && !getPageBook().isDisposed();
}
+
+ /*
+ * Method used by test cases to access the page for a participant
+ */
+ public IPage getPage(ISynchronizeParticipant participant) {
+ IWorkbenchPart part = getPart(participant);
+ if (part == null) return null;
+ try {
+ return getPageRec(part).page;
+ } catch (NullPointerException e) {
+ // The PageRec class is not visible so we can't do a null check
+ // before accessing the page.
+ return null;
+ }
+ }
+
+ private IWorkbenchPart getPart(ISynchronizeParticipant participant) {
+ return (IWorkbenchPart)fParticipantToPart.get(participant);
+ }
} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscriber/SubscriberParticipantPage.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscriber/SubscriberParticipantPage.java
index 5f6daead9..a385ae517 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscriber/SubscriberParticipantPage.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/subscriber/SubscriberParticipantPage.java
@@ -319,7 +319,7 @@ public class SubscriberParticipantPage implements IPageBookViewPage, IPropertyCh
return viewer;
}
- public StructuredViewerAdvisor getViewerConfiguration() {
+ public StructuredViewerAdvisor getViewerAdviser() {
return viewerAdvisor;
}
@@ -332,6 +332,6 @@ public class SubscriberParticipantPage implements IPageBookViewPage, IPropertyCh
}
public void setSelection(Object[] objects, boolean reveal) {
- getViewerConfiguration().setSelection(objects, reveal);
+ getViewerAdviser().setSelection(objects, reveal);
}
} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/StructuredViewerAdvisor.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/StructuredViewerAdvisor.java
index c827836ac..49f9aa330 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/StructuredViewerAdvisor.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/StructuredViewerAdvisor.java
@@ -208,16 +208,40 @@ public abstract class StructuredViewerAdvisor {
* @param reveal <code>true</code> if the selection is to be made visible, and
* <code>false</code> otherwise
*/
- public void setSelection(Object[] objects, boolean reveal) {
- Object[] viewerObjects = new Object[objects.length];
- if (modelProvider != null) {
+ public void setSelection(Object[] objects, boolean reveal) {
+ ISelection selection = getSelection(objects);
+ if (!selection.isEmpty()) {
+ viewer.setSelection(selection, reveal);
+ }
+ }
+
+ /**
+ * Gets a new selection that contains the view model objects that
+ * correspond to the given objects. The advisor will try and
+ * convert the objects into the appropriate viewer objects.
+ * This is required because the model provider controls the actual
+ * model elements in the viewer and must be consulted in order to
+ * understand what objects can be selected in the viewer.
+ * <p>
+ * This method does not affect the selection of the viewer itself.
+ * It's main purpose is for testing and should not be used by other
+ * clients.
+ *
+ * @param object the objects to select
+ * @return a selection corresponding to the given objects
+ */
+ public ISelection getSelection(Object[] objects) {
+ if (modelProvider != null) {
+ Object[] viewerObjects = new Object[objects.length];
for (int i = 0; i < objects.length; i++) {
viewerObjects[i] = modelProvider.getMapping(objects[i]);
}
- viewer.setSelection(new StructuredSelection(viewerObjects), reveal);
+ return new StructuredSelection(viewerObjects);
+ } else {
+ return StructuredSelection.EMPTY;
}
- }
-
+ }
+
/**
* Creates the model that will be shown in the viewers. This can be called before the
* viewer has been created.
@@ -275,9 +299,9 @@ public abstract class StructuredViewerAdvisor {
}
/**
- * Get the input that will be assigned to the viewer initialized by this
- * configuration. Subclass may override.
- * @return the viewer input
+ * Get the model provider that will be used to create the input
+ * for the adviser's viewer.
+ * @return the model provider
*/
protected abstract SynchronizeModelProvider getModelProvider();
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/SynchronizeViewTestAdapter.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/SynchronizeViewTestAdapter.java
index 0277dff55..7fc692f56 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/SynchronizeViewTestAdapter.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/SynchronizeViewTestAdapter.java
@@ -14,22 +14,36 @@ import junit.framework.AssertionFailedError;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.swt.widgets.Display;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.subscribers.Subscriber;
import org.eclipse.team.core.subscribers.SubscriberSyncInfoCollector;
-import org.eclipse.team.core.synchronize.*;
-import org.eclipse.team.internal.ccvs.core.*;
+import org.eclipse.team.core.synchronize.SyncInfo;
+import org.eclipse.team.core.synchronize.SyncInfoSet;
+import org.eclipse.team.core.synchronize.SyncInfoTree;
+import org.eclipse.team.internal.ccvs.core.CVSCompareSubscriber;
+import org.eclipse.team.internal.ccvs.core.CVSMergeSubscriber;
+import org.eclipse.team.internal.ccvs.core.CVSTag;
import org.eclipse.team.internal.ccvs.ui.subscriber.CompareParticipant;
import org.eclipse.team.internal.ccvs.ui.subscriber.MergeSynchronizeParticipant;
import org.eclipse.team.internal.ui.TeamUIPlugin;
+import org.eclipse.team.internal.ui.synchronize.SynchronizeModelProvider;
+import org.eclipse.team.internal.ui.synchronize.SynchronizeView;
import org.eclipse.team.tests.ccvs.core.EclipseTest;
import org.eclipse.team.tests.ccvs.core.subscriber.SyncInfoSource;
import org.eclipse.team.ui.TeamUI;
-import org.eclipse.team.ui.synchronize.*;
+import org.eclipse.team.ui.synchronize.ISynchronizeManager;
+import org.eclipse.team.ui.synchronize.ISynchronizeParticipant;
+import org.eclipse.team.ui.synchronize.ISynchronizeView;
import org.eclipse.team.ui.synchronize.subscriber.SubscriberParticipant;
+import org.eclipse.team.ui.synchronize.subscriber.SubscriberParticipantPage;
+import org.eclipse.team.ui.synchronize.viewers.SyncInfoModelElement;
+import org.eclipse.team.ui.synchronize.viewers.SynchronizeModelElement;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.part.IPage;
/**
* SyncInfoSource that obtains SyncInfo from the SynchronizeView's SyncSet.
@@ -46,18 +60,33 @@ public class SynchronizeViewTestAdapter extends SyncInfoSource {
}
public SyncInfo getSyncInfo(Subscriber subscriber, IResource resource) throws TeamException {
- SyncInfoSet set = getCollector(subscriber).getSubscriberSyncInfoSet();
- SyncInfo info = set.getSyncInfo(resource);
+ // Wait for the collector
+ SyncInfoSet set = getCollector(subscriber).getSyncInfoTree();
+ // Obtain the sync info from the viewer to ensure that the
+ // entire chain has the proper state
+ SyncInfo info = internalGetSyncInfo(subscriber, resource);
+ // Do a sanity check on the collected sync info
if (info == null) {
info = subscriber.getSyncInfo(resource);
if ((info != null && info.getKind() != SyncInfo.IN_SYNC)) {
throw new AssertionFailedError(
- "Sync info for "
+ "Sync state for "
+ resource.getFullPath()
+ " was "
+ SyncInfo.kindToString(info.getKind())
+ " but resource was not collected");
}
+ } else {
+ SyncInfo realInfo = subscriber.getSyncInfo(resource);
+ if (info.getKind() != realInfo.getKind()) {
+ throw new AssertionFailedError(
+ "Collected sync state for "
+ + resource.getFullPath()
+ + " was "
+ + SyncInfo.kindToString(info.getKind())
+ + " but the real state was "
+ + SyncInfo.kindToString(realInfo.getKind()));
+ }
}
return info;
}
@@ -79,6 +108,7 @@ public class SynchronizeViewTestAdapter extends SyncInfoSource {
private SubscriberSyncInfoCollector getCollector(Subscriber subscriber) {
SubscriberParticipant participant = getParticipant(subscriber);
if (participant == null) return null;
+ participant.setMode(SubscriberParticipant.BOTH_MODE);
SubscriberSyncInfoCollector syncInfoCollector = participant.getSubscriberSyncInfoCollector();
EclipseTest.waitForSubscriberInputHandling(syncInfoCollector);
return syncInfoCollector;
@@ -101,7 +131,7 @@ public class SynchronizeViewTestAdapter extends SyncInfoSource {
public CVSMergeSubscriber createMergeSubscriber(IProject project, CVSTag root, CVSTag branch) {
CVSMergeSubscriber mergeSubscriber = super.createMergeSubscriber(project, root, branch);
ISynchronizeManager synchronizeManager = TeamUI.getSynchronizeManager();
- ISynchronizeParticipant participant = new MergeSynchronizeParticipant(mergeSubscriber);
+ SubscriberParticipant participant = new MergeSynchronizeParticipant(mergeSubscriber);
synchronizeManager.addSynchronizeParticipants(
new ISynchronizeParticipant[] {participant});
IWorkbenchPage activePage = TeamUIPlugin.getActivePage();
@@ -121,7 +151,7 @@ public class SynchronizeViewTestAdapter extends SyncInfoSource {
public CVSCompareSubscriber createCompareSubscriber(IProject project, CVSTag tag) {
CVSCompareSubscriber s = super.createCompareSubscriber(project, tag);
ISynchronizeManager synchronizeManager = TeamUI.getSynchronizeManager();
- ISynchronizeParticipant participant = new CompareParticipant(s);
+ SubscriberParticipant participant = new CompareParticipant(s);
synchronizeManager.addSynchronizeParticipants(
new ISynchronizeParticipant[] {participant});
IWorkbenchPage activePage = TeamUIPlugin.getActivePage();
@@ -165,4 +195,27 @@ public class SynchronizeViewTestAdapter extends SyncInfoSource {
super.reset(subscriber);
getCollector(subscriber).reset();
}
+
+ private SyncInfo internalGetSyncInfo(Subscriber subscriber, IResource resource) {
+ try {
+ SubscriberParticipant participant = getParticipant(subscriber);
+ IWorkbenchPage activePage = TeamUIPlugin.getActivePage();
+ ISynchronizeView view = (ISynchronizeView)activePage.showView(ISynchronizeView.VIEW_ID);
+ IPage page = ((SynchronizeView)view).getPage(participant);
+ if (page instanceof SubscriberParticipantPage) {
+ SubscriberParticipantPage subscriberPage = (SubscriberParticipantPage)page;
+ ISelection selection = subscriberPage.getViewerAdviser().getSelection(new Object[] { resource });
+ if (!selection.isEmpty() && selection instanceof StructuredSelection) {
+ StructuredSelection ss = (StructuredSelection)selection;
+ Object o = ss.getFirstElement();
+ if (o instanceof SyncInfoModelElement) {
+ return ((SyncInfoModelElement)o).getSyncInfo();
+ }
+ }
+ }
+ } catch (PartInitException e) {
+ throw new AssertionFailedError("Cannot show sync view in active page");
+ }
+ return null;
+ }
}

Back to the top