From 77fce1e5feb3310d580f3e776974c678de77e69c Mon Sep 17 00:00:00 2001 From: Marc Englund Date: Wed, 4 Feb 2009 10:34:14 +0000 Subject: [PATCH] Sampler content modifications. svn changeset:6723/svn branch:trunk --- .../toolkit/demo/sampler/FeatureView.java | 3 +- .../accordions/AccordionDisabled.java | 9 +- .../accordions/AccordionDisabledExample.java | 21 +++-- .../features/accordions/AccordionIcons.java | 4 +- .../accordions/AccordionIconsExample.java | 21 +++-- .../sampler/features/panels/PanelBasic.java | 16 ++-- .../features/panels/PanelBasicExample.java | 43 +++++----- .../sampler/features/panels/PanelLight.java | 17 ++-- .../features/panels/PanelLightExample.java | 44 ++++++---- .../selects/ComboBoxNewItemsExample.java | 2 - .../tabsheets/TabSheetDisabledExample.java | 86 ++++++++++--------- .../tabsheets/TabSheetScrollingExample.java | 50 +++++++---- 12 files changed, 187 insertions(+), 129 deletions(-) diff --git a/src/com/itmill/toolkit/demo/sampler/FeatureView.java b/src/com/itmill/toolkit/demo/sampler/FeatureView.java index 9b7d7486c0..2c37b39894 100644 --- a/src/com/itmill/toolkit/demo/sampler/FeatureView.java +++ b/src/com/itmill/toolkit/demo/sampler/FeatureView.java @@ -34,7 +34,7 @@ public class FeatureView extends HorizontalLayout { private Feature currentFeature; public FeatureView() { - + setSizeFull(); setWidth("100%"); setMargin(true); setSpacing(true); @@ -53,6 +53,7 @@ public class FeatureView extends HorizontalLayout { right.setStyleName(Panel.STYLE_LIGHT); right.addStyleName("feature-info"); right.setWidth("369px"); + right.setHeight("100%"); addComponent(right); controls = new VerticalLayout(); diff --git a/src/com/itmill/toolkit/demo/sampler/features/accordions/AccordionDisabled.java b/src/com/itmill/toolkit/demo/sampler/features/accordions/AccordionDisabled.java index 66e9d88ec7..0670165204 100644 --- a/src/com/itmill/toolkit/demo/sampler/features/accordions/AccordionDisabled.java +++ b/src/com/itmill/toolkit/demo/sampler/features/accordions/AccordionDisabled.java @@ -2,6 +2,7 @@ package com.itmill.toolkit.demo.sampler.features.accordions; 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.Accordion; @@ -13,8 +14,10 @@ public class AccordionDisabled extends Feature { @Override public String getDescription() { - return "With an accordion component you can disable, enable," - + " hide and show tabs, similary to a tabsheet."; + return "An accordion component is a specialized case of a" + + " tabsheet, with vertically organized tabs." + + " With an accordion component you can also disable, enable," + + " hide and show tabs, similar to a tabsheet."; } @Override @@ -24,7 +27,7 @@ public class AccordionDisabled extends Feature { @Override public Class[] getRelatedFeatures() { - return new Class[] { AccordionIcons.class }; + return new Class[] { AccordionIcons.class, FeatureSet.Tabsheets.class }; } @Override diff --git a/src/com/itmill/toolkit/demo/sampler/features/accordions/AccordionDisabledExample.java b/src/com/itmill/toolkit/demo/sampler/features/accordions/AccordionDisabledExample.java index cafb2ffcc5..705a857fd7 100644 --- a/src/com/itmill/toolkit/demo/sampler/features/accordions/AccordionDisabledExample.java +++ b/src/com/itmill/toolkit/demo/sampler/features/accordions/AccordionDisabledExample.java @@ -19,6 +19,13 @@ public class AccordionDisabledExample extends VerticalLayout implements private Label l2; private Label l3; + 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"); + public AccordionDisabledExample() { setSpacing(true); @@ -26,16 +33,12 @@ public class AccordionDisabledExample extends VerticalLayout implements l2 = new Label("There are no saved notes."); 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"); - a = new Accordion(); - a.setHeight(400, UNITS_PIXELS); - a.setWidth(400, UNITS_PIXELS); - a.addTab(l1, "Saved actions", i1); - a.addTab(l2, "Notes", i2); - a.addTab(l3, "Issues", i3); + a.setHeight("300px"); + a.setWidth("400px"); + a.addTab(l1, "Saved actions", icon1); + a.addTab(l2, "Notes", icon2); + a.addTab(l3, "Issues", icon3); a.addListener(this); b1 = new Button("Disable 'Notes' tab"); diff --git a/src/com/itmill/toolkit/demo/sampler/features/accordions/AccordionIcons.java b/src/com/itmill/toolkit/demo/sampler/features/accordions/AccordionIcons.java index 06bcd27e09..b63f0cc56d 100644 --- a/src/com/itmill/toolkit/demo/sampler/features/accordions/AccordionIcons.java +++ b/src/com/itmill/toolkit/demo/sampler/features/accordions/AccordionIcons.java @@ -2,6 +2,7 @@ package com.itmill.toolkit.demo.sampler.features.accordions; 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.Accordion; @@ -26,7 +27,8 @@ public class AccordionIcons extends Feature { @Override public Class[] getRelatedFeatures() { - return new Class[] { AccordionDisabled.class }; + return new Class[] { AccordionDisabled.class, + FeatureSet.Tabsheets.class }; } @Override diff --git a/src/com/itmill/toolkit/demo/sampler/features/accordions/AccordionIconsExample.java b/src/com/itmill/toolkit/demo/sampler/features/accordions/AccordionIconsExample.java index d76892ea86..6ef5894d0e 100644 --- a/src/com/itmill/toolkit/demo/sampler/features/accordions/AccordionIconsExample.java +++ b/src/com/itmill/toolkit/demo/sampler/features/accordions/AccordionIconsExample.java @@ -9,6 +9,13 @@ import com.itmill.toolkit.ui.TabSheet.SelectedTabChangeEvent; public class AccordionIconsExample extends HorizontalLayout implements Accordion.SelectedTabChangeListener { + 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 Accordion a; public AccordionIconsExample() { @@ -18,16 +25,12 @@ public class AccordionIconsExample extends HorizontalLayout implements 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"); - a = new Accordion(); - a.setHeight(400, UNITS_PIXELS); - a.setWidth(400, UNITS_PIXELS); - a.addTab(l1, "Saved actions", i1); - a.addTab(l2, "Notes", i2); - a.addTab(l3, "Issues", i3); + a.setHeight("300px"); + a.setWidth("400px"); + a.addTab(l1, "Saved actions", icon1); + a.addTab(l2, "Notes", icon2); + a.addTab(l3, "Issues", icon3); a.addListener(this); addComponent(a); diff --git a/src/com/itmill/toolkit/demo/sampler/features/panels/PanelBasic.java b/src/com/itmill/toolkit/demo/sampler/features/panels/PanelBasic.java index 67988bcf3f..ab834ca2ff 100644 --- a/src/com/itmill/toolkit/demo/sampler/features/panels/PanelBasic.java +++ b/src/com/itmill/toolkit/demo/sampler/features/panels/PanelBasic.java @@ -2,7 +2,9 @@ package com.itmill.toolkit.demo.sampler.features.panels; 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.Layout; import com.itmill.toolkit.ui.Panel; public class PanelBasic extends Feature { @@ -13,21 +15,23 @@ public class PanelBasic extends Feature { @Override public String getDescription() { - return "Panel is a simple container for one component." - + " A caption can optionally be added." - + "
A panel typically contains a layout component" - + " where the other components can be added."; + return "Panel is a simple container that supports scrolling.
" + + " It's internal layout (by default VerticalLayout) can be" + + " configured or exchanged to get desired results. Components" + + " that are added to the Panel will in effect be added to the" + + " layout."; } @Override public APIResource[] getRelatedAPI() { - return new APIResource[] { new APIResource(Panel.class) }; + return new APIResource[] { new APIResource(Panel.class), + new APIResource(Layout.class) }; } @Override public Class[] getRelatedFeatures() { - return new Class[] { PanelLight.class }; + return new Class[] { PanelLight.class, FeatureSet.Layouts.class }; } @Override diff --git a/src/com/itmill/toolkit/demo/sampler/features/panels/PanelBasicExample.java b/src/com/itmill/toolkit/demo/sampler/features/panels/PanelBasicExample.java index 35d6faf17f..d77d21c6f8 100644 --- a/src/com/itmill/toolkit/demo/sampler/features/panels/PanelBasicExample.java +++ b/src/com/itmill/toolkit/demo/sampler/features/panels/PanelBasicExample.java @@ -9,36 +9,39 @@ import com.itmill.toolkit.ui.Button.ClickListener; public class PanelBasicExample extends VerticalLayout implements ClickListener { - private Panel p1; - private Panel p2; + private Panel panel; public PanelBasicExample() { setSpacing(true); - // First panel uses layout in which the components are added - VerticalLayout vl = new VerticalLayout(); - Label l = new Label("Push the button to toggle caption."); + // Panel 1 - with caption + panel = new Panel("This is a standard Panel"); + panel.setHeight("200px"); // we want scrollbars + + // let's adjust the panels default layout (a VerticalLayout) + VerticalLayout layout = (VerticalLayout) panel.getLayout(); + layout.setMargin(true); // we want a margin + layout.setSpacing(true); // and spacing between components + addComponent(panel); + + // Let's add a few rows to provoke scrollbars: + for (int i = 0; i < 20; i++) { + panel.addComponent(new Label( + "The quick brown fox jumps over the lazy dog.")); + } + + // Caption toggle: Button b = new Button("Toggle caption"); b.addListener(this); - vl.setSpacing(true); - vl.addComponent(l); - vl.addComponent(b); - p1 = new Panel("This is a standard Panel"); - p1.setLayout(vl); - - // We add the Label component directly to the second panel - p2 = new Panel(); - p2.addComponent(new Label("This is a standard panel without caption.")); - - addComponent(p1); - addComponent(p2); + addComponent(b); + } public void buttonClick(ClickEvent event) { - if (p1.getCaption().equals("")) { - p1.setCaption("This is a standard Panel"); + if (panel.getCaption().equals("")) { + panel.setCaption("This is a standard Panel"); } else { - p1.setCaption(""); + panel.setCaption(""); } } } diff --git a/src/com/itmill/toolkit/demo/sampler/features/panels/PanelLight.java b/src/com/itmill/toolkit/demo/sampler/features/panels/PanelLight.java index 6ce8d4e968..e3b268cc40 100644 --- a/src/com/itmill/toolkit/demo/sampler/features/panels/PanelLight.java +++ b/src/com/itmill/toolkit/demo/sampler/features/panels/PanelLight.java @@ -2,30 +2,37 @@ package com.itmill.toolkit.demo.sampler.features.panels; 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.Layout; import com.itmill.toolkit.ui.Panel; public class PanelLight extends Feature { @Override public String getName() { - return "Panel - Light style"; + return "Panel, light style"; } @Override public String getDescription() { - return "A lighter style for the Panel component is" - + " also available."; + return "Panel is a simple container that supports scrolling.
" + + " It's internal layout (by default VerticalLayout) can be" + + " configured or exchanged to get desired results. Components" + + " that are added to the Panel will in effect be added to the" + + " layout.
" + + "The 'light' version has less decorations than the regular one."; } @Override public APIResource[] getRelatedAPI() { - return new APIResource[] { new APIResource(Panel.class) }; + return new APIResource[] { new APIResource(Panel.class), + new APIResource(Layout.class) }; } @Override public Class[] getRelatedFeatures() { - return new Class[] { PanelBasic.class }; + return new Class[] { PanelBasic.class, FeatureSet.Layouts.class }; } @Override diff --git a/src/com/itmill/toolkit/demo/sampler/features/panels/PanelLightExample.java b/src/com/itmill/toolkit/demo/sampler/features/panels/PanelLightExample.java index 508c8397b2..be49cdacad 100644 --- a/src/com/itmill/toolkit/demo/sampler/features/panels/PanelLightExample.java +++ b/src/com/itmill/toolkit/demo/sampler/features/panels/PanelLightExample.java @@ -9,33 +9,41 @@ import com.itmill.toolkit.ui.Button.ClickListener; public class PanelLightExample extends VerticalLayout implements ClickListener { - private Panel p; + private Panel panel; public PanelLightExample() { setSpacing(true); - // First panel uses layout in which the components are added - VerticalLayout vl = new VerticalLayout(); - Label l = new Label("Push the button to toggle style."); - Button b = new Button("Toggle style"); + setSpacing(true); + + // Panel 1 - with caption + panel = new Panel("This is a light Panel"); + panel.setStyleName(Panel.STYLE_LIGHT); + panel.setHeight("200px"); // we want scrollbars + + // let's adjust the panels default layout (a VerticalLayout) + VerticalLayout layout = (VerticalLayout) panel.getLayout(); + layout.setMargin(true); // we want a margin + layout.setSpacing(true); // and spacing between components + addComponent(panel); + + // Let's add a few rows to provoke scrollbars: + for (int i = 0; i < 20; i++) { + panel.addComponent(new Label( + "The quick brown fox jumps over the lazy dog.")); + } + + // Caption toggle: + Button b = new Button("Toggle caption"); b.addListener(this); - vl.setSpacing(true); - vl.addComponent(l); - vl.addComponent(b); - p = new Panel("This is a light Panel"); - p.setStyleName("light"); - p.setLayout(vl); - - addComponent(p); + addComponent(b); } public void buttonClick(ClickEvent event) { - if (p.getStyleName().contains("light")) { - p.removeStyleName("light"); - p.setCaption("This is a standard Panel"); + if (panel.getCaption().equals("")) { + panel.setCaption("This is a standard Panel"); } else { - p.setStyleName("light"); - p.setCaption("This is a light Panel"); + panel.setCaption(""); } } } diff --git a/src/com/itmill/toolkit/demo/sampler/features/selects/ComboBoxNewItemsExample.java b/src/com/itmill/toolkit/demo/sampler/features/selects/ComboBoxNewItemsExample.java index 339babd2a0..f986cb088a 100644 --- a/src/com/itmill/toolkit/demo/sampler/features/selects/ComboBoxNewItemsExample.java +++ b/src/com/itmill/toolkit/demo/sampler/features/selects/ComboBoxNewItemsExample.java @@ -5,7 +5,6 @@ import com.itmill.toolkit.data.Property.ValueChangeEvent; import com.itmill.toolkit.ui.AbstractSelect; import com.itmill.toolkit.ui.ComboBox; import com.itmill.toolkit.ui.VerticalLayout; -import com.itmill.toolkit.ui.AbstractSelect.Filtering; public class ComboBoxNewItemsExample extends VerticalLayout implements Property.ValueChangeListener, AbstractSelect.NewItemHandler { @@ -22,7 +21,6 @@ public class ComboBoxNewItemsExample extends VerticalLayout implements l.addItem(cities[i]); } - l.setFilteringMode(Filtering.FILTERINGMODE_OFF); l.setNewItemsAllowed(true); l.setNewItemHandler(this); l.setImmediate(true); diff --git a/src/com/itmill/toolkit/demo/sampler/features/tabsheets/TabSheetDisabledExample.java b/src/com/itmill/toolkit/demo/sampler/features/tabsheets/TabSheetDisabledExample.java index cd66f33942..12ad969e71 100644 --- a/src/com/itmill/toolkit/demo/sampler/features/tabsheets/TabSheetDisabledExample.java +++ b/src/com/itmill/toolkit/demo/sampler/features/tabsheets/TabSheetDisabledExample.java @@ -11,42 +11,54 @@ import com.itmill.toolkit.ui.TabSheet.SelectedTabChangeEvent; public class TabSheetDisabledExample extends VerticalLayout implements TabSheet.SelectedTabChangeListener, Button.ClickListener { + 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; - private Button b1; - private Button b2; - private Label l1; - private Label l2; - private Label l3; + private Button toggleEnabled; + private Button toggleVisible; + private VerticalLayout l1; + private VerticalLayout l2; + private VerticalLayout l3; public TabSheetDisabledExample() { setSpacing(true); - l1 = new Label("There are no previously saved actions."); - l2 = new Label("There are no saved notes."); - 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 + l1 = new VerticalLayout(); + l1.setMargin(true); + l1.addComponent(new Label("There are no previously saved actions.")); + // Tab 2 content + l2 = new VerticalLayout(); + l2.setMargin(true); + l2.addComponent(new Label("There are no saved notes.")); + // Tab 3 content + 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); - b1 = new Button("Disable 'Notes' tab"); - b2 = new Button("Hide 'Issues' tab"); - b1.addListener(this); - b2.addListener(this); + toggleEnabled = new Button("Disable 'Notes' tab"); + toggleEnabled.addListener(this); + + toggleVisible = new Button("Hide 'Issues' tab"); + toggleVisible.addListener(this); HorizontalLayout hl = new HorizontalLayout(); hl.setSpacing(true); - hl.addComponent(b1); - hl.addComponent(b2); + hl.addComponent(toggleEnabled); + hl.addComponent(toggleVisible); addComponent(t); addComponent(hl); @@ -58,22 +70,18 @@ public class TabSheetDisabledExample extends VerticalLayout implements } public void buttonClick(ClickEvent event) { - if (b1.equals(event.getButton())) { // b1 clicked - if (l2.isEnabled()) { - l2.setEnabled(false); - b1.setCaption("Enable 'Notes' tab"); - } else { - l2.setEnabled(true); - b1.setCaption("Disable 'Notes' tab"); - } - } else { // b2 clicked - if (l3.isVisible()) { - l3.setVisible(false); - b2.setCaption("Show 'Issues' tab"); - } else { - l3.setVisible(true); - b2.setCaption("Hide 'Issues' tab"); - } + if (toggleEnabled.equals(event.getButton())) { + // toggleEnabled clicked + l2.setEnabled(!l2.isEnabled()); + toggleEnabled.setCaption((l2.isEnabled() ? "Disable" : "Enable") + + " 'Notes' tab"); + + } else { + // toggleVisible clicked + l3.setVisible(!l3.isVisible()); + toggleVisible.setCaption((l3.isVisible() ? "Hide" : "Show") + + " 'Issues' tab"); + } t.requestRepaint(); } diff --git a/src/com/itmill/toolkit/demo/sampler/features/tabsheets/TabSheetScrollingExample.java b/src/com/itmill/toolkit/demo/sampler/features/tabsheets/TabSheetScrollingExample.java index 102a0879e2..15c4d0ce8e 100644 --- a/src/com/itmill/toolkit/demo/sampler/features/tabsheets/TabSheetScrollingExample.java +++ b/src/com/itmill/toolkit/demo/sampler/features/tabsheets/TabSheetScrollingExample.java @@ -9,27 +9,45 @@ import com.itmill.toolkit.ui.TabSheet.SelectedTabChangeEvent; public class TabSheetScrollingExample extends VerticalLayout implements TabSheet.SelectedTabChangeListener { + 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 TabSheetScrollingExample() { - 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."); - Label l4 = new Label("There are no comments."); - Label l5 = new Label("There is no new feedback."); - - 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.")); + // Tab 4 content + VerticalLayout l4 = new VerticalLayout(); + l4.setMargin(true); + l4.addComponent(new Label("There are no comments.")); + // Tab 5 content + VerticalLayout l5 = new VerticalLayout(); + l5.setMargin(true); + l5.addComponent(new Label("There is no new feedback.")); 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.addTab(l4, "Comments", i2); - t.addTab(l5, "Feedback", i2); + t.setHeight("200px"); + t.setWidth("400px"); + t.addTab(l1, "Saved actions", icon1); + t.addTab(l2, "Notes", icon2); + t.addTab(l3, "Issues", icon3); + t.addTab(l4, "Comments", icon2); + t.addTab(l5, "Feedback", icon2); t.addListener(this); addComponent(t); -- 2.39.5