]> source.dussan.org Git - vaadin-framework.git/commitdiff
Updates to developer tests.
authorMarko Grönroos <magi@iki.fi>
Wed, 16 Apr 2008 13:48:36 +0000 (13:48 +0000)
committerMarko Grönroos <magi@iki.fi>
Wed, 16 Apr 2008 13:48:36 +0000 (13:48 +0000)
svn changeset:4186/svn branch:trunk

WebContent/ITMILL/themes/tests-magi/layouts/layoutname.html [new file with mode: 0644]
WebContent/WEB-INF/web.xml
WebContent/embeddingexample.html [new file with mode: 0644]
WebContent/embeddingiframe.html [new file with mode: 0644]
src/com/itmill/toolkit/tests/magi/ChatApplication.java [new file with mode: 0644]

diff --git a/WebContent/ITMILL/themes/tests-magi/layouts/layoutname.html b/WebContent/ITMILL/themes/tests-magi/layouts/layoutname.html
new file mode 100644 (file)
index 0000000..6b75910
--- /dev/null
@@ -0,0 +1,19 @@
+<table width="100%" height="100%">
+  <tr height="100%">
+    <td>
+      <table align="center">
+        <tr>
+          <td align="right">User&nbsp;name:</td>
+          <td><div location="username"></div></td>
+        </tr>
+        <tr>
+          <td align="right">Password:</td>
+          <td><div location="password"></div></td>
+        </tr>
+      </table>
+    </td>
+  </tr>
+  <tr>
+    <td align="right" colspan="2"><div location="okbutton"></div></td>
+  </tr>
+</table>
\ No newline at end of file
index 02817d08169292acdabc95713f0ce8884f586b61..d3d33ff94340628f0ac9d3bcdc4a781097e3c193 100644 (file)
       <param-value>com.itmill.toolkit.tests.magi.MagiTestApplication</param-value>
     </init-param>
   </servlet>
