From 17937698c3a11d02e2008f0855a7e6455d8b36e3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marko=20Gr=C3=B6nroos?= Date: Wed, 16 Apr 2008 13:48:36 +0000 Subject: [PATCH] Updates to developer tests. svn changeset:4186/svn branch:trunk --- .../themes/tests-magi/layouts/layoutname.html | 19 ++++++ WebContent/WEB-INF/web.xml | 30 +++++++- WebContent/embeddingexample.html | 37 ++++++++++ WebContent/embeddingiframe.html | 26 +++++++ .../toolkit/tests/magi/ChatApplication.java | 68 +++++++++++++++++++ 5 files changed, 179 insertions(+), 1 deletion(-) create mode 100644 WebContent/ITMILL/themes/tests-magi/layouts/layoutname.html create mode 100644 WebContent/embeddingexample.html create mode 100644 WebContent/embeddingiframe.html create mode 100644 src/com/itmill/toolkit/tests/magi/ChatApplication.java diff --git a/WebContent/ITMILL/themes/tests-magi/layouts/layoutname.html b/WebContent/ITMILL/themes/tests-magi/layouts/layoutname.html new file mode 100644 index 0000000000..6b75910783 --- /dev/null +++ b/WebContent/ITMILL/themes/tests-magi/layouts/layoutname.html @@ -0,0 +1,19 @@ + + + + + + + +
+ + + + + + + + + +
User name:
Password:
+
\ No newline at end of file diff --git a/WebContent/WEB-INF/web.xml b/WebContent/WEB-INF/web.xml index 02817d0816..d3d33ff943 100644 --- a/WebContent/WEB-INF/web.xml +++ b/WebContent/WEB-INF/web.xml @@ -365,7 +365,25 @@ com.itmill.toolkit.tests.magi.MagiTestApplication - + + + WindowTestServlet + com.itmill.toolkit.terminal.gwt.server.ApplicationServlet + + application + com.itmill.toolkit.tests.magi.WindowTestApplication + + + + + ChatServlet + com.itmill.toolkit.terminal.gwt.server.ApplicationServlet + + application + com.itmill.toolkit.tests.magi.ChatApplication + + + BrowserDemo com.itmill.toolkit.terminal.gwt.server.ApplicationServlet @@ -563,6 +581,16 @@ /testbench2/* + + WindowTestServlet + /windowtest/* + + + + ChatServlet + /chat/* + + BrowserDemo /BrowserDemo/* diff --git a/WebContent/embeddingexample.html b/WebContent/embeddingexample.html new file mode 100644 index 0000000000..35b2ffde52 --- /dev/null +++ b/WebContent/embeddingexample.html @@ -0,0 +1,37 @@ + + + + Embedding Example + + + + + + + + + + + + + + + +

This is a HTML page

+

Below is the IT Toolkit Application inside a table:

+ + + + + +
The Calculator
+ +
+
+ + diff --git a/WebContent/embeddingiframe.html b/WebContent/embeddingiframe.html new file mode 100644 index 0000000000..026a6d75c2 --- /dev/null +++ b/WebContent/embeddingiframe.html @@ -0,0 +1,26 @@ + + + + Embedding in IFrame + + + +

This is a HTML page

+

Below are two IT Mill Toolkit applications embedded inside a table:

+ + + + + + + + + + +
The CalculatorThe Color Picker
+ + + +
+ + diff --git a/src/com/itmill/toolkit/tests/magi/ChatApplication.java b/src/com/itmill/toolkit/tests/magi/ChatApplication.java new file mode 100644 index 0000000000..ffb9a9d285 --- /dev/null +++ b/src/com/itmill/toolkit/tests/magi/ChatApplication.java @@ -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)); + } +} -- 2.39.5