]> source.dussan.org Git - vaadin-framework.git/commitdiff
Updated personal tests.
authorMarko Grönroos <magi@iki.fi>
Mon, 19 Nov 2007 18:10:32 +0000 (18:10 +0000)
committerMarko Grönroos <magi@iki.fi>
Mon, 19 Nov 2007 18:10:32 +0000 (18:10 +0000)
svn changeset:2867/svn branch:trunk

13 files changed:
src/com/itmill/toolkit/tests/magi/MagiTestApplication.java
src/com/itmill/toolkit/tests/magi/TabSheetExample.java [new file with mode: 0644]
src/com/itmill/toolkit/tests/magi/images/Earth_small.png [new file with mode: 0644]
src/com/itmill/toolkit/tests/magi/images/Earth_symbol.png [new file with mode: 0644]
src/com/itmill/toolkit/tests/magi/images/Jupiter_symbol.png [new file with mode: 0644]
src/com/itmill/toolkit/tests/magi/images/Mars_symbol.png [new file with mode: 0644]
src/com/itmill/toolkit/tests/magi/images/Mercury_small.png [new file with mode: 0644]
src/com/itmill/toolkit/tests/magi/images/Mercury_symbol.png [new file with mode: 0644]
src/com/itmill/toolkit/tests/magi/images/Neptune_symbol.png [new file with mode: 0644]
src/com/itmill/toolkit/tests/magi/images/Saturn_symbol.png [new file with mode: 0644]
src/com/itmill/toolkit/tests/magi/images/Uranus_symbol.png [new file with mode: 0644]
src/com/itmill/toolkit/tests/magi/images/Venus_small.png [new file with mode: 0644]
src/com/itmill/toolkit/tests/magi/images/Venus_symbol.png [new file with mode: 0644]

index 96cd0f76d3938b9d0846531384645c93c0dde585..2583005c8ab6e61b0177fa534219f1df29460a3d 100644 (file)
@@ -8,29 +8,8 @@ import com.itmill.toolkit.data.Validator;
 import com.itmill.toolkit.data.Property.ValueChangeEvent;
 import com.itmill.toolkit.data.Property.ValueChangeListener;
 import com.itmill.toolkit.data.validator.StringLengthValidator;
