diff options
author | Marc Englund <marc.englund@itmill.com> | 2007-11-12 08:50:36 +0000 |
---|---|---|
committer | Marc Englund <marc.englund@itmill.com> | 2007-11-12 08:50:36 +0000 |
commit | 0b1700e2d214af52753aefdc1a22dc4763cf17d9 (patch) | |
tree | 1d87226a80e2b44401022b59ef8427f08a0aa216 /src/com/itmill/toolkit/demo/NotificationDemo.java | |
parent | 25ea6babe7e1545968a7e3b182e4358af43ab93d (diff) | |
download | vaadin-framework-0b1700e2d214af52753aefdc1a22dc4763cf17d9.tar.gz vaadin-framework-0b1700e2d214af52753aefdc1a22dc4763cf17d9.zip |
Removed window.
Added comments.
svn changeset:2789/svn branch:trunk
Diffstat (limited to 'src/com/itmill/toolkit/demo/NotificationDemo.java')
-rw-r--r-- | src/com/itmill/toolkit/demo/NotificationDemo.java | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/src/com/itmill/toolkit/demo/NotificationDemo.java b/src/com/itmill/toolkit/demo/NotificationDemo.java index 0d9431f440..5820b09da0 100644 --- a/src/com/itmill/toolkit/demo/NotificationDemo.java +++ b/src/com/itmill/toolkit/demo/NotificationDemo.java @@ -18,8 +18,11 @@ import com.itmill.toolkit.ui.Button.ClickListener; */ public class NotificationDemo extends com.itmill.toolkit.Application { + // Dropdown select for notification type, using the native dropdown NativeSelect type; + // Textfield for the notification caption TextField caption; + // Textfield for the notification content TextField message; /** @@ -29,27 +32,20 @@ public class NotificationDemo extends com.itmill.toolkit.Application { */ public void init() { - /* - * - Create new window for the application - Give the window a visible - * title - Set the window to be the main window of the application - */ + // Create new window for the application and give the window a visible. Window main = new Window("Notification demo"); + // set as main window setMainWindow(main); - /* - * Create a 'inline' window within the main window, and set its size. - */ - Window conf = new Window("Show Notification"); - conf.setWidth(470); - conf.setHeight(360); - main.addWindow(conf); - - // Dropdown select for notification type. + // Create the 'type' dropdown select. type = new NativeSelect("Notification type"); - type.addContainerProperty("caption", String.class, null); + // no empty selection allowed type.setNullSelectionAllowed(false); + // we want a different caption than the value + type.addContainerProperty("caption", String.class, null); type.setItemCaptionMode(Select.ITEM_CAPTION_MODE_PROPERTY); type.setItemCaptionPropertyId("caption"); + // add some content (items) using the Container API Item i = type.addItem(new Integer( Window.Notification.TYPE_HUMANIZED_MESSAGE)); i.getItemProperty("caption").setValue("Humanized message"); @@ -60,27 +56,32 @@ public class NotificationDemo extends com.itmill.toolkit.Application { i = type .addItem(new Integer(Window.Notification.TYPE_TRAY_NOTIFICATION)); i.getItemProperty("caption").setValue("Tray notification"); + // set the initially selected item type.setValue(new Integer(Window.Notification.TYPE_HUMANIZED_MESSAGE)); - conf.addComponent(type); + main.addComponent(type); // add to layout // Notification caption caption = new TextField("Caption"); - caption.setValue("Brown Fox!"); caption.setColumns(20); - conf.addComponent(caption); + caption.setValue("Brown Fox!"); + main.addComponent(caption); + // Notification message message = new RichTextArea(); message.setCaption("Message"); message.setValue("A quick one jumped over the lazy dog."); - conf.addComponent(message); + main.addComponent(message); // add to layout + // Button to show the notification Button b = new Button("Show notification", new ClickListener() { + // this is an inline ClickListener public void buttonClick(ClickEvent event) { + // show the notification getMainWindow().showNotification((String) caption.getValue(), (String) message.getValue(), ((Integer) type.getValue()).intValue()); } }); - conf.addComponent(b); + main.addComponent(b); // add button to layout } } |