--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<classpath>\r
+ <classpathentry kind="src" output="target/classes" path="src/main/java"/>\r
+ <classpathentry kind="src" output="target/classes" path="src/main/resources"/>\r
+ <classpathentry kind="src" output="target/test-classes" path="src/test/java"/>\r
+ <classpathentry kind="src" output="target/test-classes" path="src/test/resources"/>\r
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>\r
+ <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>\r
+ <classpathentry kind="output" path="target/classes"/>\r
+</classpath>\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.argeo.slc.support.jemmy</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.maven.ide.eclipse.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.maven.ide.eclipse.maven2Nature</nature>
+ </natures>
+</projectDescription>
--- /dev/null
+#Fri Aug 29 11:10:18 CEST 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.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
--- /dev/null
+<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/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.argeo.slc</groupId>
+ <artifactId>runtime</artifactId>
+ <version>0.11.4-SNAPSHOT</version>
+ <relativePath>..</relativePath>
+ </parent>
+ <groupId>org.argeo.slc.runtime</groupId>
+ <artifactId>org.argeo.slc.support.jemmy</artifactId>
+ <name>Argeo SLC Support Jemmy</name>
+ <description>Helper classes for the Jemmy framework</description>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>${version.maven-bundle-plugin}</version>
+ <configuration>
+ <instructions>
+ <Export-Package>
+ org.argeo.slc.jemmy
+ </Export-Package>
+ <Import-Package>org.netbeans.jemmy,\r
+ org.netbeans.jemmy.operators,\r
+ org.netbeans.jemmy.util
+ </Import-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+
+ </plugins>
+ </build>
+ <dependencies>
+
+ <dependency>\r
+ <groupId>org.argeo.dep.jemmy</groupId>\r
+ <artifactId>org.argeo.dep.jemmy.nb61</artifactId>\r
+ </dependency>\r
+
+ </dependencies>
+</project>
\ No newline at end of file
--- /dev/null
+package org.argeo.slc.jemmy;\r
+\r
+import java.util.ArrayList;\r
+import java.util.HashMap;\r
+import java.util.Iterator;\r
+import java.util.List;\r
+import java.util.Map;\r
+import java.util.Set;\r
+\r
+import org.netbeans.jemmy.operators.ComponentOperator;\r
+\r
+public class AbstractComponentWrapper implements ComponentWrapper {\r
+\r
+ protected ComponentWrapper parent;\r
+\r
+ /**\r
+ * List of children ComponentWrapper\r
+ */\r
+ protected List children = new ArrayList();\r
+\r
+ protected WrapperLocator locator;\r
+\r
+ protected String prefix;\r
+\r
+ public ComponentOperator find() {\r
+ return locator.find(this);\r
+ }\r
+\r
+ protected String createNewKey(String oldKey) {\r
+ return (prefix == null) ? oldKey : (prefix + "." + oldKey);\r
+ }\r
+\r
+ protected void addToAccessorMap(Map accessors, String oldKey,\r
+ Object accessor) {\r
+ String newKey = createNewKey(oldKey);\r
+ if (accessors.containsKey(newKey)) {\r
+ throw new ConfigRuntimeException("An Accessor with key '" + newKey\r
+ + "' was already registered");\r
+ }\r
+ accessors.put(newKey, accessor);\r
+ }\r
+\r
+ public Map getAccessors(Class accessorClass) {\r
+ Map accessors = new HashMap();\r
+ if (accessorClass.isInstance(this)) {\r
+ addToAccessorMap(accessors, ((Accessor) this).getFieldName(), this);\r
+ }\r
+ for (int i = 0; i < children.size(); i++) {\r
+ Map childAccessors = ((ComponentWrapper) children.get(i))\r
+ .getAccessors(accessorClass);\r
+\r
+ Set entries = childAccessors.entrySet();\r
+ Iterator it = entries.iterator();\r
+\r
+ while (it.hasNext()) {\r
+ Map.Entry keyValue = (Map.Entry) it.next();\r
+ addToAccessorMap(accessors, keyValue.getKey().toString(),\r
+ keyValue.getValue());\r
+ }\r
+ }\r
+ return accessors;\r
+ }\r
+\r
+ public ComponentWrapper getParent() {\r
+ return parent;\r
+ }\r
+\r
+ public void setParent(ComponentWrapper parent) {\r
+ if (this.parent != null) {\r
+ throw new ConfigRuntimeException("Parent already set");\r
+ }\r
+ this.parent = parent;\r
+ }\r
+\r
+ public List getChildren() {\r
+ return children;\r
+ }\r
+\r
+ public void setChildren(List children) {\r
+ this.children = children;\r
+\r
+ // check that all elements of the list are ComponentWrapper\r
+ // and set their parent\r
+ for (int i = 0; i < this.children.size(); i++) {\r
+ ComponentWrapper wrapper = (ComponentWrapper) this.children.get(i);\r
+ if (wrapper == null) {\r
+ throw new ConfigRuntimeException(\r
+ "Children of ComponentWrappers must be ComponentWrappers");\r
+ }\r
+ wrapper.setParent(this);\r
+ }\r
+ }\r
+\r
+ public WrapperLocator getLocator() {\r
+ return locator;\r
+ }\r
+\r
+ public void setLocator(WrapperLocator locator) {\r
+ this.locator = locator;\r
+ }\r
+\r
+ public String getPrefix() {\r
+ return prefix;\r
+ }\r
+\r
+ public void setPrefix(String prefix) {\r
+ this.prefix = prefix;\r
+ }\r
+\r
+}\r
--- /dev/null
+package org.argeo.slc.jemmy;\r
+\r
+public interface Accessor {\r
+\r
+ public String getFieldName();\r
+\r
+}\r
--- /dev/null
+package org.argeo.slc.jemmy;\r
+\r
+\r
+public interface Actuator extends Accessor {\r
+ \r
+ void perform();\r
+}\r
--- /dev/null
+package org.argeo.slc.jemmy;\r
+\r
+import java.util.Map;\r
+\r
+import org.netbeans.jemmy.operators.ComponentOperator;\r
+\r
+public interface ComponentWrapper {\r
+\r
+ /**\r
+ * Finds the component described by the ComponentWrapper\r
+ * in the GUI\r
+ * @return a Jemmy ComponentOperator for the found component\r
+ */\r
+ public ComponentOperator find();\r
+ \r
+ public void setParent(ComponentWrapper parent);\r
+ \r
+ public ComponentWrapper getParent();\r
+ \r
+ public Map getAccessors(Class accessorClass);\r
+}\r
--- /dev/null
+package org.argeo.slc.jemmy;\r
+\r
+public class ConfigRuntimeException extends UIRuntimeException{\r
+ /**\r
+ * \r
+ */\r
+ private static final long serialVersionUID = 1L;\r
+ public ConfigRuntimeException(){\r
+ super();\r
+ }\r
+ public ConfigRuntimeException(String s){\r
+ super(s);\r
+ }\r
+ public ConfigRuntimeException(Throwable t){\r
+ super(t);\r
+ }\r
+ public ConfigRuntimeException(String s, Throwable t){\r
+ super(s,t);\r
+ }\r
+}\r
--- /dev/null
+package org.argeo.slc.jemmy;\r
+\r
+import java.util.HashMap;\r
+import java.util.Map;\r
+\r
+import org.netbeans.jemmy.operators.ComponentOperator;\r
+\r
+public class FictiveComponentWrapper implements ComponentWrapper {\r
+\r
+ protected ComponentWrapper parent; \r
+ \r
+ public ComponentOperator find() {\r
+ // just ask the parent\r
+ return parent.find();\r
+ }\r
+\r
+ /**\r
+ * Return only itself (if the class matches)\r
+ */\r
+ public Map getAccessors(Class accessorClass) {\r
+ Map accessors = new HashMap();\r
+ if (accessorClass.isInstance(this)) {\r
+ accessors.put(((Accessor) this).getFieldName(), this);\r
+ } \r
+ return accessors;\r
+ }\r
+\r
+ public ComponentWrapper getParent() {\r
+ return parent;\r
+ }\r
+\r
+ public void setParent(ComponentWrapper parent) {\r
+ this.parent = parent;\r
+ }\r
+\r
+}\r
--- /dev/null
+package org.argeo.slc.jemmy;\r
+\r
+\r
+public interface ReadAccessor extends Accessor {\r
+ \r
+ public String get();\r
+ \r
+}\r
--- /dev/null
+package org.argeo.slc.jemmy;\r
+\r
+public class UIRuntimeException extends RuntimeException {\r
+ /**\r
+ * \r
+ */\r
+ private static final long serialVersionUID = 1L;\r
+ public UIRuntimeException(){\r
+ super();\r
+ }\r
+ public UIRuntimeException(String s){\r
+ super(s);\r
+ }\r
+ public UIRuntimeException(Throwable t){\r
+ super(t);\r
+ }\r
+ public UIRuntimeException(String s, Throwable t){\r
+ super(s,t);\r
+ }\r
+}\r
--- /dev/null
+package org.argeo.slc.jemmy;\r
+\r
+import org.netbeans.jemmy.operators.ComponentOperator;\r
+\r
+public interface WrapperLocator {\r
+\r
+ public ComponentOperator find(ComponentWrapper wrapper);\r
+}\r
--- /dev/null
+package org.argeo.slc.jemmy;\r
+\r
+\r
+public interface WriteAccessor extends Accessor {\r
+ \r
+ public void set(String value);\r
+ \r
+}\r