-\r
+
+  <servlet>
+    <servlet-name>WindowTestServlet</servlet-name>
+    <servlet-class>com.itmill.toolkit.terminal.gwt.server.ApplicationServlet</servlet-class>
+    <init-param>
+      <param-name>application</param-name>
+      <param-value>com.itmill.toolkit.tests.magi.WindowTestApplication</param-value>
+    </init-param>
+  </servlet>
+
+  <servlet>
+    <servlet-name>ChatServlet</servlet-name>
+    <servlet-class>com.itmill.toolkit.terminal.gwt.server.ApplicationServlet</servlet-class>
+    <init-param>
+      <param-name>application</param-name>
+      <param-value>com.itmill.toolkit.tests.magi.ChatApplication</param-value>
+    </init-param>
+  </servlet>
+
   <servlet>\r
     <servlet-name>BrowserDemo</servlet-name>\r
     <servlet-class>com.itmill.toolkit.terminal.gwt.server.ApplicationServlet</servlet-class>\r
     <url-pattern>/testbench2/*</url-pattern>
   </servlet-mapping>
 \r
+  <servlet-mapping>
+    <servlet-name>WindowTestServlet</servlet-name>
+    <url-pattern>/windowtest/*</url-pattern>
+  </servlet-mapping>
+
+  <servlet-mapping>
+    <servlet-name>ChatServlet</servlet-name>
+    <url-pattern>/chat/*</url-pattern>
+  </servlet-mapping>
+
   <servlet-mapping>\r
     <servlet-name>BrowserDemo</servlet-name>\r
     <url-pattern>/BrowserDemo/*</url-pattern>\r
diff --git a/WebContent/embeddingexample.html b/WebContent/embeddingexample.html
new file mode 100644 (file)
index 0000000..35b2ffd
--- /dev/null
@@ -0,0 +1,37 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\r
+<html xmlns="http://www.w3.org/1999/xhtml" >\r
+  <head>
+    <title>Embedding Example</title>\r
+
+    <!-- Set parameter for the IT Mill Toolkit Client-Side Engine. -->
+    <script type="text/javascript">
+           var itmill = {appUri:'Calc', pathInfo: '/'};\r
+    </script>
+    
+    <!-- Load the IT Mill Toolkit Client-Side Engine. -->\r
+    <script language='javascript' src='/itmill-toolkit-examples/ITMILL/widgetsets/com.itmill.toolkit.terminal.gwt.DefaultWidgetSet/com.itmill.toolkit.terminal.gwt.DefaultWidgetSet.nocache.js'></script>
+
+    <!-- We can stylize the web application. -->
+    <style>
+        #itmill-ajax-window {background: #c0c0ff;}
+        .i-button {background: pink;}
+    </style>
+  </head>\r
+
+  <body>
+    <!-- This <iframe> element is required by GWT. -->
+    <iframe id="__gwt_historyFrame" style="width:0;height:0;border:0"></iframe>
+    
+    <h1>This is a HTML page</h1>
+       <p>Below is the IT Toolkit Application inside a table:</p>
+       <table align="center" border="3" style="background: yellow;">
+         <tr><th>The Calculator</th></tr>
+         <tr>
+           <td>
+          <!-- Placeholder <div> for the IT Mill Toolkit application -->\r
+          <div id="itmill-ajax-window"/>
+        </td>
+      </tr>
+    </table>   \r
+  </body>\r
+</html>\r
diff --git a/WebContent/embeddingiframe.html b/WebContent/embeddingiframe.html
new file mode 100644 (file)
index 0000000..026a6d7
--- /dev/null
@@ -0,0 +1,26 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\r
+<html xmlns="http://www.w3.org/1999/xhtml" >\r
+  <head>
+    <title>Embedding in IFrame</title>\r
+  </head>\r
+
+  <body style="background: #d0ffd0;">
+    <h1>This is a HTML page</h1>
+       <p>Below are two IT Mill Toolkit applications embedded inside a table:</p>
+
+       <table align="center" border="3">
+         <tr>
+           <th>The Calculator</th>
+           <th>The Color Picker</th>
+         </tr>
+         <tr valign="top">
+           <td>
+             <iframe src="/itmill-toolkit-examples/Calc" height="200" width="150" frameborder="0"></iframe>
+        </td>
+           <td>
+          <iframe src="/itmill-toolkit-examples/colorpicker" height="330" width="400" frameborder="0"></iframe>
+        </td>
+      </tr>
+    </table>
+  </body>\r
+</html>\r
diff --git a/src/com/itmill/toolkit/tests/magi/ChatApplication.java b/src/com/itmill/toolkit/tests/magi/ChatApplication.java
new file mode 100644 (file)
index 0000000..ffb9a9d
--- /dev/null
@@ -0,0 +1,68 @@
+package com.itmill.toolkit.tests.magi;
+
+import java.util.*;
+import com.itmill.toolkit.Application;
+import com.itmill.toolkit.ui.*;
+import com.itmill.toolkit.ui.Button.ClickEvent;
+
+public class ChatApplication extends Application implements Button.ClickListener {
+    /* ChatApplication instances of different users.
+     * Warning: a hack, not safe, because sessions can expire. */
+    static List users = new ArrayList();
+    
+    /* Messages as a shared list. */
+    static List messages  = new ArrayList();
+    int         localSize = 0;
+
+    /* User interface. */
+    Table       messageTable = new Table();
+    TextField   username     = new TextField("Username:");
+    TextField   message      = new TextField("Message:");
+
+    public void init() {
+        final Window main = new Window ("Chat");
+        setMainWindow(main);
+        setTheme("tests-magi");
+        users.add(this);
+
+        main.addComponent(username);
+
+        main.addComponent(messageTable);
+        messageTable.addContainerProperty("Sender", String.class, "");
+        messageTable.addContainerProperty("Message", String.class, "");
+        updateTable();
+        
+        main.addComponent(message);
+        
+        Button send = new Button("Send");
+        send.addListener(this);
+        main.addComponent(send);
+
+        // Poll for new messages once a second.
+        ProgressIndicator poller = new ProgressIndicator();
+        poller.addStyleName("invisible");
+        main.addComponent(poller);
+    }
+
+    public void buttonClick(ClickEvent event) {
+        synchronized(users) {
+            // Create the new message in the shared list.
+            messages.add(new String[]{new String((String) username.getValue()),
+                                      new String((String) message.getValue())});
+
+            // Update the message tables for all users.
+            for (Iterator i = users.iterator();i.hasNext();) 
+                ((ChatApplication)i.next()).updateTable();
+        }
+    }
+
+    void updateTable() {
+        if (localSize == messages.size())
+            return; // No updating needed
+
+        // Add new messages to the table
+        while (localSize < messages.size())
+            messageTable.addItem((Object[])messages.get(localSize++),
+                                 new Integer(localSize-1));
+    }
+}