]> source.dussan.org Git - vaadin-framework.git/commitdiff
Label example added
authorMarc Englund <marc.englund@itmill.com>
Fri, 30 Nov 2007 12:38:20 +0000 (12:38 +0000)
committerMarc Englund <marc.englund@itmill.com>
Fri, 30 Nov 2007 12:38:20 +0000 (12:38 +0000)
svn changeset:3068/svn branch:trunk

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

index 62e023dd175d5898b9c810e684d2f9fa9ec4634a..d8081ebce7895b374bebcab1c05c3198cf541c64 100644 (file)
@@ -45,30 +45,33 @@ public class FeatureBrowser extends com.itmill.toolkit.Application implements
 
     private static final Object[][] demos = new Object[][] {
     // Category, Name, Desc, Class, Viewed
-            // Basic: Labels
-            { "Basic", "Labels", "Some variations of Labels", Button.class,
-                    Boolean.FALSE },
-            // Basic: Buttons
-            { "Basic", "Buttons and links",
+            // Getting started: Labels
+            { "Getting started", "Labels", "Some variations of Labels",
+                    LabelsExample.class, Boolean.FALSE },
+            // Getting started: Buttons
+            { "Getting started", "Buttons and links",
                     "Some variations of Buttons and Links", Button.class,
                     Boolean.FALSE },
-            // Basic: Fields
-            { "Basic", "User input", "TextFields, DateFields, and such",
-                    Button.class, Boolean.FALSE },
+            // Getting started: Fields
+            { "Getting started", "User input",
+                    "TextFields, DateFields, and such", Button.class,
+                    Boolean.FALSE },
             //
-            { "Basic", "RichText", "Rich text editing", RichTextExample.class,
+            { "Getting started", "RichText", "Rich text editing",
+                    RichTextExample.class, Boolean.FALSE },
+            // Getting started: Selects
+            { "Getting started", "Choices, choices",
+                    "Some variations of simple selects", Button.class,
                     Boolean.FALSE },
-            // Basic: Selects
-            { "Basic", "Choices, choices", "Some variations of simple selects",
-                    Button.class, Boolean.FALSE },
-            // Organizing: ComboBox
-            { "Organizing", "ComboBox", "ComboBox - the swiss army select",
+            // Wrangling data: ComboBox
+            { "Wrangling data", "ComboBox", "ComboBox - the swiss army select",
                     ComboBoxExample.class, Boolean.FALSE },
-            // Organizing: Table
-            { "Organizing", "Table", "A dynamic Table with bells and whistles",
-                    Button.class, Boolean.FALSE },
-            // Organizing: Tree
-            { "Organizing", "Tree", "Some variations of Buttons and Links",
+            // Wrangling data: Table
+            { "Wrangling data", "Table",
+                    "A dynamic Table with bells and whistles", Button.class,
+                    Boolean.FALSE },
+            // Wrangling data: Tree
+            { "Wrangling data", "Tree", "Some variations of Buttons and Links",
                     TreeExample.class, Boolean.FALSE },
             // Misc: Notifications
             { "Misc", "Notifications", "Notifications can improve usability",
diff --git a/src/com/itmill/toolkit/demo/featurebrowser/LabelsExample.java b/src/com/itmill/toolkit/demo/featurebrowser/LabelsExample.java
new file mode 100644 (file)
index 0000000..25fb189
--- /dev/null
@@ -0,0 +1,76 @@
+package com.itmill.toolkit.demo.featurebrowser;\r
+\r
+import com.itmill.toolkit.ui.CustomComponent;\r
+import com.itmill.toolkit.ui.GridLayout;\r
+import com.itmill.toolkit.ui.Label;\r
+import com.itmill.toolkit.ui.OrderedLayout;\r
+import com.itmill.toolkit.ui.Panel;\r
+\r
+/**\r
+ * Shows a few variations of Labels, including the effects of XHTML- and\r
+ * pre-formatted mode.\r
+ * \r
+ * @author IT Mill Ltd.\r
+ */\r
+public class LabelsExample extends CustomComponent {\r
+\r
+    private static final String xhtml = "This text has <b>HTML</b> formatting.<br/>"\r
+            + "A plain <i>Label</i> will show the markup, while a <u>XHTML-mode</u>"\r
+            + " <i>Label</i> will show the formatted text.";\r
+\r
+    private static final String pre = "This text has linebreaks.\n\n"\r
+            + "They will show up in a preformatted Label,\n"\r
+            + "but not in a \"plain\" Label.\n\n" + "       Indented row. \n"\r
+            + "       Same indentation.";\r
+\r
+    public LabelsExample() {\r
+\r
+        OrderedLayout main = new OrderedLayout();\r
+        main.setMargin(true);\r
+        setCompositionRoot(main);\r
+\r
+        GridLayout g = new GridLayout(2, 4);\r
+        main.addComponent(g);\r
+\r
+        // plain w/o caption\r
+        Panel p = new Panel("Plain");\r
+        p.setStyleName(Panel.STYLE_LIGHT);\r
+        Label l = new Label("A plain label without caption.");\r
+        p.addComponent(l);\r
+        g.addComponent(p);\r
+        // plain w/ caption\r
+        p = new Panel("Plain w/ caption");\r
+        p.setStyleName(Panel.STYLE_LIGHT);\r
+        l = new Label("A plain label with caption.");\r
+        l.setCaption("Label caption");\r
+        p.addComponent(l);\r
+        g.addComponent(p);\r
+        // plain w/ xhtml\r
+        p = new Panel("Plain w/ XHTML content");\r
+        p.setStyleName(Panel.STYLE_LIGHT);\r
+        l = new Label(xhtml);\r
+        p.addComponent(l);\r
+        g.addComponent(p);\r
+        // xhtml w/ xhtml\r
+        p = new Panel("XHTML-mode w/ XHTML content");\r
+        p.setStyleName(Panel.STYLE_LIGHT);\r
+        l = new Label(xhtml);\r
+        l.setContentMode(Label.CONTENT_XHTML);\r
+        p.addComponent(l);\r
+        g.addComponent(p);\r
+        // plain w/ preformatted\r
+        p = new Panel("Plain w/ preformatted content");\r
+        p.setStyleName(Panel.STYLE_LIGHT);\r
+        l = new Label(pre);\r
+        p.addComponent(l);\r
+        g.addComponent(p);\r
+        // preformatted w/ preformatted\r
+        p = new Panel("Preformatted-mode w/ preformatted content");\r
+        p.setStyleName(Panel.STYLE_LIGHT);\r
+        l = new Label(pre);\r
+        l.setContentMode(Label.CONTENT_PREFORMATTED);\r
+        p.addComponent(l);\r
+        g.addComponent(p);\r
+\r
+    }\r
+}\r