diff options
Diffstat (limited to 'src')
22 files changed, 187 insertions, 87 deletions
diff --git a/src/com/itmill/toolkit/demo/sampler/FeatureView.java b/src/com/itmill/toolkit/demo/sampler/FeatureView.java index fba906d70b..433d1d5510 100644 --- a/src/com/itmill/toolkit/demo/sampler/FeatureView.java +++ b/src/com/itmill/toolkit/demo/sampler/FeatureView.java @@ -17,8 +17,8 @@ import com.itmill.toolkit.ui.Button.ClickEvent; public class FeatureView extends HorizontalLayout { - private static final String MSG_SHOW_SRC = "⊞ Show Java™ source"; - private static final String MSG_HIDE_SRC = "⊟ Hide Java™ source"; + private static final String MSG_SHOW_SRC = "Show Java™ source »"; + private static final String MSG_HIDE_SRC = "Hide Java™ source"; private Panel right; private Panel left; @@ -51,10 +51,11 @@ public class FeatureView extends HorizontalLayout { right.setWidth("350px"); right.setHeight("100%"); addComponent(right); + right.getLayout().setMargin(false, true, true, true); controls = new VerticalLayout(); controls.setStyleName("feature-controls"); - controls.setCaption("Live example"); + // controls.setCaption("Live example"); showCode = new Button(MSG_SHOW_SRC, new Button.ClickListener() { public void buttonClick(ClickEvent event) { toggleSource(); @@ -95,10 +96,11 @@ public class FeatureView extends HorizontalLayout { showSource(false); left.addComponent(controls); + controls.setCaption(feature.getName()); left.addComponent(getExampleFor(feature)); - right.setCaption(feature.getName()); + right.setCaption("Description"); Label l = new Label(feature.getDescription()); l.setContentMode(Label.CONTENT_XHTML); diff --git a/src/com/itmill/toolkit/demo/sampler/SamplerApplication.java b/src/com/itmill/toolkit/demo/sampler/SamplerApplication.java index b2102c1741..4365533527 100644 --- a/src/com/itmill/toolkit/demo/sampler/SamplerApplication.java +++ b/src/com/itmill/toolkit/demo/sampler/SamplerApplication.java @@ -36,6 +36,7 @@ import com.itmill.toolkit.ui.VerticalLayout; import com.itmill.toolkit.ui.Window; import com.itmill.toolkit.ui.Button.ClickEvent; import com.itmill.toolkit.ui.Button.ClickListener; +import com.itmill.toolkit.ui.PopupView.PopupVisibilityEvent; import com.itmill.toolkit.ui.UriFragmentUtility.FragmentChangedEvent; import com.itmill.toolkit.ui.UriFragmentUtility.FragmentChangedListener; @@ -149,6 +150,9 @@ public class SamplerApplication extends Application { // breadcrumbs BreadCrumbs breadcrumbs = new BreadCrumbs(); + Button previousSample; + Button nextSample; + SamplerWindow() { // Main top/expanded-bottom layout VerticalLayout mainExpand = new VerticalLayout(); @@ -187,21 +191,20 @@ public class SamplerApplication extends Application { } }); + // Previous sample + previousSample = createPrevButton(); + nav.addComponent(previousSample); + nav.setComponentAlignment(previousSample, Alignment.MIDDLE_RIGHT); + // Next sample + nextSample = createNextButton(); + nav.addComponent(nextSample); + nav.setComponentAlignment(nextSample, Alignment.MIDDLE_LEFT); // "Search" combobox // TODO add input prompt Component search = createSearch(); nav.addComponent(search); nav.setComponentAlignment(search, Alignment.MIDDLE_LEFT); - // Previous sample - Button b = createPrevButton(); - nav.addComponent(b); - nav.setComponentAlignment(b, Alignment.MIDDLE_RIGHT); - // Next sample - b = createNextButton(); - nav.addComponent(b); - nav.setComponentAlignment(b, Alignment.MIDDLE_LEFT); - // togglebar // mainExpand.addComponent(toggleBar); toggleBar.setHeight("40px"); @@ -230,17 +233,17 @@ public class SamplerApplication extends Application { rightLayout.addComponent(mainArea); rightLayout.setExpandRatio(mainArea, 1); - // Show / hide tree - Component treeSwitch = createTreeSwitch(); - toggleBar.addComponent(treeSwitch); - toggleBar.setExpandRatio(treeSwitch, 1); - toggleBar.setComponentAlignment(treeSwitch, Alignment.MIDDLE_RIGHT); - // List/grid/coverflow Component mode = createModeSwitch(); toggleBar.addComponent(mode); toggleBar.setComponentAlignment(mode, Alignment.MIDDLE_RIGHT); + // Show / hide tree + Component treeSwitch = createTreeSwitch(); + nav.addComponent(treeSwitch); + // toggleBar.setExpandRatio(treeSwitch, 1); + nav.setComponentAlignment(treeSwitch, Alignment.MIDDLE_RIGHT); + addListener(new CloseListener() { public void windowClose(CloseEvent e) { if (getMainWindow() != SamplerWindow.this) { @@ -263,6 +266,10 @@ public class SamplerApplication extends Application { webAnalytics.trackPageview(path); uriFragmentUtility.setFragment(path, false); breadcrumbs.setPath(path); + + previousSample.setEnabled(f != null); + nextSample.setEnabled(!allFeatures.isLastId(f)); + updateFeatureList(currentList); } @@ -283,13 +290,21 @@ public class SamplerApplication extends Application { */ private Component createSearch() { - ComboBox search = new ComboBox(); + final ComboBox search = new ComboBox(); search.setWidth("160px"); search.setNewItemsAllowed(false); search.setFilteringMode(ComboBox.FILTERINGMODE_CONTAINS); search.setNullSelectionAllowed(true); search.setImmediate(true); search.setContainerDataSource(allFeatures); + for (Iterator it = allFeatures.getItemIds().iterator(); it + .hasNext();) { + Object id = it.next(); + if (id instanceof FeatureSet) { + search.setItemIcon(id, new ClassResource("folder.gif", + SamplerApplication.this)); + } + } search.addListener(new ComboBox.ValueChangeListener() { public void valueChange(ValueChangeEvent event) { Feature f = (Feature) event.getProperty().getValue(); @@ -301,8 +316,20 @@ public class SamplerApplication extends Application { } }); // TODO add icons for section/sample - + /* + * PopupView pv = new PopupView("", search) { public void + * changeVariables(Object source, Map variables) { + * super.changeVariables(source, variables); if (isPopupVisible()) { + * search.focus(); } } }; + */ PopupView pv = new PopupView("", search); + pv.addListener(new PopupView.PopupVisibilityListener() { + public void popupVisibilityChange(PopupVisibilityEvent event) { + if (event.isPopupVisible()) { + search.focus(); + } + } + }); pv.setWidth("22px"); pv.setHeight("22px"); pv.setStyleName("quickjump"); @@ -332,7 +359,12 @@ public class SamplerApplication extends Application { while (next != null && next instanceof FeatureSet) { next = allFeatures.nextItemId(next); } - currentFeature.setValue(next); + if (next != null) { + currentFeature.setValue(next); + } else { + // could potentially occur if there is an empty section + showNotification("Last sample"); + } } }); b.setWidth("22px"); @@ -354,6 +386,7 @@ public class SamplerApplication extends Application { currentFeature.setValue(prev); } }); + b.setEnabled(false); b.setWidth("22px"); b.setHeight("22px"); b.setIcon(new ThemeResource("sampler/prev.png")); @@ -471,7 +504,7 @@ public class SamplerApplication extends Application { public void show(Component c) { if (getCompositionRoot() != c) { - c.setSizeFull(); + // c.setSizeFull(); setCompositionRoot(c); } } @@ -508,7 +541,7 @@ public class SamplerApplication extends Application { current += (i > 0 ? "/" : "") + parts[i]; Feature f = FeatureSet.FEATURES.getFeatureByPath(current); link = new ActiveLink(f.getName(), new ExternalResource("#" - + f.getPathName())); + + getPathFor(f))); link.setData(f); link.addListener(this); layout.addComponent(link); @@ -634,12 +667,12 @@ public class SamplerApplication extends Application { private class FeatureGrid extends Panel implements FeatureList { - GridLayout grid = new GridLayout(5, 1); + GridLayout grid = new GridLayout(11, 1); FeatureGrid() { setSizeFull(); - getLayout().setWidth("100%"); - grid.setWidth("100%"); + getLayout().setSizeUndefined(); + // grid.setWidth("100%"); grid.setSpacing(true); addComponent(grid); setStyleName(Panel.STYLE_LIGHT); @@ -677,10 +710,10 @@ public class SamplerApplication extends Application { Button b = new Button(); b.setStyleName(Button.STYLE_LINK); b.addStyleName("screenshot"); - b.setIcon(new ClassResource(f.getClass(), f.getIconName(), - SamplerApplication.this)); - b.setWidth("120px"); - b.setHeight("120px"); + b.setIcon(new ClassResource(f.getClass(), "75-" + + f.getIconName(), SamplerApplication.this)); + b.setWidth("75px"); + b.setHeight("75px"); b.setDescription("<h3>" + f.getName() + "</h3>" + f.getDescription()); b.addListener(new Button.ClickListener() { diff --git a/src/com/itmill/toolkit/demo/sampler/features/buttons/ButtonLink.java b/src/com/itmill/toolkit/demo/sampler/features/buttons/ButtonLink.java index 94fb0933ae..996ea8d66c 100644 --- a/src/com/itmill/toolkit/demo/sampler/features/buttons/ButtonLink.java +++ b/src/com/itmill/toolkit/demo/sampler/features/buttons/ButtonLink.java @@ -14,7 +14,8 @@ public class ButtonLink extends Feature { @Override public String getDescription() { - return "A link-styled button."; + return "A link-styled button; works like a Button but looks like a Link.<br/>" + + "I.e it does not actually link somewhere, but triggers a server-side event, just like a regular button."; } @Override diff --git a/src/com/itmill/toolkit/demo/sampler/features/buttons/ButtonSwitch.java b/src/com/itmill/toolkit/demo/sampler/features/buttons/ButtonSwitch.java index f3bf7d52fc..585a218f56 100644 --- a/src/com/itmill/toolkit/demo/sampler/features/buttons/ButtonSwitch.java +++ b/src/com/itmill/toolkit/demo/sampler/features/buttons/ButtonSwitch.java @@ -3,14 +3,13 @@ package com.itmill.toolkit.demo.sampler.features.buttons; 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.demo.sampler.features.blueprints.ProminentPrimaryAction; import com.itmill.toolkit.ui.Button; public class ButtonSwitch extends Feature { @Override public String getDescription() { - return "A switch button."; + return "A switch button works like a regular button, triggering a server-side event, but it's state is 'sticky' - it toggles on or off, instead of popping right back out.<br/>Also know as a CheckBox."; } @Override @@ -20,8 +19,7 @@ public class ButtonSwitch extends Feature { @Override public Class[] getRelatedFeatures() { - return new Class[] { ButtonPush.class, ButtonLink.class, - ProminentPrimaryAction.class }; + return new Class[] { ButtonPush.class, ButtonLink.class }; } @Override diff --git a/src/com/itmill/toolkit/demo/sampler/features/commons/ErrorsExample.java b/src/com/itmill/toolkit/demo/sampler/features/commons/ErrorsExample.java index f402fa699b..8b1da6415d 100644 --- a/src/com/itmill/toolkit/demo/sampler/features/commons/ErrorsExample.java +++ b/src/com/itmill/toolkit/demo/sampler/features/commons/ErrorsExample.java @@ -11,7 +11,7 @@ public class ErrorsExample extends VerticalLayout { setSpacing(true); Panel panel = new Panel("Configure this"); - panel.setComponentError(new UserError("This panel contains errors")); + panel.setComponentError(new UserError("'Input' contains an error")); addComponent(panel); TextField input = new TextField("Input"); diff --git a/src/com/itmill/toolkit/demo/sampler/features/link/LinkCurrentWindow.java b/src/com/itmill/toolkit/demo/sampler/features/link/LinkCurrentWindow.java index 0e183780a6..7c10562a74 100644 --- a/src/com/itmill/toolkit/demo/sampler/features/link/LinkCurrentWindow.java +++ b/src/com/itmill/toolkit/demo/sampler/features/link/LinkCurrentWindow.java @@ -10,7 +10,10 @@ public class LinkCurrentWindow extends Feature { @Override public String getDescription() { - return "An external link."; + return "An external link - this is the basic HTML-style link, changing" + + " the url of the browser w/o triggering a server-side event" + + " (like the link-styled Button).<br/> By default, links open" + + " in the current browser window."; } @Override diff --git a/src/com/itmill/toolkit/demo/sampler/features/link/LinkNoDecorations.java b/src/com/itmill/toolkit/demo/sampler/features/link/LinkNoDecorations.java index ce1917615d..ae2ee5b000 100644 --- a/src/com/itmill/toolkit/demo/sampler/features/link/LinkNoDecorations.java +++ b/src/com/itmill/toolkit/demo/sampler/features/link/LinkNoDecorations.java @@ -10,7 +10,12 @@ public class LinkNoDecorations extends Feature { @Override public String getDescription() { - return "A link that opens a new window w/o decorations"; + return "An basic HTML-style (external) link, opening a browser window" + + "w/o decorations. A Link changes" + + " the url of the browser w/o triggering a server-side event" + + " (like the link-styled Button).<br/> Links can open new" + + " browser windows, and configure the amount of browser" + + " features shown, such as toolbar and addressbar."; } @Override diff --git a/src/com/itmill/toolkit/demo/sampler/features/link/LinkSizedWindow.java b/src/com/itmill/toolkit/demo/sampler/features/link/LinkSizedWindow.java index 5f044ac660..05abb6f095 100644 --- a/src/com/itmill/toolkit/demo/sampler/features/link/LinkSizedWindow.java +++ b/src/com/itmill/toolkit/demo/sampler/features/link/LinkSizedWindow.java @@ -10,7 +10,13 @@ public class LinkSizedWindow extends Feature { @Override public String getDescription() { - return "A link that opens a small new window w/o decorations"; + return "An basic HTML-style (external) link, opening a small window w/o" + + " decorations.<br/> A link changes" + + " the url of the browser w/o triggering a server-side event" + + " (like the link-styled Button).<br/> Links can open new" + + " browser windows, and configure the amount of browser" + + " features shown, such as toolbar and addressbar, and can also" + + " set the size of the window."; } @Override diff --git a/src/com/itmill/toolkit/demo/sampler/features/notifications/NotificationCustomExample.java b/src/com/itmill/toolkit/demo/sampler/features/notifications/NotificationCustomExample.java index 597d246d9b..cd1f224137 100644 --- a/src/com/itmill/toolkit/demo/sampler/features/notifications/NotificationCustomExample.java +++ b/src/com/itmill/toolkit/demo/sampler/features/notifications/NotificationCustomExample.java @@ -19,6 +19,7 @@ public class NotificationCustomExample extends VerticalLayout { public NotificationCustomExample() { setSpacing(true); + setWidth(null); // layout will grow with content final TextField caption = new TextField("Caption"); caption @@ -28,7 +29,6 @@ public class NotificationCustomExample extends VerticalLayout { final RichTextArea description = new RichTextArea(); description.setCaption("Description"); - description.setWidth("400px"); description .setDescription("Additional information; try to keep it short."); addComponent(description); @@ -50,7 +50,7 @@ public class NotificationCustomExample extends VerticalLayout { final Slider delay = new Slider("Delay (msec), -1 means click to hide"); delay .setDescription("Delay before fading<br/>Pull all the way to the left to get -1, which means forever (click to hide)."); - delay.setWidth("400px"); + delay.setWidth("100%"); // 'description' will push width delay.setMin(Notification.DELAY_FOREVER); delay.setMax(10000); addComponent(delay); diff --git a/src/com/itmill/toolkit/demo/sampler/features/notifications/NotificationErrorExample.java b/src/com/itmill/toolkit/demo/sampler/features/notifications/NotificationErrorExample.java index 0bc3c99a52..203e497899 100644 --- a/src/com/itmill/toolkit/demo/sampler/features/notifications/NotificationErrorExample.java +++ b/src/com/itmill/toolkit/demo/sampler/features/notifications/NotificationErrorExample.java @@ -11,6 +11,7 @@ public class NotificationErrorExample extends VerticalLayout { public NotificationErrorExample() { setSpacing(true); + setWidth(null); // layout will grow with content final TextField caption = new TextField("Caption", "Upload failed"); caption.setWidth("200px"); diff --git a/src/com/itmill/toolkit/demo/sampler/features/notifications/NotificationHumanizedExample.java b/src/com/itmill/toolkit/demo/sampler/features/notifications/NotificationHumanizedExample.java index 23f3006b34..87079e9d11 100644 --- a/src/com/itmill/toolkit/demo/sampler/features/notifications/NotificationHumanizedExample.java +++ b/src/com/itmill/toolkit/demo/sampler/features/notifications/NotificationHumanizedExample.java @@ -10,6 +10,7 @@ public class NotificationHumanizedExample extends VerticalLayout { public NotificationHumanizedExample() { setSpacing(true); + setWidth(null); // layout will grow with content final TextField caption = new TextField("Caption", "Document saved"); caption.setWidth("200px"); diff --git a/src/com/itmill/toolkit/demo/sampler/features/notifications/NotificationTrayExample.java b/src/com/itmill/toolkit/demo/sampler/features/notifications/NotificationTrayExample.java index e137b7d1e3..e6295d0c2b 100644 --- a/src/com/itmill/toolkit/demo/sampler/features/notifications/NotificationTrayExample.java +++ b/src/com/itmill/toolkit/demo/sampler/features/notifications/NotificationTrayExample.java @@ -11,6 +11,7 @@ public class NotificationTrayExample extends VerticalLayout { public NotificationTrayExample() { setSpacing(true); + setWidth(null); // layout will grow with content final TextField caption = new TextField("Caption", "New message"); caption.setWidth("200px"); diff --git a/src/com/itmill/toolkit/demo/sampler/features/notifications/NotificationWarningExample.java b/src/com/itmill/toolkit/demo/sampler/features/notifications/NotificationWarningExample.java index 3d6ac77345..a6b3ceecc3 100644 --- a/src/com/itmill/toolkit/demo/sampler/features/notifications/NotificationWarningExample.java +++ b/src/com/itmill/toolkit/demo/sampler/features/notifications/NotificationWarningExample.java @@ -11,6 +11,7 @@ public class NotificationWarningExample extends VerticalLayout { public NotificationWarningExample() { setSpacing(true); + setWidth(null); // layout will grow with content final TextField caption = new TextField("Caption", "Upload canceled"); caption.setWidth("200px"); diff --git a/src/com/itmill/toolkit/demo/sampler/features/selects/ComboBoxContains.java b/src/com/itmill/toolkit/demo/sampler/features/selects/ComboBoxContains.java index e6762f3f5b..7a7905c92e 100644 --- a/src/com/itmill/toolkit/demo/sampler/features/selects/ComboBoxContains.java +++ b/src/com/itmill/toolkit/demo/sampler/features/selects/ComboBoxContains.java @@ -13,10 +13,14 @@ public class ComboBoxContains extends Feature { @Override
public String getDescription() {
- return "A drop-down selection component with single item selection."
- + " A 'contains' filter has been used with this combo box,"
+ return "A drop-down selection component with single item selection.<br/>"
+ + " A 'contains' filter has been used in this example,"
+ " so you can key in some text and only the options"
- + " containing your input will be shown.";
+ + " containing your input will be shown.<br/>"
+ + " Because there are so many options, they are loaded on-demand"
+ + " (\"lazy-loading\") from the server when paging or"
+ + " filtering. This behavior is built-in and requires no extra"
+ + " code.";
}
@Override
diff --git a/src/com/itmill/toolkit/demo/sampler/features/selects/ComboBoxNewItems.java b/src/com/itmill/toolkit/demo/sampler/features/selects/ComboBoxNewItems.java index 6579b094ba..8417dc0f3d 100644 --- a/src/com/itmill/toolkit/demo/sampler/features/selects/ComboBoxNewItems.java +++ b/src/com/itmill/toolkit/demo/sampler/features/selects/ComboBoxNewItems.java @@ -13,10 +13,16 @@ public class ComboBoxNewItems extends Feature { @Override
public String getDescription() {
- return "A drop-down selection component with single item selection."
- + " This selection box also allows you to input your own"
- + " choice. Your input will also be added to the selection"
- + " of available choices.";
+ return "A drop-down selection component with single item selection.<br/>"
+ + " This example also allows you to input your own"
+ + " choice - your input will be added to the selection"
+ + " of available choices. This behavior is built-in and can"
+ + " be enabled with one method call. Note that by using this"
+ + " feature, one can easily create <i>suggestion box</i> -type"
+ + " inputs that for example remembers the users previous input,"
+ + " or provides suggestions from a list of popular choices."
+ + " Configured like this (and optionally with a filter), the"
+ + " ComboBox can be a powerful alternative to TextField.";
}
@Override
diff --git a/src/com/itmill/toolkit/demo/sampler/features/selects/ComboBoxPlain.java b/src/com/itmill/toolkit/demo/sampler/features/selects/ComboBoxPlain.java index 6dceeea68a..b65ed4aab0 100644 --- a/src/com/itmill/toolkit/demo/sampler/features/selects/ComboBoxPlain.java +++ b/src/com/itmill/toolkit/demo/sampler/features/selects/ComboBoxPlain.java @@ -14,7 +14,10 @@ public class ComboBoxPlain extends Feature { @Override
public String getDescription() {
return "A drop-down selection component with single item selection."
- + " No special features used in this example";
+ + " Shown here is the most basic variant, which basically"
+ + " provides the same functionality as a NativeSelect with"
+ + " added lazy-loading if there are many options.<br/>"
+ + " See related examples for more advanced features.";
}
@Override
diff --git a/src/com/itmill/toolkit/demo/sampler/features/selects/ComboBoxStartsWith.java b/src/com/itmill/toolkit/demo/sampler/features/selects/ComboBoxStartsWith.java index a971097b98..46a694956e 100644 --- a/src/com/itmill/toolkit/demo/sampler/features/selects/ComboBoxStartsWith.java +++ b/src/com/itmill/toolkit/demo/sampler/features/selects/ComboBoxStartsWith.java @@ -13,10 +13,14 @@ public class ComboBoxStartsWith extends Feature { @Override
public String getDescription() {
- return "A drop-down selection component with single item selection."
- + " A 'starts with' filter has been used with this combo box,"
- + " so you can key in the beginning of your selection to narrow"
- + " down the amount of choices.";
+ return "A drop-down selection component with single item selection.<br/>"
+ + " A 'starts-with' filter has been used in this example,"
+ + " so you can key in some text and only the options"
+ + " beginning with your input will be shown.<br/>"
+ + " Because there are so many options, they are loaded on-demand"
+ + " (\"lazy-loading\") from the server when paging or"
+ + " filtering. This behavior is built-in and requires no extra"
+ + " code.";
}
@Override
diff --git a/src/com/itmill/toolkit/demo/sampler/features/selects/ListSelectMultiple.java b/src/com/itmill/toolkit/demo/sampler/features/selects/ListSelectMultiple.java index 8c5c069918..e71680643d 100644 --- a/src/com/itmill/toolkit/demo/sampler/features/selects/ListSelectMultiple.java +++ b/src/com/itmill/toolkit/demo/sampler/features/selects/ListSelectMultiple.java @@ -14,8 +14,10 @@ public class ListSelectMultiple extends Feature { @Override
public String getDescription() {
return "A simple list select component with multiple item selection."
- + " A null selection is also allowed in this example."
- + "<br>You can select multiple items from the list by holding"
+ + " You can allow or disallow <i>null selection</i> - i.e the"
+ + " possibility to make an empty selection. Null selection is"
+ + " allowed in this example.<br/>"
+ + "You can select multiple items from the list by holding"
+ " the CTRL of SHIFT key while clicking the items.";
}
diff --git a/src/com/itmill/toolkit/demo/sampler/features/selects/ListSelectSingle.java b/src/com/itmill/toolkit/demo/sampler/features/selects/ListSelectSingle.java index 78ae9aee1d..e8865ae20a 100644 --- a/src/com/itmill/toolkit/demo/sampler/features/selects/ListSelectSingle.java +++ b/src/com/itmill/toolkit/demo/sampler/features/selects/ListSelectSingle.java @@ -13,8 +13,10 @@ public class ListSelectSingle extends Feature { @Override
public String getDescription() {
- return "A simple list select component with single item selection."
- + " A null selection is not allowed in this example.";
+ return "A simple list select component with single item selection.<br/>"
+ + " You can allow or disallow <i>null selection</i> - i.e the"
+ + " possibility to make an empty selection. Null selection is"
+ + " not allowed in this example.";
}
@Override
diff --git a/src/com/itmill/toolkit/demo/sampler/features/selects/ListSelectSingleExample.java b/src/com/itmill/toolkit/demo/sampler/features/selects/ListSelectSingleExample.java index 62df218ae2..78e36d6b0a 100644 --- a/src/com/itmill/toolkit/demo/sampler/features/selects/ListSelectSingleExample.java +++ b/src/com/itmill/toolkit/demo/sampler/features/selects/ListSelectSingleExample.java @@ -1,5 +1,8 @@ package com.itmill.toolkit.demo.sampler.features.selects;
+import java.util.Arrays;
+import java.util.List;
+
import com.itmill.toolkit.data.Property;
import com.itmill.toolkit.data.Property.ValueChangeEvent;
import com.itmill.toolkit.ui.ListSelect;
@@ -8,27 +11,28 @@ import com.itmill.toolkit.ui.VerticalLayout; public class ListSelectSingleExample extends VerticalLayout implements
Property.ValueChangeListener {
- private static final String[] cities = new String[] { "Berlin", "Brussels",
- "Helsinki", "Madrid", "Oslo", "Paris", "Stockholm" };
+ private static final List cities = Arrays.asList(new String[] { "Berlin",
+ "Brussels", "Helsinki", "Madrid", "Oslo", "Paris", "Stockholm" });
public ListSelectSingleExample() {
setSpacing(true);
- ListSelect l = new ListSelect("Please select a city");
- for (int i = 0; i < cities.length; i++) {
- l.addItem(cities[i]);
- }
- l.setRows(7);
- l.setNullSelectionAllowed(false);
- l.setValue("Berlin");
- l.setImmediate(true);
- l.addListener(this);
-
- addComponent(l);
+ // 'Shorthand' constructor - also supports data binding using Containers
+ ListSelect citySelect = new ListSelect("Please select a city", cities);
+
+ citySelect.setRows(7); // perfect length in out case
+ citySelect.setNullSelectionAllowed(false); // user can not 'unselect'
+ citySelect.select("Berlin"); // select this by default
+ citySelect.setImmediate(true); // send the change to the server at once
+ citySelect.addListener(this); // react when the user selects something
+
+ addComponent(citySelect);
}
/*
- * Shows a notification when a selection is made.
+ * Shows a notification when a selection is made. The listener will be
+ * called whenever the value of the component changes, i.e when the user
+ * makes a new selection.
*/
public void valueChange(ValueChangeEvent event) {
getWindow().showNotification("Selected city: " + event.getProperty());
diff --git a/src/com/itmill/toolkit/demo/sampler/features/selects/NativeSelection.java b/src/com/itmill/toolkit/demo/sampler/features/selects/NativeSelection.java index 08b9ef49b0..83cf67e122 100644 --- a/src/com/itmill/toolkit/demo/sampler/features/selects/NativeSelection.java +++ b/src/com/itmill/toolkit/demo/sampler/features/selects/NativeSelection.java @@ -2,6 +2,7 @@ package com.itmill.toolkit.demo.sampler.features.selects; import com.itmill.toolkit.demo.sampler.APIResource;
import com.itmill.toolkit.demo.sampler.Feature;
+import com.itmill.toolkit.demo.sampler.FeatureSet;
import com.itmill.toolkit.demo.sampler.NamedExternalResource;
import com.itmill.toolkit.ui.NativeSelect;
@@ -13,7 +14,15 @@ public class NativeSelection extends Feature { @Override
public String getDescription() {
- return "A native selection component provides a simple drop-down list for selecting one item.";
+ return "A NativeSelect is a a simple drop-down list"
+ + " for selecting one item. It is called <i>native</i>"
+ + " because it uses the look and feel from the browser in use.<br/>"
+ + " The ComboBox component is a much more versatile variant,"
+ + " but without the native look and feel.<br/>"
+ + " From a usability standpoint, you might also want to"
+ + " consider using a ListSelect in single-select-mode, so that"
+ + " the user can see all options right away.";
+
}
@Override
@@ -23,8 +32,8 @@ public class NativeSelection extends Feature { @Override
public Class[] getRelatedFeatures() {
- return new Class[] { ListSelectSingle.class, ListSelectMultiple.class,
- TwinColumnSelect.class };
+ return new Class[] { ComboBoxPlain.class, ListSelectSingle.class,
+ FeatureSet.Selects.class };
}
@Override
diff --git a/src/com/itmill/toolkit/demo/sampler/features/tabsheets/TabSheetIconsExample.java b/src/com/itmill/toolkit/demo/sampler/features/tabsheets/TabSheetIconsExample.java index 922974bab9..6d52fb3b35 100644 --- a/src/com/itmill/toolkit/demo/sampler/features/tabsheets/TabSheetIconsExample.java +++ b/src/com/itmill/toolkit/demo/sampler/features/tabsheets/TabSheetIconsExample.java @@ -9,23 +9,37 @@ import com.itmill.toolkit.ui.TabSheet.SelectedTabChangeEvent; public class TabSheetIconsExample extends VerticalLayout implements
TabSheet.SelectedTabChangeListener {
+ // Icons for the table
+ private static final ThemeResource icon1 = new ThemeResource(
+ "icons/action_save.gif");
+ private static final ThemeResource icon2 = new ThemeResource(
+ "icons/comment_yellow.gif");
+ private static final ThemeResource icon3 = new ThemeResource(
+ "icons/icon_info.gif");
+
private TabSheet t;
public TabSheetIconsExample() {
- Label l1 = new Label("There are no previously saved actions.");
- Label l2 = new Label("There are no saved notes.");
- Label l3 = new Label("There are currently no issues.");
-
- ThemeResource i1 = new ThemeResource("icons/action_save.gif");
- ThemeResource i2 = new ThemeResource("icons/comment_yellow.gif");
- ThemeResource i3 = new ThemeResource("icons/icon_info.gif");
+ // Tab 1 content
+ VerticalLayout l1 = new VerticalLayout();
+ l1.setMargin(true);
+ l1.addComponent(new Label("There are no previously saved actions."));
+ // Tab 2 content
+ VerticalLayout l2 = new VerticalLayout();
+ l2.setMargin(true);
+ l2.addComponent(new Label("There are no saved notes."));
+ // Tab 3 content
+ VerticalLayout l3 = new VerticalLayout();
+ l3.setMargin(true);
+ l3.addComponent(new Label("There are currently no issues."));
t = new TabSheet();
- t.setHeight(400, UNITS_PIXELS);
- t.setWidth(400, UNITS_PIXELS);
- t.addTab(l1, "Saved actions", i1);
- t.addTab(l2, "Notes", i2);
- t.addTab(l3, "Issues", i3);
+ t.setHeight("200px");
+ t.setWidth("400px");
+
+ t.addTab(l1, "Saved actions", icon1);
+ t.addTab(l2, "Notes", icon2);
+ t.addTab(l3, "Issues", icon3);
t.addListener(this);
addComponent(t);
|