diff options
author | Jani Laakso <jani.laakso@itmill.com> | 2008-04-07 15:38:15 +0000 |
---|---|---|
committer | Jani Laakso <jani.laakso@itmill.com> | 2008-04-07 15:38:15 +0000 |
commit | f51577b7567821f8bb13ecaa60eb101f708e6147 (patch) | |
tree | 10cef62ed79d94aba6e83d76f0b753f1f3cc1410 /src/com/itmill/toolkit/automatedtests/featurebrowser/NotificationExample.java | |
parent | 638fe9899be27b8f4f92dc4750f813c1210ecb1f (diff) | |
download | vaadin-framework-f51577b7567821f8bb13ecaa60eb101f708e6147.tar.gz vaadin-framework-f51577b7567821f8bb13ecaa60eb101f708e6147.zip |
Created com.itmill.toolkit.automatedtests package which contains "official" automated tests
* do not touch them unless you change automated test client's testcase scripts too.
* copy your testing application to package com.itmill.toolkit.automatedtests
* do not point to "development / testing / production" packages which are edited in the future without relation to testing
* use setDebugId's for all components that are used in testing
Moved few classes from "experimental" com.itmill.toolkit.tests package into "official" side.
Copied featurebrowser to automatedtests package and added setDebugId's for most components that are used in the testing.
svn changeset:4138/svn branch:trunk
Diffstat (limited to 'src/com/itmill/toolkit/automatedtests/featurebrowser/NotificationExample.java')
-rw-r--r-- | src/com/itmill/toolkit/automatedtests/featurebrowser/NotificationExample.java | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/src/com/itmill/toolkit/automatedtests/featurebrowser/NotificationExample.java b/src/com/itmill/toolkit/automatedtests/featurebrowser/NotificationExample.java new file mode 100644 index 0000000000..f6518c13e9 --- /dev/null +++ b/src/com/itmill/toolkit/automatedtests/featurebrowser/NotificationExample.java @@ -0,0 +1,96 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + +package com.itmill.toolkit.automatedtests.featurebrowser; + +import java.util.Date; + +import com.itmill.toolkit.data.Item; +import com.itmill.toolkit.ui.AbstractSelect; +import com.itmill.toolkit.ui.Button; +import com.itmill.toolkit.ui.CustomComponent; +import com.itmill.toolkit.ui.NativeSelect; +import com.itmill.toolkit.ui.OrderedLayout; +import com.itmill.toolkit.ui.RichTextArea; +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 NotificationExample extends CustomComponent { + + // 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; + + /** + * Default constructor; We're subclassing CustomComponent, so we need to + * choose a root component and set it as composition root. + */ + public NotificationExample() { + // Main layout + final OrderedLayout main = new OrderedLayout(); + main.setMargin(true); // use theme-specific margin + setCompositionRoot(main); + + // Create the 'type' dropdown select. + type = new NativeSelect("Notification type"); + main.addComponent(type); + // no empty selection allowed + type.setNullSelectionAllowed(false); + // we want a different caption than the value + type.addContainerProperty("caption", String.class, null); + type.setItemCaptionMode(AbstractSelect.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"); + 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"); + // set the initially selected item + type.setValue(new Integer(Window.Notification.TYPE_HUMANIZED_MESSAGE)); + + // Notification caption + caption = new TextField("Caption"); + main.addComponent(caption); + caption.setColumns(20); + caption.setValue("Brown Fox!"); + + // Notification message + message = new RichTextArea(); + main.addComponent(message); + message.setCaption("Message"); + message.setValue("A quick one jumped over the lazy dog."); + + // Button to show the notification + final Button b = new Button("Show notification", new ClickListener() { + // this is an inline ClickListener + public void buttonClick(ClickEvent event) { + // show the notification + getWindow().showNotification((String) caption.getValue(), + (String) message.getValue(), + ((Integer) type.getValue()).intValue()); + getWindow().setCaption(new Date().toString()); + } + }); + main.addComponent(b); + main.setComponentAlignment(b, OrderedLayout.ALIGNMENT_RIGHT, + OrderedLayout.ALIGNMENT_VERTICAL_CENTER); + } +} |