diff options
author | Marc Englund <marc.englund@itmill.com> | 2007-11-05 15:25:43 +0000 |
---|---|---|
committer | Marc Englund <marc.englund@itmill.com> | 2007-11-05 15:25:43 +0000 |
commit | bb05ac27ba751cfbf45fa89fe4770f2791961a84 (patch) | |
tree | 5e11a83a3f3b4a66052c7ea85861daa1d5681bce /src/com/itmill/toolkit/demo/NotificationDemo.java | |
parent | e3a17ca993c513f422fa8afa9a8097a99f0f34ac (diff) | |
download | vaadin-framework-bb05ac27ba751cfbf45fa89fe4770f2791961a84.tar.gz vaadin-framework-bb05ac27ba751cfbf45fa89fe4770f2791961a84.zip |
Notifications API.
+ small fix for richtextarea
svn changeset:2712/svn branch:trunk
Diffstat (limited to 'src/com/itmill/toolkit/demo/NotificationDemo.java')
-rw-r--r-- | src/com/itmill/toolkit/demo/NotificationDemo.java | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/src/com/itmill/toolkit/demo/NotificationDemo.java b/src/com/itmill/toolkit/demo/NotificationDemo.java new file mode 100644 index 0000000000..00cfd182dc --- /dev/null +++ b/src/com/itmill/toolkit/demo/NotificationDemo.java @@ -0,0 +1,82 @@ +package com.itmill.toolkit.demo; + +import com.itmill.toolkit.data.Item; +import com.itmill.toolkit.ui.Button; +import com.itmill.toolkit.ui.NativeSelect; +import com.itmill.toolkit.ui.RichTextArea; +import com.itmill.toolkit.ui.Select; +import com.itmill.toolkit.ui.TextField; +import com.itmill.toolkit.ui.Window; +import com.itmill.toolkit.ui.Button.ClickEvent; +import com.itmill.toolkit.ui.Button.ClickListener; + +/** + * Demonstrates the use of Notifications. + * + * @author IT Mill Ltd. + * @see com.itmill.toolkit.ui.Window + */ +public class NotificationDemo extends com.itmill.toolkit.Application { + + NativeSelect type; + TextField caption; + TextField message; + + /** + * The initialization method that is the only requirement for inheriting the + * com.itmill.toolkit.service.Application class. It will be automatically + * called by the framework when a user accesses the 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 + */ + Window main = new Window("Notification demo"); + setMainWindow(main); + + Window conf = new Window("Show Notification"); + conf.setWidth(450); + conf.setHeight(340); + main.addWindow(conf); + + type = new NativeSelect("Notification type"); + type.addContainerProperty("caption", String.class, null); + type.setNullSelectionAllowed(false); + type.setItemCaptionMode(Select.ITEM_CAPTION_MODE_PROPERTY); + type.setItemCaptionPropertyId("caption"); + Item i = type.addItem(new Integer( + Window.Notification.TYPE_HUMANIZED_MESSAGE)); + i.getItemProperty("caption").setValue("Humanized message"); + i = type.addItem(new Integer(Window.Notification.TYPE_WARNING_MESSAGE)); + i.getItemProperty("caption").setValue("Warning message"); + i = type.addItem(new Integer(Window.Notification.TYPE_ERROR_MESSAGE)); + i.getItemProperty("caption").setValue("Error message"); + i = type + .addItem(new Integer(Window.Notification.TYPE_TRAY_NOTIFICATION)); + i.getItemProperty("caption").setValue("Tray notification"); + type.setValue(new Integer(Window.Notification.TYPE_HUMANIZED_MESSAGE)); + conf.addComponent(type); + + caption = new TextField("Caption"); + caption.setValue("Saved!"); + caption.setColumns(20); + conf.addComponent(caption); + + message = new RichTextArea(); + message.setCaption("Message"); + message.setValue("Your stuff has been saved in <b>MyDocuments</b>."); + conf.addComponent(message); + + Button b = new Button("Show notification", new ClickListener() { + public void buttonClick(ClickEvent event) { + getMainWindow().showNotification((String) caption.getValue(), + (String) message.getValue(), + ((Integer) type.getValue()).intValue()); + } + + }); + conf.addComponent(b); + } +} |