Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKetan Padegaonkar2008-12-29 10:38:48 +0000
committerKetan Padegaonkar2008-12-29 10:38:48 +0000
commitcfecda7ddefc371161e5fc7bd7ec9c9bf706f52e (patch)
tree4d2f69094affb327529fe923a398f22294af0767
parent211b791a0a82e617ef6577072105471461ef5882 (diff)
downloadorg.eclipse.swtbot-cfecda7ddefc371161e5fc7bd7ec9c9bf706f52e.tar.gz
org.eclipse.swtbot-cfecda7ddefc371161e5fc7bd7ec9c9bf706f52e.tar.xz
org.eclipse.swtbot-cfecda7ddefc371161e5fc7bd7ec9c9bf706f52e.zip
RESOLVED - bug 259731: Reduce dependency footprint of SWTBot(removed jface dependency)
https://bugs.eclipse.org/bugs/show_bug.cgi?id=259731
-rw-r--r--org.eclipse.swtbot.eclipse.spy/src/org/eclipse/swtbot/eclipse/spy/EclipseWidgetTracker.java2
-rw-r--r--org.eclipse.swtbot.swt.finder.test/META-INF/MANIFEST.MF2
-rw-r--r--org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/finders/ControlFinder2Test.java5
-rw-r--r--org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/finders/ControlFinderTest.java3
-rw-r--r--org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/finders/PathGeneratorTest.java4
-rw-r--r--org.eclipse.swtbot.swt.finder/META-INF/MANIFEST.MF2
-rw-r--r--org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/finders/ControlFinder.java3
-rw-r--r--org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/finders/PathGenerator.java2
-rw-r--r--org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/matchers/AbstractMatcher.java2
-rw-r--r--org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/matchers/InGroup.java2
-rw-r--r--org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/utils/TreePath.java115
-rw-r--r--org.eclipse.swtbot.swt.spy/src/org/eclipse/swtbot/swt/spy/WidgetTracker.java2
12 files changed, 126 insertions, 18 deletions
diff --git a/org.eclipse.swtbot.eclipse.spy/src/org/eclipse/swtbot/eclipse/spy/EclipseWidgetTracker.java b/org.eclipse.swtbot.eclipse.spy/src/org/eclipse/swtbot/eclipse/spy/EclipseWidgetTracker.java
index 6bdec4de..9c555c2a 100644
--- a/org.eclipse.swtbot.eclipse.spy/src/org/eclipse/swtbot/eclipse/spy/EclipseWidgetTracker.java
+++ b/org.eclipse.swtbot.eclipse.spy/src/org/eclipse/swtbot/eclipse/spy/EclipseWidgetTracker.java
@@ -13,7 +13,6 @@ package org.eclipse.swtbot.eclipse.spy;
import java.util.Iterator;
import java.util.List;
-import org.eclipse.jface.viewers.TreePath;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.custom.CTabItem;
@@ -44,6 +43,7 @@ import org.eclipse.swtbot.swt.finder.finders.PathGenerator;
import org.eclipse.swtbot.swt.finder.resolvers.IChildrenResolver;
import org.eclipse.swtbot.swt.finder.resolvers.IParentResolver;
import org.eclipse.swtbot.swt.finder.utils.SWTUtils;
+import org.eclipse.swtbot.swt.finder.utils.TreePath;
class EclipseWidgetTracker implements Runnable {
protected IChildrenResolver childrenResolver;
diff --git a/org.eclipse.swtbot.swt.finder.test/META-INF/MANIFEST.MF b/org.eclipse.swtbot.swt.finder.test/META-INF/MANIFEST.MF
index 27af419d..8c22f547 100644
--- a/org.eclipse.swtbot.swt.finder.test/META-INF/MANIFEST.MF
+++ b/org.eclipse.swtbot.swt.finder.test/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2
Bundle-Name: SWTBot SWT Control Finder plugin (incubation)
Bundle-SymbolicName: org.eclipse.swtbot.swt.finder.test;singleton:=true
Bundle-Version: 2.0.0.qualifier
-Require-Bundle: org.eclipse.ui,
+Require-Bundle: org.eclipse.swt,
org.eclipse.swt.examples,
org.eclipse.swtbot.swt.finder,
org.apache.log4j,
diff --git a/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/finders/ControlFinder2Test.java b/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/finders/ControlFinder2Test.java
index 510b139e..ae380ab0 100644
--- a/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/finders/ControlFinder2Test.java
+++ b/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/finders/ControlFinder2Test.java
@@ -19,15 +19,12 @@ import java.util.List;
import junit.framework.Assert;
-
-import org.eclipse.jface.viewers.TreePath;
import org.eclipse.swt.custom.CTabItem;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.Widget;
-import org.eclipse.swtbot.swt.finder.finders.ControlFinder;
-import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
import org.eclipse.swtbot.swt.finder.results.VoidResult;
+import org.eclipse.swtbot.swt.finder.utils.TreePath;
/**
* @author Ketan Padegaonkar <KetanPadegaonkar [at] gmail [dot] com>
diff --git a/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/finders/ControlFinderTest.java b/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/finders/ControlFinderTest.java
index ce3709fa..2a3e7197 100644
--- a/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/finders/ControlFinderTest.java
+++ b/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/finders/ControlFinderTest.java
@@ -19,7 +19,6 @@ import java.util.List;
import junit.framework.Assert;
-import org.eclipse.jface.viewers.TreePath;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.TabFolder;
@@ -27,7 +26,7 @@ import org.eclipse.swt.widgets.TabItem;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Widget;
import org.eclipse.swtbot.swt.finder.SWTBot;
-import org.eclipse.swtbot.swt.finder.finders.ControlFinder;
+import org.eclipse.swtbot.swt.finder.utils.TreePath;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTabItem;
/**
diff --git a/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/finders/PathGeneratorTest.java b/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/finders/PathGeneratorTest.java
index 31ff3676..b86ec957 100644
--- a/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/finders/PathGeneratorTest.java
+++ b/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/finders/PathGeneratorTest.java
@@ -19,11 +19,9 @@ import java.util.List;
import junit.framework.Assert;
-import org.eclipse.jface.viewers.TreePath;
import org.eclipse.swt.widgets.TabItem;
import org.eclipse.swt.widgets.Widget;
-import org.eclipse.swtbot.swt.finder.finders.ControlFinder;
-import org.eclipse.swtbot.swt.finder.finders.PathGenerator;
+import org.eclipse.swtbot.swt.finder.utils.TreePath;
/**
* @author Ketan Padegaonkar <KetanPadegaonkar [at] gmail [dot] com>
diff --git a/org.eclipse.swtbot.swt.finder/META-INF/MANIFEST.MF b/org.eclipse.swtbot.swt.finder/META-INF/MANIFEST.MF
index c1f1e621..14aa0459 100644
--- a/org.eclipse.swtbot.swt.finder/META-INF/MANIFEST.MF
+++ b/org.eclipse.swtbot.swt.finder/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2
Bundle-Name: SWTBot SWT Control Finder plugin (incubation)
Bundle-SymbolicName: org.eclipse.swtbot.swt.finder;singleton:=true
Bundle-Version: 2.0.0.qualifier
-Require-Bundle: org.eclipse.ui,
+Require-Bundle: org.eclipse.swt,
org.junit,
org.apache.commons.collections,
org.apache.log4j,
diff --git a/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/finders/ControlFinder.java b/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/finders/ControlFinder.java
index 8c2eed40..4de1b351 100644
--- a/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/finders/ControlFinder.java
+++ b/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/finders/ControlFinder.java
@@ -15,9 +15,7 @@ import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
-
import org.apache.log4j.Logger;
-import org.eclipse.jface.viewers.TreePath;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
@@ -33,6 +31,7 @@ import org.eclipse.swtbot.swt.finder.results.ListResult;
import org.eclipse.swtbot.swt.finder.results.WidgetResult;
import org.eclipse.swtbot.swt.finder.utils.MessageFormat;
import org.eclipse.swtbot.swt.finder.utils.SWTUtils;
+import org.eclipse.swtbot.swt.finder.utils.TreePath;
import org.hamcrest.Matcher;
/**
diff --git a/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/finders/PathGenerator.java b/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/finders/PathGenerator.java
index 239a12ea..b8b39f44 100644
--- a/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/finders/PathGenerator.java
+++ b/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/finders/PathGenerator.java
@@ -11,7 +11,6 @@
package org.eclipse.swtbot.swt.finder.finders;
-import org.eclipse.jface.viewers.TreePath;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Widget;
@@ -19,6 +18,7 @@ import org.eclipse.swtbot.swt.finder.resolvers.DefaultChildrenResolver;
import org.eclipse.swtbot.swt.finder.resolvers.IChildrenResolver;
import org.eclipse.swtbot.swt.finder.results.WidgetResult;
import org.eclipse.swtbot.swt.finder.utils.SWTUtils;
+import org.eclipse.swtbot.swt.finder.utils.TreePath;
/**
* This is a path generate used to resolve paths to a component. This is intended for use only internally by the
diff --git a/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/matchers/AbstractMatcher.java b/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/matchers/AbstractMatcher.java
index a8ea2a37..5fd06d91 100644
--- a/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/matchers/AbstractMatcher.java
+++ b/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/matchers/AbstractMatcher.java
@@ -13,12 +13,12 @@ package org.eclipse.swtbot.swt.finder.matchers;
import org.apache.log4j.Logger;
-import org.eclipse.jface.viewers.TreePath;
import org.eclipse.swt.widgets.Widget;
import org.eclipse.swtbot.swt.finder.finders.PathGenerator;
import org.eclipse.swtbot.swt.finder.utils.ClassUtils;
import org.eclipse.swtbot.swt.finder.utils.MessageFormat;
import org.eclipse.swtbot.swt.finder.utils.SWTUtils;
+import org.eclipse.swtbot.swt.finder.utils.TreePath;
import org.hamcrest.BaseMatcher;
import org.hamcrest.StringDescription;
diff --git a/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/matchers/InGroup.java b/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/matchers/InGroup.java
index 3cf7ce39..2de4783a 100644
--- a/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/matchers/InGroup.java
+++ b/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/matchers/InGroup.java
@@ -12,11 +12,11 @@
package org.eclipse.swtbot.swt.finder.matchers;
-import org.eclipse.jface.viewers.TreePath;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Widget;
import org.eclipse.swtbot.swt.finder.finders.PathGenerator;
import org.eclipse.swtbot.swt.finder.utils.SWTUtils;
+import org.eclipse.swtbot.swt.finder.utils.TreePath;
import org.hamcrest.Description;
import org.hamcrest.Factory;
import org.hamcrest.Matcher;
diff --git a/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/utils/TreePath.java b/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/utils/TreePath.java
new file mode 100644
index 00000000..e6a1eeef
--- /dev/null
+++ b/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/utils/TreePath.java
@@ -0,0 +1,115 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swtbot.swt.finder.utils;
+
+import org.eclipse.swtbot.swt.finder.utils.internal.Assert;
+
+public final class TreePath {
+
+ /**
+ * Constant for representing an empty tree path.
+ */
+ public static final TreePath EMPTY = new TreePath(new Object[0]);
+
+ private Object[] segments;
+
+ private int hash;
+
+ /**
+ * Constructs a path identifying a leaf node in a tree.
+ *
+ * @param segments path of elements to a leaf node in a tree, starting with the root element
+ */
+ public TreePath(Object[] segments) {
+ Assert.isNotNull(segments);
+ for (int i = 0; i < segments.length; i++) {
+ Assert.isNotNull(segments[i]);
+ }
+ this.segments = segments;
+ }
+
+ /**
+ * Returns the element at the specified index in this path.
+ *
+ * @param index index of element to return
+ * @return element at the specified index
+ */
+ public Object getSegment(int index) {
+ return segments[index];
+ }
+
+ /**
+ * Returns the number of elements in this path.
+ *
+ * @return the number of elements in this path
+ */
+ public int getSegmentCount() {
+ return segments.length;
+ }
+
+ /**
+ * Returns the first element in this path, or <code>null</code> if this path has no segments.
+ *
+ * @return the first element in this path
+ */
+ public Object getFirstSegment() {
+ if (segments.length == 0) {
+ return null;
+ }
+ return segments[0];
+ }
+
+ /**
+ * Returns the last element in this path, or <code>null</code> if this path has no segments.
+ *
+ * @return the last element in this path
+ */
+ public Object getLastSegment() {
+ if (segments.length == 0) {
+ return null;
+ }
+ return segments[segments.length - 1];
+ }
+
+ /**
+ * Returns a copy of this tree path with one segment removed from the end, or <code>null</code> if this tree path
+ * has no segments.
+ *
+ * @return a tree path
+ */
+ public TreePath getParentPath() {
+ int segmentCount = getSegmentCount();
+ if (segmentCount < 1) {
+ return null;
+ } else if (segmentCount == 1) {
+ return EMPTY;
+ }
+ Object[] parentSegments = new Object[segmentCount - 1];
+ System.arraycopy(segments, 0, parentSegments, 0, segmentCount - 1);
+ return new TreePath(parentSegments);
+ }
+
+ /**
+ * Returns a copy of this tree path with the given segment added at the end.
+ *
+ * @param newSegment
+ * @return a tree path
+ */
+ public TreePath createChildPath(Object newSegment) {
+ int segmentCount = getSegmentCount();
+ Object[] childSegments = new Object[segmentCount + 1];
+ if (segmentCount > 0) {
+ System.arraycopy(segments, 0, childSegments, 0, segmentCount);
+ }
+ childSegments[segmentCount] = newSegment;
+ return new TreePath(childSegments);
+ }
+}
diff --git a/org.eclipse.swtbot.swt.spy/src/org/eclipse/swtbot/swt/spy/WidgetTracker.java b/org.eclipse.swtbot.swt.spy/src/org/eclipse/swtbot/swt/spy/WidgetTracker.java
index 4618585c..b02e8c79 100644
--- a/org.eclipse.swtbot.swt.spy/src/org/eclipse/swtbot/swt/spy/WidgetTracker.java
+++ b/org.eclipse.swtbot.swt.spy/src/org/eclipse/swtbot/swt/spy/WidgetTracker.java
@@ -13,7 +13,6 @@ package org.eclipse.swtbot.swt.spy;
import java.util.Iterator;
import java.util.List;
-import org.eclipse.jface.viewers.TreePath;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.custom.CTabItem;
@@ -44,6 +43,7 @@ import org.eclipse.swtbot.swt.finder.finders.PathGenerator;
import org.eclipse.swtbot.swt.finder.resolvers.IChildrenResolver;
import org.eclipse.swtbot.swt.finder.resolvers.IParentResolver;
import org.eclipse.swtbot.swt.finder.utils.SWTUtils;
+import org.eclipse.swtbot.swt.finder.utils.TreePath;
class WidgetTracker implements Runnable {
protected IChildrenResolver childrenResolver;

Back to the top