From: Marc Englund Date: Fri, 30 Nov 2007 12:38:20 +0000 (+0000) Subject: Label example added X-Git-Tag: 6.7.0.beta1~5366 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=59f513cc239fa3cbe3459da70baa81584eb17206;p=vaadin-framework.git Label example added svn changeset:3068/svn branch:trunk --- diff --git a/src/com/itmill/toolkit/demo/featurebrowser/FeatureBrowser.java b/src/com/itmill/toolkit/demo/featurebrowser/FeatureBrowser.java index 62e023dd17..d8081ebce7 100644 --- a/src/com/itmill/toolkit/demo/featurebrowser/FeatureBrowser.java +++ b/src/com/itmill/toolkit/demo/featurebrowser/FeatureBrowser.java @@ -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 index 0000000000..25fb189437 --- /dev/null +++ b/src/com/itmill/toolkit/demo/featurebrowser/LabelsExample.java @@ -0,0 +1,76 @@ +package com.itmill.toolkit.demo.featurebrowser; + +import com.itmill.toolkit.ui.CustomComponent; +import com.itmill.toolkit.ui.GridLayout; +import com.itmill.toolkit.ui.Label; +import com.itmill.toolkit.ui.OrderedLayout; +import com.itmill.toolkit.ui.Panel; + +/** + * Shows a few variations of Labels, including the effects of XHTML- and + * pre-formatted mode. + * + * @author IT Mill Ltd. + */ +public class LabelsExample extends CustomComponent { + + private static final String xhtml = "This text has HTML formatting.
" + + "A plain Label will show the markup, while a XHTML-mode" + + " Label will show the formatted text."; + + private static final String pre = "This text has linebreaks.\n\n" + + "They will show up in a preformatted Label,\n" + + "but not in a \"plain\" Label.\n\n" + " Indented row. \n" + + " Same indentation."; + + public LabelsExample() { + + OrderedLayout main = new OrderedLayout(); + main.setMargin(true); + setCompositionRoot(main); + + GridLayout g = new GridLayout(2, 4); + main.addComponent(g); + + // plain w/o caption + Panel p = new Panel("Plain"); + p.setStyleName(Panel.STYLE_LIGHT); + Label l = new Label("A plain label without caption."); + p.addComponent(l); + g.addComponent(p); + // plain w/ caption + p = new Panel("Plain w/ caption"); + p.setStyleName(Panel.STYLE_LIGHT); + l = new Label("A plain label with caption."); + l.setCaption("Label caption"); + p.addComponent(l); + g.addComponent(p); + // plain w/ xhtml + p = new Panel("Plain w/ XHTML content"); + p.setStyleName(Panel.STYLE_LIGHT); + l = new Label(xhtml); + p.addComponent(l); + g.addComponent(p); + // xhtml w/ xhtml + p = new Panel("XHTML-mode w/ XHTML content"); + p.setStyleName(Panel.STYLE_LIGHT); + l = new Label(xhtml); + l.setContentMode(Label.CONTENT_XHTML); + p.addComponent(l); + g.addComponent(p); + // plain w/ preformatted + p = new Panel("Plain w/ preformatted content"); + p.setStyleName(Panel.STYLE_LIGHT); + l = new Label(pre); + p.addComponent(l); + g.addComponent(p); + // preformatted w/ preformatted + p = new Panel("Preformatted-mode w/ preformatted content"); + p.setStyleName(Panel.STYLE_LIGHT); + l = new Label(pre); + l.setContentMode(Label.CONTENT_PREFORMATTED); + p.addComponent(l); + g.addComponent(p); + + } +}