]> source.dussan.org Git - vaadin-framework.git/commitdiff
Updated LabelsExample, added ButtonExample
authorMarc Englund <marc.englund@itmill.com>
Mon, 3 Dec 2007 13:26:46 +0000 (13:26 +0000)
committerMarc Englund <marc.englund@itmill.com>
Mon, 3 Dec 2007 13:26:46 +0000 (13:26 +0000)
svn changeset:3120/svn branch:trunk

src/com/itmill/toolkit/demo/featurebrowser/ButtonExample.java [new file with mode: 0644]
src/com/itmill/toolkit/demo/featurebrowser/FeatureBrowser.java
src/com/itmill/toolkit/demo/featurebrowser/LabelsExample.java

diff --git a/src/com/itmill/toolkit/demo/featurebrowser/ButtonExample.java b/src/com/itmill/toolkit/demo/featurebrowser/ButtonExample.java
new file mode 100644 (file)
index 0000000..2fdcb13
--- /dev/null
@@ -0,0 +1,143 @@
+package com.itmill.toolkit.demo.featurebrowser;\r
+\r
+import com.itmill.toolkit.terminal.ExternalResource;\r
+import com.itmill.toolkit.terminal.ThemeResource;\r
+import com.itmill.toolkit.ui.Button;\r
+import com.itmill.toolkit.ui.CheckBox;\r
+import com.itmill.toolkit.ui.CustomComponent;\r
+import com.itmill.toolkit.ui.Label;\r
+import com.itmill.toolkit.ui.Link;\r
+import com.itmill.toolkit.ui.OrderedLayout;\r
+import com.itmill.toolkit.ui.Panel;\r
+import com.itmill.toolkit.ui.Button.ClickEvent;\r
+\r
+/**\r
+ * Shows a few variations of Buttons and Links.\r
+ * \r
+ * @author IT Mill Ltd.\r
+ */\r
+public class ButtonExample extends CustomComponent implements\r
+        Button.ClickListener {\r
+\r
+    Panel status;\r
+\r
+    public ButtonExample() {\r
+\r
+        OrderedLayout main = new OrderedLayout();\r
+        main.setMargin(true);\r
+        setCompositionRoot(main);\r
+\r
+        OrderedLayout horiz = new OrderedLayout(\r
+                OrderedLayout.ORIENTATION_HORIZONTAL);\r
+        main.addComponent(horiz);\r
+        Panel basic = new Panel("Basic buttons");\r
+        basic.setStyleName(Panel.STYLE_LIGHT);\r
+        horiz.addComponent(basic);\r
+        Panel bells = new Panel("+ bells & whistles");\r
+        bells.setStyleName(Panel.STYLE_LIGHT);\r
+        horiz.addComponent(bells);\r
+        status = new Panel("Clicked");\r
+        status.setStyleName(Panel.STYLE_LIGHT);\r
+        horiz.addComponent(status);\r
+\r
+        Button b = new Button("Basic button");\r
+        b.addListener(this);\r
+        basic.addComponent(b);\r
+\r
+        b = new Button("Button w/ icon + tooltip");\r
+        b.addListener(this);\r
+        b.setIcon(new ThemeResource("icons/ok.png"));\r
+        b.setDescription("This button does nothing, fast");\r
+        bells.addComponent(b);\r
+\r
+        b = new CheckBox("CheckBox - a switch-button");\r
+        b.setImmediate(true); // checkboxes are not immediate by default\r
+        b.addListener(this);\r
+        basic.addComponent(b);\r
+\r
+        b = new CheckBox("CheckBox w/ icon + tooltip");\r
+        b.setImmediate(true); // checkboxes are not immediate by default\r
+        b.addListener(this);\r
+        b.setIcon(new ThemeResource("icons/ok.png"));\r
+        b.setDescription("This is a CheckBox");\r
+        bells.addComponent(b);\r
+\r
+        b = new Button("Link-style button");\r
+        b.addListener(this);\r
+        b.setStyleName(Button.STYLE_LINK);\r
+        basic.addComponent(b);\r
+\r
+        b = new Button("Link button w/ icon + tooltip");\r
+        b.addListener(this);\r
+        b.setStyleName(Button.STYLE_LINK);\r
+        b.setIcon(new ThemeResource("icons/ok.png"));\r
+        b.setDescription("Link-style, icon+tootip, no caption");\r
+        bells.addComponent(b);\r
+\r
+        b = new Button();\r
+        b.addListener(this);\r
+        b.setStyleName(Button.STYLE_LINK);\r
+        b.setIcon(new ThemeResource("icons/ok.png"));\r
+        b.setDescription("Link-style, icon+tootip, no caption");\r
+        basic.addComponent(b);\r
+\r
+        Panel links = new Panel("Links");\r
+        links.setStyleName(Panel.STYLE_LIGHT);\r
+        main.addComponent(links);\r
+        Label desc = new Label(\r
+                "The main difference between a Link and"\r
+                        + " a link-styled Button is that the Link works client-"\r
+                        + " side, whereas the Button works server side.<br/> This means"\r
+                        + " that the Button triggers some event on the server,"\r
+                        + " while the Link is a normal web-link. <br/><br/>Note that for"\r
+                        + " opening new windows, the Link might be a safer "\r
+                        + " choice, since popup-blockers might interfer with "\r
+                        + " server-initiated window opening.");\r
+        desc.setContentMode(Label.CONTENT_XHTML);\r
+        links.addComponent(desc);\r
+        Link l = new Link("IT Mill home", new ExternalResource(\r
+                "http://www.itmill.com"));\r
+        l.setDescription("Link without target name, opens in this window");\r
+        links.addComponent(l);\r
+\r
+        l = new Link("IT Mill home (new window)", new ExternalResource(\r
+                "http://www.itmill.com"));\r
+        l.setTargetName("_blank");\r
+        l.setDescription("Link with target name, opens in new window");\r
+        links.addComponent(l);\r
+\r
+        l = new Link("IT Mill home (new window, less decor)",\r
+                new ExternalResource("http://www.itmill.com"));\r
+        l.setTargetName("_blank");\r
+        l.setTargetBorder(Link.TARGET_BORDER_MINIMAL);\r
+        l.setTargetName("_blank");\r
+        l\r
+                .setDescription("Link with target name and BORDER_MINIMAL, opens in new window with less decor");\r
+        links.addComponent(l);\r
+\r
+        l = new Link("IT Mill home (new 200x200 window, no decor, icon)",\r
+                new ExternalResource("http://www.itmill.com"), "_blank", 200,\r
+                200, Link.TARGET_BORDER_NONE);\r
+        l.setTargetName("_blank");\r
+        l\r
+                .setDescription("Link with target name and BORDER_NONE, opens in new window with no decor");\r
+        l.setIcon(new ThemeResource("icons/ok.png"));\r
+        links.addComponent(l);\r
+\r
+    }\r
+\r
+    public void buttonClick(ClickEvent event) {\r
+        Button clicked = event.getButton();\r
+        String caption = clicked.getCaption();\r
+        if (caption == null) {\r
+            caption = "&lt;icon&gt;";\r
+        }\r
+        status.removeAllComponents();\r
+        Label l = new Label("Clicked: " + caption + "<br/>" + "Value: "\r
+                + clicked.getValue());\r
+        l.setContentMode(Label.CONTENT_XHTML);\r
+        status.addComponent(l);\r
+\r
+    }\r
+\r
+}\r
index fd254f73f01ba64c140086014b52ca9f1ba16a6a..220ac9960f47664c1786e8934ef599a7c3699e1b 100644 (file)
@@ -52,7 +52,7 @@ public class FeatureBrowser extends com.itmill.toolkit.Application implements
                     LabelsExample.class },
             // Getting started: Buttons
             { "Getting started", "Buttons and links",
-                    "Some variations of Buttons and Links", Button.class },
+                    "Some variations of Buttons and Links", ButtonExample.class },
             // Getting started: Fields
             { "Getting started", "User input",
                     "TextFields, DateFields, and such", Button.class },
index 04e335276789836dcb05dc29504abd460afea4d2..adb4b53bbccc99dc91d3c693344f13a0df63ea93 100644 (file)
@@ -39,10 +39,11 @@ public class LabelsExample extends CustomComponent {
         p.addComponent(l);\r
         g.addComponent(p);\r
         // plain w/ caption\r
-        p = new Panel("Plain w/ caption");\r
+        p = new Panel("Plain w/ caption + tooltip");\r
         p.setStyleName(Panel.STYLE_LIGHT);\r
         l = new Label("A plain label with caption.");\r
         l.setCaption("Label caption");\r
+        l.setDescription("This is a description (tooltip) for the label.");\r
         p.addComponent(l);\r
         g.addComponent(p);\r
         // plain w/ xhtml\r