-import com.itmill.toolkit.terminal.ClassResource;
-import com.itmill.toolkit.terminal.DownloadStream;
-import com.itmill.toolkit.terminal.ExternalResource;
-import com.itmill.toolkit.terminal.StreamResource;
-import com.itmill.toolkit.terminal.UserError;
-import com.itmill.toolkit.ui.AbstractSelect;
-import com.itmill.toolkit.ui.Button;
-import com.itmill.toolkit.ui.CheckBox;
-import com.itmill.toolkit.ui.DateField;
-import com.itmill.toolkit.ui.Embedded;
-import com.itmill.toolkit.ui.ExpandLayout;
-import com.itmill.toolkit.ui.FormLayout;
-import com.itmill.toolkit.ui.GridLayout;
-import com.itmill.toolkit.ui.Label;
-import com.itmill.toolkit.ui.Link;
-import com.itmill.toolkit.ui.OrderedLayout;
-import com.itmill.toolkit.ui.Panel;
-import com.itmill.toolkit.ui.Select;
-import com.itmill.toolkit.ui.TabSheet;
-import com.itmill.toolkit.ui.Table;
-import com.itmill.toolkit.ui.TextField;
-import com.itmill.toolkit.ui.Tree;
-import com.itmill.toolkit.ui.Window;
+import com.itmill.toolkit.terminal.*;
+import com.itmill.toolkit.ui.*;
 
 public class MagiTestApplication extends com.itmill.toolkit.Application {
     Window main = new Window("Application window");
@@ -85,9 +64,9 @@ public class MagiTestApplication extends com.itmill.toolkit.Application {
                     "tree", "embedded", "textfield", "textfieldvalidation",
                     "datefield", "button", "select/select", "select/native",
                     "select/optiongroup", "select/twincol", "filterselect",
-                    "tabsheet", "validator", "table", "upload", "link",
+                    "validator", "table", "upload", "link",
                     "gridlayout", "orderedlayout", "formlayout", "panel",
-                    "expandlayout", "alignment", "alignment/grid", "window",
+                    "expandlayout", "tabsheet", "alignment", "alignment/grid", "window",
                     "window/opener", "window/multiple", "classresource" };
             for (int i = 0; i < examples.length; i++) {
                 main.addComponent(new Label("<a href='/tk/testbench2/"
@@ -97,57 +76,32 @@ public class MagiTestApplication extends com.itmill.toolkit.Application {
             return null;
         }
 
-        if (example.equals("defaultbutton")) {
-            example_defaultButton(main, param);
-        } else if (example.equals("label")) {
-            example_Label(main, param);
-        } else if (example.equals("labelcontent")) {
-            example_LabelContent(main, param);
-        } else if (example.equals("tree")) {
-            example_Tree(main, param);
-        } else if (example.equals("embedded")) {
-            example_Embedded(main, param);
-        } else if (example.equals("textfield")) {
-            example_TextField(main, param);
-        } else if (example.equals("textfieldvalidation")) {
-            example_TextFieldValidation(main, param);
-        } else if (example.equals("datefield")) {
-            example_DateField(main, param);
-        } else if (example.equals("button")) {
-            example_Button(main, param);
-        } else if (example.equals("checkbox")) {
-            example_CheckBox(main, param);
-        } else if (example.equals("select")) {
-            example_Select(main, param);
-        } else if (example.equals("filterselect")) {
-            example_FilterSelect(main, param);
-        } else if (example.equals("tabsheet")) {
-            example_TabSheet(main, param);
-        } else if (example.equals("validator")) {
-            example_Validator(main, param);
-        } else if (example.equals("table")) {
-            example_Table(main, param);
-        } else if (example.equals("upload")) {
-            example_Upload(main, param);
-        } else if (example.equals("link")) {
-            example_Link(main, param);
-        } else if (example.equals("gridlayout")) {
-            example_GridLayout(main, param);
-        } else if (example.equals("orderedlayout")) {
-            example_OrderedLayout(main, param);
-        } else if (example.equals("formlayout")) {
-            example_FormLayout(main, param);
-        } else if (example.equals("panel")) {
-            example_Panel(main, param);
-        } else if (example.equals("expandlayout")) {
-            example_ExpandLayout(main, param);
-        } else if (example.equals("alignment")) {
-            example_Alignment(main, param);
-        } else if (example.equals("window")) {
-            example_Window(main, param);
-        } else if (example.equals("classresource")) {
-            example_ClassResource(main, param);
-        } else {
+        if (example.equals("defaultbutton"))            example_defaultButton(main, param);
+        else if (example.equals("label"))               example_Label(main, param);
+        else if (example.equals("labelcontent"))        example_LabelContent(main, param);
+        else if (example.equals("tree"))                example_Tree(main, param);
+        else if (example.equals("embedded"))            example_Embedded(main, param);
+        else if (example.equals("textfield"))           example_TextField(main, param);
+        else if (example.equals("textfieldvalidation")) example_TextFieldValidation(main, param);
+        else if (example.equals("datefield"))           example_DateField(main, param);
+        else if (example.equals("button"))              example_Button(main, param);
+        else if (example.equals("checkbox"))            example_CheckBox(main, param);
+        else if (example.equals("select"))              example_Select(main, param);
+        else if (example.equals("filterselect"))        example_FilterSelect(main, param);
+        else if (example.equals("validator"))           example_Validator(main, param);
+        else if (example.equals("table"))               example_Table(main, param);
+        else if (example.equals("upload"))              example_Upload(main, param);
+        else if (example.equals("link"))                example_Link(main, param);
+        else if (example.equals("gridlayout"))          example_GridLayout(main, param);
+        else if (example.equals("orderedlayout"))       example_OrderedLayout(main, param);
+        else if (example.equals("formlayout"))          example_FormLayout(main, param);
+        else if (example.equals("tabsheet"))            example_TabSheet(main, param);
+        else if (example.equals("panel"))               example_Panel(main, param);
+        else if (example.equals("expandlayout"))        example_ExpandLayout(main, param);
+        else if (example.equals("alignment"))           example_Alignment(main, param);
+        else if (example.equals("window"))              example_Window(main, param);
+        else if (example.equals("classresource"))       example_ClassResource(main, param);
+        else {
             ; // main.addComponent(new Label("Unknown test '"+example+"'."));
         }
 
@@ -371,30 +325,6 @@ public class MagiTestApplication extends com.itmill.toolkit.Application {
         // date.setResolution(DateField.RESOLUTION_DAY);
     }
 
-    void example_TabSheet(Window main, String param) {
-        // main.addComponent(new TabSheetExample());
-
-        TabSheet tabsheet = new TabSheet();
-        /*
-         * tabsheet.addTab(new Label("Contents of the first tab"), "First Tab",
-         * null); tabsheet.addTab(new Label("Contents of the second tab"),
-         * "Second Tab", null); tabsheet.addTab(new Label("Contents of the third
-         * tab"), "Third Tab", null);
-         */
-
-        tabsheet.addTab(new Label("Contents of the first tab"), "First Tab",
-                new ClassResource("images/Mercury_small.png", main
-                        .getApplication()));
-        tabsheet.addTab(new Label("Contents of the second tab"), "Second Tab",
-                new ClassResource("images/Venus_small.png", main
-                        .getApplication()));
-        tabsheet.addTab(new Label("Contents of the third tab"), "Third tab",
-                new ClassResource("images/Earth_small.png", main
-                        .getApplication()));
-
-        main.addComponent(tabsheet);
-    }
-
     void example_Validator(Window main, String param) {
         main.addComponent(new SSNField());
     }
@@ -625,7 +555,29 @@ public class MagiTestApplication extends com.itmill.toolkit.Application {
         }
     }
 
-    void example_Embedded(Window main, String param) {
+    void example_TabSheet(Window main, String param) {
+        if (param.equals("icon")) {
+            TabSheet tabsheet = new TabSheet();
+        
+            tabsheet.addTab(new Label("Contents of the first tab"),
+                            "First Tab",
+                            new ClassResource ("images/Mercury_small.png", main.getApplication()));
+            tabsheet.addTab(new Label("Contents of the second tab"),
+                            "Second Tab",
+                            new ClassResource ("images/Venus_small.png", this));
+            tabsheet.addTab(new Label("Contents of the third tab"),
+                            "Third tab",
+                            new ClassResource ("images/Earth_small.png", this));
+        
+            main.addComponent(tabsheet);
+            //main.addComponent(new Embedded("Emb", new ClassResource ("images/Mercury_small.png", this)));
+        
+        } else {
+            main.addComponent(new TabSheetExample());
+        }
+    }
+
+   void example_Embedded(Window main, String param) {
         Embedded image = new Embedded("", new ClassResource("smiley.jpg", this));
         image.addStyleName("omaimage");
         main.addComponent(image);
diff --git a/src/com/itmill/toolkit/tests/magi/TabSheetExample.java b/src/com/itmill/toolkit/tests/magi/TabSheetExample.java
new file mode 100644 (file)
index 0000000..200b123
--- /dev/null
@@ -0,0 +1,53 @@
+package com.itmill.toolkit.tests.magi;
+import com.itmill.toolkit.ui.*;
+import com.itmill.toolkit.ui.Button.ClickEvent;
+import com.itmill.toolkit.ui.TabSheet.SelectedTabChangeEvent;
+
+public class TabSheetExample extends CustomComponent implements Button.ClickListener, TabSheet.SelectedTabChangeListener {
+       TabSheet tabsheet = new TabSheet();
+       Button tab1 = new Button("Push this button");
+       Label  tab2 = new Label("Contents of Second Tab");
+       Label  tab3 = new Label("Contents of Third Tab");
+       
+       TabSheetExample () {
+               setCompositionRoot (tabsheet);
+
+               /* Listen for changes in tab selection. */
+               tabsheet.addListener(this);
+
+               /* First tab contains a button, for which we listen button click events. */
+               tab1.addListener(this);
+               tabsheet.addTab(tab1, "First Tab", null);
+
+               /* A tab that is initially invisible. */
+               tab2.setVisible(false);
+               tabsheet.addTab(tab2, "Second Tab", null);
+               
+               /* A tab that is initially disabled. */
+               tab3.setEnabled(false);
+               tabsheet.addTab(tab3, "Third tab", null);
+       }
+
+       public void buttonClick(ClickEvent event) {
+               /* Enable the invisible and disabled tabs. */
+               tab2.setVisible(true);
+               tab3.setEnabled(true);
+               
+               /* Change selection automatically to second tab. */
+               tabsheet.setSelectedTab(tab2);
+       }
+
+       public void selectedTabChange(SelectedTabChangeEvent event) {
+               /* Cast to a TabSheet. This isn't really necessary in this example,
+                * as we have only one TabSheet component, but would be useful if
+                * there were multiple TabSheets. */
+               TabSheet source = (TabSheet) event.getSource();
+               if (source == tabsheet) {
+                       /* If the first tab was selected. */
+                       if (source.getSelectedTab() == tab1) {
+                               tab2.setVisible(false);
+                               tab3.setEnabled(false);
+                       }
+               }
+       }
+}
diff --git a/src/com/itmill/toolkit/tests/magi/images/Earth_small.png b/src/com/itmill/toolkit/tests/magi/images/Earth_small.png
new file mode 100644 (file)
index 0000000..abe9227
Binary files /dev/null and b/src/com/itmill/toolkit/tests/magi/images/Earth_small.png differ
diff --git a/src/com/itmill/toolkit/tests/magi/images/Earth_symbol.png b/src/com/itmill/toolkit/tests/magi/images/Earth_symbol.png
new file mode 100644 (file)
index 0000000..6060358
Binary files /dev/null and b/src/com/itmill/toolkit/tests/magi/images/Earth_symbol.png differ
diff --git a/src/com/itmill/toolkit/tests/magi/images/Jupiter_symbol.png b/src/com/itmill/toolkit/tests/magi/images/Jupiter_symbol.png
new file mode 100644 (file)
index 0000000..7a973be
Binary files /dev/null and b/src/com/itmill/toolkit/tests/magi/images/Jupiter_symbol.png differ
diff --git a/src/com/itmill/toolkit/tests/magi/images/Mars_symbol.png b/src/com/itmill/toolkit/tests/magi/images/Mars_symbol.png
new file mode 100644 (file)
index 0000000..7ab7616
Binary files /dev/null and b/src/com/itmill/toolkit/tests/magi/images/Mars_symbol.png differ
diff --git a/src/com/itmill/toolkit/tests/magi/images/Mercury_small.png b/src/com/itmill/toolkit/tests/magi/images/Mercury_small.png
new file mode 100644 (file)
index 0000000..ef69931
Binary files /dev/null and b/src/com/itmill/toolkit/tests/magi/images/Mercury_small.png differ
diff --git a/src/com/itmill/toolkit/tests/magi/images/Mercury_symbol.png b/src/com/itmill/toolkit/tests/magi/images/Mercury_symbol.png
new file mode 100644 (file)
index 0000000..97c09d1
Binary files /dev/null and b/src/com/itmill/toolkit/tests/magi/images/Mercury_symbol.png differ
diff --git a/src/com/itmill/toolkit/tests/magi/images/Neptune_symbol.png b/src/com/itmill/toolkit/tests/magi/images/Neptune_symbol.png
new file mode 100644 (file)
index 0000000..2b84811
Binary files /dev/null and b/src/com/itmill/toolkit/tests/magi/images/Neptune_symbol.png differ
diff --git a/src/com/itmill/toolkit/tests/magi/images/Saturn_symbol.png b/src/com/itmill/toolkit/tests/magi/images/Saturn_symbol.png
new file mode 100644 (file)
index 0000000..f4b7e5c
Binary files /dev/null and b/src/com/itmill/toolkit/tests/magi/images/Saturn_symbol.png differ
diff --git a/src/com/itmill/toolkit/tests/magi/images/Uranus_symbol.png b/src/com/itmill/toolkit/tests/magi/images/Uranus_symbol.png
new file mode 100644 (file)
index 0000000..74f755f
Binary files /dev/null and b/src/com/itmill/toolkit/tests/magi/images/Uranus_symbol.png differ
diff --git a/src/com/itmill/toolkit/tests/magi/images/Venus_small.png b/src/com/itmill/toolkit/tests/magi/images/Venus_small.png
new file mode 100644 (file)
index 0000000..7bcac3f
Binary files /dev/null and b/src/com/itmill/toolkit/tests/magi/images/Venus_small.png differ
diff --git a/src/com/itmill/toolkit/tests/magi/images/Venus_symbol.png b/src/com/itmill/toolkit/tests/magi/images/Venus_symbol.png
new file mode 100644 (file)
index 0000000..6d08313
Binary files /dev/null and b/src/com/itmill/toolkit/tests/magi/images/Venus_symbol.png differ