Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Michel-Lemieux2004-02-25 20:34:58 +0000
committerJean Michel-Lemieux2004-02-25 20:34:58 +0000
commit4a1ca77df6f4238416a8715a8c35819611d5992a (patch)
tree03e4ed09e94442352cb8c3143df59d3b22725627 /tests/org.eclipse.team.tests.core
parenta650f9521c18cb3c840475358086bf5f4052a824 (diff)
downloadeclipse.platform.team-4a1ca77df6f4238416a8715a8c35819611d5992a.tar.gz
eclipse.platform.team-4a1ca77df6f4238416a8715a8c35819611d5992a.tar.xz
eclipse.platform.team-4a1ca77df6f4238416a8715a8c35819611d5992a.zip
SyncView API released to HEAD.
Diffstat (limited to 'tests/org.eclipse.team.tests.core')
-rw-r--r--tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/TeamTest.java57
-rw-r--r--tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/AllTeamSynchronizeTests.java42
-rw-r--r--tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/SyncInfoSetContentProviderTest.java107
-rw-r--r--tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/TestDiffNodePresentationModel.java209
-rw-r--r--tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/TestSyncInfo.java39
-rw-r--r--tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/views/ContentProviderTestView.java54
-rw-r--r--tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/views/TestTreeViewer.java46
7 files changed, 519 insertions, 35 deletions
diff --git a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/TeamTest.java b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/TeamTest.java
index 3370456bb..35727acdb 100644
--- a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/TeamTest.java
+++ b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/TeamTest.java
@@ -10,32 +10,35 @@
*******************************************************************************/
package org.eclipse.team.tests.core;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
+import java.io.*;
+import java.util.*;
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Status;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.eclipse.core.resources.*;
+import org.eclipse.core.runtime.*;
import org.eclipse.core.tests.harness.EclipseWorkspaceTest;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.core.sync.IRemoteResource;
public class TeamTest extends EclipseWorkspaceTest {
protected static IProgressMonitor DEFAULT_MONITOR = new NullProgressMonitor();
protected static final IProgressMonitor DEFAULT_PROGRESS_MONITOR = new NullProgressMonitor();
+ public static Test suite(Class c) {
+ String testName = System.getProperty("eclipse.team.testName");
+ if (testName == null) {
+ TestSuite suite = new TestSuite(c);
+ return suite;
+ } else {
+ try {
+ return (Test)c.getConstructor(new Class[] { String.class }).newInstance(new Object[] {testName});
+ } catch (Exception e) {
+ fail(e.getMessage());
+ // Above will throw so below is never actually reached
+ return null;
+ }
+ }
+ }
public TeamTest() {
super();
@@ -145,22 +148,6 @@ public class TeamTest extends EclipseWorkspaceTest {
}
}
- // Assert that the two containers have equal contents
- protected void assertEquals(IRemoteResource container1, IResource container2) throws CoreException, TeamException {
- if (container2.getType() == IResource.FILE) {
- // Ignore .project file
- if (container2.getName().equals(".project"))
- return;
- assertTrue(compareContent(container1.getContents(DEFAULT_MONITOR), ((IFile) container2).getContents()));
- } else {
- IRemoteResource[] remoteResources = container1.members(DEFAULT_MONITOR);
- IResource[] localResources = ((IFolder) container2).members();
- for (int i = 0; i < localResources.length; i++) {
- assertEquals(remoteResources[i], localResources[i]);
- }
- }
- }
-
public void appendText(IResource resource, String text, boolean prepend) throws CoreException, IOException {
IFile file = (IFile) resource;
InputStream in = file.getContents();
diff --git a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/AllTeamSynchronizeTests.java b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/AllTeamSynchronizeTests.java
new file mode 100644
index 000000000..24f9123be
--- /dev/null
+++ b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/AllTeamSynchronizeTests.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.tests.ui.synchronize;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.eclipse.core.tests.harness.EclipseWorkspaceTest;
+
+public class AllTeamSynchronizeTests extends EclipseWorkspaceTest {
+
+ /**
+ * Constructor for CVSClientTest.
+ */
+ public AllTeamSynchronizeTests() {
+ super();
+ }
+
+ /**
+ * Constructor for CVSClientTest.
+ * @param name
+ */
+ public AllTeamSynchronizeTests(String name) {
+ super(name);
+ }
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite();
+ suite.addTest(TestDiffNodePresentationModel.suite());
+ suite.addTest(SyncInfoSetContentProviderTest.suite());
+ return suite;
+ }
+}
+
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
new file mode 100644
index 000000000..2d4d6421d
--- /dev/null
+++ b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/SyncInfoSetContentProviderTest.java
@@ -0,0 +1,107 @@
+/*******************************************************************************
+ * 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.tests.ui.synchronize;
+
+import java.util.Iterator;
+import java.util.List;
+
+import junit.framework.Test;
+
+import org.eclipse.core.resources.*;
+import org.eclipse.team.core.synchronize.SyncInfoTree;
+import org.eclipse.team.ui.synchronize.viewers.SynchronizeModelProvider;
+import org.eclipse.team.ui.synchronize.viewers.CompressedFoldersModelProvider;
+
+/**
+ * Tests for the SyncInfoSet content providers.
+ */
+public class SyncInfoSetContentProviderTest extends TestDiffNodePresentationModel {
+
+ /**
+ * Constructor for CVSProviderTest
+ */
+ public SyncInfoSetContentProviderTest() {
+ super();
+ }
+
+ /**
+ * Constructor for CVSProviderTest
+ */
+ public SyncInfoSetContentProviderTest(String name) {
+ super(name);
+ }
+
+ public static Test suite() {
+ return suite(SyncInfoSetContentProviderTest.class);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.tests.ui.synchronize.TestDiffNodePresentationModel#getDiffNodeController()
+ */
+ protected SynchronizeModelProvider getDiffNodeController(SyncInfoTree set) {
+ return new CompressedFoldersModelProvider(set);
+ }
+
+ private void assertFolderPresent(IFolder folder, List resources) {
+ // First, if the folder is out-of-sync, it should be visible
+ for (Iterator iter = resources.iterator(); iter.hasNext();) {
+ IResource resource = (IResource) iter.next();
+ if (resource.equals(folder)) {
+ // The folder should be present.
+ // Remove it since it has been verified
+ iter.remove();
+ return;
+ }
+ }
+ // If the folder contains a file in the list, it is also OK
+ for (Iterator iter = resources.iterator(); iter.hasNext();) {
+ IResource resource = (IResource) iter.next();
+ if (resource.getType() == IResource.FILE && resource.getParent().equals(folder)) {
+ // The compressed folder is valid since it contains an out-of-sync file
+ // However, the resource is left since it has not been verified (only it's parent)
+ return;
+ }
+ }
+ fail("Folder " + folder.getFullPath() + " should not be visible but is.");
+ }
+
+ private void assertFilePresent(IResource itemResource, List resources) {
+ for (Iterator iter = resources.iterator(); iter.hasNext();) {
+ IResource resource = (IResource) iter.next();
+ if (resource.equals(itemResource)) {
+ // The resource has been verified so it can be removed
+ iter.remove();
+ return;
+ }
+ }
+ fail("Resource " + itemResource.getFullPath() + " should not be visible but is.");
+ }
+
+ private void assertProjectPresent(IProject project, List resources) {
+// First, if the project is out-of-sync, it should be visible
+ for (Iterator iter = resources.iterator(); iter.hasNext();) {
+ IResource resource = (IResource) iter.next();
+ if (resource.equals(project)) {
+ // The folder should be present.
+ // Remove it since it has been verified
+ iter.remove();
+ return;
+ }
+ }
+ for (Iterator iter = resources.iterator(); iter.hasNext();) {
+ IResource resource = (IResource) iter.next();
+ if (resource.getProject().equals(project)) {
+ return;
+ }
+ }
+ fail("Project " + project.getName() + " should not be visible but is.");
+ }
+}
diff --git a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/TestDiffNodePresentationModel.java b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/TestDiffNodePresentationModel.java
new file mode 100644
index 000000000..833849309
--- /dev/null
+++ b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/TestDiffNodePresentationModel.java
@@ -0,0 +1,209 @@
+/*******************************************************************************
+ * 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.tests.ui.synchronize;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.Test;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.swt.widgets.Item;
+import org.eclipse.team.core.TeamException;
+import org.eclipse.team.core.synchronize.*;
+import org.eclipse.team.internal.ui.Utils;
+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.*;
+
+
+public class TestDiffNodePresentationModel extends TeamTest {
+
+ private ContentProviderTestView view;
+ private SyncInfoTree set;
+ private TreeViewerAdvisor configuration;
+
+ public TestDiffNodePresentationModel() {
+ super();
+ }
+
+ public TestDiffNodePresentationModel(String name) {
+ super(name);
+ }
+
+ public static Test suite() {
+ return suite(TestDiffNodePresentationModel.class);
+ }
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ this.set = new SyncInfoTree();
+ this.configuration = new TreeViewerAdvisor(set) {
+ protected SynchronizeModelProvider getDiffNodeController() {
+ return TestDiffNodePresentationModel.this.getDiffNodeController(set);
+ }
+ };
+ view = ContentProviderTestView.findViewInActivePage(null);
+ configuration.initializeViewer(view.getViewer());
+ }
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ set = null;
+ configuration.dispose();
+ super.tearDown();
+ }
+
+ protected SynchronizeModelProvider getDiffNodeController(SyncInfoTree set) {
+ return new HierarchicalModelProvider(set);
+ }
+
+ /*
+ * This method creates a project with the given resources, imports
+ * it to CVS and checks it out
+ */
+ protected IProject createProject(String prefix, String[] resources) throws CoreException {
+ IProject project = getUniqueTestProject(prefix);
+ buildResources(project, resources, true);
+ return project;
+ }
+
+ /*
+ * Create a test project using the currently running test case as the project name prefix
+ */
+ protected IProject createProject(String[] resources) throws CoreException {
+ return createProject(getName(), resources);
+ }
+
+ private void adjustSet(SyncInfoSet set, IProject project, String[] resourceStrings, int[] syncKind) throws TeamException {
+ IResource[] resources = buildResources(project, resourceStrings);
+ try {
+ set.beginInput();
+ for (int i = 0; i < resources.length; i++) {
+ IResource resource = resources[i];
+ int kind = syncKind[i];
+ if (kind == SyncInfo.IN_SYNC) {
+ set.remove(resource);
+ } else {
+ SyncInfo newInfo = new TestSyncInfo(resource, kind);
+ set.add(newInfo);
+ }
+ }
+ } finally {
+ set.endInput(null);
+ }
+ }
+
+ /**
+ * Ensure that the resource
+ * @param resources
+ */
+ protected void assertProperVisibleItems() {
+ IResource[] resources = set.getResources();
+ List resourceList = new ArrayList();
+ for (int i = 0; i < resources.length; i++) {
+ IResource resource = resources[i];
+ resourceList.add(resource);
+ }
+ TestTreeViewer viewer = view.getViewer();
+ Item[] items = viewer.getRootItems();
+ if (resources.length == 0) {
+ assertTrue("There are items visible when there should not be.", items.length == 0);
+ return;
+ }
+ // Test that all items in the tree are expected
+ for (int i = 0; i < items.length; i++) {
+ Item item = items[i];
+ assertThatAllOutOfSyncResourcesAreShown(item, resourceList);
+ }
+ // Test that all expected resources and their parents are present
+ assertTrue("The tree did not contain all expected resources: " + resourceList.toString(), resourceList.isEmpty());
+ }
+
+ /**
+ * Traverse every element shown in the view and ensure that every out-of-sync
+ * resource in the set is at least shown. This doesn't test the actual logical
+ * organization, but does ensure that all out-of-sync resources are shown only
+ * once.
+ */
+ protected void assertThatAllOutOfSyncResourcesAreShown(Item item, List outOfSyncResources) {
+ Object node = item.getData();
+ SyncInfo info = (SyncInfo)Utils.getAdapter(node, SyncInfo.class);
+ if(info != null) {
+ assertTrue("The tree contained an out-of-sync resource that wasn't in the set", outOfSyncResources.remove(info.getLocal()));
+ }
+ Item[] children = view.getViewer().getChildren(item);
+ for (int i = 0; i < children.length; i++) {
+ Item child = children[i];
+ assertThatAllOutOfSyncResourcesAreShown(child, outOfSyncResources);
+ }
+ }
+
+ public void testNestedFolder() throws CoreException {
+ IProject project = createProject(new String[]{"file.txt", "folder1/file2.txt", "folder1/folder2/file3.txt"});
+ adjustSet(set, project,
+ new String[]{"file.txt"},
+ new int[]{SyncInfo.OUTGOING | SyncInfo.CHANGE});
+ assertProperVisibleItems();
+ adjustSet(set, project,
+ new String[]{"folder1/file2.txt", "folder1/folder2/file3.txt"},
+ new int[]{SyncInfo.OUTGOING | SyncInfo.CHANGE, SyncInfo.OUTGOING | SyncInfo.CHANGE});
+ assertProperVisibleItems();
+ adjustSet(set, project,
+ new String[]{"folder1/file2.txt"},
+ new int[]{SyncInfo.IN_SYNC,});
+ assertProperVisibleItems();
+ }
+
+ public void testParentRemovalWithChildRemaining() throws CoreException {
+ IProject project = createProject(new String[]{"file.txt", "folder1/file2.txt", "folder1/folder2/file3.txt"});
+ adjustSet(set, project,
+ new String[]{"folder1/folder2/", "folder1/folder2/file3.txt"},
+ new int[]{SyncInfo.CONFLICTING | SyncInfo.CHANGE, SyncInfo.CONFLICTING | SyncInfo.CHANGE});
+ assertProperVisibleItems();
+
+ adjustSet(set, project,
+ new String[]{"folder1/folder2/", "folder1/folder2/file3.txt"},
+ new int[]{SyncInfo.IN_SYNC, SyncInfo.OUTGOING | SyncInfo.CHANGE});
+ assertProperVisibleItems();
+ }
+
+ public void testEmptyFolderChange() throws CoreException {
+ IProject project = createProject(new String[]{"file.txt", "folder1/file2.txt", "folder1/folder2/file3.txt", "folder3/"});
+ adjustSet(set, project,
+ new String[]{"folder1/folder2/", "folder1/folder2/file3.txt"},
+ new int[]{SyncInfo.CONFLICTING | SyncInfo.CHANGE, SyncInfo.CONFLICTING | SyncInfo.CHANGE});
+ assertProperVisibleItems();
+
+ adjustSet(set, project,
+ new String[]{"folder1/folder2/", "folder1/folder2/file3.txt"},
+ new int[]{SyncInfo.IN_SYNC, SyncInfo.OUTGOING | SyncInfo.CHANGE});
+ assertProperVisibleItems();
+
+ adjustSet(set, project,
+ new String[]{"folder1/folder2/file3.txt"},
+ new int[]{SyncInfo.IN_SYNC});
+ assertProperVisibleItems();
+
+ adjustSet(set, project,
+ new String[]{"folder3/"},
+ new int[]{SyncInfo.INCOMING | SyncInfo.ADDITION});
+ assertProperVisibleItems();
+ }
+}
diff --git a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/TestSyncInfo.java b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/TestSyncInfo.java
new file mode 100644
index 000000000..2a1150ac8
--- /dev/null
+++ b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/TestSyncInfo.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * 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.tests.ui.synchronize;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.team.core.TeamException;
+import org.eclipse.team.core.synchronize.SyncInfo;
+
+public class TestSyncInfo extends SyncInfo {
+
+ private int kind;
+
+ public TestSyncInfo(IResource resource, int kind) throws TeamException {
+ super(resource, null, null, null);
+ this.kind = kind;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.core.subscribers.SyncInfo#calculateKind()
+ */
+ protected int calculateKind() throws TeamException {
+ return this.kind;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.core.subscribers.SyncInfo#getKind()
+ */
+ public int getKind() {
+ return kind;
+ }
+}
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
new file mode 100644
index 000000000..f6047411a
--- /dev/null
+++ b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/views/ContentProviderTestView.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * 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.tests.ui.views;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.team.internal.ui.TeamUIPlugin;
+import org.eclipse.ui.*;
+import org.eclipse.ui.part.ViewPart;
+
+public class ContentProviderTestView extends ViewPart {
+
+ public static final String VIEW_ID = "org.eclipse.team.tests.ui.views.ContentProviderTestView";
+
+ private TestTreeViewer viewer;
+
+ public static ContentProviderTestView findViewInActivePage(IWorkbenchPage activePage) {
+ try {
+ if (activePage == null) {
+ activePage = TeamUIPlugin.getActivePage();
+ if (activePage == null) return null;
+ }
+ IViewPart part = activePage.findView(VIEW_ID);
+ if (part == null)
+ part = activePage.showView(VIEW_ID);
+ return (ContentProviderTestView)part;
+ } catch (PartInitException pe) {
+ return null;
+ }
+ }
+
+ public ContentProviderTestView() {
+ }
+
+ public void createPartControl(Composite parent) {
+ viewer = new TestTreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
+ }
+
+ public void setFocus() {
+ viewer.getControl().setFocus();
+ }
+
+ public TestTreeViewer getViewer() {
+ return viewer;
+ }
+} \ No newline at end of file
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
new file mode 100644
index 000000000..7803f5ff2
--- /dev/null
+++ b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/views/TestTreeViewer.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.tests.ui.views;
+
+import org.eclipse.compare.structuremergeviewer.DiffNode;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.widgets.*;
+
+public class TestTreeViewer extends TreeViewer {
+
+ public TestTreeViewer(Composite parent) {
+ super(parent);
+ }
+
+ public TestTreeViewer(Composite parent, int style) {
+ super(parent, style);
+ }
+
+ public TestTreeViewer(Tree tree) {
+ super(tree);
+ }
+
+ public Item[] getRootItems() {
+ expandAll();
+ return getChildren(getControl());
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.AbstractTreeViewer#getChildren(org.eclipse.swt.widgets.Widget)
+ */
+ public Item[] getChildren(Widget o) {
+ return super.getChildren(o);
+ }
+
+ public boolean hasItemFor(DiffNode node) {
+ return findItem(node) != null;
+ }
+}

Back to the top