]> source.dussan.org Git - vaadin-framework.git/commitdiff
added testingId field to Paintable
authorMatti Tahvonen <matti.tahvonen@itmill.com>
Fri, 14 Dec 2007 09:51:46 +0000 (09:51 +0000)
committerMatti Tahvonen <matti.tahvonen@itmill.com>
Fri, 14 Dec 2007 09:51:46 +0000 (09:51 +0000)
svn changeset:3240/svn branch:trunk

src/com/itmill/toolkit/data/Buffered.java
src/com/itmill/toolkit/data/Validator.java
src/com/itmill/toolkit/terminal/CompositeErrorMessage.java
src/com/itmill/toolkit/terminal/Paintable.java
src/com/itmill/toolkit/terminal/SystemError.java
src/com/itmill/toolkit/terminal/UserError.java
src/com/itmill/toolkit/terminal/gwt/server/ApplicationServlet.java
src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java
src/com/itmill/toolkit/ui/AbstractComponent.java
src/com/itmill/toolkit/ui/CustomComponent.java

index bddcb8489e3a1daf0f2d89fd6df1030b22fd91b7..450d63c37cf60f8bd6666cf69515c64675d34629 100644 (file)
@@ -298,5 +298,15 @@ public interface Buffered {
         public void requestRepaintRequests() {
         }
 
+        public String getTestingIdentifier() {
+            // TODO Auto-generated method stub
+            return null;
+        }
+
+        public void setTestingIdentifier(String id) {
+            throw new UnsupportedOperationException(
+                    "Setting testing id for this Paintable is not implemented");
+        }
+
     }
 }
index b56186bf694a15a40a80e3b32880f81e1fd5cc5b..e2cb3b31f96f73204668bed138ea303b701793cc 100644 (file)
@@ -162,5 +162,14 @@ public interface Validator {
         public void requestRepaintRequests() {
         }
 
+        public String getTestingIdentifier() {
+            return null;
+        }
+
+        public void setTestingIdentifier(String id) {
+            throw new UnsupportedOperationException(
+                    "Setting testing id for this Paintable is not implemented");
+        }
+
     }
 }
index ba3616466c9a8b30548168e2c32213397265e8e1..da4533e62909e242ba5fa44ce06af0b30ac8e822 100644 (file)
@@ -174,4 +174,13 @@ public class CompositeErrorMessage implements ErrorMessage {
 
         return retval;
     }
+
+    public String getTestingIdentifier() {
+        return null;
+    }
+
+    public void setTestingIdentifier(String id) {
+        throw new UnsupportedOperationException(
+                "Setting testing id for this Paintable is not implemented");
+    }
 }
index aad66cdaf2af5bc4977c515336146592ee89cc50..4ea9b4ed5eebc973fedbee9d4664a49cd17576dc 100644 (file)
@@ -43,6 +43,17 @@ public interface Paintable extends java.util.EventListener {
      */
     public void requestRepaint();
 
+    /**
+     * Adds an unique id for component that get's transferred to terminal for
+     * testing purposes.
+     * 
+     * @param id
+     *                A short (< 20 chars) alphanumeric indentifier
+     */
+    public void setTestingIdentifier(String id);
+
+    public String getTestingIdentifier();
+
     /**
      * Repaint request event is thrown when the paintable needs to be repainted.
      * This is typically done when the <code>paint</code> method would return
index f5f3623ef592c6d8d1bd5585177f0095f67376c9..b8571323fed5e1c33a8fbcd52bd1bad2f49c7901 100644 (file)
@@ -123,4 +123,13 @@ public class SystemError extends RuntimeException implements ErrorMessage {
     public void requestRepaintRequests() {
     }
 
+    public String getTestingIdentifier() {
+        return null;
+    }
+
+    public void setTestingIdentifier(String id) {
+        throw new UnsupportedOperationException(
+                "Setting testing id for this Paintable is not implemented");
+    }
+
 }
index 8d13b3c15565132398d97a7893ca20b2e481ef46..5318dbc686ef32f940fce492277b7c347e07eccc 100644 (file)
@@ -140,4 +140,13 @@ public class UserError implements ErrorMessage {
         return msg;
     }
 
+    public String getTestingIdentifier() {
+        return null;
+    }
+
+    public void setTestingIdentifier(String id) {
+        throw new UnsupportedOperationException(
+                "Setting testing id for this Paintable is not implemented");
+    }
+
 }
index bdc93fcd0b991cf6d6adc3936222d57efc58ddcf..b6b0792a3fe0ccc46b5f50cfed6eb33efd57dfd7 100644 (file)
@@ -723,9 +723,9 @@ public class ApplicationServlet extends HttpServlet {
         if (testingToolsServerUri == null) {
             // Default behavior is that ATFServer application exists on
             // same application server as current application does.
-            testingToolsServerUri = "http" + (request.isSecure() ? "s" : "")
-                    + "://" + request.getServerName() + ":"
-                    + request.getLocalPort() + "/ATF/ATFServer";
+            testingToolsServerUri = "http" + (request.isSecure() ? "s" : "") + "://"
+                    + request.getServerName() + ":" + request.getLocalPort()
+                    + "/ATF/ATFServer";
         }
         return testingToolsServerUri;
     }
index a73d6acc396ec160e39c10a21315840c86a9b6e7..e636f4710537e0d23cd1b4fa30ddfd2c2a810686 100644 (file)
@@ -737,7 +737,11 @@ public class CommunicationManager implements Paintable.RepaintRequestListener,
 
         String id = (String) paintableIdMap.get(paintable);
         if (id == null) {
-            id = "PID" + Integer.toString(idSequence++);
+            // use testing identifier as id if set
+            id = paintable.getTestingIdentifier();
+            if (id == null) {
+                id = "PID" + Integer.toString(idSequence++);
+            }
             paintableIdMap.put(paintable, id);
             idPaintableMap.put(id, paintable);
         }
index d62939add75362853cdab7fc9e857c0e237a8293..8750fbce8fc9621c2b15a1397c723ecd3a156af5 100644 (file)
@@ -113,6 +113,8 @@ public abstract class AbstractComponent implements Component, MethodEventSource
      */
     private boolean repaintRequestListenersNotified = false;
 
+    private String testingId;
+
     /* Constructor ***************************************************** */
 
     /**
@@ -130,6 +132,14 @@ public abstract class AbstractComponent implements Component, MethodEventSource
      */
     public abstract String getTag();
 
+    public void setTestingIdentifier(String id) {
+        testingId = id;
+    }
+
+    public String getTestingIdentifier() {
+        return testingId;
+    }
+
     /**
      * Gets style for component. Multiple styles are joined with spaces.
      * 
index 42fadb63dda386618e9f26b79c86e1f2cd97b21b..f407d1b05a27ce38299a8f3c240df4785cd45b89 100644 (file)
@@ -62,6 +62,8 @@ public class CustomComponent implements Component {
      */
     private boolean repaintRequestListenersNotified = false;
 
+    private String testingId;
+
     /**
      * Constructs a new custom component.
      * 
@@ -498,4 +500,12 @@ public class CustomComponent implements Component {
 
     }
 
+    public void setTestingIdentifier(String id) {
+        testingId = id;
+    }
+
+    public String getTestingIdentifier() {
+        return testingId;
+    }
+
 }