Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMickael Istria2012-12-19 12:46:53 +0000
committerGerrit Code Review @ Eclipse.org2013-01-08 10:21:30 +0000
commitc878ee8136d60ac8a8306007de744e1f979819b0 (patch)
tree40217aee3f51777221e46e5d5b182e4fffbc35b2
parentc43009b92512f8463da6192c7662d60ff6a3fbe5 (diff)
downloadorg.eclipse.swtbot-c878ee8136d60ac8a8306007de744e1f979819b0.tar.gz
org.eclipse.swtbot-c878ee8136d60ac8a8306007de744e1f979819b0.tar.xz
org.eclipse.swtbot-c878ee8136d60ac8a8306007de744e1f979819b0.zip
A Code Generator that records events and generate relevant code
-rw-r--r--org.eclipse.swtbot.generator.feature/.project17
-rw-r--r--org.eclipse.swtbot.generator.feature/build.properties (renamed from org.eclipse.swtbot.generator.test/build.properties)17
-rw-r--r--org.eclipse.swtbot.generator.feature/epl-v10.html328
-rw-r--r--org.eclipse.swtbot.generator.feature/feature.properties140
-rw-r--r--org.eclipse.swtbot.generator.feature/feature.xml28
-rw-r--r--org.eclipse.swtbot.generator.feature/feature.xml~80
-rw-r--r--org.eclipse.swtbot.generator.feature/license.html107
-rw-r--r--org.eclipse.swtbot.generator.feature/pom.xml25
-rw-r--r--org.eclipse.swtbot.generator.test/.classpath7
-rw-r--r--org.eclipse.swtbot.generator.test/.project28
-rw-r--r--org.eclipse.swtbot.generator.test/.settings/org.eclipse.jdt.core.prefs21
-rw-r--r--org.eclipse.swtbot.generator.test/META-INF/MANIFEST.MF13
-rw-r--r--org.eclipse.swtbot.generator.test/pom.xml20
-rw-r--r--org.eclipse.swtbot.generator.test/src/org/eclipse/swtbot/generator/CombinationGeneratorMain.java30
-rw-r--r--org.eclipse.swtbot.generator.test/src/org/eclipse/swtbot/generator/MethodGeneratorTest.java126
-rw-r--r--org.eclipse.swtbot.generator/META-INF/MANIFEST.MF14
-rw-r--r--org.eclipse.swtbot.generator/build.properties3
-rw-r--r--org.eclipse.swtbot.generator/plugin.xml18
-rw-r--r--org.eclipse.swtbot.generator/schema/generator.exsd97
-rw-r--r--org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/HamcrestFactoryWriter.java129
-rw-r--r--org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/HamcrestWriter.java35
-rw-r--r--org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/MatcherGeneratorMain.java96
-rw-r--r--org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/MethodFactory.java56
-rw-r--r--org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/MethodGenerator.java192
-rw-r--r--org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/QuickReferenceWriter.java56
-rw-r--r--org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/SWTBotGeneratorFactoryReader.java63
-rw-r--r--org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/SWTBotGeneratorMain.java29
-rw-r--r--org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/SugarGenerator.java61
-rw-r--r--org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/XmlConfigurator.java90
-rw-r--r--org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/framework/GenerationRule.java29
-rw-r--r--org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/framework/Generator.java21
-rw-r--r--org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/framework/WidgetUtils.java42
-rw-r--r--org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/framework/rules/AbstractTreeGenerationRule.java76
-rw-r--r--org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/framework/rules/CComboSelectionRule.java62
-rw-r--r--org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/framework/rules/CheckboxClickedRule.java53
-rw-r--r--org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/framework/rules/ComboSelectionRule.java62
-rw-r--r--org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/framework/rules/DoubleClickTreeItemRule.java28
-rw-r--r--org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/framework/rules/ExpandTreeItemRule.java28
-rw-r--r--org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/framework/rules/MenuClickedRule.java69
-rw-r--r--org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/framework/rules/ModifyTextRule.java52
-rw-r--r--org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/framework/rules/PushButtonClickedRule.java53
-rw-r--r--org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/framework/rules/RadioButtonClickedRule.java53
-rw-r--r--org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/framework/rules/SWTBotGeneratorRules.java39
-rw-r--r--org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/framework/rules/SelectTreeItemRule.java29
-rw-r--r--org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/ui/BotGeneratorEventDispatcher.java125
-rw-r--r--org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/ui/GeneratorExtensionPointManager.java38
-rw-r--r--org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/ui/RecorderDialog.java144
-rw-r--r--org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/ui/StartupRecorder.java71
-rw-r--r--org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotText.java6
-rw-r--r--org.eclipse.swtbot.test/feature.xml6
-rw-r--r--org.eclipse.swtbot.updatesite/category.xml3
-rw-r--r--pom.xml2
52 files changed, 1940 insertions, 1077 deletions
diff --git a/org.eclipse.swtbot.generator.feature/.project b/org.eclipse.swtbot.generator.feature/.project
new file mode 100644
index 00000000..71c57931
--- /dev/null
+++ b/org.eclipse.swtbot.generator.feature/.project
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.swtbot.eclipse</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.pde.FeatureBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.FeatureNature</nature>
+ </natures>
+</projectDescription>
diff --git a/org.eclipse.swtbot.generator.test/build.properties b/org.eclipse.swtbot.generator.feature/build.properties
index a0607871..aff40513 100644
--- a/org.eclipse.swtbot.generator.test/build.properties
+++ b/org.eclipse.swtbot.generator.feature/build.properties
@@ -4,11 +4,18 @@
# 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:
# Ketan Padegaonkar - initial API and implementation
###############################################################################
-source.. = src/
-output.. = bin/
-bin.includes = META-INF/,\
- .
+bin.includes = feature.xml,\
+ license.html,\
+ epl-v10.html,\
+ feature.properties
+jars.compile.order = .
+source.. =
+src.includes = feature.xml,\
+ build.properties,\
+ epl-v10.html,\
+ license.html,\
+ feature.properties
diff --git a/org.eclipse.swtbot.generator.feature/epl-v10.html b/org.eclipse.swtbot.generator.feature/epl-v10.html
new file mode 100644
index 00000000..ed4b1966
--- /dev/null
+++ b/org.eclipse.swtbot.generator.feature/epl-v10.html
@@ -0,0 +1,328 @@
+<html xmlns:o="urn:schemas-microsoft-com:office:office"
+xmlns:w="urn:schemas-microsoft-com:office:word"
+xmlns="http://www.w3.org/TR/REC-html40">
+
+<head>
+<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
+<meta name=ProgId content=Word.Document>
+<meta name=Generator content="Microsoft Word 9">
+<meta name=Originator content="Microsoft Word 9">
+<link rel=File-List
+href="./Eclipse%20EPL%202003_11_10%20Final_files/filelist.xml">
+<title>Eclipse Public License - Version 1.0</title>
+<!--[if gte mso 9]><xml>
+ <o:DocumentProperties>
+ <o:Revision>2</o:Revision>
+ <o:TotalTime>3</o:TotalTime>
+ <o:Created>2004-03-05T23:03:00Z</o:Created>
+ <o:LastSaved>2004-03-05T23:03:00Z</o:LastSaved>
+ <o:Pages>4</o:Pages>
+ <o:Words>1626</o:Words>
+ <o:Characters>9270</o:Characters>
+ <o:Lines>77</o:Lines>
+ <o:Paragraphs>18</o:Paragraphs>
+ <o:CharactersWithSpaces>11384</o:CharactersWithSpaces>
+ <o:Version>9.4402</o:Version>
+ </o:DocumentProperties>
+</xml><![endif]--><!--[if gte mso 9]><xml>
+ <w:WordDocument>
+ <w:TrackRevisions/>
+ </w:WordDocument>
+</xml><![endif]-->
+<style>
+<!--
+ /* Font Definitions */
+@font-face
+ {font-family:Tahoma;
+ panose-1:2 11 6 4 3 5 4 4 2 4;
+ mso-font-charset:0;
+ mso-generic-font-family:swiss;
+ mso-font-pitch:variable;
+ mso-font-signature:553679495 -2147483648 8 0 66047 0;}
+ /* Style Definitions */
+p.MsoNormal, li.MsoNormal, div.MsoNormal
+ {mso-style-parent:"";
+ margin:0in;
+ margin-bottom:.0001pt;
+ mso-pagination:widow-orphan;
+ font-size:12.0pt;
+ font-family:"Times New Roman";
+ mso-fareast-font-family:"Times New Roman";}
+p
+ {margin-right:0in;
+ mso-margin-top-alt:auto;
+ mso-margin-bottom-alt:auto;
+ margin-left:0in;
+ mso-pagination:widow-orphan;
+ font-size:12.0pt;
+ font-family:"Times New Roman";
+ mso-fareast-font-family:"Times New Roman";}
+p.BalloonText, li.BalloonText, div.BalloonText
+ {mso-style-name:"Balloon Text";
+ margin:0in;
+ margin-bottom:.0001pt;
+ mso-pagination:widow-orphan;
+ font-size:8.0pt;
+ font-family:Tahoma;
+ mso-fareast-font-family:"Times New Roman";}
+@page Section1
+ {size:8.5in 11.0in;
+ margin:1.0in 1.25in 1.0in 1.25in;
+ mso-header-margin:.5in;
+ mso-footer-margin:.5in;
+ mso-paper-source:0;}
+div.Section1
+ {page:Section1;}
+-->
+</style>
+</head>
+
+<body lang=EN-US style='tab-interval:.5in'>
+
+<div class=Section1>
+
+<p align=center style='text-align:center'><b>Eclipse Public License - v 1.0</b>
+</p>
+
+<p><span style='font-size:10.0pt'>THE ACCOMPANYING PROGRAM IS PROVIDED UNDER
+THE TERMS OF THIS ECLIPSE PUBLIC LICENSE (&quot;AGREEMENT&quot;). ANY USE,
+REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE
+OF THIS AGREEMENT.</span> </p>
+
+<p><b><span style='font-size:10.0pt'>1. DEFINITIONS</span></b> </p>
+
+<p><span style='font-size:10.0pt'>&quot;Contribution&quot; means:</span> </p>
+
+<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
+in the case of the initial Contributor, the initial code and documentation
+distributed under this Agreement, and<br clear=left>
+b) in the case of each subsequent Contributor:</span></p>
+
+<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>i)
+changes to the Program, and</span></p>
+
+<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>ii)
+additions to the Program;</span></p>
+
+<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>where
+such changes and/or additions to the Program originate from and are distributed
+by that particular Contributor. A Contribution 'originates' from a Contributor
+if it was added to the Program by such Contributor itself or anyone acting on
+such Contributor's behalf. Contributions do not include additions to the
+Program which: (i) are separate modules of software distributed in conjunction
+with the Program under their own license agreement, and (ii) are not derivative
+works of the Program. </span></p>
+
+<p><span style='font-size:10.0pt'>&quot;Contributor&quot; means any person or
+entity that distributes the Program.</span> </p>
+
+<p><span style='font-size:10.0pt'>&quot;Licensed Patents &quot; mean patent
+claims licensable by a Contributor which are necessarily infringed by the use
+or sale of its Contribution alone or when combined with the Program. </span></p>
+
+<p><span style='font-size:10.0pt'>&quot;Program&quot; means the Contributions
+distributed in accordance with this Agreement.</span> </p>
+
+<p><span style='font-size:10.0pt'>&quot;Recipient&quot; means anyone who
+receives the Program under this Agreement, including all Contributors.</span> </p>
+
+<p><b><span style='font-size:10.0pt'>2. GRANT OF RIGHTS</span></b> </p>
+
+<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
+Subject to the terms of this Agreement, each Contributor hereby grants Recipient
+a non-exclusive, worldwide, royalty-free copyright license to<span
+style='color:red'> </span>reproduce, prepare derivative works of, publicly
+display, publicly perform, distribute and sublicense the Contribution of such
+Contributor, if any, and such derivative works, in source code and object code
+form.</span></p>
+
+<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b)
+Subject to the terms of this Agreement, each Contributor hereby grants
+Recipient a non-exclusive, worldwide,<span style='color:green'> </span>royalty-free
+patent license under Licensed Patents to make, use, sell, offer to sell, import
+and otherwise transfer the Contribution of such Contributor, if any, in source
+code and object code form. This patent license shall apply to the combination
+of the Contribution and the Program if, at the time the Contribution is added
+by the Contributor, such addition of the Contribution causes such combination
+to be covered by the Licensed Patents. The patent license shall not apply to
+any other combinations which include the Contribution. No hardware per se is
+licensed hereunder. </span></p>
+
+<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>c)
+Recipient understands that although each Contributor grants the licenses to its
+Contributions set forth herein, no assurances are provided by any Contributor
+that the Program does not infringe the patent or other intellectual property
+rights of any other entity. Each Contributor disclaims any liability to Recipient
+for claims brought by any other entity based on infringement of intellectual
+property rights or otherwise. As a condition to exercising the rights and
+licenses granted hereunder, each Recipient hereby assumes sole responsibility
+to secure any other intellectual property rights needed, if any. For example,
+if a third party patent license is required to allow Recipient to distribute
+the Program, it is Recipient's responsibility to acquire that license before
+distributing the Program.</span></p>
+
+<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>d)
+Each Contributor represents that to its knowledge it has sufficient copyright
+rights in its Contribution, if any, to grant the copyright license set forth in
+this Agreement. </span></p>
+
+<p><b><span style='font-size:10.0pt'>3. REQUIREMENTS</span></b> </p>
+
+<p><span style='font-size:10.0pt'>A Contributor may choose to distribute the
+Program in object code form under its own license agreement, provided that:</span>
+</p>
+
+<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
+it complies with the terms and conditions of this Agreement; and</span></p>
+
+<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b)
+its license agreement:</span></p>
+
+<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>i)
+effectively disclaims on behalf of all Contributors all warranties and
+conditions, express and implied, including warranties or conditions of title
+and non-infringement, and implied warranties or conditions of merchantability
+and fitness for a particular purpose; </span></p>
+
+<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>ii)
+effectively excludes on behalf of all Contributors all liability for damages,
+including direct, indirect, special, incidental and consequential damages, such
+as lost profits; </span></p>
+
+<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>iii)
+states that any provisions which differ from this Agreement are offered by that
+Contributor alone and not by any other party; and</span></p>
+
+<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>iv)
+states that source code for the Program is available from such Contributor, and
+informs licensees how to obtain it in a reasonable manner on or through a
+medium customarily used for software exchange.<span style='color:blue'> </span></span></p>
+
+<p><span style='font-size:10.0pt'>When the Program is made available in source
+code form:</span> </p>
+
+<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
+it must be made available under this Agreement; and </span></p>
+
+<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b) a
+copy of this Agreement must be included with each copy of the Program. </span></p>
+
+<p><span style='font-size:10.0pt'>Contributors may not remove or alter any
+copyright notices contained within the Program. </span></p>
+
+<p><span style='font-size:10.0pt'>Each Contributor must identify itself as the
+originator of its Contribution, if any, in a manner that reasonably allows
+subsequent Recipients to identify the originator of the Contribution. </span></p>
+
+<p><b><span style='font-size:10.0pt'>4. COMMERCIAL DISTRIBUTION</span></b> </p>
+
+<p><span style='font-size:10.0pt'>Commercial distributors of software may
+accept certain responsibilities with respect to end users, business partners
+and the like. While this license is intended to facilitate the commercial use
+of the Program, the Contributor who includes the Program in a commercial
+product offering should do so in a manner which does not create potential
+liability for other Contributors. Therefore, if a Contributor includes the
+Program in a commercial product offering, such Contributor (&quot;Commercial
+Contributor&quot;) hereby agrees to defend and indemnify every other
+Contributor (&quot;Indemnified Contributor&quot;) against any losses, damages and
+costs (collectively &quot;Losses&quot;) arising from claims, lawsuits and other
+legal actions brought by a third party against the Indemnified Contributor to
+the extent caused by the acts or omissions of such Commercial Contributor in
+connection with its distribution of the Program in a commercial product
+offering. The obligations in this section do not apply to any claims or Losses
+relating to any actual or alleged intellectual property infringement. In order
+to qualify, an Indemnified Contributor must: a) promptly notify the Commercial
+Contributor in writing of such claim, and b) allow the Commercial Contributor
+to control, and cooperate with the Commercial Contributor in, the defense and
+any related settlement negotiations. The Indemnified Contributor may participate
+in any such claim at its own expense.</span> </p>
+
+<p><span style='font-size:10.0pt'>For example, a Contributor might include the
+Program in a commercial product offering, Product X. That Contributor is then a
+Commercial Contributor. If that Commercial Contributor then makes performance
+claims, or offers warranties related to Product X, those performance claims and
+warranties are such Commercial Contributor's responsibility alone. Under this
+section, the Commercial Contributor would have to defend claims against the
+other Contributors related to those performance claims and warranties, and if a
+court requires any other Contributor to pay any damages as a result, the
+Commercial Contributor must pay those damages.</span> </p>
+
+<p><b><span style='font-size:10.0pt'>5. NO WARRANTY</span></b> </p>
+
+<p><span style='font-size:10.0pt'>EXCEPT AS EXPRESSLY SET FORTH IN THIS
+AGREEMENT, THE PROGRAM IS PROVIDED ON AN &quot;AS IS&quot; BASIS, WITHOUT
+WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING,
+WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
+MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely
+responsible for determining the appropriateness of using and distributing the
+Program and assumes all risks associated with its exercise of rights under this
+Agreement , including but not limited to the risks and costs of program errors,
+compliance with applicable laws, damage to or loss of data, programs or
+equipment, and unavailability or interruption of operations. </span></p>
+
+<p><b><span style='font-size:10.0pt'>6. DISCLAIMER OF LIABILITY</span></b> </p>
+
+<p><span style='font-size:10.0pt'>EXCEPT AS EXPRESSLY SET FORTH IN THIS
+AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF
+THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF
+THE POSSIBILITY OF SUCH DAMAGES.</span> </p>
+
+<p><b><span style='font-size:10.0pt'>7. GENERAL</span></b> </p>
+
+<p><span style='font-size:10.0pt'>If any provision of this Agreement is invalid
+or unenforceable under applicable law, it shall not affect the validity or
+enforceability of the remainder of the terms of this Agreement, and without
+further action by the parties hereto, such provision shall be reformed to the
+minimum extent necessary to make such provision valid and enforceable.</span> </p>
+
+<p><span style='font-size:10.0pt'>If Recipient institutes patent litigation
+against any entity (including a cross-claim or counterclaim in a lawsuit)
+alleging that the Program itself (excluding combinations of the Program with
+other software or hardware) infringes such Recipient's patent(s), then such
+Recipient's rights granted under Section 2(b) shall terminate as of the date
+such litigation is filed. </span></p>
+
+<p><span style='font-size:10.0pt'>All Recipient's rights under this Agreement
+shall terminate if it fails to comply with any of the material terms or
+conditions of this Agreement and does not cure such failure in a reasonable
+period of time after becoming aware of such noncompliance. If all Recipient's
+rights under this Agreement terminate, Recipient agrees to cease use and
+distribution of the Program as soon as reasonably practicable. However,
+Recipient's obligations under this Agreement and any licenses granted by
+Recipient relating to the Program shall continue and survive. </span></p>
+
+<p><span style='font-size:10.0pt'>Everyone is permitted to copy and distribute
+copies of this Agreement, but in order to avoid inconsistency the Agreement is
+copyrighted and may only be modified in the following manner. The Agreement
+Steward reserves the right to publish new versions (including revisions) of
+this Agreement from time to time. No one other than the Agreement Steward has
+the right to modify this Agreement. The Eclipse Foundation is the initial
+Agreement Steward. The Eclipse Foundation may assign the responsibility to
+serve as the Agreement Steward to a suitable separate entity. Each new version
+of the Agreement will be given a distinguishing version number. The Program
+(including Contributions) may always be distributed subject to the version of
+the Agreement under which it was received. In addition, after a new version of
+the Agreement is published, Contributor may elect to distribute the Program
+(including its Contributions) under the new version. Except as expressly stated
+in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to
+the intellectual property of any Contributor under this Agreement, whether
+expressly, by implication, estoppel or otherwise. All rights in the Program not
+expressly granted under this Agreement are reserved.</span> </p>
+
+<p><span style='font-size:10.0pt'>This Agreement is governed by the laws of the
+State of New York and the intellectual property laws of the United States of
+America. No party to this Agreement will bring a legal action under this
+Agreement more than one year after the cause of action arose. Each party waives
+its rights to a jury trial in any resulting litigation.</span> </p>
+
+<p class=MsoNormal><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></p>
+
+</div>
+
+</body>
+
+</html> \ No newline at end of file
diff --git a/org.eclipse.swtbot.generator.feature/feature.properties b/org.eclipse.swtbot.generator.feature/feature.properties
new file mode 100644
index 00000000..b3dd40db
--- /dev/null
+++ b/org.eclipse.swtbot.generator.feature/feature.properties
@@ -0,0 +1,140 @@
+# "licenseURL" property - URL of the "Feature License"
+# do not translate value - just change to point to a locale-specific HTML page
+licenseURL=license.html
+
+copyright=\
+Copyright (c) 2007-2010 Ketan Padegaonkar and others.\n\
+All rights reserved. This program and the accompanying materials\n\
+are made available under the terms of the Eclipse Public License v1.0\n\
+which accompanies this distribution, and is available at\n\
+http://www.eclipse.org/legal/epl-v10.html\n\
+\n\
+Contributors:\n\
+ Ketan Padegaonkar - initial API and implementation
+
+# "license" property - text of the "Feature Update License"
+# should be plain text version of license agreement pointed to be "licenseURL"
+license=\
+Eclipse Foundation Software User Agreement\n\
+April 14, 2010\n\
+\n\
+Usage Of Content\n\
+\n\
+THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR\n\
+OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY "CONTENT").\n\
+USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS\n\
+AGREEMENT AND/OR THE TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR\n\
+NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU\n\
+AGREE THAT YOUR USE OF THE CONTENT IS GOVERNED BY THIS AGREEMENT\n\
+AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS\n\
+OR NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE\n\
+TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND CONDITIONS\n\
+OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED\n\
+BELOW, THEN YOU MAY NOT USE THE CONTENT.\n\
+\n\
+Applicable Licenses\n\
+\n\
+Unless otherwise indicated, all Content made available by the\n\
+Eclipse Foundation is provided to you under the terms and conditions of\n\
+the Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is\n\
+provided with this Content and is also available at http://www.eclipse.org/legal/epl-v10.html.\n\
+For purposes of the EPL, "Program" will mean the Content.\n\
+\n\
+Content includes, but is not limited to, source code, object code,\n\
+documentation and other files maintained in the Eclipse Foundation source code\n\
+repository ("Repository") in software modules ("Modules") and made available\n\
+as downloadable archives ("Downloads").\n\
+\n\
+ - Content may be structured and packaged into modules to facilitate delivering,\n\
+ extending, and upgrading the Content. Typical modules may include plug-ins ("Plug-ins"),\n\
+ plug-in fragments ("Fragments"), and features ("Features").\n\
+ - Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java(TM) ARchive)\n\
+ in a directory named "plugins".\n\
+ - A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material.\n\
+ Each Feature may be packaged as a sub-directory in a directory named "features".\n\
+ Within a Feature, files named "feature.xml" may contain a list of the names and version\n\
+ numbers of the Plug-ins and/or Fragments associated with that Feature.\n\
+ - Features may also include other Features ("Included Features"). Within a Feature, files\n\
+ named "feature.xml" may contain a list of the names and version numbers of Included Features.\n\
+\n\
+The terms and conditions governing Plug-ins and Fragments should be\n\
+contained in files named "about.html" ("Abouts"). The terms and\n\
+conditions governing Features and Included Features should be contained\n\
+in files named "license.html" ("Feature Licenses"). Abouts and Feature\n\
+Licenses may be located in any directory of a Download or Module\n\
+including, but not limited to the following locations:\n\
+\n\
+ - The top-level (root) directory\n\
+ - Plug-in and Fragment directories\n\
+ - Inside Plug-ins and Fragments packaged as JARs\n\
+ - Sub-directories of the directory named "src" of certain Plug-ins\n\
+ - Feature directories\n\
+\n\
+Note: if a Feature made available by the Eclipse Foundation is installed using the\n\
+Provisioning Technology (as defined below), you must agree to a license ("Feature \n\
+Update License") during the installation process. If the Feature contains\n\
+Included Features, the Feature Update License should either provide you\n\
+with the terms and conditions governing the Included Features or inform\n\
+you where you can locate them. Feature Update Licenses may be found in\n\
+the "license" property of files named "feature.properties" found within a Feature.\n\
+Such Abouts, Feature Licenses, and Feature Update Licenses contain the\n\
+terms and conditions (or references to such terms and conditions) that\n\
+govern your use of the associated Content in that directory.\n\
+\n\
+THE ABOUTS, FEATURE LICENSES, AND FEATURE UPDATE LICENSES MAY REFER\n\
+TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS.\n\
+SOME OF THESE OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):\n\
+\n\
+ - Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html)\n\
+ - Apache Software License 1.1 (available at http://www.apache.org/licenses/LICENSE)\n\
+ - Apache Software License 2.0 (available at http://www.apache.org/licenses/LICENSE-2.0)\n\
+ - Metro Link Public License 1.00 (available at http://www.opengroup.org/openmotif/supporters/metrolink/license.html)\n\
+ - Mozilla Public License Version 1.1 (available at http://www.mozilla.org/MPL/MPL-1.1.html)\n\
+\n\
+IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR\n\
+TO USE OF THE CONTENT. If no About, Feature License, or Feature Update License\n\
+is provided, please contact the Eclipse Foundation to determine what terms and conditions\n\
+govern that particular Content.\n\
+\n\
+\n\Use of Provisioning Technology\n\
+\n\
+The Eclipse Foundation makes available provisioning software, examples of which include,\n\
+but are not limited to, p2 and the Eclipse Update Manager ("Provisioning Technology") for\n\
+the purpose of allowing users to install software, documentation, information and/or\n\
+other materials (collectively "Installable Software"). This capability is provided with\n\
+the intent of allowing such users to install, extend and update Eclipse-based products.\n\
+Information about packaging Installable Software is available at\n\
+http://eclipse.org/equinox/p2/repository_packaging.html ("Specification").\n\
+\n\
+You may use Provisioning Technology to allow other parties to install Installable Software.\n\
+You shall be responsible for enabling the applicable license agreements relating to the\n\
+Installable Software to be presented to, and accepted by, the users of the Provisioning Technology\n\
+in accordance with the Specification. By using Provisioning Technology in such a manner and\n\
+making it available in accordance with the Specification, you further acknowledge your\n\
+agreement to, and the acquisition of all necessary rights to permit the following:\n\
+\n\
+ 1. A series of actions may occur ("Provisioning Process") in which a user may execute\n\
+ the Provisioning Technology on a machine ("Target Machine") with the intent of installing,\n\
+ extending or updating the functionality of an Eclipse-based product.\n\
+ 2. During the Provisioning Process, the Provisioning Technology may cause third party\n\
+ Installable Software or a portion thereof to be accessed and copied to the Target Machine.\n\
+ 3. Pursuant to the Specification, you will provide to the user the terms and conditions that\n\
+ govern the use of the Installable Software ("Installable Software Agreement") and such\n\
+ Installable Software Agreement shall be accessed from the Target Machine in accordance\n\
+ with the Specification. Such Installable Software Agreement must inform the user of the\n\
+ terms and conditions that govern the Installable Software and must solicit acceptance by\n\
+ the end user in the manner prescribed in such Installable Software Agreement. Upon such\n\
+ indication of agreement by the user, the provisioning Technology will complete installation\n\
+ of the Installable Software.\n\
+\n\
+Cryptography\n\
+\n\
+Content may contain encryption software. The country in which you are\n\
+currently may have restrictions on the import, possession, and use,\n\
+and/or re-export to another country, of encryption software. BEFORE\n\
+using any encryption software, please check the country's laws,\n\
+regulations and policies concerning the import, possession, or use, and\n\
+re-export of encryption software, to see if this is permitted.\n\
+\n\
+Java and all Java-based trademarks are trademarks of Oracle Corporation in the United States, other countries, or both.\n
+########### end of license property ##########################################
diff --git a/org.eclipse.swtbot.generator.feature/feature.xml b/org.eclipse.swtbot.generator.feature/feature.xml
new file mode 100644
index 00000000..dab85d92
--- /dev/null
+++ b/org.eclipse.swtbot.generator.feature/feature.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<feature
+ id="org.eclipse.swtbot.generator.feature"
+ label="SWTBot Recorder and Test Generator (incubation)"
+ version="2.1.0.qualifier"
+ provider-name="Eclipse.org"
+ plugin="org.eclipse.swtbot.eclipse.ui">
+
+ <description url="http://eclipse.org/">
+ SWTBot Generator: Enable recording of Events and generates code accordingly
+ </description>
+
+ <copyright>
+ %copyright
+ </copyright>
+
+ <license url="%licenseURL">
+ %license
+ </license>
+
+ <plugin
+ id="org.eclipse.swtbot.generator"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+</feature>
diff --git a/org.eclipse.swtbot.generator.feature/feature.xml~ b/org.eclipse.swtbot.generator.feature/feature.xml~
new file mode 100644
index 00000000..022c2d43
--- /dev/null
+++ b/org.eclipse.swtbot.generator.feature/feature.xml~
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<feature
+ id="org.eclipse.swtbot.eclipse"
+ label="SWTBot for Eclipse Testing (incubation)"
+ version="2.0.5.qualifier"
+ provider-name="Eclipse.org"
+ plugin="org.eclipse.swtbot.eclipse.ui">
+
+ <description url="http://eclipse.org/">
+ SWTBot for testing eclipse based plugins and applications (incubation)
+ </description>
+
+ <copyright>
+ %copyright
+ </copyright>
+
+ <license url="%licenseURL">
+ %license
+ </license>
+
+ <url>
+ <update label="SWTBot update site" url="http://download.eclipse.org/technology/swtbot/update-site"/>
+ </url>
+
+ <includes
+ id="org.eclipse.swtbot"
+ version="0.0.0"/>
+
+ <includes
+ id="org.eclipse.swtbot.forms"
+ version="0.0.0"/>
+
+ <requires>
+ <import plugin="org.eclipse.osgi"/>
+ <import plugin="org.junit4"/>
+ <import plugin="org.apache.log4j"/>
+ <import plugin="org.eclipse.core.commands"/>
+ <import plugin="org.eclipse.core.runtime"/>
+ <import plugin="org.eclipse.jface"/>
+ <import plugin="org.eclipse.swt"/>
+ <import plugin="org.eclipse.ui.workbench"/>
+ <import plugin="org.eclipse.ui"/>
+ <import plugin="org.hamcrest"/>
+ <import plugin="org.eclipse.ui.editors"/>
+ <import plugin="org.eclipse.swtbot.swt.finder"/>
+ <import plugin="org.eclipse.swtbot.junit4_x"/>
+ <import plugin="org.eclipse.equinox.app"/>
+ <import plugin="org.eclipse.jdt.junit.runtime"/>
+ <import plugin="org.eclipse.ui.ide"/>
+ </requires>
+
+ <plugin
+ id="org.eclipse.swtbot.eclipse.finder"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.eclipse.swtbot.go"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.eclipse.swtbot.eclipse.core"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.eclipse.swtbot.eclipse.spy"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+</feature>
diff --git a/org.eclipse.swtbot.generator.feature/license.html b/org.eclipse.swtbot.generator.feature/license.html
new file mode 100644
index 00000000..c184ca36
--- /dev/null
+++ b/org.eclipse.swtbot.generator.feature/license.html
@@ -0,0 +1,107 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
+<title>Eclipse Foundation Software User Agreement</title>
+</head>
+
+<body lang="EN-US">
+<h2>Eclipse Foundation Software User Agreement</h2>
+<p>April 14, 2010</p>
+
+<h3>Usage Of Content</h3>
+
+<p>THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR OTHER MATERIALS FOR OPEN SOURCE PROJECTS
+ (COLLECTIVELY &quot;CONTENT&quot;). USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS AGREEMENT AND/OR THE TERMS AND
+ CONDITIONS OF LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU AGREE THAT YOUR USE
+ OF THE CONTENT IS GOVERNED BY THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR
+ NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND
+ CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW, THEN YOU MAY NOT USE THE CONTENT.</p>
+
+<h3>Applicable Licenses</h3>
+
+<p>Unless otherwise indicated, all Content made available by the Eclipse Foundation is provided to you under the terms and conditions of the Eclipse Public License Version 1.0
+ (&quot;EPL&quot;). A copy of the EPL is provided with this Content and is also available at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+ For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<p>Content includes, but is not limited to, source code, object code, documentation and other files maintained in the Eclipse Foundation source code
+ repository (&quot;Repository&quot;) in software modules (&quot;Modules&quot;) and made available as downloadable archives (&quot;Downloads&quot;).</p>
+
+<ul>
+ <li>Content may be structured and packaged into modules to facilitate delivering, extending, and upgrading the Content. Typical modules may include plug-ins (&quot;Plug-ins&quot;), plug-in fragments (&quot;Fragments&quot;), and features (&quot;Features&quot;).</li>
+ <li>Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java&trade; ARchive) in a directory named &quot;plugins&quot;.</li>
+ <li>A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material. Each Feature may be packaged as a sub-directory in a directory named &quot;features&quot;. Within a Feature, files named &quot;feature.xml&quot; may contain a list of the names and version numbers of the Plug-ins
+ and/or Fragments associated with that Feature.</li>
+ <li>Features may also include other Features (&quot;Included Features&quot;). Within a Feature, files named &quot;feature.xml&quot; may contain a list of the names and version numbers of Included Features.</li>
+</ul>
+
+<p>The terms and conditions governing Plug-ins and Fragments should be contained in files named &quot;about.html&quot; (&quot;Abouts&quot;). The terms and conditions governing Features and
+Included Features should be contained in files named &quot;license.html&quot; (&quot;Feature Licenses&quot;). Abouts and Feature Licenses may be located in any directory of a Download or Module
+including, but not limited to the following locations:</p>
+
+<ul>
+ <li>The top-level (root) directory</li>
+ <li>Plug-in and Fragment directories</li>
+ <li>Inside Plug-ins and Fragments packaged as JARs</li>
+ <li>Sub-directories of the directory named &quot;src&quot; of certain Plug-ins</li>
+ <li>Feature directories</li>
+</ul>
+
+<p>Note: if a Feature made available by the Eclipse Foundation is installed using the Provisioning Technology (as defined below), you must agree to a license (&quot;Feature Update License&quot;) during the
+installation process. If the Feature contains Included Features, the Feature Update License should either provide you with the terms and conditions governing the Included Features or
+inform you where you can locate them. Feature Update Licenses may be found in the &quot;license&quot; property of files named &quot;feature.properties&quot; found within a Feature.
+Such Abouts, Feature Licenses, and Feature Update Licenses contain the terms and conditions (or references to such terms and conditions) that govern your use of the associated Content in
+that directory.</p>
+
+<p>THE ABOUTS, FEATURE LICENSES, AND FEATURE UPDATE LICENSES MAY REFER TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS. SOME OF THESE
+OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):</p>
+
+<ul>
+ <li>Common Public License Version 1.0 (available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a>)</li>
+ <li>Apache Software License 1.1 (available at <a href="http://www.apache.org/licenses/LICENSE">http://www.apache.org/licenses/LICENSE</a>)</li>
+ <li>Apache Software License 2.0 (available at <a href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</a>)</li>
+ <li>Metro Link Public License 1.00 (available at <a href="http://www.opengroup.org/openmotif/supporters/metrolink/license.html">http://www.opengroup.org/openmotif/supporters/metrolink/license.html</a>)</li>
+ <li>Mozilla Public License Version 1.1 (available at <a href="http://www.mozilla.org/MPL/MPL-1.1.html">http://www.mozilla.org/MPL/MPL-1.1.html</a>)</li>
+</ul>
+
+<p>IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR TO USE OF THE CONTENT. If no About, Feature License, or Feature Update License is provided, please
+contact the Eclipse Foundation to determine what terms and conditions govern that particular Content.</p>
+
+
+<h3>Use of Provisioning Technology</h3>
+
+<p>The Eclipse Foundation makes available provisioning software, examples of which include, but are not limited to, p2 and the Eclipse
+ Update Manager (&quot;Provisioning Technology&quot;) for the purpose of allowing users to install software, documentation, information and/or
+ other materials (collectively &quot;Installable Software&quot;). This capability is provided with the intent of allowing such users to
+ install, extend and update Eclipse-based products. Information about packaging Installable Software is available at <a
+ href="http://eclipse.org/equinox/p2/repository_packaging.html">http://eclipse.org/equinox/p2/repository_packaging.html</a>
+ (&quot;Specification&quot;).</p>
+
+<p>You may use Provisioning Technology to allow other parties to install Installable Software. You shall be responsible for enabling the
+ applicable license agreements relating to the Installable Software to be presented to, and accepted by, the users of the Provisioning Technology
+ in accordance with the Specification. By using Provisioning Technology in such a manner and making it available in accordance with the
+ Specification, you further acknowledge your agreement to, and the acquisition of all necessary rights to permit the following:</p>
+
+<ol>
+ <li>A series of actions may occur (&quot;Provisioning Process&quot;) in which a user may execute the Provisioning Technology
+ on a machine (&quot;Target Machine&quot;) with the intent of installing, extending or updating the functionality of an Eclipse-based
+ product.</li>
+ <li>During the Provisioning Process, the Provisioning Technology may cause third party Installable Software or a portion thereof to be
+ accessed and copied to the Target Machine.</li>
+ <li>Pursuant to the Specification, you will provide to the user the terms and conditions that govern the use of the Installable
+ Software (&quot;Installable Software Agreement&quot;) and such Installable Software Agreement shall be accessed from the Target
+ Machine in accordance with the Specification. Such Installable Software Agreement must inform the user of the terms and conditions that govern
+ the Installable Software and must solicit acceptance by the end user in the manner prescribed in such Installable Software Agreement. Upon such
+ indication of agreement by the user, the provisioning Technology will complete installation of the Installable Software.</li>
+</ol>
+
+<h3>Cryptography</h3>
+
+<p>Content may contain encryption software. The country in which you are currently may have restrictions on the import, possession, and use, and/or re-export to
+ another country, of encryption software. BEFORE using any encryption software, please check the country's laws, regulations and policies concerning the import,
+ possession, or use, and re-export of encryption software, to see if this is permitted.</p>
+
+<p><small>Java and all Java-based trademarks are trademarks of Oracle Corporation in the United States, other countries, or both.</small></p>
+</body>
+</html>
diff --git a/org.eclipse.swtbot.generator.feature/pom.xml b/org.eclipse.swtbot.generator.feature/pom.xml
new file mode 100644
index 00000000..733437bc
--- /dev/null
+++ b/org.eclipse.swtbot.generator.feature/pom.xml
@@ -0,0 +1,25 @@
+<!-- Copyright (c) 2011 PetalsLink.
+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
+
+Authors:
+* Mickael Istria (PetalsLink)
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
+ http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.eclipse.swtbot.features</groupId>
+ <artifactId>org.eclipse.swtbot.generator.feature</artifactId>
+ <packaging>eclipse-feature</packaging>
+ <parent>
+ <groupId>org.eclipse.swtbot</groupId>
+ <artifactId>parent</artifactId>
+ <version>2.1.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+</project>
diff --git a/org.eclipse.swtbot.generator.test/.classpath b/org.eclipse.swtbot.generator.test/.classpath
deleted file mode 100644
index 64c5e31b..00000000
--- a/org.eclipse.swtbot.generator.test/.classpath
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/org.eclipse.swtbot.generator.test/.project b/org.eclipse.swtbot.generator.test/.project
deleted file mode 100644
index 120010e4..00000000
--- a/org.eclipse.swtbot.generator.test/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.swtbot.generator.test</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>
diff --git a/org.eclipse.swtbot.generator.test/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.swtbot.generator.test/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 1a5a41ea..00000000
--- a/org.eclipse.swtbot.generator.test/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,21 +0,0 @@
-#Tue Dec 16 23:22:40 IST 2008
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
-org.eclipse.jdt.core.compiler.compliance=1.5
-org.eclipse.jdt.core.compiler.doc.comment.support=disabled
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning
-org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled
-org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=enabled
-org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled
-org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=protected
-org.eclipse.jdt.core.compiler.problem.missingJavadocComments=warning
-org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled
-org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=protected
-org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=all_standard_tags
-org.eclipse.jdt.core.compiler.problem.missingJavadocTags=warning
-org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled
-org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=protected
-org.eclipse.jdt.core.compiler.source=1.5
diff --git a/org.eclipse.swtbot.generator.test/META-INF/MANIFEST.MF b/org.eclipse.swtbot.generator.test/META-INF/MANIFEST.MF
deleted file mode 100644
index 4bdcbac9..00000000
--- a/org.eclipse.swtbot.generator.test/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,13 +0,0 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: Generator Test Plug-in (incubation)
-Bundle-SymbolicName: org.eclipse.swtbot.generator.test
-Bundle-Version: 2.1.0.qualifier
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
-Require-Bundle: org.eclipse.swtbot.swt.finder,
- org.hamcrest.core,
- org.hamcrest.integration,
- org.hamcrest.library,
- org.junit4,
- org.eclipse.swtbot.generator,
- org.eclipse.ui
diff --git a/org.eclipse.swtbot.generator.test/pom.xml b/org.eclipse.swtbot.generator.test/pom.xml
deleted file mode 100644
index 250391ab..00000000
--- a/org.eclipse.swtbot.generator.test/pom.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<!-- Copyright (c) 2011 PetalsLink. 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 Authors: * Mickael Istria (PetalsLink) -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
- http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <groupId>org.eclipse.swtbot.tests</groupId>
- <artifactId>org.eclipse.swtbot.generator.test</artifactId>
- <packaging>eclipse-plugin</packaging>
- <parent>
- <groupId>org.eclipse.swtbot</groupId>
- <artifactId>parent</artifactId>
- <version>2.1.0-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
-
-</project> \ No newline at end of file
diff --git a/org.eclipse.swtbot.generator.test/src/org/eclipse/swtbot/generator/CombinationGeneratorMain.java b/org.eclipse.swtbot.generator.test/src/org/eclipse/swtbot/generator/CombinationGeneratorMain.java
deleted file mode 100644
index d438e302..00000000
--- a/org.eclipse.swtbot.generator.test/src/org/eclipse/swtbot/generator/CombinationGeneratorMain.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Ketan Padegaonkar 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:
- * Ketan Padegaonkar - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swtbot.generator;
-
-import java.util.List;
-
-import org.eclipse.swtbot.swt.finder.ReferenceBy;
-
-/**
- * @author Ketan Padegaonkar &lt;KetanPadegaonkar [at] gmail [dot] com&gt;
- * @version $Id$
- */
-class CombinationGeneratorMain {
- public static void main(String[] args) {
- ReferenceBy[] values = ReferenceBy.values();
- List<List<ReferenceBy>> combinations = ReferenceBy.getCombinations(values);
- for (List<ReferenceBy> list : combinations) {
- System.out.println(list);
- }
- }
-
-}
diff --git a/org.eclipse.swtbot.generator.test/src/org/eclipse/swtbot/generator/MethodGeneratorTest.java b/org.eclipse.swtbot.generator.test/src/org/eclipse/swtbot/generator/MethodGeneratorTest.java
deleted file mode 100644
index 50ff6c7a..00000000
--- a/org.eclipse.swtbot.generator.test/src/org/eclipse/swtbot/generator/MethodGeneratorTest.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Ketan Padegaonkar 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:
- * Ketan Padegaonkar - initial API and implementation
- * Ketan Padegaonkar - http://swtbot.org/bugzilla/show_bug.cgi?id=126
- *******************************************************************************/
-package org.eclipse.swtbot.generator;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.hasItem;
-import static org.junit.Assert.assertEquals;
-
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.ToolItem;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swtbot.swt.finder.ReferenceBy;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotButton;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarButton;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarPushButton;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * @author Ketan Padegaonkar &lt;KetanPadegaonkar [at] gmail [dot] com&gt;
- * @version $Id$
- */
-public class MethodGeneratorTest {
-
- private MethodGenerator inGroup;
- private MethodGenerator withTextInGroup;
- private MethodGenerator withStyleWithTextInGroup;
- private MethodGenerator withStyle;
- private MethodGenerator withSubclassedWidgets;
-
- @Test
- public void generatesMethodArgumentsGivenASingleReference() throws Exception {
- assertThat(inGroup.methodArguments(), equalTo("String inGroup"));
- }
-
- @Test
- public void generatesMethodArgumentsGivenTwoReferences() throws Exception {
- assertThat(withTextInGroup.methodArguments(), equalTo("String text, String inGroup"));
- }
-
- @Test
- public void generatesMethodContentsWithIndexGivenASingleReference() throws Exception {
- assertEquals(" @SuppressWarnings({\"unchecked\", \"rawtypes\"})\n" + " public SWTBotButton buttonInGroup(String inGroup, int index) {\n"
- + " Matcher matcher = allOf(widgetOfType(Button.class), inGroup(inGroup));\n"
- + " return new SWTBotButton((Button) widget(matcher, index), matcher);\n" + " }\n", inGroup.methodContentsWithIndex());
- }
-
- @Test
- public void generatesMethodContentsWithIndexGivenTwoReferences() throws Exception {
- assertEquals(" @SuppressWarnings({\"unchecked\", \"rawtypes\"})\n"
- + " public SWTBotButton buttonInGroup(String text, String inGroup, int index) {\n"
- + " Matcher matcher = allOf(widgetOfType(Button.class), withText(text), inGroup(inGroup));\n"
- + " return new SWTBotButton((Button) widget(matcher, index), matcher);\n" + " }\n", withTextInGroup
- .methodContentsWithIndex());
- }
-
- @Test
- public void generatesMethodContentsWithIndexAndStyleGivenTwoReferences() throws Exception {
- assertEquals(
- " @SuppressWarnings({\"unchecked\", \"rawtypes\"})\n"
- + " public SWTBotTree treeInGroup(String text, String inGroup, int index) {\n"
- + " Matcher matcher = allOf(widgetOfType(Tree.class), withText(text), inGroup(inGroup), withStyle(SWT.FOO_STYLE, \"SWT.FOO_STYLE\"));\n"
- + " return new SWTBotTree((Tree) widget(matcher, index), matcher);\n" + " }\n", withStyleWithTextInGroup
- .methodContentsWithIndex());
- }
-
- @Test
- public void generatesMethodContentsWithStyleWithNoReferences() throws Exception {
- assertEquals(" @SuppressWarnings({\"unchecked\", \"rawtypes\"})\n" + " public SWTBotTree tree(int index) {\n"
- + " Matcher matcher = allOf(widgetOfType(Tree.class), withStyle(SWT.FOO_STYLE, \"SWT.FOO_STYLE\"));\n"
- + " return new SWTBotTree((Tree) widget(matcher, index), matcher);\n" + " }\n", withStyle.methodContentsWithIndex());
- }
-
- @Test
- public void generatesMethodContentsWithoutIndexGivenASingleReference() throws Exception {
- assertEquals(" public SWTBotButton buttonInGroup(String inGroup) {\n" + " return buttonInGroup(inGroup, 0);\n" + " }\n", inGroup
- .methodContents());
- }
-
- @Test
- public void generatesMethodContentsWithoutIndexGivenTwoReferences() throws Exception {
- assertEquals(" public SWTBotButton buttonInGroup(String text, String inGroup) {\n" + " return buttonInGroup(text, inGroup, 0);\n"
- + " }\n", withTextInGroup.methodContents());
- }
-
- @Test
- public void generatesMethodContentsWithSubclassedTypes() throws Exception {
- assertEquals(" @SuppressWarnings({\"unchecked\", \"rawtypes\"})\n" +
- " public SWTBotToolbarButton toolbarToggleButtonInGroup(String text, String inGroup, int index) {\n" +
- " Matcher matcher = allOf(widgetOfType(ToolItem.class), withText(text), inGroup(inGroup), withStyle(SWT.FOO_STYLE, \"SWT.FOO_STYLE\"));\n" +
- " return new SWTBotToolbarPushButton((ToolItem) widget(matcher, index), matcher);\n" +
- " }\n" +
- "", withSubclassedWidgets.methodContentsWithIndex());
- }
-
- @Test
- public void generatesImports() throws Exception {
- assertThat(inGroup.imports(), hasItem("import org.eclipse.swtbot.swt.finder.widgets.SWTBotButton"));
- assertThat(inGroup.imports(), hasItem("import org.eclipse.swt.widgets.Button"));
- }
-
- @Before
- public void setUp() throws Exception {
- inGroup = new MethodGenerator(SWTBotButton.class, SWTBotButton.class, Button.class, "button", "SWT.NONE", ReferenceBy.IN_GROUP);
- withTextInGroup = new MethodGenerator(SWTBotButton.class, SWTBotButton.class, Button.class, "button", "SWT.NONE", ReferenceBy.TEXT,
- ReferenceBy.IN_GROUP);
- withStyle = new MethodGenerator(SWTBotTree.class, SWTBotTree.class, Tree.class, "tree", "SWT.FOO_STYLE", ReferenceBy.NONE);
- withStyleWithTextInGroup = new MethodGenerator(SWTBotTree.class, SWTBotTree.class, Tree.class, "tree", "SWT.FOO_STYLE", ReferenceBy.TEXT,
- ReferenceBy.IN_GROUP);
-
- withSubclassedWidgets = new MethodGenerator(SWTBotToolbarButton.class, SWTBotToolbarPushButton.class, ToolItem.class, "toolbarToggleButton", "SWT.FOO_STYLE", ReferenceBy.TEXT,
- ReferenceBy.IN_GROUP);
- }
-
-}
diff --git a/org.eclipse.swtbot.generator/META-INF/MANIFEST.MF b/org.eclipse.swtbot.generator/META-INF/MANIFEST.MF
index b4a58e5f..86135658 100644
--- a/org.eclipse.swtbot.generator/META-INF/MANIFEST.MF
+++ b/org.eclipse.swtbot.generator/META-INF/MANIFEST.MF
@@ -1,16 +1,12 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: SWTBot Code Generator Plug-in (incubation)
-Bundle-SymbolicName: org.eclipse.swtbot.generator
+Bundle-SymbolicName: org.eclipse.swtbot.generator;singleton:=true
Bundle-Version: 2.1.0.qualifier
Bundle-Vendor: Eclipse.org - SWTBot
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-ClassPath: .
-Export-Package: org.eclipse.swtbot.generator
-Import-Package: com.thoughtworks.qdox;version="1.6.3",
- org.eclipse.swt.widgets,
- org.eclipse.swtbot.eclipse.finder,
- org.eclipse.swtbot.forms.finder.widgets,
- org.eclipse.swtbot.swt.finder,
- org.eclipse.swtbot.swt.finder.utils,
- org.hamcrest.generator.config;version="1.1.0"
+Export-Package: org.eclipse.swtbot.generator.framework
+Import-Package: org.eclipse.swt.widgets
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime
diff --git a/org.eclipse.swtbot.generator/build.properties b/org.eclipse.swtbot.generator/build.properties
index 44d32856..8cc3219b 100644
--- a/org.eclipse.swtbot.generator/build.properties
+++ b/org.eclipse.swtbot.generator/build.properties
@@ -14,4 +14,5 @@ bin.includes = META-INF/,\
.,\
about.html,\
LICENSE.EPL,\
- about_files/
+ about_files/,\
+ plugin.xml
diff --git a/org.eclipse.swtbot.generator/plugin.xml b/org.eclipse.swtbot.generator/plugin.xml
new file mode 100644
index 00000000..a8c3f78e
--- /dev/null
+++ b/org.eclipse.swtbot.generator/plugin.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension-point id="botGeneratorSupport" name="UI Bot Code Generator" schema="schema/generator.exsd"/>
+ <extension
+ point="org.eclipse.ui.startup">
+ <startup
+ class="org.eclipse.swtbot.generator.ui.StartupRecorder">
+ </startup>
+ </extension>
+ <extension
+ point="org.eclipse.swtbot.generator.botGeneratorSupport">
+ <generator
+ class="org.eclipse.swtbot.generator.framework.rules.SWTBotGeneratorRules">
+ </generator>
+ </extension>
+
+</plugin>
diff --git a/org.eclipse.swtbot.generator/schema/generator.exsd b/org.eclipse.swtbot.generator/schema/generator.exsd
new file mode 100644
index 00000000..427801fc
--- /dev/null
+++ b/org.eclipse.swtbot.generator/schema/generator.exsd
@@ -0,0 +1,97 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.swtbot.generator" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.eclipse.swtbot.generator" id="generator" name="UI Bot Code Generator"/>
+ </appinfo>
+ <documentation>
+ [Enter description of this extension point.]
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="generator"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation/>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation/>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation/>
+ <appinfo>
+ <meta.attribute translatable="true"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="generator">
+ <complexType>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>Add support for a new Generator class.
+A generator is a class providing a set of rules, to match the UI events and react differently.
+It can be used to plug in the recorder you how framework support, so you can generate soe test for other frameworks than SWTBot (pure-Eclipse, RedDeer, WindowTester...)
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.swtbot.generator.framework.Generator"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="since"/>
+ </appinfo>
+ <documentation>
+ [Enter the first release in which this extension point appears.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="examples"/>
+ </appinfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="apiinfo"/>
+ </appinfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="implementation"/>
+ </appinfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+
+</schema>
diff --git a/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/HamcrestFactoryWriter.java b/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/HamcrestFactoryWriter.java
deleted file mode 100644
index 4a53e1ea..00000000
--- a/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/HamcrestFactoryWriter.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Ketan Padegaonkar 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:
- * Ketan Padegaonkar - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swtbot.generator;
-
-import java.io.FileWriter;
-import java.io.PrintWriter;
-import java.util.Set;
-import java.util.TreeSet;
-
-import org.eclipse.swtbot.swt.finder.utils.FileUtils;
-
-/**
- * @author Ketan Padegaonkar &lt;KetanPadegaonkar [at] gmail [dot] com&gt;
- * @version $Id$
- */
-public class HamcrestFactoryWriter implements HamcrestWriter {
-
- private final String packageName;
- private final String shortClassName;
- private final PrintWriter output;
-
- private final String newLine = "\n"; //$NON-NLS-1$
- private final String superClass;
-
- public HamcrestFactoryWriter(String packageName, String shortClassName, String superClass, FileWriter fileWriter) {
- this.packageName = packageName;
- this.shortClassName = shortClassName;
- this.superClass = superClass;
- output = new PrintWriter(fileWriter);
-
- }
-
- public void writeHeader(Set<String> imports) {
- output.append("// Generated source. DO NOT MODIFY.").append(newLine); //$NON-NLS-1$
- output.append("// To add new widgets, please see README file in the generator plugin.").append(newLine); //$NON-NLS-1$
- output.append("package ").append(packageName).append(';').append(newLine); //$NON-NLS-1$
- output.append(newLine);
- output.append(newLine);
- writeImports(imports);
- }
-
- public void beginClassDefinition() {
- output.append(newLine);
- output.append(newLine);
-
- output.append(FileUtils.read("templates/" + shortClassName + "/javadoc").trim()); //$NON-NLS-1$
- output.append(newLine);
- output.append("public class ").append(shortClassName).append(" extends "+ superClass + " {").append(newLine).append(newLine); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
-
-
- public void writeFooter() {
- output.append(newLine);
- output.append(FileUtils.read("templates/" + shortClassName + "/additionalMethods")); //$NON-NLS-1$
-
- output.append(newLine);
-
- output.append('}').append(newLine);
- }
-
- public void close() {
- output.close();
- }
-
- public void flush() {
- output.flush();
- }
-
- public void writeMethod(String method) {
- output.append(method.toString()).append(newLine);
- }
-
- private void writeImports(Set<String> imports) {
-
- imports = new TreeSet<String>(imports);
- imports.addAll(FileUtils.readlines("templates/" + shortClassName + "/imports"));
-
-
- for (String importz : imports) {
- output.append(importz).append(";").append(newLine); //$NON-NLS-1$
- }
-
- }
-
- public void beginConstructors() {
- output.append(" /**\n" +
- " * Constructs a bot.\n" +
- " */\n" +
- " public " + shortClassName + "() {\n" +
- " this(new ControlFinder(), new MenuFinder());\n" +
- " }\n" +
- "\n" +
- " /**\n" +
- " * Constructs a bot that will match the contents of the given parentWidget.\n" +
- " * \n" +
- " * @param parent the parent\n" +
- " */\n" +
- " public " + shortClassName + "(Widget parent) {\n" +
- " this(new ChildrenControlFinder(parent), new MenuFinder());\n" +
- " }\n" +
- " /**\n" +
- " * Constructs an instance of the bot using the given control finder and menu finder.\n" +
- " * \n" +
- " * @param controlFinder the {@link ControlFinder} used to identify and find controls.\n" +
- " * @param menuFinder the {@link MenuFinder} used to find menu items.\n" +
- " */\n" +
- " public " + shortClassName + "(ControlFinder controlFinder, MenuFinder menuFinder) {\n" +
- " this(new Finder(controlFinder, menuFinder));\n" +
- " }\n" +
- "\n" +
- " /**\n" +
- " * Constructs a bot with the given finder.\n" +
- " * \n" +
- " * @param finder the finder.\n" +
- " */\n" +
- " public " + shortClassName + "(Finder finder) {\n" +
- " super(finder);\n" +
- " }\n\n");
- }
-}
diff --git a/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/HamcrestWriter.java b/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/HamcrestWriter.java
deleted file mode 100644
index b2e309f7..00000000
--- a/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/HamcrestWriter.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Ketan Padegaonkar 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:
- * Ketan Padegaonkar - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swtbot.generator;
-
-import java.util.Set;
-
-/**
- * @author Ketan Padegaonkar &lt;KetanPadegaonkar [at] gmail [dot] com&gt;
- * @version $Id$
- */
-public interface HamcrestWriter {
-
- public abstract void writeMethod(String method);
-
- public abstract void writeHeader(Set<String> imports);
-
- public abstract void beginClassDefinition();
-
- public abstract void writeFooter();
-
- public abstract void flush();
-
- public abstract void close();
-
- public abstract void beginConstructors();
-
-}
diff --git a/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/MatcherGeneratorMain.java b/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/MatcherGeneratorMain.java
deleted file mode 100644
index 5e2c0478..00000000
--- a/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/MatcherGeneratorMain.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Ketan Padegaonkar 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:
- * Ketan Padegaonkar - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swtbot.generator;
-
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.IOException;
-
-/**
- * @author Ketan Padegaonkar &lt;KetanPadegaonkar [at] gmail [dot] com&gt;
- * @version $Id$
- */
-public class MatcherGeneratorMain {
-
- private static final String newLine = "\n"; //$NON-NLS-1$
-
- public static void main(String[] args) {
- try {
- org.hamcrest.generator.config.XmlConfigurator.main(new String[] { "swtbot-matchers.xml", "../org.eclipse.swtbot.swt.finder/src", //$NON-NLS-1$ //$NON-NLS-2$
- "org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory_Original", "../org.eclipse.swtbot.swt.finder/src" }); //$NON-NLS-1$ //$NON-NLS-2$
-
- org.hamcrest.generator.config.XmlConfigurator.main(new String[] { "swtbot-eclipse-matchers.xml", //$NON-NLS-1$
- "../org.eclipse.swtbot.eclipse.finder/src", "org.eclipse.swtbot.eclipse.finder.matchers.WidgetMatcherFactory_Original", //$NON-NLS-1$ //$NON-NLS-2$
- "../org.eclipse.swtbot.eclipse.finder/src" }); //$NON-NLS-1$
-
- makeEclipseWidgetMatcherFactoryExtendSWTBotWidgetMatcherFactory();
- makeWidgetMatcherFactoryAbstract();
-
- } catch (Throwable e) {
- e.printStackTrace();
- }
- }
-
- /**
- * @throws FileNotFoundException
- * @throws IOException
- */
- private static void makeEclipseWidgetMatcherFactoryExtendSWTBotWidgetMatcherFactory() throws FileNotFoundException, IOException {
- String sourceFile = "../org.eclipse.swtbot.eclipse.finder/src/org/eclipse/swtbot/eclipse/finder/matchers/WidgetMatcherFactory_Original.java"; //$NON-NLS-1$
- BufferedReader reader = new BufferedReader(new FileReader(sourceFile));
-
- BufferedWriter writer = new BufferedWriter(new FileWriter(
- "../org.eclipse.swtbot.eclipse.finder/src/org/eclipse/swtbot/eclipse/finder/matchers/WidgetMatcherFactory.java")); //$NON-NLS-1$
- writer.append("// Generated source. DO NOT MODIFY.").append(newLine); //$NON-NLS-1$
- writer.append("// To add new new methods, please see README file in the generator plugin.").append(newLine); //$NON-NLS-1$
-
- while (reader.ready()) {
- String line = reader.readLine();
- line = line.replaceAll("^// Generated source.$", "");
- line = line.replaceAll("public class WidgetMatcherFactory_Original \\{", //$NON-NLS-1$
- "public abstract class WidgetMatcherFactory extends org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory {"); //$NON-NLS-1$
- writer.write(line);
- writer.write("\n"); //$NON-NLS-1$
- }
- writer.close();
- reader.close();
- new File(sourceFile).delete();
- }
-
- /**
- * @throws FileNotFoundException
- * @throws IOException
- */
- private static void makeWidgetMatcherFactoryAbstract() throws FileNotFoundException, IOException {
- String sourceFile = "../org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/matchers/WidgetMatcherFactory_Original.java"; //$NON-NLS-1$
- BufferedReader reader = new BufferedReader(new FileReader(sourceFile));
-
- BufferedWriter writer = new BufferedWriter(new FileWriter(
- "../org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/matchers/WidgetMatcherFactory.java")); //$NON-NLS-1$
- writer.append("// Generated source. DO NOT MODIFY.").append(newLine); //$NON-NLS-1$
- writer.append("// To add new new methods, please see README file in the generator plugin.").append(newLine); //$NON-NLS-1$
-
- while (reader.ready()) {
- String line = reader.readLine();
- line = line.replaceAll("^// Generated source.$", "");
- line = line.replaceAll("public class WidgetMatcherFactory_Original \\{", "public abstract class WidgetMatcherFactory {"); //$NON-NLS-1$ //$NON-NLS-2$
- writer.write(line);
- writer.write("\n"); //$NON-NLS-1$
- }
- writer.close();
- reader.close();
- new File(sourceFile).delete();
- }
-}
diff --git a/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/MethodFactory.java b/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/MethodFactory.java
deleted file mode 100644
index 6602d223..00000000
--- a/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/MethodFactory.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Ketan Padegaonkar 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:
- * Ketan Padegaonkar - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swtbot.generator;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-
-import org.eclipse.swt.widgets.Widget;
-import org.eclipse.swtbot.swt.finder.ReferenceBy;
-import org.eclipse.swtbot.swt.finder.SWTBotWidget;
-
-/**
- * @author Ketan Padegaonkar &lt;KetanPadegaonkar [at] gmail [dot] com&gt;
- * @version $Id$
- */
-public class MethodFactory {
-
- public static ArrayList<String> methods(SWTBotWidget annotation, Class<?> returnType, Class<?> creationType, Class<? extends Widget> widgetType, String methodPrefix) {
- ArrayList<String> result = new ArrayList<String>();
-
- List<List<ReferenceBy>> references = getReferenceCombinations(annotation);
- for (List<ReferenceBy> list : references) {
- result.add(new MethodGenerator(returnType, creationType, widgetType, methodPrefix, annotation.style().name(), list).commentContents());
- result.add(new MethodGenerator(returnType, creationType, widgetType, methodPrefix, annotation.style().name(), list).methodContents());
- result.add(new MethodGenerator(returnType, creationType, widgetType, methodPrefix, annotation.style().name(), list).commentContentsWithIndex());
- result.add(new MethodGenerator(returnType, creationType, widgetType, methodPrefix, annotation.style().name(), list).methodContentsWithIndex());
- }
- return result;
- }
-
- private static List<List<ReferenceBy>> getReferenceCombinations(SWTBotWidget annotation) {
- List<ReferenceBy> value = new ArrayList<ReferenceBy>(Arrays.asList(annotation.referenceBy()));
- value.addAll(Arrays.asList(annotation.defaultReferenceBy()));
- ReferenceBy[] array = value.toArray(new ReferenceBy[] {});
- return ReferenceBy.getCombinations(array);
- }
-
- public static Collection<? extends String> imports(SWTBotWidget annotation, Class<?> returnType, Class<? extends Widget> widgetType, String methodPrefix) {
- ArrayList<String> result = new ArrayList<String>();
- List<List<ReferenceBy>> references = getReferenceCombinations(annotation);
- for (List<ReferenceBy> list : references) {
- result.addAll(new MethodGenerator(returnType, null, widgetType, methodPrefix, annotation.style().name(), list).imports());
- }
- return result;
- }
-}
diff --git a/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/MethodGenerator.java b/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/MethodGenerator.java
deleted file mode 100644
index 1489d64e..00000000
--- a/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/MethodGenerator.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2010 Ketan Padegaonkar 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:
- * Ketan Padegaonkar - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swtbot.generator;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.swtbot.swt.finder.ReferenceBy;
-import org.eclipse.swtbot.swt.finder.utils.ClassUtils;
-
-/**
- * Generate a method given the way a widget can be referenced.
- *
- * @author Ketan Padegaonkar &lt;KetanPadegaonkar [at] gmail [dot] com&gt;
- * @version $Id$
- */
-public class MethodGenerator {
-
- private final ReferenceBy[] list;
- private final Class<?> returnType;
- private final String methodNamePrefix;
- private final Class<?> widgetType;
- private final String style;
- private final Class<?> creationType;
-
- public MethodGenerator(Class<?> returnType, Class<?> creationType, Class<?> widgetType, String methodNamePrefix, String style, List<ReferenceBy> list) {
- this.returnType = returnType;
- this.creationType = creationType;
- this.widgetType = widgetType;
- this.methodNamePrefix = methodNamePrefix;
- this.style = style;
- this.list = list.toArray(new ReferenceBy[] {});
- }
-
- public MethodGenerator(Class<?> returnType, Class<?> creationType, Class<?> widgetType, String methodNamePrefix, String style, ReferenceBy... list) {
- this.returnType = returnType;
- this.creationType = creationType;
- this.widgetType = widgetType;
- this.methodNamePrefix = methodNamePrefix;
- this.style = style;
- this.list = list;
- }
-
- public String methodArguments() {
- StringBuffer result = new StringBuffer();
- String delimiter = ", "; //$NON-NLS-1$
-
- for (ReferenceBy ref : list) {
- result.append(ref.methodArgument()).append(delimiter);
- }
- result.lastIndexOf(delimiter);
- result.replace(result.length() - delimiter.length(), result.length(), ""); //$NON-NLS-1$
-
- return result.toString();
- }
-
- public String methodContentsWithIndex() {
- String result = " @SuppressWarnings({\"unchecked\", \"rawtypes\"})\n"; //$NON-NLS-1$
- result += " public " + ClassUtils.simpleClassName(returnType) + " " + methodName() + methodArgsWithIndex() + " {\n"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- result += " Matcher matcher = allOf(" + instanceOf() + (otherMatchers().length() > 0 ? ", " : "") + otherMatchers() + ");\n"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- result += " return new " + ClassUtils.simpleClassName(creationType) + "((" + ClassUtils.simpleClassName(widgetType) //$NON-NLS-1$ //$NON-NLS-2$
- + ") widget(matcher, index), matcher);\n"; //$NON-NLS-1$
- result += " }\n"; //$NON-NLS-1$
- return result;
- }
-
- public String methodContents() {
- String result = ""; //$NON-NLS-1$
- result += " public " + ClassUtils.simpleClassName(returnType) + " " + methodName() + methodArgsWithoutIndex() + " {\n"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- result += " return " + methodName() + "(" + (methodInvocationArgs().equals(", ") ? "" : methodInvocationArgs()) + "0);\n"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- result += " }\n"; //$NON-NLS-1$
- return result;
- }
-
- public String commentContents() {
- String string = ""; //$NON-NLS-1$
- string += params();
- string += returnStatement();
- string += throwsStatement();
- return comment(string);
- }
-
- public String commentContentsWithIndex() {
- String string = ""; //$NON-NLS-1$
- string += params();
- string += "@param index the index of the widget.\n"; //$NON-NLS-1$
- string += returnStatement();
- string += throwsStatement();
- string += "\n"; //$NON-NLS-1$
- return comment(string);
- }
-
- private String throwsStatement() {
- return "@throws WidgetNotFoundException if the widget is not found or is disposed.\n";
- }
-
- private String returnStatement() {
- String string = "@return a {@link " + ClassUtils.simpleClassName(returnType) + "}"; //$NON-NLS-1$ //$NON-NLS-2$
- for (ReferenceBy ref : list) {
- string += " " + ref.describeJavaDoc(); //$NON-NLS-1$
- }
- return string + ".\n";
- }
-
- private String params() {
- String string = ""; //$NON-NLS-1$
- for (ReferenceBy ref : list) {
- string += ref.paramJavaDoc();
- }
- return string;
- }
-
- private String comment(String string) {
- String[] lines = string.split("\n"); //$NON-NLS-1$
- StringBuffer buf = new StringBuffer();
- buf.append(" /**\n"); //$NON-NLS-1$
- for (String line : lines) {
- buf.append(" * ").append(line).append("\n"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- buf.append(" */"); //$NON-NLS-1$
- return buf.toString();
- }
-
- private String methodInvocationArgs() {
- String invocation = ""; //$NON-NLS-1$
- String[] methodArgs = methodArguments().split(","); //$NON-NLS-1$
- for (String methodArg : methodArgs) {
- String[] arg = methodArg.split("\\s"); //$NON-NLS-1$
- invocation += arg[arg.length - 1] + ", "; //$NON-NLS-1$
- }
- return invocation;
- }
-
- private String otherMatchers() {
- StringBuffer result = new StringBuffer();
- String delimiter = ", "; //$NON-NLS-1$
-
- for (ReferenceBy ref : list) {
- String matcherMethod = ref.matcherMethod();
- if (matcherMethod.trim().length() > 0)
- result.append(matcherMethod).append(delimiter);
- }
-
- if (hasStyle())
- result.append("withStyle(" + style + ", \"" + style + "\")").append(delimiter); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
- if (result.lastIndexOf(delimiter) >= 0)
- result.replace(result.length() - delimiter.length(), result.length(), ""); //$NON-NLS-1$
-
- return result.toString();
- }
-
- private boolean hasStyle() {
- return !"SWT.NONE".equals(style); //$NON-NLS-1$
- }
-
- private String instanceOf() {
- return "widgetOfType(" + ClassUtils.simpleClassName(widgetType) + ".class)"; //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- private String methodArgsWithIndex() {
- return "(" + methodArguments() + (methodArguments().length() > 0 ? ", " : "") + "int index)"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
-
- private String methodArgsWithoutIndex() {
- return "(" + methodArguments() + ")"; //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- private String methodName() {
- StringBuffer methodName = new StringBuffer(methodNamePrefix);
- for (ReferenceBy ref : list) {
- methodName.append(ref.methodNameSuffix());
- }
- return methodName.toString();
- }
-
- public List<String> imports() {
- ArrayList<String> imports = new ArrayList<String>();
- imports.add("import " + returnType.getName()); //$NON-NLS-1$
- imports.add("import " + widgetType.getName()); //$NON-NLS-1$
- return imports;
- }
-
-}
diff --git a/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/QuickReferenceWriter.java b/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/QuickReferenceWriter.java
deleted file mode 100644
index 666d1d05..00000000
--- a/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/QuickReferenceWriter.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Ketan Padegaonkar 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:
- * Ketan Padegaonkar - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swtbot.generator;
-
-import java.io.PrintStream;
-import java.util.Set;
-
-/**
- * @author Ketan Padegaonkar &lt;KetanPadegaonkar [at] gmail [dot] com&gt;
- * @version $Id$
- */
-public class QuickReferenceWriter implements HamcrestWriter {
-
- private final PrintStream out;
-
- public QuickReferenceWriter(PrintStream out) {
- this.out = out;
- }
-
- public void writeMethod(String method) {
- out.println(method.split("\n")[0]); //$NON-NLS-1$
- }
-
- public void writeHeader(Set<String> imports) {
-
- }
-
- public void writeFooter() {
-
- }
-
- public void flush() {
-
- }
-
- public void close() {
-
- }
-
- public void beginClassDefinition() {
-
- }
-
- public void beginConstructors() {
-
- }
-
-}
diff --git a/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/SWTBotGeneratorFactoryReader.java b/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/SWTBotGeneratorFactoryReader.java
deleted file mode 100644
index de9442df..00000000
--- a/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/SWTBotGeneratorFactoryReader.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Ketan Padegaonkar 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:
- * Ketan Padegaonkar - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swtbot.generator;
-
-import java.lang.reflect.Constructor;
-import java.util.ArrayList;
-import java.util.Collection;
-
-import org.eclipse.swtbot.swt.finder.SWTBotWidget;
-
-/**
- * @author Ketan Padegaonkar &lt;KetanPadegaonkar [at] gmail [dot] com&gt;
- * @version $Id$
- */
-public class SWTBotGeneratorFactoryReader {
-
- private SWTBotWidget annotation;
- private Constructor<?> constructor;
- private Class<?> clasz;
-
- public SWTBotGeneratorFactoryReader(String className) throws ClassNotFoundException {
- clasz = Class.forName(className);
- annotation = getSWTBotAnnotation();
- constructor = getConstructor();
- }
-
- public ArrayList<String> getMethods() {
- if (annotation == null)
- return new ArrayList<String>();
-
- Class<?> returnType;
-
- returnType = annotation.returnType();
- if (returnType == Object.class)
- returnType = constructor.getDeclaringClass();
-
- Class<?> creationType = constructor.getDeclaringClass();
- return MethodFactory.methods(annotation, returnType, creationType, annotation.clasz(), annotation.preferredName());
- }
-
- public Collection<? extends String> getImports() {
- if (annotation == null)
- return new ArrayList<String>();
- return MethodFactory.imports(annotation, constructor.getDeclaringClass(), annotation.clasz(), annotation.preferredName());
- }
-
- private Constructor<?> getConstructor() {
- return clasz.getConstructors()[0];
- }
-
- private SWTBotWidget getSWTBotAnnotation() {
- return clasz.getAnnotation(SWTBotWidget.class);
- }
-
-}
diff --git a/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/SWTBotGeneratorMain.java b/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/SWTBotGeneratorMain.java
deleted file mode 100644
index a37e709c..00000000
--- a/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/SWTBotGeneratorMain.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Ketan Padegaonkar 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:
- * Ketan Padegaonkar - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swtbot.generator;
-
-import java.io.File;
-
-/**
- * @author Ketan Padegaonkar &lt;KetanPadegaonkar [at] gmail [dot] com&gt;
- * @version $Id$
- */
-public class SWTBotGeneratorMain {
-
- public static void main(String[] args) {
- try {
- XmlConfigurator.main("widgets.xml", "org.eclipse.swtbot.swt.finder.SWTBot", "SWTBotFactory", new File("../org.eclipse.swtbot.swt.finder/src" ));
- XmlConfigurator.main("widgets-forms.xml", "org.eclipse.swtbot.forms.finder.SWTFormsBot", "SWTBot", new File("../org.eclipse.swtbot.forms.finder/src" ));
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-}
diff --git a/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/SugarGenerator.java b/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/SugarGenerator.java
deleted file mode 100644
index 31e7eafe..00000000
--- a/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/SugarGenerator.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Ketan Padegaonkar 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:
- * Ketan Padegaonkar - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swtbot.generator;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-import java.util.TreeSet;
-
-/**
- * @author Ketan Padegaonkar &lt;KetanPadegaonkar [at] gmail [dot] com&gt;
- * @version $Id$
- */
-public class SugarGenerator {
-
- private final List<HamcrestWriter> factoryWriters = new ArrayList<HamcrestWriter>();
- private final List<String> factoryMethods = new ArrayList<String>();
- private final Set<String> imports = new TreeSet<String>();
-
- public void addWriter(HamcrestWriter quickReferenceWriter) {
- factoryWriters.add(quickReferenceWriter);
- }
-
- public void generate() {
- for (HamcrestWriter factoryWriter : factoryWriters) {
- factoryWriter.writeHeader(imports);
- factoryWriter.beginClassDefinition();
- factoryWriter.beginConstructors();
- writeMethods(factoryWriter);
- factoryWriter.writeFooter();
- factoryWriter.flush();
- }
- }
-
- private void writeMethods(HamcrestWriter factoryWriter) {
- for (String method : factoryMethods)
- factoryWriter.writeMethod(method);
- }
-
- public void close() {
- for (HamcrestWriter factoryWriter : factoryWriters)
- factoryWriter.close();
- }
-
- public void addFactoryMethods(SWTBotGeneratorFactoryReader doxFactoryReader) {
- factoryMethods.addAll(doxFactoryReader.getMethods());
- }
-
- public void addImports(SWTBotGeneratorFactoryReader doxFactoryReader) {
- imports.addAll(doxFactoryReader.getImports());
- }
-
-}
diff --git a/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/XmlConfigurator.java b/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/XmlConfigurator.java
deleted file mode 100644
index 7a851c13..00000000
--- a/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/XmlConfigurator.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/**
- * This file is derived from Hamcrest's {@link org.hamcrest.generator.config.XmlConfigurator} class.
- * Portions modified by Ketan Padegaonkar are provided under the EPL.
- *
- * Copyright (c) 2008 Ketan Padegaonkar 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:
- * Ketan Padegaonkar - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swtbot.generator;
-
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-
-import org.xml.sax.Attributes;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.DefaultHandler;
-
-public class XmlConfigurator {
-
- private final SugarGenerator sugarConfiguration;
- private final SAXParserFactory saxParserFactory;
-
- public XmlConfigurator(SugarGenerator sugarConfiguration, ClassLoader classLoader) {
- this.sugarConfiguration = sugarConfiguration;
- saxParserFactory = SAXParserFactory.newInstance();
- saxParserFactory.setNamespaceAware(true);
- }
-
- public void load(InputSource inputSource) throws ParserConfigurationException, SAXException, IOException {
- SAXParser saxParser = saxParserFactory.newSAXParser();
- saxParser.parse(inputSource, new DefaultHandler() {
- @Override
- public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
- if (localName.equals("widget")) { //$NON-NLS-1$
- String className = attributes.getValue("class"); //$NON-NLS-1$
- try {
- addClass(className);
- } catch (ClassNotFoundException e) {
- throw new SAXException("Cannot find Matcher class : " + className); //$NON-NLS-1$
- }
- }
- }
- });
- }
-
- private void addClass(String className) throws ClassNotFoundException {
- sugarConfiguration.addFactoryMethods(new SWTBotGeneratorFactoryReader(className));
- sugarConfiguration.addImports(new SWTBotGeneratorFactoryReader(className));
- }
-
- public static void main(String configFile, String fullClassName, String superClass, File outputDir) throws Exception {
-
- String fileName = fullClassName.replace('.', File.separatorChar) + ".java"; //$NON-NLS-1$
- int dotIndex = fullClassName.lastIndexOf("."); //$NON-NLS-1$
- String packageName = dotIndex == -1 ? "" : fullClassName.substring(0, dotIndex); //$NON-NLS-1$
- String shortClassName = fullClassName.substring(dotIndex + 1);
-
- if (!outputDir.isDirectory()) {
- System.err.println("Output directory not found : " + outputDir.getAbsolutePath()); //$NON-NLS-1$
- System.exit(-1);
- }
-
- File outputFile = new File(outputDir, fileName);
- outputFile.getParentFile().mkdirs();
-
- SugarGenerator sugarGenerator = new SugarGenerator();
- try {
- sugarGenerator.addWriter(new HamcrestFactoryWriter(packageName, shortClassName, superClass, new FileWriter(outputFile)));
- sugarGenerator.addWriter(new QuickReferenceWriter(System.out));
-
- XmlConfigurator xmlConfigurator = new XmlConfigurator(sugarGenerator, XmlConfigurator.class.getClassLoader());
- xmlConfigurator.load(new InputSource(configFile));
- System.out.println("Generating " + fullClassName); //$NON-NLS-1$
- sugarGenerator.generate();
- } finally {
- sugarGenerator.close();
- }
- }
-}
diff --git a/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/framework/GenerationRule.java b/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/framework/GenerationRule.java
new file mode 100644
index 00000000..3e73bb53
--- /dev/null
+++ b/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/framework/GenerationRule.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat Inc..
+ * 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:
+ * Mickael Istria (Red Hat) - initial API and implementation
+ * Rastislav Wagner (Red Hat) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swtbot.generator.framework;
+
+import org.eclipse.swt.widgets.Event;
+
+public abstract class GenerationRule {
+
+ public abstract boolean appliesTo(Event event);
+
+ public abstract void initializeForEvent(Event event) ;
+
+ public String generateCode() {
+ return getWidgetAccessor() + getActon();
+ }
+
+ protected abstract String getWidgetAccessor();
+ protected abstract String getActon();
+
+}
diff --git a/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/framework/Generator.java b/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/framework/Generator.java
new file mode 100644
index 00000000..af0d5f0e
--- /dev/null
+++ b/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/framework/Generator.java
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat Inc..
+ * 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:
+ * Mickael Istria (Red Hat) - initial API and implementation
+ * Rastislav Wagner (Red Hat) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swtbot.generator.framework;
+
+import java.util.List;
+
+public interface Generator {
+
+ public List<GenerationRule> createRules();
+ public String getLabel();
+
+}
diff --git a/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/framework/WidgetUtils.java b/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/framework/WidgetUtils.java
new file mode 100644
index 00000000..fc55f195
--- /dev/null
+++ b/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/framework/WidgetUtils.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat Inc..
+ * 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:
+ * Mickael Istria (Red Hat) - initial API and implementation
+ * Rastislav Wagner (Red Hat) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swtbot.generator.framework;
+
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+
+public class WidgetUtils {
+
+ public static int getIndex(Control control) {
+ // This is the reverse method of
+ // Matcher matcher = allOf(widgetOfType(Button.class), withStyle(SWT.PUSH, "SWT.PUSH"));
+ // return new SWTBotButton((Button) widget(matcher, index), matcher);
+ // TODO? Evaluate reusing matchers here too
+
+ int index = 0;
+ Composite parent = null;
+ do {
+ parent = control.getParent();
+ for (Control c : parent.getChildren()) {
+ if(c.equals(control)){
+ return index;
+ } else if (c.getClass().equals(control.getClass())){
+ index++;
+ }
+ }
+ } while(!(parent instanceof Shell));
+
+ throw new RuntimeException("Could not determine index for widget " + control);
+ }
+
+}
diff --git a/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/framework/rules/AbstractTreeGenerationRule.java b/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/framework/rules/AbstractTreeGenerationRule.java
new file mode 100644
index 00000000..99eab168
--- /dev/null
+++ b/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/framework/rules/AbstractTreeGenerationRule.java
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat Inc..
+ * 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:
+ * Mickael Istria (Red Hat) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swtbot.generator.framework.rules;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.swtbot.generator.framework.GenerationRule;
+import org.eclipse.swtbot.generator.framework.WidgetUtils;
+
+public abstract class AbstractTreeGenerationRule extends GenerationRule {
+
+ private Tree tree;
+ private TreeItem item;
+
+ /**
+ * Subclasses should call super.appliesTo first, and then
+ * verify their conditions
+ * @param event
+ * @return
+ */
+ @Override
+ public boolean appliesTo(Event event) {
+ return event.widget instanceof Tree && event.item instanceof TreeItem;
+ }
+
+ @Override
+ public void initializeForEvent(Event event) {
+ this.tree = (Tree)event.widget;
+ this.item = (TreeItem)event.item;
+ }
+
+ @Override
+ protected String getWidgetAccessor() {
+ StringBuilder res = new StringBuilder();
+ res.append("bot.tree(");
+ int index = WidgetUtils.getIndex(this.tree);
+ if (index != 0) {
+ res.append(index);
+ }
+ res.append(")");
+ List<String> path = new ArrayList<String>();
+ TreeItem currentItem = this.item;
+ while (currentItem != null) {
+ if (currentItem != null && currentItem.getText() != null) {
+ path.add(currentItem.getText());
+ }
+ currentItem = currentItem.getParentItem();
+ }
+ Collections.reverse(path);
+ boolean first = true;
+ for (String text : path) {
+ if (first) {
+ res.append(".getTreeItem(\"");
+ first = false;
+ } else {
+ res.append(".getNode(\"");
+ }
+ res.append(text);
+ res.append("\")");
+ }
+ return res.toString();
+ }
+}
diff --git a/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/framework/rules/CComboSelectionRule.java b/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/framework/rules/CComboSelectionRule.java
new file mode 100644
index 00000000..6960b591
--- /dev/null
+++ b/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/framework/rules/CComboSelectionRule.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat Inc..
+ * 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:
+ * Mickael Istria (Red Hat) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swtbot.generator.framework.rules;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swtbot.generator.framework.GenerationRule;
+import org.eclipse.swtbot.generator.framework.WidgetUtils;
+
+public class CComboSelectionRule extends GenerationRule {
+
+ private Combo combo;
+ private String newSelection;
+ private int newSelectionIndex;
+
+ @Override
+ public boolean appliesTo(Event event) {
+ return event.widget instanceof Combo && event.type == SWT.Selection;
+ }
+
+ @Override
+ public void initializeForEvent(Event event) {
+ this.combo = (Combo)event.widget;
+ this.newSelection = this.combo.getText();
+ this.newSelectionIndex = this.combo.getSelectionIndex();
+ }
+
+ @Override
+ protected String getWidgetAccessor() {
+ int index = WidgetUtils.getIndex(this.combo);
+ if (index != 0) {
+ return "bot.combo(" + index + ")";
+ } else {
+ return "bot.combo()";
+ }
+ }
+
+ @Override
+ protected String getActon() {
+ StringBuilder res = new StringBuilder();
+ res.append(".select(");
+ if (this.newSelection != null) {
+ res.append('"');
+ res.append(this.newSelection);
+ res.append("\")");
+ } else {
+ res.append(this.newSelectionIndex);
+ res.append(")");
+ }
+ return res.toString();
+ }
+
+}
diff --git a/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/framework/rules/CheckboxClickedRule.java b/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/framework/rules/CheckboxClickedRule.java
new file mode 100644
index 00000000..1f493680
--- /dev/null
+++ b/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/framework/rules/CheckboxClickedRule.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat Inc..
+ * 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:
+ * Mickael Istria (Red Hat) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swtbot.generator.framework.rules;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swtbot.generator.framework.GenerationRule;
+import org.eclipse.swtbot.generator.framework.WidgetUtils;
+
+public class CheckboxClickedRule extends GenerationRule {
+
+ private String buttonText;
+ private int index;
+
+ @Override
+ public boolean appliesTo(Event event) {
+ return event.widget instanceof Button &&
+ (((Button)event.widget).getStyle() & SWT.RADIO) != 0
+ && event.type == SWT.Selection;
+ }
+
+ @Override
+ public void initializeForEvent(Event event) {
+ this.buttonText = ((Button)event.widget).getText().replace("&", "");
+ if (this.buttonText == null) {
+ this.index = WidgetUtils.getIndex((Button)event.widget);
+ }
+ }
+
+ @Override
+ protected String getWidgetAccessor() {
+ if (this.buttonText != null) {
+ return "bot.radio(\"" + this.buttonText + "\")";
+ } else {
+ return "bot.radio(" + this.index + ")";
+ }
+ }
+
+ @Override
+ protected String getActon() {
+ return ".click()";
+ }
+
+}
diff --git a/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/framework/rules/ComboSelectionRule.java b/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/framework/rules/ComboSelectionRule.java
new file mode 100644
index 00000000..bad81e81
--- /dev/null
+++ b/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/framework/rules/ComboSelectionRule.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat Inc..
+ * 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:
+ * Mickael Istria (Red Hat) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swtbot.generator.framework.rules;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CCombo;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swtbot.generator.framework.GenerationRule;
+import org.eclipse.swtbot.generator.framework.WidgetUtils;
+
+public class ComboSelectionRule extends GenerationRule {
+
+ private CCombo combo;
+ private String newSelection;
+ private int newSelectionIndex;
+
+ @Override
+ public boolean appliesTo(Event event) {
+ return event.widget instanceof CCombo && event.type == SWT.Selection;
+ }
+
+ @Override
+ public void initializeForEvent(Event event) {
+ this.combo = (CCombo)event.widget;
+ this.newSelection = this.combo.getText();
+ this.newSelectionIndex = this.combo.getSelectionIndex();
+ }
+
+ @Override
+ protected String getWidgetAccessor() {
+ int index = WidgetUtils.getIndex(this.combo);
+ if (index != 0) {
+ return "bot.combo(" + index + ")";
+ } else {
+ return "bot.combo()";
+ }
+ }
+
+ @Override
+ protected String getActon() {
+ StringBuilder res = new StringBuilder();
+ res.append(".select(");
+ if (this.newSelection != null) {
+ res.append('"');
+ res.append(this.newSelection);
+ res.append("\")");
+ } else {
+ res.append(this.newSelectionIndex);
+ res.append(")");
+ }
+ return res.toString();
+ }
+
+}
diff --git a/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/framework/rules/DoubleClickTreeItemRule.java b/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/framework/rules/DoubleClickTreeItemRule.java
new file mode 100644
index 00000000..def48120
--- /dev/null
+++ b/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/framework/rules/DoubleClickTreeItemRule.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat Inc..
+ * 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:
+ * Mickael Istria (Red Hat) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swtbot.generator.framework.rules;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Event;
+
+public class DoubleClickTreeItemRule extends AbstractTreeGenerationRule {
+
+ @Override
+ public boolean appliesTo(Event event) {
+ return super.appliesTo(event) && event.type == SWT.MouseDoubleClick;
+ }
+
+ @Override
+ protected String getActon() {
+ return ".doubleClick()";
+ }
+
+}
diff --git a/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/framework/rules/ExpandTreeItemRule.java b/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/framework/rules/ExpandTreeItemRule.java
new file mode 100644
index 00000000..2de8e00d
--- /dev/null
+++ b/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/framework/rules/ExpandTreeItemRule.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat Inc..
+ * 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:
+ * Mickael Istria (Red Hat) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swtbot.generator.framework.rules;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Event;
+
+public class ExpandTreeItemRule extends AbstractTreeGenerationRule {
+
+ @Override
+ public boolean appliesTo(Event e) {
+ return super.appliesTo(e) && e.type == SWT.Expand;
+ }
+
+ @Override
+ protected String getActon() {
+ return ".expand()";
+ }
+
+}
diff --git a/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/framework/rules/MenuClickedRule.java b/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/framework/rules/MenuClickedRule.java
new file mode 100644
index 00000000..8bfae4c0
--- /dev/null
+++ b/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/framework/rules/MenuClickedRule.java
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat Inc..
+ * 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:
+ * Mickael Istria (Red Hat) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swtbot.generator.framework.rules;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+import org.eclipse.swtbot.generator.framework.GenerationRule;
+
+public class MenuClickedRule extends GenerationRule {
+
+ private MenuItem item;
+
+ @Override
+ public boolean appliesTo(Event event) {
+ return event.type == SWT.Selection && event.widget instanceof MenuItem;
+ }
+
+ @Override
+ public void initializeForEvent(Event event) {
+ this.item = (MenuItem)event.widget;
+ }
+
+ @Override
+ protected String getWidgetAccessor() {
+ StringBuilder code = new StringBuilder();
+ List<String> path = new ArrayList<String>();
+ path.add(cleanMenuText(this.item.getText()));
+ MenuItem currentItem = this.item;
+ Menu parent = null;
+ while (currentItem != null && (parent = currentItem.getParent()) != null) {
+ currentItem = parent.getParentItem();
+ if (currentItem != null && currentItem.getText() != null) {
+ path.add(cleanMenuText(currentItem.getText()));
+ }
+ }
+ Collections.reverse(path);
+ code.append("bot");
+ for (String text : path) {
+ code.append(".menu(\"");
+ code.append(text);
+ code.append("\")");
+ }
+ return code.toString();
+ }
+
+ private static String cleanMenuText(String text) {
+ return text.replace("&", "").split("\t")[0];
+ }
+
+ @Override
+ protected String getActon() {
+ return ".click()";
+ }
+
+}
diff --git a/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/framework/rules/ModifyTextRule.java b/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/framework/rules/ModifyTextRule.java
new file mode 100644
index 00000000..3ee15064
--- /dev/null
+++ b/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/framework/rules/ModifyTextRule.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat Inc..
+ * 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:
+ * Mickael Istria (Red Hat) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swtbot.generator.framework.rules;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swtbot.generator.framework.GenerationRule;
+import org.eclipse.swtbot.generator.framework.WidgetUtils;
+
+public class ModifyTextRule extends GenerationRule {
+
+ private Text text;
+ private String newValue;
+
+ @Override
+ public boolean appliesTo(Event event) {
+ return event.widget instanceof Text && event.type == SWT.Modify;
+ }
+
+ @Override
+ public void initializeForEvent(Event event) {
+ this.text = (Text)event.widget;
+ this.newValue = this.text.getText();
+ }
+
+ @Override
+ protected String getWidgetAccessor() {
+ StringBuilder res = new StringBuilder();
+ res.append("bot.text(");
+ int index = WidgetUtils.getIndex(this.text);
+ if (index != 0) {
+ res.append(index);
+ }
+ res.append(")");
+ return res.toString();
+ }
+
+ @Override
+ protected String getActon() {
+ return ".setText(\"" + this.newValue + "\")";
+ }
+
+}
diff --git a/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/framework/rules/PushButtonClickedRule.java b/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/framework/rules/PushButtonClickedRule.java
new file mode 100644
index 00000000..a70df011
--- /dev/null
+++ b/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/framework/rules/PushButtonClickedRule.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat Inc..
+ * 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:
+ * Mickael Istria (Red Hat) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swtbot.generator.framework.rules;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swtbot.generator.framework.GenerationRule;
+import org.eclipse.swtbot.generator.framework.WidgetUtils;
+
+public class PushButtonClickedRule extends GenerationRule {
+
+ private String buttonText;
+ private int index;
+
+ @Override
+ public boolean appliesTo(Event event) {
+ return event.widget instanceof Button &&
+ (((Button)event.widget).getStyle() & SWT.PUSH) != 0
+ && event.type == SWT.Selection;
+ }
+
+ @Override
+ public void initializeForEvent(Event event) {
+ this.buttonText = ((Button)event.widget).getText().replace("&", "");
+ if (this.buttonText == null) {
+ this.index = WidgetUtils.getIndex((Button)event.widget);
+ }
+ }
+
+ @Override
+ protected String getWidgetAccessor() {
+ if (this.buttonText != null) {
+ return "bot.button(\"" + this.buttonText + "\")";
+ } else {
+ return "bot.button(" + this.index + ")";
+ }
+ }
+
+ @Override
+ protected String getActon() {
+ return ".click()";
+ }
+
+}
diff --git a/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/framework/rules/RadioButtonClickedRule.java b/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/framework/rules/RadioButtonClickedRule.java
new file mode 100644
index 00000000..7dc4b6ec
--- /dev/null
+++ b/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/framework/rules/RadioButtonClickedRule.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat Inc..
+ * 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:
+ * Mickael Istria (Red Hat) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swtbot.generator.framework.rules;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swtbot.generator.framework.GenerationRule;
+import org.eclipse.swtbot.generator.framework.WidgetUtils;
+
+public class RadioButtonClickedRule extends GenerationRule {
+
+ private String buttonText;
+ private int index;
+
+ @Override
+ public boolean appliesTo(Event event) {
+ return event.widget instanceof Button &&
+ (((Button)event.widget).getStyle() & SWT.CHECK) != 0
+ && event.type == SWT.Selection;
+ }
+
+ @Override
+ public void initializeForEvent(Event event) {
+ this.buttonText = ((Button)event.widget).getText().replace("&", "");
+ if (this.buttonText == null) {
+ this.index = WidgetUtils.getIndex((Button)event.widget);
+ }
+ }
+
+ @Override
+ protected String getWidgetAccessor() {
+ if (this.buttonText != null) {
+ return "bot.checkBox(\"" + this.buttonText + "\")";
+ } else {
+ return "bot.checkBox(" + this.index + ")";
+ }
+ }
+
+ @Override
+ protected String getActon() {
+ return ".click()";
+ }
+
+}
diff --git a/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/framework/rules/SWTBotGeneratorRules.java b/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/framework/rules/SWTBotGeneratorRules.java
new file mode 100644
index 00000000..b19b3b22
--- /dev/null
+++ b/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/framework/rules/SWTBotGeneratorRules.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat Inc..
+ * 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:
+ * Mickael Istria (Red Hat) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swtbot.generator.framework.rules;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.swtbot.generator.framework.GenerationRule;
+import org.eclipse.swtbot.generator.framework.Generator;
+
+public class SWTBotGeneratorRules implements Generator {
+
+ public List<GenerationRule> createRules() {
+ List<GenerationRule> res = new ArrayList<GenerationRule>();
+ res.add(new PushButtonClickedRule());
+ res.add(new CheckboxClickedRule());
+ res.add(new RadioButtonClickedRule());
+ res.add(new ComboSelectionRule());
+ res.add(new CComboSelectionRule());
+ res.add(new ExpandTreeItemRule());
+ res.add(new DoubleClickTreeItemRule());
+ res.add(new MenuClickedRule());
+ res.add(new SelectTreeItemRule());
+ res.add(new ModifyTextRule());
+ return res;
+ }
+
+ public String getLabel() {
+ return "SWTBot";
+ }
+}
diff --git a/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/framework/rules/SelectTreeItemRule.java b/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/framework/rules/SelectTreeItemRule.java
new file mode 100644
index 00000000..9cee9bfe
--- /dev/null
+++ b/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/framework/rules/SelectTreeItemRule.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat Inc..
+ * 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:
+ * Mickael Istria (Red Hat) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swtbot.generator.framework.rules;
+
+import org.eclipse.swt.widgets.Event;
+
+import org.eclipse.swt.SWT;
+
+public class SelectTreeItemRule extends AbstractTreeGenerationRule {
+
+ @Override
+ public boolean appliesTo(Event e) {
+ return super.appliesTo(e) && e.type == SWT.Selection;
+ }
+
+ @Override
+ protected String getActon() {
+ return ".select()";
+ }
+
+}
diff --git a/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/ui/BotGeneratorEventDispatcher.java b/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/ui/BotGeneratorEventDispatcher.java
new file mode 100644
index 00000000..78db9915
--- /dev/null
+++ b/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/ui/BotGeneratorEventDispatcher.java
@@ -0,0 +1,125 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat Inc..
+ * 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:
+ * Mickael Istria (Red Hat) - initial API and implementation
+ * Rastislav Wagner (Red Hat) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swtbot.generator.ui;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swtbot.generator.framework.GenerationRule;
+import org.eclipse.swtbot.generator.framework.Generator;
+
+public class BotGeneratorEventDispatcher implements Listener {
+
+ public static interface CodeGenerationListener {
+ public void handleCodeGenerated(String code);
+ }
+
+ private Generator generator;
+ private List<GenerationRule> generationRules;
+ private List<CodeGenerationListener> listeners = new ArrayList<CodeGenerationListener>();
+ private Shell ignoredShell;
+ private boolean recording;
+ private Event lastModifyEvent;
+
+ public void setGenerator(Generator generator) {
+ this.generator = generator;
+ this.generationRules = generator.createRules();
+ }
+
+ public void handleEvent(Event event) {
+ if (this.ignoredShell != null && event.widget instanceof Control && this.ignoredShell.equals(getShell((Control)event.widget))) {
+ return;
+ }
+ if (event.widget instanceof Control &&
+ ! (((Control)event.widget).isFocusControl() && ((Control)event.widget).isVisible() && ((Control)event.widget).isEnabled())) {
+ return;
+ }
+
+ /* Excpetion 1: Modify Events are a stream, only last one is interesting
+ We should check whether an event was supported by another rule between 2 modifies.
+ If yes => It's a new setText, apply setText rule if any
+ If no => It's still the same setText, event is stored for later
+ */
+ if (this.lastModifyEvent != null) {
+ // unrelated event
+ if (event.type != SWT.Modify || event.widget != this.lastModifyEvent.widget) {
+ processRules(this.lastModifyEvent);
+ this.lastModifyEvent = null;
+ }
+ }
+ if (event.type == SWT.Modify) {
+ Control control = (Control)event.widget;
+ // new event or next one on same widget
+ if (this.lastModifyEvent == null || this.lastModifyEvent.widget == control) {
+ this.lastModifyEvent = event;
+ // Store for later usage so it can be overriden if a newer ModifyEvent on samme widget happen
+ return;
+ }
+ }
+
+ processRules(event);
+ }
+
+ private void processRules(Event event) {
+ for (GenerationRule rule : this.generationRules) {
+ if (rule.appliesTo(event)) {
+ rule.initializeForEvent(event);
+ //rule.setPreviousEvent()
+ dispatchCodeGenerated(rule.generateCode());
+ }
+ }
+ }
+
+ private static Shell getShell(Control widget) {
+ while (widget != null) {
+ if (widget.getParent() == null) {
+ return (Shell)widget;
+ } else {
+ widget = ((Control)widget).getParent();
+ }
+ }
+ return null;
+ }
+
+
+ private void dispatchCodeGenerated(String code) {
+ for (CodeGenerationListener listener : this.listeners) {
+ listener.handleCodeGenerated(code);
+ }
+ }
+
+ public void addListener(CodeGenerationListener listener) {
+ this.listeners.add(listener);
+ }
+
+ public void ignoreShell(Shell shell) {
+ this.ignoredShell = shell;
+ }
+
+ public boolean isReording() {
+ return this.recording;
+ }
+
+ public void switchRecording() {
+ this.recording = !this.recording;
+ }
+
+ public Generator getCurrentGenerator() {
+ return this.generator;
+ }
+
+}
diff --git a/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/ui/GeneratorExtensionPointManager.java b/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/ui/GeneratorExtensionPointManager.java
new file mode 100644
index 00000000..97cfe4f7
--- /dev/null
+++ b/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/ui/GeneratorExtensionPointManager.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat Inc..
+ * 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:
+ * Mickael Istria (Red Hat) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swtbot.generator.ui;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.swtbot.generator.framework.Generator;
+
+public class GeneratorExtensionPointManager {
+
+ private final static String EXTENSION_POINT_ID = "org.eclipse.swtbot.generator.botGeneratorSupport";
+
+ public static List<Generator> loadGenerators() {
+ List<Generator> res = new ArrayList<Generator>();
+ for (IConfigurationElement ext : Platform.getExtensionRegistry().getConfigurationElementsFor(EXTENSION_POINT_ID)) {
+ try {
+ Generator generator = (Generator)ext.createExecutableExtension("class");
+ res.add(generator);
+ } catch (CoreException ex) {
+ // TODO log
+ }
+ }
+ return res;
+ }
+
+}
diff --git a/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/ui/RecorderDialog.java b/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/ui/RecorderDialog.java
new file mode 100644
index 00000000..e3293bbb
--- /dev/null
+++ b/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/ui/RecorderDialog.java
@@ -0,0 +1,144 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat Inc..
+ * 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:
+ * Mickael Istria (Red Hat) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swtbot.generator.ui;
+
+import java.util.List;
+
+import org.eclipse.jface.dialogs.TitleAreaDialog;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.ComboViewer;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.dnd.Clipboard;
+import org.eclipse.swt.dnd.TextTransfer;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.layout.RowLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swtbot.generator.framework.Generator;
+import org.eclipse.swtbot.generator.ui.BotGeneratorEventDispatcher.CodeGenerationListener;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+
+public class RecorderDialog extends TitleAreaDialog {
+
+ private BotGeneratorEventDispatcher recorder;
+ private List<Generator> availableGenerators;
+
+ /**
+ * Create the dialog.
+ * @param parentShell
+ */
+ public RecorderDialog(Shell parentShell, BotGeneratorEventDispatcher recorder, List<Generator> availableGenerators) {
+ super(parentShell);
+ setShellStyle(SWT.CLOSE | SWT.MODELESS | SWT.BORDER | SWT.TITLE | SWT.RESIZE | SWT.MAX);
+ setBlockOnOpen(false);
+ this.recorder = recorder;
+ this.availableGenerators = availableGenerators;
+ }
+
+ /**
+ * Create contents of the dialog.
+ * @param parent
+ */
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ setTitle("SWTBot Test Recorder");
+ Composite container = (Composite) super.createDialogArea(parent);
+ container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ container.setLayout(new GridLayout(1, false));
+
+ Composite generatorSelectionContainer = new Composite(container, SWT.NONE);
+ generatorSelectionContainer.setLayout(new GridLayout(2, false));
+ Label selectorLabel = new Label(generatorSelectionContainer, SWT.NONE);
+ selectorLabel.setText("Target Bot API:");
+ selectorLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
+ ComboViewer comboViewer = new ComboViewer(generatorSelectionContainer);
+ comboViewer.setContentProvider(new ArrayContentProvider());
+ comboViewer.setLabelProvider(new LabelProvider() {
+ @Override
+ public String getText(Object o) {
+ return ((Generator)o).getLabel();
+ }
+ });
+ comboViewer.setInput(this.availableGenerators);
+ comboViewer.setSelection(new StructuredSelection(this.recorder.getCurrentGenerator()));
+ comboViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ Generator newGenerator = (Generator) ((IStructuredSelection)event.getSelection()).getFirstElement();
+ recorder.setGenerator(newGenerator);
+ }
+ });
+
+ final Text generatedCode = new Text(container, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
+ generatedCode.setText("// Generated code goes there\n");
+ generatedCode.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ Composite actionsComposite = new Composite(container, SWT.NONE);
+ actionsComposite.setLayout(new RowLayout(SWT.HORIZONTAL));
+
+ final Button recordPauseButton = new Button(actionsComposite, SWT.PUSH);
+ recordPauseButton.setText(this.recorder.isReording() ? "Pause" : "Start Recording");
+ final Button copyButton = new Button(actionsComposite, SWT.PUSH);
+ copyButton.setToolTipText("Copy");
+ copyButton.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_COPY));
+
+ recordPauseButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ recorder.switchRecording();
+ recordPauseButton.setText(recorder.isReording() ? "Pause" : "Start Recording");
+ }
+ });
+ this.recorder.addListener(new CodeGenerationListener() {
+ public void handleCodeGenerated(String code) {
+ generatedCode.setText(generatedCode.getText() + code + ";\n");
+ }
+ });
+ copyButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ final Clipboard cb = new Clipboard(Display.getCurrent());
+ TextTransfer textTransfer = TextTransfer.getInstance();
+ cb.setContents(new Object[] { generatedCode.getText() }, new Transfer[] { textTransfer });
+ cb.dispose();
+ }
+ });
+
+ return container;
+ }
+
+ @Override
+ public void createButtonsForButtonBar(Composite parent) {
+ // Override to remove default buttons
+ }
+
+ /**
+ * Return the initial size of the dialog.
+ */
+ @Override
+ protected Point getInitialSize() {
+ return new Point(450, 650);
+ }
+}
diff --git a/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/ui/StartupRecorder.java b/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/ui/StartupRecorder.java
new file mode 100644
index 00000000..3c121ba0
--- /dev/null
+++ b/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/ui/StartupRecorder.java
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat Inc..
+ * 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:
+ * Mickael Istria (Red Hat) - initial API and implementation
+ * Rastislav Wagner (Red Hat) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swtbot.generator.ui;
+
+import java.util.List;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ShellAdapter;
+import org.eclipse.swt.events.ShellEvent;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swtbot.generator.framework.Generator;
+import org.eclipse.ui.IStartup;
+import org.eclipse.ui.PlatformUI;
+
+public class StartupRecorder implements IStartup {
+
+ private static final String ENABLEMENT_PROPERTY = "org.eclipse.swtbot.generator.enable";
+
+ public void earlyStartup() {
+ if (Boolean.parseBoolean(System.getProperty(ENABLEMENT_PROPERTY)) != true) {
+ return;
+ }
+
+ final List<Generator> availableGenerators = GeneratorExtensionPointManager.loadGenerators();
+ Generator generator = availableGenerators.get(0);
+ final BotGeneratorEventDispatcher dispatcher = new BotGeneratorEventDispatcher();
+ dispatcher.setGenerator(generator);
+
+ final Display display = PlatformUI.getWorkbench().getDisplay();
+
+ display.asyncExec(new Runnable() {
+ public void run() {
+ display.addFilter(SWT.Activate, dispatcher);
+ display.addFilter(SWT.Close, dispatcher);
+ display.addFilter(SWT.Selection, dispatcher);
+ display.addFilter(SWT.Expand, dispatcher);
+ display.addFilter(SWT.Modify, dispatcher);
+ Shell recorderShell = new Shell(PlatformUI.getWorkbench().getDisplay(), SWT.CLOSE | SWT.MODELESS | SWT.BORDER | SWT.TITLE);
+ recorderShell.setText("SWTBot test recorder");
+ dispatcher.ignoreShell(recorderShell);
+ RecorderDialog recorderDialog = new RecorderDialog(recorderShell, dispatcher, availableGenerators);
+ recorderDialog.open();
+ recorderDialog.getShell().addShellListener(new ShellAdapter() {
+ public void shellClosed(ShellEvent e) {
+ display.removeFilter(SWT.Activate, dispatcher);
+ display.removeFilter(SWT.Close, dispatcher);
+ display.removeFilter(SWT.MouseDown, dispatcher);
+ display.removeFilter(SWT.MouseDoubleClick, dispatcher);
+ display.removeFilter(SWT.MouseUp, dispatcher);
+ display.removeFilter(SWT.KeyDown, dispatcher);
+ display.removeFilter(SWT.Selection, dispatcher);
+ display.removeFilter(SWT.Expand, dispatcher);
+ display.removeFilter(SWT.Modify, dispatcher);
+ }
+ });
+ }
+
+ });
+ }
+
+}
diff --git a/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotText.java b/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotText.java
index e6641e9a..86810f1f 100644
--- a/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotText.java
+++ b/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotText.java
@@ -23,7 +23,7 @@ import org.hamcrest.SelfDescribing;
/**
* This represents a {@link Text} widget.
- *
+ *
* @author Ketan Padegaonkar &lt;KetanPadegaonkar [at] gmail [dot] com&gt;
* @version $Id$
*/
@@ -32,7 +32,7 @@ public class SWTBotText extends AbstractSWTBot<Text> {
/**
* Constructs a new instance of this object.
- *
+ *
* @param w the widget.
* @throws WidgetNotFoundException if the widget is <code>null</code> or widget has been disposed.
*/
@@ -42,7 +42,7 @@ public class SWTBotText extends AbstractSWTBot<Text> {
/**
* Constructs a new instance of this object.
- *
+ *
* @param w the widget.
* @param description the description of the widget, this will be reported by {@link #toString()}
* @throws WidgetNotFoundException if the widget is <code>null</code> or widget has been disposed.
diff --git a/org.eclipse.swtbot.test/feature.xml b/org.eclipse.swtbot.test/feature.xml
index 917ee339..d46a1213 100644
--- a/org.eclipse.swtbot.test/feature.xml
+++ b/org.eclipse.swtbot.test/feature.xml
@@ -88,12 +88,6 @@
unpack="false"/>
<plugin
- id="org.eclipse.swtbot.generator.test"
- download-size="0"
- install-size="0"
- version="0.0.0"/>
-
- <plugin
id="org.eclipse.swtbot.eclipse.ui.test"
download-size="0"
install-size="0"
diff --git a/org.eclipse.swtbot.updatesite/category.xml b/org.eclipse.swtbot.updatesite/category.xml
index b860df57..424e38e7 100644
--- a/org.eclipse.swtbot.updatesite/category.xml
+++ b/org.eclipse.swtbot.updatesite/category.xml
@@ -15,6 +15,9 @@
<feature url="features/org.eclipse.swtbot.ide_0.0.0.jar" id="org.eclipse.swtbot.ide" version="0.0.0">
<category name="SWTBot - IDE Integration"/>
</feature>
+ <feature url="features/org.eclipse.swtbot.generator.feature_0.0.0.jar" id="org.eclipse.swtbot.generator.feature" version="0.0.0">
+ <category name="SWTBot - IDE Integration"/>
+ </feature>
<feature url="features/org.eclipse.swtbot.eclipse.test.junit_0.0.0.jar" id="org.eclipse.swtbot.eclipse.test.junit" version="0.0.0">
<category name="SWTBot - Headless Support"/>
</feature>
diff --git a/pom.xml b/pom.xml
index 3e96b776..dad3976b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -51,10 +51,10 @@
<module>org.eclipse.swtbot.eclipse.gef</module>
<module>org.eclipse.swtbot.ide</module>
<module>org.eclipse.swtbot.eclipse.junit.headless</module>
+ <module>org.eclipse.swtbot.generator.feature</module>
<!-- Repo -->
<module>org.eclipse.swtbot.updatesite</module>
<!-- Tests -->
- <module>org.eclipse.swtbot.generator.test</module>
<module>org.eclipse.swtbot.eclipse.ui.test</module>
<module>org.eclipse.swtbot.swt.finder.test.keyboards</module>
<module>org.eclipse.swtbot.swt.finder.test</module>

Back to the top