From: <gjo...@us...> - 2007-05-18 17:23:23
|
Revision: 2382 http://abbot.svn.sourceforge.net/abbot/?rev=2382&view=rev Author: gjohnsto Date: 2007-05-18 10:23:22 -0700 (Fri, 18 May 2007) Log Message: ----------- Initial import. Added Paths: ----------- abbot.swt/trunk/abbot.swt.wtp/.classpath abbot.swt/trunk/abbot.swt.wtp/.project abbot.swt/trunk/abbot.swt.wtp/META-INF/ abbot.swt/trunk/abbot.swt.wtp/META-INF/MANIFEST.MF abbot.swt/trunk/abbot.swt.wtp/bin/ abbot.swt/trunk/abbot.swt.wtp/build.properties abbot.swt/trunk/abbot.swt.wtp/src/ abbot.swt/trunk/abbot.swt.wtp/src/abbot/ abbot.swt/trunk/abbot.swt.wtp/src/abbot/swt/ abbot.swt/trunk/abbot.swt.wtp/src/abbot/swt/wtp/ abbot.swt/trunk/abbot.swt.wtp/src/abbot/swt/wtp/dom/ abbot.swt/trunk/abbot.swt.wtp/src/abbot/swt/wtp/dom/DOMNodeFinder.java abbot.swt/trunk/abbot.swt.wtp/src/abbot/swt/wtp/dom/DOMNodeFinderImpl.java abbot.swt/trunk/abbot.swt.wtp/src/abbot/swt/wtp/dom/DOMNodeMatcher.java abbot.swt/trunk/abbot.swt.wtp/src/abbot/swt/wtp/dom/matcher/ abbot.swt/trunk/abbot.swt.wtp/src/abbot/swt/wtp/dom/matcher/DOMNodeTagNameMatcher.java abbot.swt/trunk/abbot.swt.wtp/src/subbu/ abbot.swt/trunk/abbot.swt.wtp/src/subbu/abbot/ abbot.swt/trunk/abbot.swt.wtp/src/subbu/abbot/test/ abbot.swt/trunk/abbot.swt.wtp/src/subbu/abbot/test/FindNodeTest.java Added: abbot.swt/trunk/abbot.swt.wtp/.classpath =================================================================== --- abbot.swt/trunk/abbot.swt.wtp/.classpath (rev 0) +++ abbot.swt/trunk/abbot.swt.wtp/.classpath 2007-05-18 17:23:22 UTC (rev 2382) @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="src" path="src"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="output" path="bin"/> +</classpath> Added: abbot.swt/trunk/abbot.swt.wtp/.project =================================================================== --- abbot.swt/trunk/abbot.swt.wtp/.project (rev 0) +++ abbot.swt/trunk/abbot.swt.wtp/.project 2007-05-18 17:23:22 UTC (rev 2382) @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>abbot.swt.wtp</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> Added: abbot.swt/trunk/abbot.swt.wtp/META-INF/MANIFEST.MF =================================================================== --- abbot.swt/trunk/abbot.swt.wtp/META-INF/MANIFEST.MF (rev 0) +++ abbot.swt/trunk/abbot.swt.wtp/META-INF/MANIFEST.MF 2007-05-18 17:23:22 UTC (rev 2382) @@ -0,0 +1,12 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Abbot for SWT WTP Support +Bundle-SymbolicName: abbot.swt.wtp +Bundle-Version: 1.0.0 +Bundle-Vendor: IBM +Eclipse-LazyStart: true +Require-Bundle: org.junit;bundle-version="[3.8.2,4.0.0)", + abbot.swt;bundle-version="[1.0.0,2.0.0)", + org.eclipse.wst.xml.ui;bundle-version="[1.0.0,3.0.0)" +Export-Package: abbot.swt.wtp.dom, + abbot.swt.wtp.dom.matcher Added: abbot.swt/trunk/abbot.swt.wtp/build.properties =================================================================== --- abbot.swt/trunk/abbot.swt.wtp/build.properties (rev 0) +++ abbot.swt/trunk/abbot.swt.wtp/build.properties 2007-05-18 17:23:22 UTC (rev 2382) @@ -0,0 +1,4 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . Added: abbot.swt/trunk/abbot.swt.wtp/src/abbot/swt/wtp/dom/DOMNodeFinder.java =================================================================== --- abbot.swt/trunk/abbot.swt.wtp/src/abbot/swt/wtp/dom/DOMNodeFinder.java (rev 0) +++ abbot.swt/trunk/abbot.swt.wtp/src/abbot/swt/wtp/dom/DOMNodeFinder.java 2007-05-18 17:23:22 UTC (rev 2382) @@ -0,0 +1,9 @@ +package abbot.swt.wtp.dom; + +import org.w3c.dom.Node; + +import abbot.swt.finder.generic.Finder; + +public interface DOMNodeFinder extends Finder<Node> { + +} Added: abbot.swt/trunk/abbot.swt.wtp/src/abbot/swt/wtp/dom/DOMNodeFinderImpl.java =================================================================== --- abbot.swt/trunk/abbot.swt.wtp/src/abbot/swt/wtp/dom/DOMNodeFinderImpl.java (rev 0) +++ abbot.swt/trunk/abbot.swt.wtp/src/abbot/swt/wtp/dom/DOMNodeFinderImpl.java 2007-05-18 17:23:22 UTC (rev 2382) @@ -0,0 +1,64 @@ +package abbot.swt.wtp.dom; + +import org.w3c.dom.Document; +import org.w3c.dom.Node; +import org.w3c.dom.traversal.DocumentTraversal; +import org.w3c.dom.traversal.NodeFilter; +import org.w3c.dom.traversal.NodeIterator; + +import abbot.swt.finder.generic.Matcher; +import abbot.swt.finder.generic.NotFoundException; + +public class DOMNodeFinderImpl implements DOMNodeFinder { + + protected static final int DEFAULT_WHAT_TO_SHOW = NodeFilter.SHOW_ELEMENT; + + protected static final NodeFilter DEFAULT_NODE_FILTER = null; + + protected static final boolean DEFAULT_ENTITY_REFERENCE_EXPANSION = false; + + protected final Document document; + + protected final int whatToShow; + + protected final NodeFilter filter; + + protected final boolean entityReferenceExpansion; + + public DOMNodeFinderImpl(Document document) { + this(document, DEFAULT_WHAT_TO_SHOW, DEFAULT_NODE_FILTER, + DEFAULT_ENTITY_REFERENCE_EXPANSION); + } + + public DOMNodeFinderImpl(Document document, int whatToShow) { + this(document, whatToShow, DEFAULT_NODE_FILTER, DEFAULT_ENTITY_REFERENCE_EXPANSION); + } + + public DOMNodeFinderImpl(Document document, int whatToShow, NodeFilter filter, + boolean entityReferenceExpansion) { + this.document = document; + this.whatToShow = whatToShow; + this.filter = filter; + this.entityReferenceExpansion = entityReferenceExpansion; + } + + public Node find(Matcher<Node> matcher) throws NotFoundException { + return find(document, matcher); + } + + public Node find(Node root, Matcher<Node> matcher) throws NotFoundException { + NodeIterator iter = ((DocumentTraversal) document).createNodeIterator( + root, + whatToShow, + filter, + entityReferenceExpansion); + for (;;) { + Node node = iter.nextNode(); + if (node == null) + throw new NotFoundException(); + if (matcher.matches(node)) + return node; + } + } + +} Added: abbot.swt/trunk/abbot.swt.wtp/src/abbot/swt/wtp/dom/DOMNodeMatcher.java =================================================================== --- abbot.swt/trunk/abbot.swt.wtp/src/abbot/swt/wtp/dom/DOMNodeMatcher.java (rev 0) +++ abbot.swt/trunk/abbot.swt.wtp/src/abbot/swt/wtp/dom/DOMNodeMatcher.java 2007-05-18 17:23:22 UTC (rev 2382) @@ -0,0 +1,9 @@ +package abbot.swt.wtp.dom; + +import org.w3c.dom.Node; + +import abbot.swt.finder.generic.Matcher; + +public interface DOMNodeMatcher extends Matcher<Node> { + +} Added: abbot.swt/trunk/abbot.swt.wtp/src/abbot/swt/wtp/dom/matcher/DOMNodeTagNameMatcher.java =================================================================== --- abbot.swt/trunk/abbot.swt.wtp/src/abbot/swt/wtp/dom/matcher/DOMNodeTagNameMatcher.java (rev 0) +++ abbot.swt/trunk/abbot.swt.wtp/src/abbot/swt/wtp/dom/matcher/DOMNodeTagNameMatcher.java 2007-05-18 17:23:22 UTC (rev 2382) @@ -0,0 +1,20 @@ +package abbot.swt.wtp.dom.matcher; + +import org.w3c.dom.Node; + +import abbot.swt.wtp.dom.DOMNodeMatcher; + + +public class DOMNodeTagNameMatcher implements DOMNodeMatcher { + + private final String tagName; + + public DOMNodeTagNameMatcher(String tagName) { + this.tagName = tagName; + } + + public boolean matches(Node node) { + return node.getNodeName().equals(tagName); + } + +} Added: abbot.swt/trunk/abbot.swt.wtp/src/subbu/abbot/test/FindNodeTest.java =================================================================== --- abbot.swt/trunk/abbot.swt.wtp/src/subbu/abbot/test/FindNodeTest.java (rev 0) +++ abbot.swt/trunk/abbot.swt.wtp/src/subbu/abbot/test/FindNodeTest.java 2007-05-18 17:23:22 UTC (rev 2382) @@ -0,0 +1,56 @@ +package subbu.abbot.test; + +import junit.framework.TestCase; + +public class FindNodeTest extends TestCase { + +// private static final String PROJECT_NAME = "dynamic"; +// private static WebProjectHelper webProjectHelper; +// +// public void testBasicHTML() throws WidgetNotFoundException, +// MultipleWidgetsFoundException { +// // get active Document model +// IEditorPart editorPart = abbot.swt.gef.util.WorkbenchUtilities.getActiveEditor(); +// IDesignPage page = ((HTMLEditor)editorPart).getDesignPage(); +// HTMLEditDomain editDomain = (HTMLEditDomain) editorPart.getAdapter(HTMLEditDomain.class); +// IDOMModel domModel = editDomain.getActiveModel(); +// Document document = domModel.getDocument(); +// +// // get relevant DOM node +// DOMNodeMatcher domMatcher = new DOMNodeMatcherByTagName("h:inputText"); +// DOMNodeFinder domFinder = new DOMNodeFinderImpl(document); +// Node node = domFinder.find(domMatcher); +// +// // finally get the node's size +// WysiwygView viewer = (WysiwygView) ((HTMLDesignPage) page).getActiveViewer(); +// List rectList = viewer.getNodeRects(node); +// System.out.println((Rectangle)rectList.get(0)); +// } +// +// public static Test suite() +// { +// SWTTestSetup setup = new SWTTestSetup(new TestSuite( +// FindNodeTest.class)) +// { +// @Override +// protected void setUp() throws Exception +// { +// super.setUp(); +//// webProjectHelper = new WebProjectHelper(PROJECT_NAME, false); +// WidgetTester.getWidgetTester().wait(new JobManagerIdleCondition(), 60000, 2000); +// WorkbenchUtil.openPerspective("Web"); +// // When this above break point is hit, create a new JSP page +// // drag-and-drop "Input" from "Enhanced Faces Component" +// // and then continue this break-point. Eventually these actions +// // need to be automated. +// } +// +// protected void tearDown() +// { +//// webProjectHelper.dispose(); +// } +// }; +// return setup; +// } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |