From: Marc Englund Date: Fri, 31 Oct 2008 14:53:03 +0000 (+0000) Subject: Sampler updates, Notification samples added. X-Git-Tag: 6.7.0.beta1~3885 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=82fb813839420dd7b239f312afeb5f63b1087ce9;p=vaadin-framework.git Sampler updates, Notification samples added. svn changeset:5791/svn branch:trunk --- diff --git a/src/com/itmill/toolkit/demo/sampler/SamplerApplication.java b/src/com/itmill/toolkit/demo/sampler/SamplerApplication.java index 33825ad6dc..f8b0014ffa 100644 --- a/src/com/itmill/toolkit/demo/sampler/SamplerApplication.java +++ b/src/com/itmill/toolkit/demo/sampler/SamplerApplication.java @@ -23,6 +23,11 @@ import com.itmill.toolkit.demo.sampler.features.buttons.ButtonSwitch; import com.itmill.toolkit.demo.sampler.features.link.LinkCurrentWindow; import com.itmill.toolkit.demo.sampler.features.link.LinkNoDecorations; import com.itmill.toolkit.demo.sampler.features.link.LinkSizedWindow; +import com.itmill.toolkit.demo.sampler.features.notifications.NotificationCustom; +import com.itmill.toolkit.demo.sampler.features.notifications.NotificationError; +import com.itmill.toolkit.demo.sampler.features.notifications.NotificationHumanized; +import com.itmill.toolkit.demo.sampler.features.notifications.NotificationTray; +import com.itmill.toolkit.demo.sampler.features.notifications.NotificationWarning; import com.itmill.toolkit.terminal.ClassResource; import com.itmill.toolkit.terminal.DownloadStream; import com.itmill.toolkit.terminal.ExternalResource; @@ -71,6 +76,14 @@ public class SamplerApplication extends Application { }), + new FeatureSet("Notifications", new Feature[] { + new NotificationHumanized(), // humanized + new NotificationWarning(), // warning + new NotificationTray(), // tray + new NotificationError(), // error + new NotificationCustom(), // error + }), + }), new FeatureSet("Unsorted", new Feature[] { @@ -556,21 +569,21 @@ public class SamplerApplication extends Application { if (f instanceof FeatureSet) { newRow(); Label title = new Label(f.getName()); - title.setWidth("100%"); - title - .setStyleName((c.isRoot(f) ? "section" - : "subsection")); - if (c.isRoot(f)) { - // newRow(); + title.setWidth("100%"); + title.setStyleName("section"); addComponent(title, 0, getCursorY(), getColumns() - 1, getCursorY()); } else { + title.setStyleName("subsection"); addComponent(title); } setComponentAlignment(title, ALIGNMENT_LEFT, ALIGNMENT_VERTICAL_CENTER); } else { + if (getCursorX() == 0) { + space(); + } Button b = new Button(); b.setStyleName(Button.STYLE_LINK); b.addStyleName("screenshot"); diff --git a/src/com/itmill/toolkit/demo/sampler/features/blueprints/ProminentPrimaryActionExample.java b/src/com/itmill/toolkit/demo/sampler/features/blueprints/ProminentPrimaryActionExample.java index 5266ca1e9b..cd8b5ea7c9 100644 --- a/src/com/itmill/toolkit/demo/sampler/features/blueprints/ProminentPrimaryActionExample.java +++ b/src/com/itmill/toolkit/demo/sampler/features/blueprints/ProminentPrimaryActionExample.java @@ -44,6 +44,6 @@ public class ProminentPrimaryActionExample extends OrderedLayout implements */ public void buttonClick(ClickEvent event) { getWindow().showNotification( - event.getButton().getCaption() + " clicked"); + "\"" + event.getButton().getCaption() + "\" clicked"); } } diff --git a/src/com/itmill/toolkit/demo/sampler/features/notifications/NotificationCustom.java b/src/com/itmill/toolkit/demo/sampler/features/notifications/NotificationCustom.java new file mode 100644 index 0000000000..f4d2afe3be --- /dev/null +++ b/src/com/itmill/toolkit/demo/sampler/features/notifications/NotificationCustom.java @@ -0,0 +1,42 @@ +package com.itmill.toolkit.demo.sampler.features.notifications; + +import com.itmill.toolkit.demo.sampler.APIResource; +import com.itmill.toolkit.demo.sampler.Feature; +import com.itmill.toolkit.demo.sampler.NamedExternalResource; +import com.itmill.toolkit.ui.Window; + +public class NotificationCustom extends Feature { + + @Override + public String getDescription() { + return "Notifications are lightweight informational messages," + + " used to inform the user of various events.
" + + "The notification can have a caption, a richtext" + + " description, and an icon. Position and delay can" + + " also be customized.
Not that more often than" + + " not, less is more: try to make the messages short" + + " and to the point."; + } + + @Override + public APIResource[] getRelatedAPI() { + return new APIResource[] { new APIResource(Window.class), + new APIResource(Window.Notification.class) }; + } + + @Override + public Class[] getRelatedFeatures() { + return new Class[] { NotificationHumanized.class, + NotificationWarning.class, NotificationError.class, + NotificationTray.class }; + } + + @Override + public NamedExternalResource[] getRelatedResources() { + return new NamedExternalResource[] { new NamedExternalResource( + "Monolog Boxes and Transparent Messages", + "http://humanized.com/weblog/2006/09/11/monolog_boxes_and_transparent_messages/") }; + + } + +} diff --git a/src/com/itmill/toolkit/demo/sampler/features/notifications/NotificationCustom.png b/src/com/itmill/toolkit/demo/sampler/features/notifications/NotificationCustom.png new file mode 100644 index 0000000000..c248516d5d Binary files /dev/null and b/src/com/itmill/toolkit/demo/sampler/features/notifications/NotificationCustom.png differ diff --git a/src/com/itmill/toolkit/demo/sampler/features/notifications/NotificationCustomExample.java b/src/com/itmill/toolkit/demo/sampler/features/notifications/NotificationCustomExample.java new file mode 100644 index 0000000000..78defa1f3d --- /dev/null +++ b/src/com/itmill/toolkit/demo/sampler/features/notifications/NotificationCustomExample.java @@ -0,0 +1,132 @@ +package com.itmill.toolkit.demo.sampler.features.notifications; + +import com.itmill.toolkit.data.Item; +import com.itmill.toolkit.data.Property; +import com.itmill.toolkit.ui.Button; +import com.itmill.toolkit.ui.NativeSelect; +import com.itmill.toolkit.ui.OrderedLayout; +import com.itmill.toolkit.ui.RichTextArea; +import com.itmill.toolkit.ui.Slider; +import com.itmill.toolkit.ui.TextField; +import com.itmill.toolkit.ui.Button.ClickEvent; +import com.itmill.toolkit.ui.Window.Notification; + +public class NotificationCustomExample extends OrderedLayout { + + private static final Object CAPTION_PROPERTY = new Object(); + + public NotificationCustomExample() { + setSpacing(true); + + final TextField caption = new TextField("Caption"); + caption + .setDescription("Main info; a short caption-only notification is often most effective."); + caption.setWidth("200px"); + addComponent(caption); + + final RichTextArea description = new RichTextArea(); + description.setCaption("Description"); + description.setWidth("400px"); + description + .setDescription("Additional information; try to keep it short."); + addComponent(description); + + OrderedLayout horiz = new OrderedLayout( + OrderedLayout.ORIENTATION_HORIZONTAL); + horiz.setSpacing(true); + addComponent(horiz); + + final NativeSelect position = new NativeSelect("Position"); + position.setNullSelectionAllowed(false); + horiz.addComponent(position); + initPositionItems(position); + + final NativeSelect style = new NativeSelect("Style"); + position.setNullSelectionAllowed(false); + horiz.addComponent(style); + initTypeItems(style); + + final Slider delay = new Slider("Delay (msec), -1 means click to hide"); + delay + .setDescription("Delay before fading
Pull all the way to the left to get -1, which means forever (click to hide)."); + delay.setWidth("400px"); + delay.setHeight("20px"); + delay.setMin(Notification.DELAY_FOREVER); + delay.setMax(10000); + addComponent(delay); + + // TODO icon select + + Button show = new Button("Show notification", + new Button.ClickListener() { + // "Inline" click listener; this is where the + // notification is actually created and shown. + public void buttonClick(ClickEvent event) { + // create Notification instance and customize + Notification n = new Notification((String) caption + .getValue(), (String) description.getValue(), + (Integer) style.getValue()); + n.setPosition((Integer) position.getValue()); + Double d = (Double) delay.getValue(); + n.setDelayMsec(d.intValue()); // sec->msec + getWindow().showNotification(n); + } + }); + addComponent(show); + setComponentAlignment(show, ALIGNMENT_RIGHT, ALIGNMENT_VERTICAL_CENTER); + + } + + /* + * Helper to fill the position select with the various possibilities + */ + private void initPositionItems(NativeSelect position) { + position.addContainerProperty(CAPTION_PROPERTY, String.class, null); + position.setItemCaptionPropertyId(CAPTION_PROPERTY); + Item i = position.addItem(Notification.POSITION_TOP_LEFT); + Property c = i.getItemProperty(CAPTION_PROPERTY); + c.setValue("Top left"); + i = position.addItem(Notification.POSITION_CENTERED_TOP); + c = i.getItemProperty(CAPTION_PROPERTY); + c.setValue("Top centered"); + i = position.addItem(Notification.POSITION_TOP_RIGHT); + c = i.getItemProperty(CAPTION_PROPERTY); + c.setValue("Top right"); + i = position.addItem(Notification.POSITION_CENTERED); + c = i.getItemProperty(CAPTION_PROPERTY); + c.setValue("Centered"); + i = position.addItem(Notification.POSITION_BOTTOM_LEFT); + c = i.getItemProperty(CAPTION_PROPERTY); + c.setValue("Bottom left"); + i = position.addItem(Notification.POSITION_CENTERED_BOTTOM); + c = i.getItemProperty(CAPTION_PROPERTY); + c.setValue("Bottom, centered"); + i = position.addItem(Notification.POSITION_BOTTOM_RIGHT); + c = i.getItemProperty(CAPTION_PROPERTY); + c.setValue("Bottom right"); + position.setValue(Notification.POSITION_CENTERED); + } + + /* + * Helper to fill the position select with the various possibilities + */ + private void initTypeItems(NativeSelect type) { + type.addContainerProperty(CAPTION_PROPERTY, String.class, null); + type.setItemCaptionPropertyId(CAPTION_PROPERTY); + Item i = type.addItem(Notification.TYPE_HUMANIZED_MESSAGE); + Property c = i.getItemProperty(CAPTION_PROPERTY); + c.setValue("Humanized"); + i = type.addItem(Notification.TYPE_WARNING_MESSAGE); + c = i.getItemProperty(CAPTION_PROPERTY); + c.setValue("Warning"); + i = type.addItem(Notification.TYPE_ERROR_MESSAGE); + c = i.getItemProperty(CAPTION_PROPERTY); + c.setValue("Error"); + i = type.addItem(Notification.TYPE_TRAY_NOTIFICATION); + c = i.getItemProperty(CAPTION_PROPERTY); + c.setValue("Tray"); + + type.setValue(Notification.TYPE_HUMANIZED_MESSAGE); + } + +} diff --git a/src/com/itmill/toolkit/demo/sampler/features/notifications/NotificationError.java b/src/com/itmill/toolkit/demo/sampler/features/notifications/NotificationError.java new file mode 100644 index 0000000000..d1de16f715 --- /dev/null +++ b/src/com/itmill/toolkit/demo/sampler/features/notifications/NotificationError.java @@ -0,0 +1,42 @@ +package com.itmill.toolkit.demo.sampler.features.notifications; + +import com.itmill.toolkit.demo.sampler.APIResource; +import com.itmill.toolkit.demo.sampler.Feature; +import com.itmill.toolkit.demo.sampler.NamedExternalResource; +import com.itmill.toolkit.ui.Window; + +public class NotificationError extends Feature { + + @Override + public String getDescription() { + return "Notifications are lightweight informational messages," + + " used to inform the user of various events. The" + + " Error variant is modal, and is to be used for" + + " messages that must be seen by the user.
" + + " The Error message must be closed by clicking" + + " the notification.
Candidates for an" + + " Error notification include 'Save failed'," + + " 'Permission denied', and other situations that the" + + " user must be made aware of.
It's a good idea to" + + " provide hints about what went wrong, and how the user'" + + " can proceed to correct the situation."; + } + + @Override + public APIResource[] getRelatedAPI() { + return new APIResource[] { new APIResource(Window.class), + new APIResource(Window.Notification.class) }; + } + + @Override + public Class[] getRelatedFeatures() { + return new Class[] { NotificationHumanized.class, + NotificationWarning.class, NotificationTray.class }; + } + + @Override + public NamedExternalResource[] getRelatedResources() { + return null; + } + +} diff --git a/src/com/itmill/toolkit/demo/sampler/features/notifications/NotificationError.png b/src/com/itmill/toolkit/demo/sampler/features/notifications/NotificationError.png new file mode 100644 index 0000000000..6c5e1d36c7 Binary files /dev/null and b/src/com/itmill/toolkit/demo/sampler/features/notifications/NotificationError.png differ diff --git a/src/com/itmill/toolkit/demo/sampler/features/notifications/NotificationErrorExample.java b/src/com/itmill/toolkit/demo/sampler/features/notifications/NotificationErrorExample.java new file mode 100644 index 0000000000..e8442e654e --- /dev/null +++ b/src/com/itmill/toolkit/demo/sampler/features/notifications/NotificationErrorExample.java @@ -0,0 +1,40 @@ +package com.itmill.toolkit.demo.sampler.features.notifications; + +import com.itmill.toolkit.ui.Button; +import com.itmill.toolkit.ui.OrderedLayout; +import com.itmill.toolkit.ui.TextField; +import com.itmill.toolkit.ui.Button.ClickEvent; +import com.itmill.toolkit.ui.Window.Notification; + +public class NotificationErrorExample extends OrderedLayout { + + public NotificationErrorExample() { + setSpacing(true); + + final TextField caption = new TextField("Caption", "Upload failed"); + caption.setWidth("200px"); + addComponent(caption); + + final TextField description = new TextField( + "Description", + "Invoices-2008.csv could not be read.
" + + "Perhaps the file is damaged, or in the wrong format?
" + + "Try re-exporting and uploading the file again."); + description.setWidth("300px"); + addComponent(description); + + Button show = new Button("Show notification", + new Button.ClickListener() { + public void buttonClick(ClickEvent event) { + getWindow().showNotification( + (String) caption.getValue(), + (String) description.getValue(), + Notification.TYPE_ERROR_MESSAGE); + + } + }); + addComponent(show); + setComponentAlignment(show, ALIGNMENT_RIGHT, ALIGNMENT_VERTICAL_CENTER); + + } +} diff --git a/src/com/itmill/toolkit/demo/sampler/features/notifications/NotificationHumanized.java b/src/com/itmill/toolkit/demo/sampler/features/notifications/NotificationHumanized.java new file mode 100644 index 0000000000..1ad401f385 --- /dev/null +++ b/src/com/itmill/toolkit/demo/sampler/features/notifications/NotificationHumanized.java @@ -0,0 +1,44 @@ +package com.itmill.toolkit.demo.sampler.features.notifications; + +import com.itmill.toolkit.demo.sampler.APIResource; +import com.itmill.toolkit.demo.sampler.Feature; +import com.itmill.toolkit.demo.sampler.NamedExternalResource; +import com.itmill.toolkit.ui.Window; + +public class NotificationHumanized extends Feature { + + @Override + public String getDescription() { + return "Notifications are lightweight informational messages," + + " used to inform the user of various events. The" + + " Humanized variant is an implementation of" + + " the transparent message -pattern, and is meant" + + " to indicate non-critical events while interrupting" + + " the user as little as possible.
" + + "The Humanized message quickly fades away once" + + " the user interacts with the application (e.g. moves" + + " mouse, types)
Candidates for a" + + " Humanized notification include 'XYZ saved'," + + " 'Added XYZ', and other messages that the user can" + + " safely ignore, once the application is familliar."; + } + + @Override + public APIResource[] getRelatedAPI() { + return new APIResource[] { new APIResource(Window.class), + new APIResource(Window.Notification.class) }; + } + + @Override + public Class[] getRelatedFeatures() { + return new Class[] { NotificationWarning.class }; + } + + @Override + public NamedExternalResource[] getRelatedResources() { + return new NamedExternalResource[] { new NamedExternalResource( + "Monolog Boxes and Transparent Messages", + "http://humanized.com/weblog/2006/09/11/monolog_boxes_and_transparent_messages/") }; + } + +} diff --git a/src/com/itmill/toolkit/demo/sampler/features/notifications/NotificationHumanized.png b/src/com/itmill/toolkit/demo/sampler/features/notifications/NotificationHumanized.png new file mode 100644 index 0000000000..5153749f7d Binary files /dev/null and b/src/com/itmill/toolkit/demo/sampler/features/notifications/NotificationHumanized.png differ diff --git a/src/com/itmill/toolkit/demo/sampler/features/notifications/NotificationHumanizedExample.java b/src/com/itmill/toolkit/demo/sampler/features/notifications/NotificationHumanizedExample.java new file mode 100644 index 0000000000..11e904391c --- /dev/null +++ b/src/com/itmill/toolkit/demo/sampler/features/notifications/NotificationHumanizedExample.java @@ -0,0 +1,35 @@ +package com.itmill.toolkit.demo.sampler.features.notifications; + +import com.itmill.toolkit.ui.Button; +import com.itmill.toolkit.ui.OrderedLayout; +import com.itmill.toolkit.ui.TextField; +import com.itmill.toolkit.ui.Button.ClickEvent; + +public class NotificationHumanizedExample extends OrderedLayout { + + public NotificationHumanizedExample() { + setSpacing(true); + + final TextField caption = new TextField("Caption", "Document saved"); + caption.setWidth("200px"); + addComponent(caption); + + final TextField description = new TextField("Description", + "Invoices-2008.csv"); + description.setWidth("300px"); + addComponent(description); + + Button show = new Button("Show notification", + new Button.ClickListener() { + public void buttonClick(ClickEvent event) { + getWindow().showNotification( + (String) caption.getValue(), + (String) description.getValue()); + + } + }); + addComponent(show); + setComponentAlignment(show, ALIGNMENT_RIGHT, ALIGNMENT_VERTICAL_CENTER); + + } +} diff --git a/src/com/itmill/toolkit/demo/sampler/features/notifications/NotificationTray.java b/src/com/itmill/toolkit/demo/sampler/features/notifications/NotificationTray.java new file mode 100644 index 0000000000..3227de211b --- /dev/null +++ b/src/com/itmill/toolkit/demo/sampler/features/notifications/NotificationTray.java @@ -0,0 +1,45 @@ +package com.itmill.toolkit.demo.sampler.features.notifications; + +import com.itmill.toolkit.demo.sampler.APIResource; +import com.itmill.toolkit.demo.sampler.Feature; +import com.itmill.toolkit.demo.sampler.NamedExternalResource; +import com.itmill.toolkit.ui.Window; + +public class NotificationTray extends Feature { + + @Override + public String getDescription() { + return "Notifications are lightweight informational messages," + + " used to inform the user of various events. The" + + " Tray variant shows up in the lower left corner," + + " and is meant to interrupt the user as little as possible" + + " even if it's shown for a while. " + + "The Tray message fades away after a few moments" + + " once the user interacts with the application (e.g. moves" + + " mouse, types)
Candidates for a" + + " Tray notification include 'New message received'," + + " 'Job XYZ completed' - generally notifications about events" + + " that have been delayed, or occur in the background" + + " (as opposed to being a direct result of the users last action.)"; + } + + @Override + public APIResource[] getRelatedAPI() { + return new APIResource[] { new APIResource(Window.class), + new APIResource(Window.Notification.class) }; + } + + @Override + public Class[] getRelatedFeatures() { + return new Class[] { NotificationHumanized.class, + NotificationWarning.class }; + } + + @Override + public NamedExternalResource[] getRelatedResources() { + return new NamedExternalResource[] { new NamedExternalResource( + "Monolog Boxes and Transparent Messages", + "http://humanized.com/weblog/2006/09/11/monolog_boxes_and_transparent_messages/") }; + } + +} diff --git a/src/com/itmill/toolkit/demo/sampler/features/notifications/NotificationTray.png b/src/com/itmill/toolkit/demo/sampler/features/notifications/NotificationTray.png new file mode 100644 index 0000000000..129d92b958 Binary files /dev/null and b/src/com/itmill/toolkit/demo/sampler/features/notifications/NotificationTray.png differ diff --git a/src/com/itmill/toolkit/demo/sampler/features/notifications/NotificationTrayExample.java b/src/com/itmill/toolkit/demo/sampler/features/notifications/NotificationTrayExample.java new file mode 100644 index 0000000000..a22feb5cc5 --- /dev/null +++ b/src/com/itmill/toolkit/demo/sampler/features/notifications/NotificationTrayExample.java @@ -0,0 +1,37 @@ +package com.itmill.toolkit.demo.sampler.features.notifications; + +import com.itmill.toolkit.ui.Button; +import com.itmill.toolkit.ui.OrderedLayout; +import com.itmill.toolkit.ui.TextField; +import com.itmill.toolkit.ui.Button.ClickEvent; +import com.itmill.toolkit.ui.Window.Notification; + +public class NotificationTrayExample extends OrderedLayout { + + public NotificationTrayExample() { + setSpacing(true); + + final TextField caption = new TextField("Caption", "New message"); + caption.setWidth("200px"); + addComponent(caption); + + final TextField description = new TextField("Description", + "John: Could you upload Invoices-2008.csv so that..."); + description.setWidth("300px"); + addComponent(description); + + Button show = new Button("Show notification", + new Button.ClickListener() { + public void buttonClick(ClickEvent event) { + getWindow().showNotification( + (String) caption.getValue(), + (String) description.getValue(), + Notification.TYPE_TRAY_NOTIFICATION); + + } + }); + addComponent(show); + setComponentAlignment(show, ALIGNMENT_RIGHT, ALIGNMENT_VERTICAL_CENTER); + + } +} diff --git a/src/com/itmill/toolkit/demo/sampler/features/notifications/NotificationWarning.java b/src/com/itmill/toolkit/demo/sampler/features/notifications/NotificationWarning.java new file mode 100644 index 0000000000..06b4240395 --- /dev/null +++ b/src/com/itmill/toolkit/demo/sampler/features/notifications/NotificationWarning.java @@ -0,0 +1,44 @@ +package com.itmill.toolkit.demo.sampler.features.notifications; + +import com.itmill.toolkit.demo.sampler.APIResource; +import com.itmill.toolkit.demo.sampler.Feature; +import com.itmill.toolkit.demo.sampler.NamedExternalResource; +import com.itmill.toolkit.ui.Window; + +public class NotificationWarning extends Feature { + + @Override + public String getDescription() { + return "Notifications are lightweight informational messages," + + " used to inform the user of various events. The" + + " Warning variant is an implementation of" + + " the transparent message -pattern, and is meant" + + " to interrupt the user as little as possible, while" + + " still drawing the needed attention." + + "The Warning message fades away after a few moments" + + " once the user interacts with the application (e.g. moves" + + " mouse, types)
Candidates for a" + + " Warning notification include 'You canceled XYZ'," + + " 'XYZ deleted', and other situations that the user should" + + " be made aware of, but are probably intentional."; + } + + @Override + public APIResource[] getRelatedAPI() { + return new APIResource[] { new APIResource(Window.class), + new APIResource(Window.Notification.class) }; + } + + @Override + public Class[] getRelatedFeatures() { + return new Class[] { NotificationHumanized.class }; + } + + @Override + public NamedExternalResource[] getRelatedResources() { + return new NamedExternalResource[] { new NamedExternalResource( + "Monolog Boxes and Transparent Messages", + "http://humanized.com/weblog/2006/09/11/monolog_boxes_and_transparent_messages/") }; + } + +} diff --git a/src/com/itmill/toolkit/demo/sampler/features/notifications/NotificationWarning.png b/src/com/itmill/toolkit/demo/sampler/features/notifications/NotificationWarning.png new file mode 100644 index 0000000000..16f55564a8 Binary files /dev/null and b/src/com/itmill/toolkit/demo/sampler/features/notifications/NotificationWarning.png differ diff --git a/src/com/itmill/toolkit/demo/sampler/features/notifications/NotificationWarningExample.java b/src/com/itmill/toolkit/demo/sampler/features/notifications/NotificationWarningExample.java new file mode 100644 index 0000000000..e5fd3f43d5 --- /dev/null +++ b/src/com/itmill/toolkit/demo/sampler/features/notifications/NotificationWarningExample.java @@ -0,0 +1,37 @@ +package com.itmill.toolkit.demo.sampler.features.notifications; + +import com.itmill.toolkit.ui.Button; +import com.itmill.toolkit.ui.OrderedLayout; +import com.itmill.toolkit.ui.TextField; +import com.itmill.toolkit.ui.Button.ClickEvent; +import com.itmill.toolkit.ui.Window.Notification; + +public class NotificationWarningExample extends OrderedLayout { + + public NotificationWarningExample() { + setSpacing(true); + + final TextField caption = new TextField("Caption", "Upload canceled"); + caption.setWidth("200px"); + addComponent(caption); + + final TextField description = new TextField("Description", + "Invoices-2008.csv will not be processed"); + description.setWidth("300px"); + addComponent(description); + + Button show = new Button("Show notification", + new Button.ClickListener() { + public void buttonClick(ClickEvent event) { + getWindow().showNotification( + (String) caption.getValue(), + (String) description.getValue(), + Notification.TYPE_WARNING_MESSAGE); + + } + }); + addComponent(show); + setComponentAlignment(show, ALIGNMENT_RIGHT, ALIGNMENT_VERTICAL_CENTER); + + } +}