diff options
Diffstat (limited to 'src/com/itmill/toolkit')
28 files changed, 2534 insertions, 85 deletions
diff --git a/src/com/itmill/toolkit/automatedtests/ComponentsInTable.java b/src/com/itmill/toolkit/automatedtests/ComponentsInTable.java new file mode 100644 index 0000000000..619b54bdb7 --- /dev/null +++ b/src/com/itmill/toolkit/automatedtests/ComponentsInTable.java @@ -0,0 +1,74 @@ +/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
+package com.itmill.toolkit.automatedtests;
+
+import java.util.Date;
+import java.util.Vector;
+
+import com.itmill.toolkit.ui.Button;
+import com.itmill.toolkit.ui.CustomComponent;
+import com.itmill.toolkit.ui.OrderedLayout;
+import com.itmill.toolkit.ui.Table;
+import com.itmill.toolkit.ui.Button.ClickEvent;
+
+public class ComponentsInTable extends CustomComponent {
+
+ public ComponentsInTable(int cols, int rows) {
+ final OrderedLayout main = new OrderedLayout();
+ setCompositionRoot(main);
+
+ main.addComponent(getTestTable(cols, rows));
+ }
+
+ public static Table getTestTable(int cols, int rows) {
+ final Table t = new Table();
+ t.setColumnCollapsingAllowed(true);
+ for (int i = 0; i < cols; i++) {
+ t.addContainerProperty(testString[i], String.class, "");
+ }
+ t.addContainerProperty("button", Button.class, null);
+ for (int i = 0; i < rows; i++) {
+ final Vector content = new Vector();
+ for (int j = 0; j < cols; j++) {
+ content.add(rndString());
+ }
+ content.add(new Button("b" + i, new Button.ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ Button b = event.getButton();
+ System.out.println(event.getButton().getCaption()
+ + " click: " + (new Date()).toGMTString());
+ System.out.println(event.getButton().getApplication());
+
+ }
+ }));
+ t.addItem(content.toArray(), "" + i);
+ }
+ t.setRowHeaderMode(Table.ROW_HEADER_MODE_ID);
+ return t;
+ }
+
+ static String[] testString = new String[] { "Jacob", "Michael", "Joshua",
+ "Matthew", "Ethan", "Andrew", "Daniel", "Anthony", "Christopher",
+ "Joseph", "William", "Alexander", "Ryan", "David", "Nicholas",
+ "Tyler", "James", "John", "Jonathan", "Nathan", "Samuel",
+ "Christian", "Noah", "Dylan", "Benjamin", "Logan", "Brandon",
+ "Gabriel", "Zachary", "Jose", "Elijah", "Angel", "Kevin", "Jack",
+ "Caleb", "Justin", "Austin", "Evan", "Robert", "Thomas", "Luke",
+ "Mason", "Aidan", "Jackson", "Isaiah", "Jordan", "Gavin", "Connor",
+ "Aiden", "Isaac", "Jason", "Cameron", "Hunter", "Jayden", "Juan",
+ "Charles", "Aaron", "Lucas", "Luis", "Owen", "Landon", "Diego",
+ "Brian", "Adam", "Adrian", "Kyle", "Eric", "Ian", "Nathaniel",
+ "Carlos", "Alex", "Bryan", "Jesus", "Julian", "Sean", "Carter",
+ "Hayden", "Jeremiah", "Cole", "Brayden", "Wyatt", "Chase",
+ "Steven", "Timothy", "Dominic", "Sebastian", "Xavier", "Jaden",
+ "Jesse", "Devin", "Seth", "Antonio", "Richard", "Miguel", "Colin",
+ "Cody", "Alejandro", "Caden", "Blake", "Carson" };
+
+ public static String rndString() {
+ return testString[(int) (Math.random() * testString.length)];
+ }
+
+}
diff --git a/src/com/itmill/toolkit/automatedtests/SimplestApplication.java b/src/com/itmill/toolkit/automatedtests/SimplestApplication.java new file mode 100644 index 0000000000..a81e1daa1a --- /dev/null +++ b/src/com/itmill/toolkit/automatedtests/SimplestApplication.java @@ -0,0 +1,17 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + +package com.itmill.toolkit.automatedtests; + +import com.itmill.toolkit.ui.Label; +import com.itmill.toolkit.ui.Window; + +public class SimplestApplication extends com.itmill.toolkit.Application { + + public void init() { + final Window main = new Window("Simplest Application window"); + setMainWindow(main); + main.addComponent(new Label("Simplest Application label")); + } +} diff --git a/src/com/itmill/toolkit/automatedtests/featurebrowser/ButtonExample.java b/src/com/itmill/toolkit/automatedtests/featurebrowser/ButtonExample.java new file mode 100644 index 0000000000..5f73b3fc43 --- /dev/null +++ b/src/com/itmill/toolkit/automatedtests/featurebrowser/ButtonExample.java @@ -0,0 +1,149 @@ +/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
+package com.itmill.toolkit.automatedtests.featurebrowser;
+
+import com.itmill.toolkit.terminal.ExternalResource;
+import com.itmill.toolkit.terminal.ThemeResource;
+import com.itmill.toolkit.ui.Button;
+import com.itmill.toolkit.ui.CheckBox;
+import com.itmill.toolkit.ui.CustomComponent;
+import com.itmill.toolkit.ui.Label;
+import com.itmill.toolkit.ui.Link;
+import com.itmill.toolkit.ui.OrderedLayout;
+import com.itmill.toolkit.ui.Panel;
+import com.itmill.toolkit.ui.Button.ClickEvent;
+
+/**
+ * Shows a few variations of Buttons and Links.
+ *
+ * @author IT Mill Ltd.
+ */
+public class ButtonExample extends CustomComponent implements
+ Button.ClickListener {
+
+ public ButtonExample() {
+
+ final OrderedLayout main = new OrderedLayout();
+ main.setMargin(true);
+ setCompositionRoot(main);
+
+ final OrderedLayout horiz = new OrderedLayout(
+ OrderedLayout.ORIENTATION_HORIZONTAL);
+ main.addComponent(horiz);
+ final Panel basic = new Panel("Basic buttons");
+ basic.setStyleName(Panel.STYLE_LIGHT);
+ horiz.addComponent(basic);
+
+ final Panel bells = new Panel("w/ bells & whistles");
+ bells.setStyleName(Panel.STYLE_LIGHT);
+ horiz.addComponent(bells);
+
+ Button b = new Button("Basic button");
+ b.setDebugId("Basic1");
+ b.addListener(this);
+ basic.addComponent(b);
+
+ b = new Button("Button w/ icon + tooltip");
+ b.setDebugId("Button2");
+ b.addListener(this);
+ b.setIcon(new ThemeResource("icons/ok.png"));
+ b.setDescription("This button does nothing, fast");
+ bells.addComponent(b);
+
+ b = new CheckBox("CheckBox - a switch-button");
+ b.setDebugId("Button3");
+ b.setImmediate(true); // checkboxes are not immediate by default
+ b.addListener(this);
+ basic.addComponent(b);
+
+ b = new CheckBox("CheckBox w/ icon + tooltip");
+ b.setDebugId("Button4");
+ b.setImmediate(true); // checkboxes are not immediate by default
+ b.addListener(this);
+ b.setIcon(new ThemeResource("icons/ok.png"));
+ b.setDescription("This is a CheckBox");
+ bells.addComponent(b);
+
+ b = new Button("Link-style button");
+ b.setDebugId("Button5");
+ b.addListener(this);
+ b.setStyleName(Button.STYLE_LINK);
+ basic.addComponent(b);
+
+ b = new Button("Link button w/ icon + tooltip");
+ b.setDebugId("Button6");
+ b.addListener(this);
+ b.setStyleName(Button.STYLE_LINK);
+ b.setIcon(new ThemeResource("icons/ok.png"));
+ b.setDescription("Link-style, icon+tootip, no caption");
+ bells.addComponent(b);
+
+ b = new Button();
+ b.setDebugId("Button7");
+ b.addListener(this);
+ b.setStyleName(Button.STYLE_LINK);
+ b.setIcon(new ThemeResource("icons/ok.png"));
+ b.setDescription("Link-style, icon+tootip, no caption");
+ basic.addComponent(b);
+
+ final Panel links = new Panel("Links");
+ links.setStyleName(Panel.STYLE_LIGHT);
+ main.addComponent(links);
+ final Label desc = new Label(
+ "The main difference between a Link and"
+ + " a link-styled Button is that the Link works client-"
+ + " side, whereas the Button works server side.<br/> This means"
+ + " that the Button triggers some event on the server,"
+ + " while the Link is a normal web-link. <br/><br/>Note that for"
+ + " opening new windows, the Link might be a safer "
+ + " choice, since popup-blockers might interfer with "
+ + " server-initiated window opening.");
+ desc.setContentMode(Label.CONTENT_XHTML);
+ links.addComponent(desc);
+ Link l = new Link("IT Mill home", new ExternalResource(
+ "http://www.itmill.com"));
+ l.setDebugId("Link1");
+ l.setDescription("Link without target name, opens in this window");
+ links.addComponent(l);
+
+ l = new Link("IT Mill home (new window)", new ExternalResource(
+ "http://www.itmill.com"));
+ l.setDebugId("Link2");
+ l.setTargetName("_blank");
+ l.setDescription("Link with target name, opens in new window");
+ links.addComponent(l);
+
+ l = new Link("IT Mill home (new window, less decor)",
+ new ExternalResource("http://www.itmill.com"));
+ l.setDebugId("Link3");
+ l.setTargetName("_blank");
+ l.setTargetBorder(Link.TARGET_BORDER_MINIMAL);
+ l.setTargetName("_blank");
+ l
+ .setDescription("Link with target name and BORDER_MINIMAL, opens in new window with less decor");
+ links.addComponent(l);
+
+ l = new Link("IT Mill home (new 200x200 window, no decor, icon)",
+ new ExternalResource("http://www.itmill.com"), "_blank", 200,
+ 200, Link.TARGET_BORDER_NONE);
+ l.setDebugId("Link4");
+ l.setTargetName("_blank");
+ l
+ .setDescription("Link with target name and BORDER_NONE, opens in new window with no decor");
+ l.setIcon(new ThemeResource("icons/ok.png"));
+ links.addComponent(l);
+
+ }
+
+ public void buttonClick(ClickEvent event) {
+ final Button b = event.getButton();
+ getWindow().showNotification(
+ "Clicked"
+ + (b instanceof CheckBox ? ", value: "
+ + event.getButton().getValue() : ""));
+
+ }
+
+}
diff --git a/src/com/itmill/toolkit/automatedtests/featurebrowser/ClientCachingExample.java b/src/com/itmill/toolkit/automatedtests/featurebrowser/ClientCachingExample.java new file mode 100644 index 0000000000..42199b1cd1 --- /dev/null +++ b/src/com/itmill/toolkit/automatedtests/featurebrowser/ClientCachingExample.java @@ -0,0 +1,70 @@ +/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
+package com.itmill.toolkit.automatedtests.featurebrowser;
+
+import com.itmill.toolkit.terminal.PaintException;
+import com.itmill.toolkit.terminal.PaintTarget;
+import com.itmill.toolkit.ui.CustomComponent;
+import com.itmill.toolkit.ui.Label;
+import com.itmill.toolkit.ui.Layout;
+import com.itmill.toolkit.ui.OrderedLayout;
+import com.itmill.toolkit.ui.TabSheet;
+
+/**
+ * This example is a (simple) demonstration of client-side caching. The content
+ * in one tab is intentionally made very slow to produce server-side. When the
+ * user changes to this tab for the first time, there will be a 3 second wait
+ * before the content shows up, but the second time it shows up immediately
+ * since the content has not changed and is cached client-side.
+ *
+ * @author IT Mill Ltd.
+ */
+public class ClientCachingExample extends CustomComponent {
+
+ private static final String msg = "This example is a (simple) demonstration of client-side caching."
+ + " The content in one tab is intentionally made very slow to"
+ + " 'produce' server-side. When you changes to this tab for the"
+ + " first time, there will be a 3 second wait before the content"
+ + " shows up, but the second time it shows up immediately since the"
+ + " content has not changed and is cached client-side.";
+
+ public ClientCachingExample() {
+
+ final OrderedLayout main = new OrderedLayout();
+ main.setMargin(true);
+ setCompositionRoot(main);
+
+ main.addComponent(new Label(msg));
+
+ final TabSheet ts = new TabSheet();
+ main.addComponent(ts);
+
+ Layout layout = new OrderedLayout();
+ layout.setMargin(true);
+ Label l = new Label("This is a normal label, quick to render.");
+ l.setCaption("A normal label");
+ layout.addComponent(l);
+
+ ts.addTab(layout, "Normal", null);
+
+ layout = new OrderedLayout();
+ layout.setMargin(true);
+ l = new Label("Slow label - until cached client side.") {
+ public void paintContent(PaintTarget target) throws PaintException {
+ try {
+ Thread.sleep(3000);
+ } catch (final Exception e) {
+ // IGNORED
+ }
+ super.paintContent(target);
+ }
+
+ };
+ l.setCaption("A slow label");
+ layout.addComponent(l);
+ ts.addTab(layout, "Slow", null);
+
+ }
+}
diff --git a/src/com/itmill/toolkit/automatedtests/featurebrowser/ComboBoxExample.java b/src/com/itmill/toolkit/automatedtests/featurebrowser/ComboBoxExample.java new file mode 100644 index 0000000000..03271a98e3 --- /dev/null +++ b/src/com/itmill/toolkit/automatedtests/featurebrowser/ComboBoxExample.java @@ -0,0 +1,73 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + +package com.itmill.toolkit.automatedtests.featurebrowser; + +import java.util.Random; + +import com.itmill.toolkit.ui.ComboBox; +import com.itmill.toolkit.ui.CustomComponent; +import com.itmill.toolkit.ui.OrderedLayout; +import com.itmill.toolkit.ui.AbstractSelect.Filtering; + +/** + * + */ +public class ComboBoxExample extends CustomComponent { + + private static final String[] firstnames = new String[] { "John", "Mary", + "Joe", "Sarah", "Jeff", "Jane", "Peter", "Marc", "Robert", "Paula", + "Lenny", "Kenny", "Nathan", "Nicole", "Laura", "Jos", "Josie", + "Linus" }; + + private static final String[] lastnames = new String[] { "Torvalds", + "Smith", "Adams", "Black", "Wilson", "Richards", "Thompson", + "McGoff", "Halas", "Jones", "Beck", "Sheridan", "Picard", "Hill", + "Fielding", "Einstein" }; + + public ComboBoxExample() { + final OrderedLayout main = new OrderedLayout(); + main.setMargin(true); + setCompositionRoot(main); + + // starts-with filter + final ComboBox s1 = new ComboBox("Select with starts-with filter"); + s1.setDebugId("ComboBoxStartFilter"); + s1.setFilteringMode(Filtering.FILTERINGMODE_STARTSWITH); + s1.setColumns(20); + Random r = new Random(5); + for (int i = 0; i < 105; i++) { + s1 + .addItem(firstnames[(int) (r.nextDouble() * (firstnames.length - 1))] + + " " + + lastnames[(int) (r.nextDouble() * (lastnames.length - 1))]); + } + s1.setImmediate(true); + main.addComponent(s1); + + // contains filter + final ComboBox s2 = new ComboBox("Select with contains filter"); + s2.setDebugId("ComboBoxContainsFilter"); + s2.setFilteringMode(Filtering.FILTERINGMODE_CONTAINS); + s2.setColumns(20); + for (int i = 0; i < 500; i++) { + s2 + .addItem(firstnames[(int) (r.nextDouble() * (firstnames.length - 1))] + + " " + + lastnames[(int) (r.nextDouble() * (lastnames.length - 1))]); + } + s2.setImmediate(true); + main.addComponent(s2); + + // initially empty + final ComboBox s3 = new ComboBox("Initially empty; enter your own"); + s3.setDebugId("EmptyComboBox"); + s3.setColumns(20); + s3.setImmediate(true); + s3.setNewItemsAllowed(true); + main.addComponent(s3); + + } + +} diff --git a/src/com/itmill/toolkit/automatedtests/featurebrowser/EmbeddedBrowserExample.java b/src/com/itmill/toolkit/automatedtests/featurebrowser/EmbeddedBrowserExample.java new file mode 100644 index 0000000000..2134c8cff3 --- /dev/null +++ b/src/com/itmill/toolkit/automatedtests/featurebrowser/EmbeddedBrowserExample.java @@ -0,0 +1,74 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + +package com.itmill.toolkit.automatedtests.featurebrowser; + +import com.itmill.toolkit.data.Property.ValueChangeEvent; +import com.itmill.toolkit.terminal.ExternalResource; +import com.itmill.toolkit.ui.Embedded; +import com.itmill.toolkit.ui.ExpandLayout; +import com.itmill.toolkit.ui.Select; + +/** + * Demonstrates the use of Embedded and "suggesting" Select by creating a simple + * web-browser. Note: does not check for recursion. + * + * @author IT Mill Ltd. + * @see com.itmill.toolkit.ui.Window + */ +public class EmbeddedBrowserExample extends ExpandLayout implements + Select.ValueChangeListener { + + // Default URL to open. + private static final String DEFAULT_URL = "http://www.itmill.com/index_itmill_toolkit.htm"; + + // The embedded page + Embedded emb = new Embedded(); + + public EmbeddedBrowserExample() { + this(new String[] { DEFAULT_URL, + "http://www.itmill.com/index_developers.htm", + "http://toolkit.itmill.com/demo/doc/api/", + "http://www.itmill.com/manual/index.html" }); + } + + public EmbeddedBrowserExample(String[] urls) { + setSizeFull(); + + // create the address combobox + final Select select = new Select(); + // allow input + select.setNewItemsAllowed(true); + // no empty selection + select.setNullSelectionAllowed(false); + // no 'go' -button clicking necessary + select.setImmediate(true); + // add some pre-configured URLs + for (int i = 0; i < urls.length; i++) { + select.addItem(urls[i]); + } + // add to layout + addComponent(select); + // add listener and select initial URL + select.addListener(this); + select.setValue(urls[0]); + + // configure the embedded and add to layout + emb.setType(Embedded.TYPE_BROWSER); + addComponent(emb); + // make the embedded as large as possible + expand(emb); + + } + + public void valueChange(ValueChangeEvent event) { + final String url = (String) event.getProperty().getValue(); + if (url != null) { + // the selected url has changed, let's go there + emb.setSource(new ExternalResource(url)); + } + + } + +} diff --git a/src/com/itmill/toolkit/automatedtests/featurebrowser/FeatureBrowser.java b/src/com/itmill/toolkit/automatedtests/featurebrowser/FeatureBrowser.java new file mode 100644 index 0000000000..4eb7f9e321 --- /dev/null +++ b/src/com/itmill/toolkit/automatedtests/featurebrowser/FeatureBrowser.java @@ -0,0 +1,369 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + +package com.itmill.toolkit.automatedtests.featurebrowser; + +import java.util.HashMap; + +import com.itmill.toolkit.data.Item; +import com.itmill.toolkit.data.Property; +import com.itmill.toolkit.data.Property.ValueChangeEvent; +import com.itmill.toolkit.data.util.HierarchicalContainer; +import com.itmill.toolkit.data.util.IndexedContainer; +import com.itmill.toolkit.terminal.ExternalResource; +import com.itmill.toolkit.terminal.ThemeResource; +import com.itmill.toolkit.ui.AbstractSelect; +import com.itmill.toolkit.ui.Button; +import com.itmill.toolkit.ui.Component; +import com.itmill.toolkit.ui.Embedded; +import com.itmill.toolkit.ui.ExpandLayout; +import com.itmill.toolkit.ui.Label; +import com.itmill.toolkit.ui.Layout; +import com.itmill.toolkit.ui.OrderedLayout; +import com.itmill.toolkit.ui.Select; +import com.itmill.toolkit.ui.SplitPanel; +import com.itmill.toolkit.ui.TabSheet; +import com.itmill.toolkit.ui.Table; +import com.itmill.toolkit.ui.Tree; +import com.itmill.toolkit.ui.Window; +import com.itmill.toolkit.ui.Button.ClickEvent; + +/** + * + * @author IT Mill Ltd. + * @see com.itmill.toolkit.ui.Window + */ +public class FeatureBrowser extends com.itmill.toolkit.Application implements + Select.ValueChangeListener { + + // Property IDs + private static final Object PROPERTY_ID_CATEGORY = "Category"; + private static final Object PROPERTY_ID_NAME = "Name"; + private static final Object PROPERTY_ID_DESC = "Description"; + private static final Object PROPERTY_ID_CLASS = "Class"; + private static final Object PROPERTY_ID_VIEWED = "Viewed"; + + // Global components + private Tree tree; + private Table table; + private TabSheet ts; + + // Example "cache" + private final HashMap exampleInstances = new HashMap(); + private String section; + + // List of examples + private static final Object[][] demos = new Object[][] { + // Category, Name, Desc, Class, Viewed + // Getting started: Labels + { "Getting started", "Labels", "Some variations of Labels", + LabelExample.class }, + // Getting started: Buttons + { "Getting started", "Buttons and links", + "Various Buttons and Links", ButtonExample.class }, + // Getting started: Fields + { "Getting started", "Basic value input", + "TextFields, DateFields, and such", ValueInputExample.class }, + // + { "Getting started", "RichText", "Rich text editing", + RichTextExample.class }, + // Getting started: Selects + { "Getting started", "Choices, choices", + "Some variations of simple selects", SelectExample.class }, + // Layouts + { "Getting started", "Layouts", "Laying out components", + LayoutExample.class }, + // Wrangling data: ComboBox + { "Wrangling data", "ComboBox", "ComboBox - the swiss army select", + ComboBoxExample.class }, + // Wrangling data: Table + { + "Wrangling data", + "Table (\"grid\")", + "Table with bells, whistles, editmode and actions (contextmenu)", + TableExample.class }, + // Wrangling data: Tree + { "Wrangling data", "Tree", "A hierarchy of things", + TreeExample.class }, + // Misc: Notifications + { "Misc", "Notifications", "Notifications can improve usability", + NotificationExample.class }, + // Misc: Caching + { "Misc", "Client caching", "Demonstrating of client-side caching", + ClientCachingExample.class }, + // Misc: Embedded + { "Misc", "Embedding", + "Embedding resources - another site in this case", + EmbeddedBrowserExample.class }, + // Windowing + { "Misc", "Windowing", "About windowing", WindowingExample.class }, + // JavaScript API + { "Misc", "JavaScript API", + "JavaScript to IT Mill Toolkit communication", + JavaScriptAPIExample.class }, + // END + }; + + public void init() { + + // Need to set a theme for ThemeResources to work + setTheme("example"); + + // Create new window for the application and give the window a visible. + final Window main = new Window("IT Mill Toolkit 5"); + main.setDebugId("mainWindow"); + // set as main window + setMainWindow(main); + + final SplitPanel split = new SplitPanel( + SplitPanel.ORIENTATION_HORIZONTAL); + split.setSplitPosition(200, SplitPanel.UNITS_PIXELS); + main.setLayout(split); + + final HashMap sectionIds = new HashMap(); + final HierarchicalContainer container = createContainer(); + final Object rootId = container.addItem(); + Item item = container.getItem(rootId); + Property p = item.getItemProperty(PROPERTY_ID_NAME); + p.setValue("All examples"); + for (int i = 0; i < demos.length; i++) { + final Object[] demo = demos[i]; + final String section = (String) demo[0]; + Object sectionId; + if (sectionIds.containsKey(section)) { + sectionId = sectionIds.get(section); + } else { + sectionId = container.addItem(); + sectionIds.put(section, sectionId); + container.setParent(sectionId, rootId); + item = container.getItem(sectionId); + p = item.getItemProperty(PROPERTY_ID_NAME); + p.setValue(section); + } + final Object id = container.addItem(); + container.setParent(id, sectionId); + initItem(container.getItem(id), demo); + + } + + tree = new Tree(); + tree.setDebugId("FeatureBrowser: Main Tree"); + tree.setSelectable(true); + tree.setMultiSelect(false); + tree.setNullSelectionAllowed(false); + tree.setContainerDataSource(container); + tree.setItemCaptionMode(AbstractSelect.ITEM_CAPTION_MODE_PROPERTY); + tree.setItemCaptionPropertyId(PROPERTY_ID_NAME); + tree.addListener(this); + tree.setImmediate(true); + tree.expandItemsRecursively(rootId); + + split.addComponent(tree); + + final SplitPanel split2 = new SplitPanel(); + split2.setSplitPosition(200, SplitPanel.UNITS_PIXELS); + split.addComponent(split2); + + table = new Table(); + table.setDebugId("FeatureBrowser: Main Table"); + table.setSizeFull(); + table.setColumnReorderingAllowed(true); + table.setColumnCollapsingAllowed(true); + table.setSelectable(true); + table.setMultiSelect(false); + table.setNullSelectionAllowed(false); + try { + table.setContainerDataSource((IndexedContainer) container.clone()); + } catch (final Exception e) { + e.printStackTrace(System.err); + } + // Hide some columns + table.setVisibleColumns(new Object[] { PROPERTY_ID_CATEGORY, + PROPERTY_ID_NAME, PROPERTY_ID_DESC, PROPERTY_ID_VIEWED }); + table.addListener(this); + table.setImmediate(true); + split2.addComponent(table); + + final ExpandLayout exp = new ExpandLayout(); + exp.setMargin(true); + split2.addComponent(exp); + + final OrderedLayout wbLayout = new OrderedLayout( + OrderedLayout.ORIENTATION_HORIZONTAL); + Button b = new Button("Open in sub-window", new Button.ClickListener() { + public void buttonClick(ClickEvent event) { + Component component = (Component) ts.getComponentIterator() + .next(); + String caption = ts.getTabCaption(component); + try { + component = (Component) component.getClass().newInstance(); + } catch (Exception e) { + // Could not create + return; + } + Window w = new Window(caption); + w.setWidth(640); + if (Layout.class.isAssignableFrom(component.getClass())) { + w.setLayout((Layout) component); + } else { + // w.getLayout().getSize().setSizeFull(); + w.addComponent(component); + } + getMainWindow().addWindow(w); + } + }); + b.setStyleName(Button.STYLE_LINK); + wbLayout.addComponent(b); + b = new Button("Open in native window", new Button.ClickListener() { + public void buttonClick(ClickEvent event) { + Component component = (Component) ts.getComponentIterator() + .next(); + final String caption = ts.getTabCaption(component); + Window w = getWindow(caption); + if (w == null) { + try { + component = (Component) component.getClass() + .newInstance(); + } catch (final Exception e) { + // Could not create + return; + } + w = new Window(caption); + w.setName(caption); + if (Layout.class.isAssignableFrom(component.getClass())) { + w.setLayout((Layout) component); + } else { + // w.getLayout().getSize().setSizeFull(); + w.addComponent(component); + } + addWindow(w); + } + getMainWindow().open(new ExternalResource(w.getURL()), caption); + } + }); + b.setStyleName(Button.STYLE_LINK); + wbLayout.addComponent(b); + + exp.addComponent(wbLayout); + exp.setComponentAlignment(wbLayout, OrderedLayout.ALIGNMENT_RIGHT, + OrderedLayout.ALIGNMENT_TOP); + + ts = new TabSheet(); + ts.setSizeFull(); + ts.addTab(new Label(""), "Choose example", null); + exp.addComponent(ts); + exp.expand(ts); + + final Label status = new Label( + "<a href=\"http://www.itmill.com/developers/\">Developer Area</a>" + + " | <a href=\"http://www.itmill.com/documentation/\">Documentation</a>"); + status.setContentMode(Label.CONTENT_XHTML); + exp.addComponent(status); + exp.setComponentAlignment(status, OrderedLayout.ALIGNMENT_RIGHT, + OrderedLayout.ALIGNMENT_VERTICAL_CENTER); + + // select initial section ("All") + tree.setValue(rootId); + + getMainWindow() + .showNotification( + "Welcome", + "Choose an example to begin.<br/><br/>And remember to experiment!", + Window.Notification.TYPE_TRAY_NOTIFICATION); + } + + private void initItem(Item item, Object[] data) { + int p = 0; + Property prop = item.getItemProperty(PROPERTY_ID_CATEGORY); + prop.setValue(data[p++]); + prop = item.getItemProperty(PROPERTY_ID_NAME); + prop.setValue(data[p++]); + prop = item.getItemProperty(PROPERTY_ID_DESC); + prop.setValue(data[p++]); + prop = item.getItemProperty(PROPERTY_ID_CLASS); + prop.setValue(data[p++]); + } + + private HierarchicalContainer createContainer() { + final HierarchicalContainer c = new HierarchicalContainer(); + c.addContainerProperty(PROPERTY_ID_CATEGORY, String.class, null); + c.addContainerProperty(PROPERTY_ID_NAME, String.class, ""); + c.addContainerProperty(PROPERTY_ID_DESC, String.class, ""); + c.addContainerProperty(PROPERTY_ID_CLASS, Class.class, null); + c.addContainerProperty(PROPERTY_ID_VIEWED, Embedded.class, null); + return c; + } + + public void valueChange(ValueChangeEvent event) { + if (event.getProperty() == tree) { + final Object id = tree.getValue(); + final Item item = tree.getItem(id); + // + String newSection; + if (tree.isRoot(id)) { + newSection = ""; // show all sections + } else if (tree.hasChildren(id)) { + newSection = (String) item.getItemProperty(PROPERTY_ID_NAME) + .getValue(); + } else { + newSection = (String) item + .getItemProperty(PROPERTY_ID_CATEGORY).getValue(); + } + + table.setValue(null); + final IndexedContainer c = (IndexedContainer) table + .getContainerDataSource(); + + if (newSection != null && !newSection.equals(section)) { + c.removeAllContainerFilters(); + c.addContainerFilter(PROPERTY_ID_CATEGORY, newSection, false, + true); + } + section = newSection; + if (!tree.hasChildren(id)) { + // Example, not section + // update table selection + table.setValue(id); + } + + } else if (event.getProperty() == table) { + if (table.getValue() != null) { + table.removeListener(this); + tree.setValue(table.getValue()); + table.addListener(this); + final Item item = table.getItem(table.getValue()); + final Class c = (Class) item.getItemProperty(PROPERTY_ID_CLASS) + .getValue(); + final Component component = getComponent(c); + if (component != null) { + final String caption = (String) item.getItemProperty( + PROPERTY_ID_NAME).getValue(); + ts.removeAllComponents(); + ts.addTab(component, caption, null); + } + // update "viewed" state + final Property p = item.getItemProperty(PROPERTY_ID_VIEWED); + if (p.getValue() == null) { + p.setValue(new Embedded("", new ThemeResource( + "icons/ok.png"))); + } + table.requestRepaint(); + } + } + + } + + private Component getComponent(Class componentClass) { + if (!exampleInstances.containsKey(componentClass)) { + try { + final Component c = (Component) componentClass.newInstance(); + exampleInstances.put(componentClass, c); + } catch (final Exception e) { + return null; + } + } + return (Component) exampleInstances.get(componentClass); + } + +} diff --git a/src/com/itmill/toolkit/automatedtests/featurebrowser/JavaScriptAPIExample.java b/src/com/itmill/toolkit/automatedtests/featurebrowser/JavaScriptAPIExample.java new file mode 100644 index 0000000000..15f4e36777 --- /dev/null +++ b/src/com/itmill/toolkit/automatedtests/featurebrowser/JavaScriptAPIExample.java @@ -0,0 +1,95 @@ +/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
+package com.itmill.toolkit.automatedtests.featurebrowser;
+
+import java.util.Date;
+
+import com.itmill.toolkit.terminal.PaintException;
+import com.itmill.toolkit.terminal.PaintTarget;
+import com.itmill.toolkit.ui.Button;
+import com.itmill.toolkit.ui.CustomComponent;
+import com.itmill.toolkit.ui.Label;
+import com.itmill.toolkit.ui.OrderedLayout;
+import com.itmill.toolkit.ui.TextField;
+import com.itmill.toolkit.ui.Button.ClickEvent;
+
+/**
+ * An example using a RichTextArea to edit a Label in XHTML-mode.
+ *
+ */
+public class JavaScriptAPIExample extends CustomComponent {
+
+ public static final String txt = "(more examples will be added here as the APIs are made public)<br/><br/><A href=\"javascript:itmill.forceSync();\">javascript:itmill.forceSync();</A>";
+
+ private final OrderedLayout main;
+ private final Label l;
+ private final TextField editor = new TextField();
+
+ public JavaScriptAPIExample() {
+ // main layout
+ main = new OrderedLayout();
+ main.setMargin(true);
+ setCompositionRoot(main);
+ editor.setRows(7);
+ editor.setColumns(50);
+ // Add the label
+ l = new Label(txt);
+ l.setContentMode(Label.CONTENT_XHTML);
+ main.addComponent(l);
+ // Edit button with inline click-listener
+ Button b = new Button("Edit", new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ // swap Label <-> RichTextArea
+ if (main.getComponentIterator().next() == l) {
+ editor.setValue(l.getValue());
+ main.replaceComponent(l, editor);
+ event.getButton().setCaption("Save");
+ } else {
+ l.setValue(editor.getValue());
+ main.replaceComponent(editor, l);
+ event.getButton().setCaption("Edit");
+ }
+ }
+ });
+ main.addComponent(b);
+ main.setComponentAlignment(b, OrderedLayout.ALIGNMENT_RIGHT,
+ OrderedLayout.ALIGNMENT_VERTICAL_CENTER);
+
+ //
+ Label l = new Label(
+ "This label will update it's server-side value AFTER it's rendered to the client-side. "
+ + "The client will be synchronized on reload, when you click a button, "
+ + "or when itmill.forceSync() is called.") {
+
+ public void paintContent(PaintTarget target) throws PaintException {
+
+ super.paintContent(target);
+ Delay d = new Delay(this);
+ d.start();
+ }
+
+ };
+ main.addComponent(l);
+
+ }
+
+ private class Delay extends Thread {
+ Label label;
+
+ public Delay(Label l) {
+ label = l;
+ }
+
+ public void run() {
+ try {
+ Thread.sleep(500);
+ label.setValue(new Date().toString());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ }
+}
diff --git a/src/com/itmill/toolkit/automatedtests/featurebrowser/LabelExample.java b/src/com/itmill/toolkit/automatedtests/featurebrowser/LabelExample.java new file mode 100644 index 0000000000..ec90f37231 --- /dev/null +++ b/src/com/itmill/toolkit/automatedtests/featurebrowser/LabelExample.java @@ -0,0 +1,93 @@ +/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
+package com.itmill.toolkit.automatedtests.featurebrowser;
+
+import com.itmill.toolkit.ui.CustomComponent;
+import com.itmill.toolkit.ui.GridLayout;
+import com.itmill.toolkit.ui.Label;
+import com.itmill.toolkit.ui.OrderedLayout;
+import com.itmill.toolkit.ui.Panel;
+
+/**
+ * Shows a few variations of Labels, including the effects of XHTML- and
+ * pre-formatted mode.
+ *
+ * @author IT Mill Ltd.
+ */
+public class LabelExample extends CustomComponent {
+
+ private static final String xhtml = "This text has <b>HTML</b> formatting.<br/>"
+ + "A plain <i>Label</i> will show the markup, while a <u>XHTML-mode</u>"
+ + " <i>Label</i> will show the formatted text.";
+
+ private static final String pre = "This text has linebreaks.\n\n"
+ + "They will show up in a preformatted Label,\n"
+ + "but not in a \"plain\" Label.\n\n"
+ + " This is an indented row. \n Same indentation here.";
+
+ public LabelExample() {
+
+ final OrderedLayout main = new OrderedLayout();
+ main.setMargin(true);
+ setCompositionRoot(main);
+
+ final GridLayout g = new GridLayout(2, 4);
+ main.addComponent(g);
+
+ // plain w/o caption
+ Panel p = new Panel("Plain");
+ p.setDebugId(p.getCaption());
+ p.setStyleName(Panel.STYLE_LIGHT);
+ Label l = new Label("A plain label without caption.");
+ l.setDebugId("label1");
+ p.addComponent(l);
+ g.addComponent(p);
+ // plain w/ caption
+ p = new Panel("Plain w/ caption + tooltip");
+ p.setDebugId(p.getCaption());
+ p.setStyleName(Panel.STYLE_LIGHT);
+ l = new Label("A plain label with caption.");
+ l.setCaption("Label caption");
+ l.setDebugId("label2");
+ l.setDescription("This is a description (tooltip) for the label.");
+ p.addComponent(l);
+ g.addComponent(p);
+ // plain w/ xhtml
+ p = new Panel("Plain w/ XHTML content");
+ p.setDebugId(p.getCaption());
+ p.setStyleName(Panel.STYLE_LIGHT);
+ l = new Label(xhtml);
+ l.setDebugId("label3");
+ p.addComponent(l);
+ g.addComponent(p);
+ // xhtml w/ xhtml
+ p = new Panel("XHTML-mode w/ XHTML content");
+ p.setDebugId(p.getCaption());
+ p.setStyleName(Panel.STYLE_LIGHT);
+ l = new Label(xhtml);
+ l.setDebugId("label4");
+ l.setContentMode(Label.CONTENT_XHTML);
+ p.addComponent(l);
+ g.addComponent(p);
+ // plain w/ preformatted
+ p = new Panel("Plain w/ preformatted content");
+ p.setDebugId(p.getCaption());
+ p.setStyleName(Panel.STYLE_LIGHT);
+ l = new Label(pre);
+ l.setDebugId("label5");
+ p.addComponent(l);
+ g.addComponent(p);
+ // preformatted w/ preformatted
+ p = new Panel("Preformatted-mode w/ preformatted content");
+ p.setDebugId(p.getCaption());
+ p.setStyleName(Panel.STYLE_LIGHT);
+ l = new Label(pre);
+ l.setDebugId("label6");
+ l.setContentMode(Label.CONTENT_PREFORMATTED);
+ p.addComponent(l);
+ g.addComponent(p);
+
+ }
+}
diff --git a/src/com/itmill/toolkit/automatedtests/featurebrowser/LayoutExample.java b/src/com/itmill/toolkit/automatedtests/featurebrowser/LayoutExample.java new file mode 100644 index 0000000000..184e3f1812 --- /dev/null +++ b/src/com/itmill/toolkit/automatedtests/featurebrowser/LayoutExample.java @@ -0,0 +1,91 @@ +/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
+package com.itmill.toolkit.automatedtests.featurebrowser;
+
+import com.itmill.toolkit.ui.CustomComponent;
+import com.itmill.toolkit.ui.GridLayout;
+import com.itmill.toolkit.ui.Label;
+import com.itmill.toolkit.ui.OrderedLayout;
+import com.itmill.toolkit.ui.Panel;
+import com.itmill.toolkit.ui.TabSheet;
+
+/**
+ * A few examples of layout possibilities.
+ *
+ * @author IT Mill Ltd.
+ */
+public class LayoutExample extends CustomComponent {
+
+ public LayoutExample() {
+
+ final OrderedLayout main = new OrderedLayout();
+ main.setMargin(true);
+ setCompositionRoot(main);
+
+ final GridLayout g = new GridLayout(2, 5);
+ main.addComponent(g);
+
+ // panel
+ Panel p = new Panel("This is a normal panel");
+ p.setDebugId("NormalPanel");
+ Label l = new Label("A normal panel.");
+ p.addComponent(l);
+ g.addComponent(p);
+ // lightpanel
+ p = new Panel("This is a light panel");
+ p.setDebugId("LightPanel");
+ p.setStyleName(Panel.STYLE_LIGHT);
+ l = new Label("A light-style panel.");
+ p.addComponent(l);
+ g.addComponent(p);
+
+ TabSheet ts = new TabSheet();
+ g.addComponent(ts, 0, 1, 1, 1);
+
+ OrderedLayout ol = new OrderedLayout();
+ ol.setDebugId("VerticalOrderedLayout");
+ ol.setMargin(true);
+ ol.addComponent(new Label("Component 1"));
+ ol.addComponent(new Label("Component 2"));
+ ol.addComponent(new Label("Component 3"));
+ ts.addTab(ol, "Vertical OrderedLayout", null);
+
+ ol = new OrderedLayout(OrderedLayout.ORIENTATION_HORIZONTAL);
+ ol.setDebugId("HorizontalOrderedLayout");
+ ol.setMargin(true);
+ ol.addComponent(new Label("Component 1"));
+ ol.addComponent(new Label("Component 2"));
+ ol.addComponent(new Label("Component 3"));
+ ts.addTab(ol, "Horizontal OrderedLayout", null);
+
+ final GridLayout gl = new GridLayout(3, 3);
+ gl.setDebugId("GridLayout");
+ gl.setMargin(true);
+ gl.addComponent(new Label("Component 1.1"));
+ gl.addComponent(new Label("Component 1.2"));
+ gl.addComponent(new Label("Component 1.3"));
+ gl.addComponent(new Label("Component 2.2"), 1, 1);
+ gl.addComponent(new Label("Component 3.1"), 0, 2);
+ gl.addComponent(new Label("Component 3.3"), 2, 2);
+ ts.addTab(gl, "GridLayout", null);
+
+ /*- TODO spitpanel removed for now - do we need it here?
+ ts = new TabSheet();
+ ts.setHeight(150);
+ g.addComponent(ts, 0, 2, 1, 2);
+
+ SplitPanel sp = new SplitPanel();
+ sp.addComponent(new Label("Component 1"));
+ sp.addComponent(new Label("Component 2"));
+ ts.addTab(sp, "Vertical SplitPanel", null);
+
+ sp = new SplitPanel(SplitPanel.ORIENTATION_HORIZONTAL);
+ sp.addComponent(new Label("Component 1"));
+ sp.addComponent(new Label("Component 2"));
+ ts.addTab(sp, "Horizontal SplitPanel", null);
+ -*/
+
+ }
+}
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); + } +} diff --git a/src/com/itmill/toolkit/automatedtests/featurebrowser/RichTextExample.java b/src/com/itmill/toolkit/automatedtests/featurebrowser/RichTextExample.java new file mode 100644 index 0000000000..edc65899f3 --- /dev/null +++ b/src/com/itmill/toolkit/automatedtests/featurebrowser/RichTextExample.java @@ -0,0 +1,60 @@ +/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
+package com.itmill.toolkit.automatedtests.featurebrowser;
+
+import com.itmill.toolkit.ui.Button;
+import com.itmill.toolkit.ui.CustomComponent;
+import com.itmill.toolkit.ui.Label;
+import com.itmill.toolkit.ui.OrderedLayout;
+import com.itmill.toolkit.ui.RichTextArea;
+import com.itmill.toolkit.ui.Button.ClickEvent;
+
+/**
+ * An example using a RichTextArea to edit a Label in XHTML-mode.
+ *
+ */
+public class RichTextExample extends CustomComponent {
+
+ public static final String txt = "<h1>RichText editor example</h1>"
+ + "To edit this text, press the <b>Edit</b> button below."
+ + "<br/>"
+ + "See the <A href=\"http://www.itmill.com/documentation/itmill-toolkit-5-reference-manual/\">manual</a> "
+ + "for more information.";
+
+ private final OrderedLayout main;
+ private final Label l;
+ private final RichTextArea editor = new RichTextArea();
+ private final Button b;
+
+ public RichTextExample() {
+ // main layout
+ main = new OrderedLayout();
+ main.setMargin(true);
+ setCompositionRoot(main);
+ // Add the label
+ l = new Label(txt);
+ l.setContentMode(Label.CONTENT_XHTML);
+ main.addComponent(l);
+ // Edit button with inline click-listener
+ b = new Button("Edit", new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ // swap Label <-> RichTextArea
+ if (main.getComponentIterator().next() == l) {
+ editor.setValue(l.getValue());
+ main.replaceComponent(l, editor);
+ b.setCaption("Save");
+ } else {
+ l.setValue(editor.getValue());
+ main.replaceComponent(editor, l);
+ b.setCaption("Edit");
+ }
+ }
+ });
+ main.addComponent(b);
+ main.setComponentAlignment(b, OrderedLayout.ALIGNMENT_RIGHT,
+ OrderedLayout.ALIGNMENT_VERTICAL_CENTER);
+ }
+
+}
diff --git a/src/com/itmill/toolkit/automatedtests/featurebrowser/SelectExample.java b/src/com/itmill/toolkit/automatedtests/featurebrowser/SelectExample.java new file mode 100644 index 0000000000..c6369562ad --- /dev/null +++ b/src/com/itmill/toolkit/automatedtests/featurebrowser/SelectExample.java @@ -0,0 +1,107 @@ +/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
+package com.itmill.toolkit.automatedtests.featurebrowser;
+
+import com.itmill.toolkit.data.Property.ValueChangeEvent;
+import com.itmill.toolkit.ui.AbstractSelect;
+import com.itmill.toolkit.ui.ComboBox;
+import com.itmill.toolkit.ui.CustomComponent;
+import com.itmill.toolkit.ui.Field;
+import com.itmill.toolkit.ui.ListSelect;
+import com.itmill.toolkit.ui.NativeSelect;
+import com.itmill.toolkit.ui.OptionGroup;
+import com.itmill.toolkit.ui.OrderedLayout;
+import com.itmill.toolkit.ui.Panel;
+import com.itmill.toolkit.ui.TwinColSelect;
+
+/**
+ * Shows some basic fields for value input; TextField, DateField, Slider...
+ *
+ * @author IT Mill Ltd.
+ */
+public class SelectExample extends CustomComponent {
+
+ // listener that shows a value change notification
+ private final Field.ValueChangeListener listener = new Field.ValueChangeListener() {
+ public void valueChange(ValueChangeEvent event) {
+ getWindow().showNotification("" + event.getProperty().getValue());
+ }
+ };
+
+ public SelectExample() {
+ final OrderedLayout main = new OrderedLayout();
+ main.setMargin(true);
+ setCompositionRoot(main);
+
+ final OrderedLayout horiz = new OrderedLayout(
+ OrderedLayout.ORIENTATION_HORIZONTAL);
+ main.addComponent(horiz);
+ final Panel single = new Panel("Single selects");
+ single.setStyleName(Panel.STYLE_LIGHT);
+ horiz.addComponent(single);
+ final Panel multi = new Panel("Multi selects");
+ multi.setStyleName(Panel.STYLE_LIGHT);
+ horiz.addComponent(multi);
+
+ // radio button group
+ AbstractSelect sel = new OptionGroup("OptionGroup");
+ sel.setDebugId("RadioButtons");
+ initSelect(sel);
+ single.addComponent(sel);
+ // checkbox group
+ sel = new OptionGroup("OptionGroup");
+ sel.setDebugId("OptionGroup");
+ sel.setMultiSelect(true); // TODO: throws if set after listener - why?
+ initSelect(sel);
+ multi.addComponent(sel);
+ // single-select list
+ sel = new ListSelect("ListSelect");
+ sel.setDebugId("SingleListSelect");
+ ((ListSelect) sel).setColumns(15);
+ initSelect(sel);
+ single.addComponent(sel);
+ // multi-select list
+ sel = new ListSelect("ListSelect");
+ sel.setDebugId("MultiListSelect");
+ ((ListSelect) sel).setColumns(15);
+ sel.setMultiSelect(true);
+ initSelect(sel);
+ multi.addComponent(sel);
+ // native-style dropdows
+ sel = new NativeSelect("NativeSelect");
+ sel.setDebugId("NativeSelect");
+ ((NativeSelect) sel).setColumns(15);
+ initSelect(sel);
+ single.addComponent(sel);
+ // combobox
+ sel = new ComboBox("ComboBox");
+ sel.setDebugId("ComboBox");
+ ((ComboBox) sel).setColumns(15);
+ initSelect(sel);
+ single.addComponent(sel);
+ // "twin column" select
+ sel = new TwinColSelect("TwinColSelect");
+ sel.setDebugId("TwinColSelect");
+ ((TwinColSelect) sel).setColumns(15);
+ initSelect(sel);
+ multi.addComponent(sel);
+ }
+
+ /*
+ * Initialize select with some values, make immediate and add listener.
+ */
+ private void initSelect(AbstractSelect sel) {
+ for (int i = 1; i <= 5; i++) {
+ sel.addItem("Item " + i);
+ }
+ // select one item
+ sel.select("Item 1");
+
+ // make immediate, add listener
+ sel.setImmediate(true);
+ sel.addListener(listener);
+ }
+
+}
diff --git a/src/com/itmill/toolkit/automatedtests/featurebrowser/TableExample.java b/src/com/itmill/toolkit/automatedtests/featurebrowser/TableExample.java new file mode 100644 index 0000000000..83f9ca1b76 --- /dev/null +++ b/src/com/itmill/toolkit/automatedtests/featurebrowser/TableExample.java @@ -0,0 +1,295 @@ +/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
+package com.itmill.toolkit.automatedtests.featurebrowser;
+
+import java.util.Iterator;
+import java.util.Random;
+import java.util.Set;
+
+import com.itmill.toolkit.data.Item;
+import com.itmill.toolkit.data.Property;
+import com.itmill.toolkit.event.Action;
+import com.itmill.toolkit.ui.Button;
+import com.itmill.toolkit.ui.CheckBox;
+import com.itmill.toolkit.ui.CustomComponent;
+import com.itmill.toolkit.ui.OrderedLayout;
+import com.itmill.toolkit.ui.Table;
+import com.itmill.toolkit.ui.Button.ClickEvent;
+
+/**
+ * Table example.
+ *
+ * @author IT Mill Ltd.
+ */
+public class TableExample extends CustomComponent implements Action.Handler,
+ Button.ClickListener {
+
+ // Actions
+ private static final Action ACTION_SAVE = new Action("Save");
+ private static final Action ACTION_DELETE = new Action("Delete");
+ private static final Action ACTION_HIRE = new Action("Hire");
+ // Action sets
+ private static final Action[] ACTIONS_NOHIRE = new Action[] { ACTION_SAVE,
+ ACTION_DELETE };
+ private static final Action[] ACTIONS_HIRE = new Action[] { ACTION_HIRE,
+ ACTION_SAVE, ACTION_DELETE };
+ // Properties
+ private static final Object PROPERTY_SPECIES = "Species";
+ private static final Object PROPERTY_TYPE = "Type";
+ private static final Object PROPERTY_KIND = "Kind";
+ private static final Object PROPERTY_HIRED = "Hired";
+
+ // "global" components
+ Table source;
+ Table saved;
+ Button saveSelected;
+ Button hireSelected;
+ Button deleteSelected;
+ Button deselect;
+
+ public TableExample() {
+ // main layout
+ final OrderedLayout main = new OrderedLayout();
+ main.setMargin(true);
+ setCompositionRoot(main);
+
+ // "source" table with bells & whistlesenabled
+ source = new Table("All creatures");
+ source.setPageLength(7);
+ source.setWidth(550);
+ source.setColumnCollapsingAllowed(true);
+ source.setColumnReorderingAllowed(true);
+ source.setSelectable(true);
+ source.setMultiSelect(true);
+ source.setRowHeaderMode(Table.ROW_HEADER_MODE_ID);
+ fillTable(source);
+ source.addActionHandler(this);
+ main.addComponent(source);
+ source.setDebugId("AllCreatures");
+
+ // x-selected button row
+ final OrderedLayout horiz = new OrderedLayout(
+ OrderedLayout.ORIENTATION_HORIZONTAL);
+ horiz.setMargin(false, false, true, false);
+ main.addComponent(horiz);
+ saveSelected = new Button("Save selected");
+ saveSelected.setStyleName(Button.STYLE_LINK);
+ saveSelected.addListener(this);
+ horiz.addComponent(saveSelected);
+ hireSelected = new Button("Hire selected");
+ hireSelected.setStyleName(Button.STYLE_LINK);
+ hireSelected.addListener(this);
+ horiz.addComponent(hireSelected);
+ deleteSelected = new Button("Delete selected");
+ deleteSelected.setStyleName(Button.STYLE_LINK);
+ deleteSelected.addListener(this);
+ horiz.addComponent(deleteSelected);
+ deselect = new Button("Deselect all");
+ deselect.setStyleName(Button.STYLE_LINK);
+ deselect.addListener(this);
+ horiz.addComponent(deselect);
+ final CheckBox editmode = new CheckBox("Editmode ");
+ editmode.setDebugId("editMode");
+ editmode.addListener(new CheckBox.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ source.setEditable(((Boolean) event.getButton().getValue())
+ .booleanValue());
+ }
+ });
+ editmode.setImmediate(true);
+ horiz.addComponent(editmode);
+
+ // "saved" table, minimalistic
+ saved = new Table("Saved creatures");
+ saved.setPageLength(5);
+ saved.setWidth(550);
+ saved.setSelectable(false);
+ saved.setColumnHeaderMode(Table.COLUMN_HEADER_MODE_HIDDEN);
+ saved.setRowHeaderMode(Table.ROW_HEADER_MODE_ID);
+ initProperties(saved);
+ saved.addActionHandler(this);
+ main.addComponent(saved);
+ saved.setDebugId("SavedCreatures");
+
+ final CheckBox b = new CheckBox("Modify saved creatures");
+ b.setDebugId("modifySavedCreatures");
+ b.addListener(new CheckBox.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ saved.setEditable(((Boolean) event.getButton().getValue())
+ .booleanValue());
+ }
+ });
+ b.setImmediate(true);
+ main.addComponent(b);
+
+ }
+
+ // set up the properties (columns)
+ private void initProperties(Table table) {
+ table.addContainerProperty(PROPERTY_SPECIES, String.class, "");
+ table.addContainerProperty(PROPERTY_TYPE, String.class, "");
+ table.addContainerProperty(PROPERTY_KIND, String.class, "");
+ table
+ .addContainerProperty(PROPERTY_HIRED, Boolean.class,
+ Boolean.FALSE);
+ }
+
+ // fill the table with some random data
+ private void fillTable(Table table) {
+ initProperties(table);
+
+ final String[] sp = new String[] { "Fox", "Dog", "Cat", "Moose",
+ "Penguin", "Cow" };
+ final String[] ty = new String[] { "Quick", "Lazy", "Sleepy",
+ "Fidgety", "Crazy", "Kewl" };
+ final String[] ki = new String[] { "Jumping", "Walking", "Sleeping",
+ "Skipping", "Dancing" };
+
+ Random r = new Random(5);
+
+ for (int i = 0; i < 100; i++) {
+ final String s = sp[(int) (r.nextDouble() * sp.length)];
+ final String t = ty[(int) (r.nextDouble() * ty.length)];
+ final String k = ki[(int) (r.nextDouble() * ki.length)];
+ table.addItem(new Object[] { s, t, k, Boolean.FALSE }, new Integer(
+ i));
+ }
+
+ }
+
+ // Called for each item (row), returns valid actions for that item
+ public Action[] getActions(Object target, Object sender) {
+ if (sender == source) {
+ final Item item = source.getItem(target);
+ // save, delete, and hire if not already hired
+ if (item != null
+ && item.getItemProperty(PROPERTY_HIRED).getValue() == Boolean.FALSE) {
+ return ACTIONS_HIRE;
+ } else {
+ return ACTIONS_NOHIRE;
+ }
+ } else {
+ // "saved" table only has one action
+ return new Action[] { ACTION_DELETE };
+ }
+ }
+
+ // called when an action is invoked on an item (row)
+ public void handleAction(Action action, Object sender, Object target) {
+ if (sender == source) {
+ Item item = source.getItem(target);
+ if (action == ACTION_HIRE) {
+ // set HIRED property to true
+ item.getItemProperty(PROPERTY_HIRED).setValue(Boolean.TRUE);
+ source.requestRepaint();
+ if (saved.containsId(target)) {
+ item = saved.getItem(target);
+ item.getItemProperty(PROPERTY_HIRED).setValue(Boolean.TRUE);
+ saved.requestRepaint();
+ }
+ getWindow().showNotification("Hired", "" + item);
+
+ } else if (action == ACTION_SAVE) {
+ if (saved.containsId(target)) {
+ // let's not save twice
+ getWindow().showNotification("Already saved", "" + item);
+ return;
+ }
+ // "manual" copy of the item properties we want
+ final Item added = saved.addItem(target);
+ Property p = added.getItemProperty(PROPERTY_SPECIES);
+ p.setValue(item.getItemProperty(PROPERTY_SPECIES).getValue());
+ p = added.getItemProperty(PROPERTY_TYPE);
+ p.setValue(item.getItemProperty(PROPERTY_TYPE).getValue());
+ p = added.getItemProperty(PROPERTY_KIND);
+ p.setValue(item.getItemProperty(PROPERTY_KIND).getValue());
+ p = added.getItemProperty(PROPERTY_HIRED);
+ p.setValue(item.getItemProperty(PROPERTY_HIRED).getValue());
+ getWindow().showNotification("Saved", "" + item);
+ } else {
+ // ACTION_DELETE
+ getWindow().showNotification("Deleted ", "" + item);
+ source.removeItem(target);
+ }
+
+ } else {
+ // sender==saved
+ if (action == ACTION_DELETE) {
+ final Item item = saved.getItem(target);
+ getWindow().showNotification("Deleted", "" + item);
+ saved.removeItem(target);
+ }
+ }
+ }
+
+ public void buttonClick(ClickEvent event) {
+ final Button b = event.getButton();
+ if (b == deselect) {
+ source.setValue(null);
+ } else if (b == saveSelected) {
+ // loop each selected and copy to "saved" table
+ final Set selected = (Set) source.getValue();
+ int s = 0;
+ for (final Iterator it = selected.iterator(); it.hasNext();) {
+ final Object id = it.next();
+ if (!saved.containsId(id)) {
+ final Item item = source.getItem(id);
+ final Item added = saved.addItem(id);
+ // "manual" copy of the properties we want
+ Property p = added.getItemProperty(PROPERTY_SPECIES);
+ p.setValue(item.getItemProperty(PROPERTY_SPECIES)
+ .getValue());
+ p = added.getItemProperty(PROPERTY_TYPE);
+ p.setValue(item.getItemProperty(PROPERTY_TYPE).getValue());
+ p = added.getItemProperty(PROPERTY_KIND);
+ p.setValue(item.getItemProperty(PROPERTY_KIND).getValue());
+ p = added.getItemProperty(PROPERTY_HIRED);
+ p.setValue(item.getItemProperty(PROPERTY_HIRED).getValue());
+ s++;
+ }
+ }
+ getWindow().showNotification("Saved " + s);
+ saved.requestRepaint();
+
+ } else if (b == hireSelected) {
+ // loop each selected and set property HIRED to true
+ int s = 0;
+ final Set selected = (Set) source.getValue();
+ for (final Iterator it = selected.iterator(); it.hasNext();) {
+ final Object id = it.next();
+ Item item = source.getItem(id);
+ final Property p = item.getItemProperty(PROPERTY_HIRED);
+ if (p.getValue() == Boolean.FALSE) {
+ p.setValue(Boolean.TRUE);
+ source.requestRepaint();
+ s++;
+ }
+ if (saved.containsId(id)) {
+ // also update "saved" table
+ item = saved.getItem(id);
+ item.getItemProperty(PROPERTY_HIRED).setValue(Boolean.TRUE);
+ saved.requestRepaint();
+ }
+ }
+ getWindow().showNotification("Hired " + s);
+
+ } else {
+ // loop trough selected and delete
+ int s = 0;
+ final Set selected = (Set) source.getValue();
+ for (final Iterator it = selected.iterator(); it.hasNext();) {
+ final Object id = it.next();
+ if (source.containsId(id)) {
+ s++;
+ source.removeItem(id);
+ source.requestRepaint();
+ }
+ }
+ getWindow().showNotification("Deleted " + s);
+ }
+
+ }
+
+}
diff --git a/src/com/itmill/toolkit/automatedtests/featurebrowser/TreeExample.java b/src/com/itmill/toolkit/automatedtests/featurebrowser/TreeExample.java new file mode 100644 index 0000000000..f5c0bd5042 --- /dev/null +++ b/src/com/itmill/toolkit/automatedtests/featurebrowser/TreeExample.java @@ -0,0 +1,161 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + +package com.itmill.toolkit.automatedtests.featurebrowser; + +import com.itmill.toolkit.data.Item; +import com.itmill.toolkit.data.Property; +import com.itmill.toolkit.data.Property.ValueChangeEvent; +import com.itmill.toolkit.event.Action; +import com.itmill.toolkit.ui.AbstractSelect; +import com.itmill.toolkit.ui.CustomComponent; +import com.itmill.toolkit.ui.Label; +import com.itmill.toolkit.ui.OrderedLayout; +import com.itmill.toolkit.ui.Panel; +import com.itmill.toolkit.ui.TextField; +import com.itmill.toolkit.ui.Tree; + +/** + * Demonstrates basic Tree -functionality. Actions are used for add/remove item + * functionality, and a ValueChangeListener reacts to both the Tree and the + * TextField. + */ +public class TreeExample extends CustomComponent implements Action.Handler, + Tree.ValueChangeListener { + + private static final Action ADD = new Action("Add item"); + private static final Action DELETE = new Action("Delete item"); + private static final Action[] actions = new Action[] { ADD, DELETE }; + + // Id for the caption property + private static final Object CAPTION_PROPERTY = "caption"; + + private static final String desc = "Try both right- and left-click!"; + + Tree tree; + TextField editor; + + public TreeExample() { + final OrderedLayout main = new OrderedLayout( + OrderedLayout.ORIENTATION_HORIZONTAL); + main.setDebugId("mainLayout"); + main.setMargin(true); + setCompositionRoot(main); + + // Panel w/ Tree + Panel p = new Panel("Select item"); + p.setStyleName(Panel.STYLE_LIGHT); + p.setWidth(250); + // Description + p.addComponent(new Label(desc)); + // Tree with a few items + tree = new Tree(); + tree.setDebugId("tree"); + tree.setImmediate(true); + // we'll use a property for caption instead of the item id ("value"), + // so that multiple items can have the same caption + tree.addContainerProperty(CAPTION_PROPERTY, String.class, ""); + tree.setItemCaptionMode(AbstractSelect.ITEM_CAPTION_MODE_PROPERTY); + tree.setItemCaptionPropertyId(CAPTION_PROPERTY); + for (int i = 1; i <= 3; i++) { + final Object id = addCaptionedItem("Section " + i, null); + tree.expandItem(id); + addCaptionedItem("Team A", id); + addCaptionedItem("Team B", id); + } + // listen for selections + tree.addListener(this); + // "context menu" + tree.addActionHandler(this); + p.addComponent(tree); + main.addComponent(p); + + // Panel w/ TextField ("editor") + p = new Panel("Edit item caption"); + p.setStyleName(Panel.STYLE_LIGHT); + editor = new TextField(); + // make immediate, instead of adding an "apply" button + editor.setImmediate(true); + editor.setEnabled(false); + editor.setColumns(15); + p.addComponent(editor); + main.addComponent(p); + } + + public Action[] getActions(Object target, Object sender) { + // We can provide different actions for each target (item), but we'll + // use the same actions all the time. + return actions; + } + + public void handleAction(Action action, Object sender, Object target) { + if (action == DELETE) { + tree.removeItem(target); + } else { + // Add + final Object id = addCaptionedItem("New Item", target); + tree.expandItem(target); + tree.setValue(id); + editor.focus(); + } + } + + public void valueChange(ValueChangeEvent event) { + final Object id = tree.getValue(); // selected item id + if (event.getProperty() == tree) { + // a Tree item was (un) selected + if (id == null) { + // no selecteion, disable TextField + editor.removeListener(this); + editor.setValue(""); + editor.setEnabled(false); + } else { + // item selected + // first remove previous listener + editor.removeListener(this); + // enable TextField and update value + editor.setEnabled(true); + final Item item = tree.getItem(id); + editor.setValue(item.getItemProperty(CAPTION_PROPERTY) + .getValue()); + // listen for TextField changes + editor.addListener(this); + editor.focus(); + } + } else { + // TextField + if (id != null) { + final Item item = tree.getItem(id); + final Property p = item.getItemProperty(CAPTION_PROPERTY); + p.setValue(editor.getValue()); + tree.requestRepaint(); + } + + } + } + + /** + * Helper to add an item with specified caption and (optional) parent. + * + * @param caption + * The item caption + * @param parent + * The (optional) parent item id + * @return the created item's id + */ + private Object addCaptionedItem(String caption, Object parent) { + // add item, let tree decide id + final Object id = tree.addItem(); + // get the created item + final Item item = tree.getItem(id); + // set our "caption" property + final Property p = item.getItemProperty(CAPTION_PROPERTY); + p.setValue(caption); + if (parent != null) { + tree.setParent(id, parent); + } + return id; + } + +} diff --git a/src/com/itmill/toolkit/automatedtests/featurebrowser/ValueInputExample.java b/src/com/itmill/toolkit/automatedtests/featurebrowser/ValueInputExample.java new file mode 100644 index 0000000000..dc5ad33456 --- /dev/null +++ b/src/com/itmill/toolkit/automatedtests/featurebrowser/ValueInputExample.java @@ -0,0 +1,151 @@ +/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
+package com.itmill.toolkit.automatedtests.featurebrowser;
+
+import com.itmill.toolkit.data.Property.ValueChangeEvent;
+import com.itmill.toolkit.ui.CustomComponent;
+import com.itmill.toolkit.ui.DateField;
+import com.itmill.toolkit.ui.Field;
+import com.itmill.toolkit.ui.InlineDateField;
+import com.itmill.toolkit.ui.OrderedLayout;
+import com.itmill.toolkit.ui.Panel;
+import com.itmill.toolkit.ui.Slider;
+import com.itmill.toolkit.ui.TextField;
+import com.itmill.toolkit.ui.Window.Notification;
+
+/**
+ * Shows some basic fields for value input; TextField, DateField, Slider...
+ *
+ * @author IT Mill Ltd.
+ */
+public class ValueInputExample extends CustomComponent {
+
+ public ValueInputExample() {
+ final OrderedLayout main = new OrderedLayout();
+ main.setMargin(true);
+ setCompositionRoot(main);
+
+ // listener that shows a value change notification
+ final Field.ValueChangeListener listener = new Field.ValueChangeListener() {
+ public void valueChange(ValueChangeEvent event) {
+ getWindow().showNotification("Received",
+ "<pre>" + event.getProperty().getValue() + "</pre>",
+ Notification.TYPE_WARNING_MESSAGE);
+ }
+ };
+
+ // TextField
+ OrderedLayout horiz = new OrderedLayout(
+ OrderedLayout.ORIENTATION_HORIZONTAL);
+ main.addComponent(horiz);
+ Panel left = new Panel("TextField");
+ left.setStyleName(Panel.STYLE_LIGHT);
+ horiz.addComponent(left);
+ Panel right = new Panel("multiline");
+ right.setStyleName(Panel.STYLE_LIGHT);
+ horiz.addComponent(right);
+ // basic TextField
+ TextField tf = new TextField("Basic");
+ tf.setDebugId("BasicTextField");
+ tf.setColumns(15);
+ tf.setImmediate(true);
+ tf.addListener(listener);
+ left.addComponent(tf);
+ // multiline TextField a.k.a TextArea
+ tf = new TextField("Area");
+ tf.setDebugId("AreaTextField");
+ tf.setColumns(15);
+ tf.setRows(5);
+ tf.setImmediate(true);
+ tf.addListener(listener);
+ right.addComponent(tf);
+
+ // DateFields
+ horiz = new OrderedLayout(OrderedLayout.ORIENTATION_HORIZONTAL);
+ main.addComponent(horiz);
+ left = new Panel("DateField");
+ left.setStyleName(Panel.STYLE_LIGHT);
+ horiz.addComponent(left);
+ right = new Panel("inline");
+ right.setStyleName(Panel.STYLE_LIGHT);
+ horiz.addComponent(right);
+ // default
+ DateField df = new DateField("Day resolution");
+ df.setDebugId("DayResolutionDateField");
+ df.addListener(listener);
+ df.setImmediate(true);
+ df.setResolution(DateField.RESOLUTION_DAY);
+ left.addComponent(df);
+ // minute
+ df = new DateField("Minute resolution");
+ df.setDebugId("MinuteResolutionDateField");
+ df.addListener(listener);
+ df.setImmediate(true);
+ df.setResolution(DateField.RESOLUTION_MIN);
+ left.addComponent(df);
+ // year
+ df = new DateField("Year resolution");
+ df.setDebugId("YearResolutionDateField");
+ df.addListener(listener);
+ df.setImmediate(true);
+ df.setResolution(DateField.RESOLUTION_YEAR);
+ left.addComponent(df);
+ // msec
+ df = new DateField("Millisecond resolution");
+ df.setDebugId("MillisecondResolutionDateField");
+ df.addListener(listener);
+ df.setImmediate(true);
+ df.setResolution(DateField.RESOLUTION_MSEC);
+ left.addComponent(df);
+ // Inline
+ df = new InlineDateField();
+ df.setDebugId("InlineDateField");
+ df.addListener(listener);
+ df.setImmediate(true);
+ right.addComponent(df);
+
+ // Slider
+ left = new Panel("Slider");
+ left.setStyleName(Panel.STYLE_LIGHT);
+ main.addComponent(left);
+ // int slider
+ Slider slider = new Slider(0, 100);
+ slider.setDebugId("Slider1");
+ slider.setSize(300);
+ slider.setImmediate(true);
+ slider.addListener(new Slider.ValueChangeListener() {
+ public void valueChange(ValueChangeEvent event) {
+ // update caption when value changes
+ final Slider s = (Slider) event.getProperty();
+ s.setCaption("Value: " + s.getValue());
+ }
+ });
+ try {
+ slider.setValue(20);
+ } catch (final Exception e) {
+ e.printStackTrace(System.err);
+ }
+ left.addComponent(slider);
+ // double slider
+ slider = new Slider(0.0, 1.0, 1);
+ slider.setDebugId("Slider2");
+ slider.setImmediate(true);
+ slider.addListener(new Slider.ValueChangeListener() {
+ public void valueChange(ValueChangeEvent event) {
+ // update caption when value changes
+ final Slider s = (Slider) event.getProperty();
+ s.setCaption("Value: " + s.getValue());
+ }
+ });
+ try {
+ slider.setValue(0.5);
+ } catch (final Exception e) {
+ e.printStackTrace(System.err);
+ }
+ left.addComponent(slider);
+
+ }
+
+}
diff --git a/src/com/itmill/toolkit/automatedtests/featurebrowser/WindowingExample.java b/src/com/itmill/toolkit/automatedtests/featurebrowser/WindowingExample.java new file mode 100644 index 0000000000..9da87d87a6 --- /dev/null +++ b/src/com/itmill/toolkit/automatedtests/featurebrowser/WindowingExample.java @@ -0,0 +1,104 @@ +/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
+package com.itmill.toolkit.automatedtests.featurebrowser;
+
+import java.net.URL;
+
+import com.itmill.toolkit.terminal.ExternalResource;
+import com.itmill.toolkit.ui.Button;
+import com.itmill.toolkit.ui.CustomComponent;
+import com.itmill.toolkit.ui.Label;
+import com.itmill.toolkit.ui.OrderedLayout;
+import com.itmill.toolkit.ui.Window;
+import com.itmill.toolkit.ui.Button.ClickEvent;
+
+/**
+ * @author marc
+ *
+ */
+public class WindowingExample extends CustomComponent {
+
+ public static final String txt = "<p>There are two main types of windows: application-level windows, and"
+ + "\"subwindows\". </p><p> A subwindow is rendered as a \"inline\" popup window"
+ + " within the (native) browser window to which it was added. You can create"
+ + " a subwindow by creating a new Window and adding it to a application-level window, for instance"
+ + " your main window. </p><p> In contrast, you create a application-level window by"
+ + " creating a new Window and adding it to the Application. Application-level"
+ + " windows are not shown by default - you need to open a browser window for"
+ + " the url representing the window. You can think of the application-level"
+ + " windows as separate views into your application - and a way to create a"
+ + " \"native\" browser window. </p><p> Depending on your needs, it's also"
+ + " possible to create a new window instance (with it's own internal state)"
+ + " for each new (native) browser window, or you can share the same instance"
+ + " (and state) between several browser windows (the latter is most useful"
+ + " for read-only views).</p>";
+
+ private URL windowUrl = null;
+
+ public WindowingExample() {
+ final OrderedLayout main = new OrderedLayout();
+ main.setMargin(true);
+ setCompositionRoot(main);
+
+ final Label l = new Label(txt);
+ l.setContentMode(Label.CONTENT_XHTML);
+ main.addComponent(l);
+
+ main.addComponent(new Button("Create a new subwindow",
+ new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ final Window w = new Window("Subwindow");
+ final Label l = new Label(txt);
+ l.setContentMode(Label.CONTENT_XHTML);
+ w.addComponent(l);
+ getApplication().getMainWindow().addWindow(w);
+ }
+ }));
+ main.addComponent(new Button("Create a new modal window",
+ new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ final Window w = new Window("Modal window");
+ w.setModal(true);
+ final Label l = new Label(txt);
+ l.setContentMode(Label.CONTENT_XHTML);
+ w.addComponent(l);
+ getApplication().getMainWindow().addWindow(w);
+ }
+ }));
+ main.addComponent(new Button(
+ "Open a application-level window, with shared state",
+ new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ if (windowUrl == null) {
+ final Window w = new Window("Subwindow");
+ final Label l = new Label(txt);
+ l.setContentMode(Label.CONTENT_XHTML);
+ w.addComponent(l);
+ getApplication().addWindow(w);
+ windowUrl = w.getURL();
+ }
+ getApplication().getMainWindow().open(
+ new ExternalResource(windowUrl), "_new");
+ }
+ }));
+ main.addComponent(new Button(
+ "Create a new application-level window, with it's own state",
+ new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ final Window w = new Window("Subwindow");
+ getApplication().addWindow(w);
+ final Label l = new Label(
+ "Each opened window has its own"
+ + " name, and is accessed trough its own uri.");
+ l.setCaption("Window " + w.getName());
+ w.addComponent(l);
+ getApplication().getMainWindow().open(
+ new ExternalResource(w.getURL()), "_new");
+ }
+ }));
+
+ }
+
+}
diff --git a/src/com/itmill/toolkit/automatedtests/robustness/Robustness.java b/src/com/itmill/toolkit/automatedtests/robustness/Robustness.java new file mode 100644 index 0000000000..c8034e2677 --- /dev/null +++ b/src/com/itmill/toolkit/automatedtests/robustness/Robustness.java @@ -0,0 +1,90 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + +package com.itmill.toolkit.automatedtests.robustness; + +import com.itmill.toolkit.automatedtests.util.Log; +import com.itmill.toolkit.automatedtests.util.RandomComponents; +import com.itmill.toolkit.ui.Button; +import com.itmill.toolkit.ui.ComponentContainer; +import com.itmill.toolkit.ui.Label; +import com.itmill.toolkit.ui.Window; +import com.itmill.toolkit.ui.Button.ClickEvent; + +public abstract class Robustness extends com.itmill.toolkit.Application + implements Button.ClickListener { + + static int totalCount = 0; + + int count = 0; + + final Window main = new Window("Robustness tests by featurebrowser"); + + Button close = new Button("Close application"); + + Button remove = new Button("Remove all components"); + + Button create = new Button("Create"); + + Label label = new Label(); + + ComponentContainer stressLayout; + + RandomComponents randomComponents = new RandomComponents(); + + public void init() { + createNewView(); + } + + public void createNewView() { + setMainWindow(main); + main.setDebugId("MainWindow"); + main.removeAllComponents(); + + main.addComponent(label); + main.addComponent(close); + main.addComponent(remove); + main.addComponent(create); + close.addListener(this); + remove.addListener(this); + create.addListener(this); + + remove.setDescription("After this garbage collector should" + + " be able to collect every component" + + " inside stressLayout."); + + close.setDebugId("close"); + remove.setDebugId("remove"); + create.setDebugId("create"); + + } + + public void buttonClick(ClickEvent event) { + if (event.getButton() == create) + create(); + else if (event.getButton() == remove) { + main.removeAllComponents(); + close.removeListener(this); + remove.removeListener(this); + create.removeListener(this); + close = null; + remove = null; + create = null; + label = null; + stressLayout = null; + System.out.println("main.getLayout()=" + main.getLayout()); + System.out.println(Log.getMemoryStatistics()); + } else if (event.getButton() == close) { + System.out.println("Before close, memory statistics:"); + System.out.println(Log.getMemoryStatistics()); + close(); + // Still valueUnbound (session expiration) needs to occur for GC to + // do its work + System.out.println("After close, memory statistics:"); + System.out.println(Log.getMemoryStatistics()); + } + } + + public abstract void create(); +} diff --git a/src/com/itmill/toolkit/tests/robustness/RobustnessComplex.java b/src/com/itmill/toolkit/automatedtests/robustness/RobustnessComplex.java index dffaeed09d..4f9325693d 100644 --- a/src/com/itmill/toolkit/tests/robustness/RobustnessComplex.java +++ b/src/com/itmill/toolkit/automatedtests/robustness/RobustnessComplex.java @@ -1,6 +1,10 @@ -package com.itmill.toolkit.tests.robustness; +/* +@ITMillApache2LicenseForJavaFiles@ + */ -import com.itmill.toolkit.tests.util.Log; +package com.itmill.toolkit.automatedtests.robustness; + +import com.itmill.toolkit.automatedtests.util.Log; import com.itmill.toolkit.ui.Button; import com.itmill.toolkit.ui.Label; @@ -27,7 +31,7 @@ public class RobustnessComplex extends Robustness implements stressLayout.addComponent(label); // fill with random components - randomComponents.fillLayout(stressLayout, 25); + randomComponents.fillLayout(stressLayout, 50); // add new component container to main layout main.addComponent(stressLayout); diff --git a/src/com/itmill/toolkit/automatedtests/util/DebugId.java b/src/com/itmill/toolkit/automatedtests/util/DebugId.java new file mode 100644 index 0000000000..03dc6cedec --- /dev/null +++ b/src/com/itmill/toolkit/automatedtests/util/DebugId.java @@ -0,0 +1,49 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + +package com.itmill.toolkit.automatedtests.util; + +import java.util.HashMap; + +import com.itmill.toolkit.ui.Component; + +public class DebugId { + + private static HashMap debugIds = new HashMap(); + + /** + * Generate static debug id based on package and component type. If + * duplicate package, component type then number of instances count is + * appended to debugId. + * + * @param c + */ + public static void set(Component c, String description) { + String debugId = ""; + + // add package name + StackTraceElement[] st = new Throwable().fillInStackTrace() + .getStackTrace(); + try { + debugId += st[3].getClassName(); + } catch (Exception e) { + e.printStackTrace(); + } + + // add component type + debugId += c.getClass(); + + // add given description + debugId += description; + + if (debugIds.containsKey(debugId)) { + int count = ((Integer) debugIds.get(debugId)).intValue(); + count++; + debugIds.put(debugId, new Integer(count)); + debugId = debugId + "-" + count; + } + + c.setDebugId(debugId); + } +} diff --git a/src/com/itmill/toolkit/tests/util/Log.java b/src/com/itmill/toolkit/automatedtests/util/Log.java index e587201bf6..43c0efe9df 100644 --- a/src/com/itmill/toolkit/tests/util/Log.java +++ b/src/com/itmill/toolkit/automatedtests/util/Log.java @@ -1,4 +1,8 @@ -package com.itmill.toolkit.tests.util; +/* +@ITMillApache2LicenseForJavaFiles@ + */ + +package com.itmill.toolkit.automatedtests.util; import java.text.DateFormat; import java.text.SimpleDateFormat; @@ -34,8 +38,6 @@ public class Log { public static int ERROR = 3; - // public List messages = new LinkedList(); - private static Log log; public static HashMap classMethodCallCounter = new HashMap(); @@ -45,7 +47,6 @@ public class Log { } public static void reset() { - // log.messages = new LinkedList(); classMethodCallCounter = new HashMap(); } @@ -61,16 +62,10 @@ public class Log { .getStackTrace(); try { String key = ""; - // Class fromCallerClass = Class.forName(st[4].getClassName()); - // String fromMethodName = st[4].getMethodName(); - // Class callerClass = Class.forName(st[3].getClassName()); String methodName = st[3].getMethodName(); int line = st[3].getLineNumber(); String clazz = st[3].getClassName() + ".java"; - // String clazz = st[3].getClassName().substring( - // st[3].getClassName().lastIndexOf('.') + 1) - // + ".java"; key = "(" + clazz + ":" + line + ")" + " " + methodName; Integer value = (Integer) classMethodCallCounter.get(key); if (value == null) @@ -83,19 +78,6 @@ public class Log { return "unknown class.method"; } - // List stacks = new ArrayList(); - // for (int i = 0; i < st.length; i++) { - // try { - // Class callerClass = Class.forName(st[i].getClassName()); - // String methodName = st[i].getMethodName(); - // System.out.println(i + " = " + callerClass + ", " + methodName); - // stacks.add(callerClass.getSimpleName()); - // } catch (ClassNotFoundException e) { - // } - // } - // System.out.println("\n"); - // return ""; - } public static String getClassMethodCounters() { @@ -108,18 +90,8 @@ public class Log { return result; } - // public String toString() { - // StringBuffer sb = new StringBuffer(2048); - // for (final Iterator it = messages.iterator(); it.hasNext();) { - // Message msg = (Message) it.next(); - // sb.append(msg.toString() + "\n"); - // } - // return sb.toString(); - // } - public void add(int type, String message) { String source = getSource(); - // log.messages.add(new Message(DEBUG, message, source)); if (type >= debug) { if (showClassInformation) System.out.println(source + ": " + message); @@ -144,33 +116,6 @@ public class Log { log.add(ERROR, message); } - public class Message { - - private final long timemillis = System.currentTimeMillis(); - - private final int type; - - private final String source; - - private final String message; - - public Message(int type, String message, String source) { - this.source = source; - this.type = type; - this.message = message; - } - - public String toString() { - return df.format(new Date(timemillis)) + ";" + source + ";" + type - + ";" + message; - } - - } - - // public List getMessages() { - // return messages; - // } - /** * Simple way to check for memory consumption without profiler. */ diff --git a/src/com/itmill/toolkit/tests/util/MultiListener.java b/src/com/itmill/toolkit/automatedtests/util/MultiListener.java index efdc7f9dc8..f210099369 100644 --- a/src/com/itmill/toolkit/tests/util/MultiListener.java +++ b/src/com/itmill/toolkit/automatedtests/util/MultiListener.java @@ -1,4 +1,8 @@ -package com.itmill.toolkit.tests.util; +/* +@ITMillApache2LicenseForJavaFiles@ + */ + +package com.itmill.toolkit.automatedtests.util; import com.itmill.toolkit.data.Container.ItemSetChangeEvent; import com.itmill.toolkit.data.Container.ItemSetChangeListener; diff --git a/src/com/itmill/toolkit/automatedtests/util/RandomComponents.java b/src/com/itmill/toolkit/automatedtests/util/RandomComponents.java new file mode 100644 index 0000000000..395924c1ee --- /dev/null +++ b/src/com/itmill/toolkit/automatedtests/util/RandomComponents.java @@ -0,0 +1,278 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + +package com.itmill.toolkit.automatedtests.util; + +import java.util.ArrayList; +import java.util.Random; + +import com.itmill.toolkit.automatedtests.ComponentsInTable; +import com.itmill.toolkit.data.Container.ItemSetChangeListener; +import com.itmill.toolkit.data.Container.PropertySetChangeListener; +import com.itmill.toolkit.data.Property.ValueChangeListener; +import com.itmill.toolkit.demo.featurebrowser.ButtonExample; +import com.itmill.toolkit.demo.featurebrowser.ClientCachingExample; +import com.itmill.toolkit.demo.featurebrowser.ComboBoxExample; +import com.itmill.toolkit.demo.featurebrowser.EmbeddedBrowserExample; +import com.itmill.toolkit.demo.featurebrowser.JavaScriptAPIExample; +import com.itmill.toolkit.demo.featurebrowser.LabelExample; +import com.itmill.toolkit.demo.featurebrowser.LayoutExample; +import com.itmill.toolkit.demo.featurebrowser.NotificationExample; +import com.itmill.toolkit.demo.featurebrowser.RichTextExample; +import com.itmill.toolkit.demo.featurebrowser.SelectExample; +import com.itmill.toolkit.demo.featurebrowser.TableExample; +import com.itmill.toolkit.demo.featurebrowser.TreeExample; +import com.itmill.toolkit.demo.featurebrowser.ValueInputExample; +import com.itmill.toolkit.demo.featurebrowser.WindowingExample; +import com.itmill.toolkit.terminal.ExternalResource; +import com.itmill.toolkit.terminal.ThemeResource; +import com.itmill.toolkit.ui.AbstractComponent; +import com.itmill.toolkit.ui.Button; +import com.itmill.toolkit.ui.ComponentContainer; +import com.itmill.toolkit.ui.DateField; +import com.itmill.toolkit.ui.Embedded; +import com.itmill.toolkit.ui.GridLayout; +import com.itmill.toolkit.ui.Label; +import com.itmill.toolkit.ui.Link; +import com.itmill.toolkit.ui.OrderedLayout; +import com.itmill.toolkit.ui.Panel; +import com.itmill.toolkit.ui.Select; +import com.itmill.toolkit.ui.TabSheet; +import com.itmill.toolkit.ui.TextField; + +public class RandomComponents { + + private Random rand = null; + + public RandomComponents() { + // Always use the same seed, used to ensure deterministic behaviour + rand = new Random(1); + } + + /** + * Get random component container + * + * @param caption + * @return + */ + public ComponentContainer getRandomComponentContainer(String caption) { + ComponentContainer result = null; + final int randint = rand.nextInt(5); + switch (randint) { + + case 0: + result = new OrderedLayout(OrderedLayout.ORIENTATION_HORIZONTAL); + ((OrderedLayout) result).setCaption("OrderedLayout_horizontal_" + + caption); + break; + case 1: + result = new OrderedLayout(OrderedLayout.ORIENTATION_VERTICAL); + ((OrderedLayout) result).setCaption("OrderedLayout_vertical_" + + caption); + break; + case 2: + GridLayout gl; + if (rand.nextInt(1) > 0) { + gl = new GridLayout(); + } else { + gl = new GridLayout(rand.nextInt(3) + 1, rand.nextInt(3) + 1); + } + gl.setCaption("GridLayout_" + caption); + gl.setDescription(gl.getCaption()); + for (int x = 0; x < gl.getColumns(); x++) { + for (int y = 0; y < gl.getRows(); y++) { + // gl.addComponent(getExamplePicture("x=" + x + ", y=" + y), + // x, y); + gl.addComponent(new Label("x=" + x + ", y=" + y)); + } + } + result = gl; + break; + case 3: + result = new Panel(); + ((Panel) result).setCaption("Panel_" + caption); + break; + case 4: + final TabSheet ts = new TabSheet(); + ts.setCaption("TabSheet_" + caption); + // randomly select one of the tabs + final int selectedTab = rand.nextInt(3); + final ArrayList tabs = new ArrayList(); + for (int i = 0; i < 3; i++) { + String tabCaption = "tab" + i; + if (selectedTab == i) { + tabCaption = "tabX"; + } + tabs.add(new OrderedLayout()); + ts.addTab((ComponentContainer) tabs.get(tabs.size() - 1), + tabCaption, null); + } + ts.setSelectedTab((ComponentContainer) tabs.get(selectedTab)); + result = ts; + break; + } + + return result; + } + + public AbstractComponent getRandomComponent(int caption) { + AbstractComponent result = null; + int randint = rand.nextInt(23); + MultiListener l = new MultiListener(); + switch (randint) { + case 0: + // Label + result = new Label(); + result.setCaption("Label component " + caption); + result.setDebugId(result.getCaption()); + break; + case 1: + // Button + result = new Button(); + result.setCaption("Button component " + caption); + result.setDebugId(result.getCaption()); + // some listeners + ((Button) result).addListener((Button.ClickListener) l); + break; + case 2: + // TextField + result = new TextField(); + result.setCaption("TextField component " + caption); + result.setDebugId(result.getCaption()); + break; + case 3: + // Select + result = new Select("Select component " + caption); + result.setCaption("Select component " + caption); + result.setDebugId(result.getCaption()); + result.setImmediate(true); + ((Select) result).setNewItemsAllowed(true); + // items + ((Select) result).addItem("first"); + ((Select) result).addItem("first"); + ((Select) result).addItem("first"); + ((Select) result).addItem("second"); + ((Select) result).addItem("third"); + ((Select) result).addItem("fourth"); + // some listeners + ((Select) result).addListener((ValueChangeListener) l); + ((Select) result).addListener((PropertySetChangeListener) l); + ((Select) result).addListener((ItemSetChangeListener) l); + break; + case 4: + // Link + result = new Link("", new ExternalResource("http://www.itmill.com")); + result.setCaption("Link component " + caption); + break; + case 5: + // Link + result = new Panel(); + result.setCaption("Panel component " + caption); + ((Panel) result) + .addComponent(new Label( + "Panel is a container for other components, by default it draws a frame around it's " + + "extremities and may have a caption to clarify the nature of the contained components' purpose." + + " Panel contains an layout where the actual contained components are added, " + + "this layout may be switched on the fly.")); + ((Panel) result).setWidth(250); + break; + case 6: + // Datefield + result = new DateField(); + ((DateField) result).setStyleName("calendar"); + ((DateField) result).setValue(new java.util.Date()); + result.setCaption("Calendar component " + caption); + result.setDebugId(result.getCaption()); + break; + case 7: + // Datefield + result = new DateField(); + ((DateField) result).setValue(new java.util.Date()); + result.setCaption("Calendar component " + caption); + result.setDebugId(result.getCaption()); + break; + case 8: + result = new OrderedLayout(); + ((OrderedLayout) result).addComponent(new ButtonExample()); + break; + case 9: + result = new OrderedLayout(); + ((OrderedLayout) result).addComponent(new ClientCachingExample()); + break; + case 10: + result = new OrderedLayout(); + ((OrderedLayout) result).addComponent(new ComboBoxExample()); + break; + case 11: + result = new OrderedLayout(); + ((OrderedLayout) result).addComponent(new EmbeddedBrowserExample()); + break; + case 12: + result = new OrderedLayout(); + ((OrderedLayout) result).addComponent(new JavaScriptAPIExample()); + break; + case 13: + result = new OrderedLayout(); + ((OrderedLayout) result).addComponent(new LabelExample()); + break; + case 14: + result = new OrderedLayout(); + ((OrderedLayout) result).addComponent(new LayoutExample()); + break; + case 15: + result = new OrderedLayout(); + ((OrderedLayout) result).addComponent(new NotificationExample()); + break; + case 16: + result = new OrderedLayout(); + ((OrderedLayout) result).addComponent(new RichTextExample()); + break; + case 17: + result = new OrderedLayout(); + ((OrderedLayout) result).addComponent(new SelectExample()); + break; + case 18: + result = new OrderedLayout(); + ((OrderedLayout) result).addComponent(new ValueInputExample()); + break; + case 19: + result = new OrderedLayout(); + ((OrderedLayout) result).addComponent(new WindowingExample()); + break; + case 20: + result = new OrderedLayout(); + ((OrderedLayout) result).addComponent(new TreeExample()); + break; + case 21: + result = new OrderedLayout(); + ((OrderedLayout) result).addComponent(new TableExample()); + break; + case 22: + result = new OrderedLayout(); + ((OrderedLayout) result) + .addComponent(new ComponentsInTable(4, 1000)); + break; + } + + return result; + } + + /** + * Add demo components to given container + * + * @param container + */ + public void fillLayout(ComponentContainer container, int numberOfComponents) { + for (int i = 0; i < numberOfComponents; i++) { + container.addComponent(getRandomComponent(i)); + } + } + + public AbstractComponent getExamplePicture(String caption) { + final ThemeResource res = new ThemeResource("test.png"); + final Embedded em = new Embedded("Embedded " + caption, res); + return em; + } + +} diff --git a/src/com/itmill/toolkit/launcher/ITMillToolkitWebMode.java b/src/com/itmill/toolkit/launcher/ITMillToolkitWebMode.java index 0d8297504c..cc74ce87b5 100644 --- a/src/com/itmill/toolkit/launcher/ITMillToolkitWebMode.java +++ b/src/com/itmill/toolkit/launcher/ITMillToolkitWebMode.java @@ -12,8 +12,6 @@ import org.mortbay.jetty.Server; import org.mortbay.jetty.nio.SelectChannelConnector;
import org.mortbay.jetty.webapp.WebAppContext;
-import com.itmill.toolkit.launcher.util.BrowserLauncher;
-
/**
* Class for running Jetty servlet container within Eclipse project.
*
@@ -42,7 +40,7 @@ public class ITMillToolkitWebMode { // Start Browser
System.out.println("Starting Web Browser.");
if (url != null) {
- BrowserLauncher.openBrowser(url);
+ // BrowserLauncher.openBrowser(url);
}
}
diff --git a/src/com/itmill/toolkit/tests/TestComponentsAndLayouts.java b/src/com/itmill/toolkit/tests/TestComponentsAndLayouts.java index 028a0bda34..0d55cd5c82 100644 --- a/src/com/itmill/toolkit/tests/TestComponentsAndLayouts.java +++ b/src/com/itmill/toolkit/tests/TestComponentsAndLayouts.java @@ -96,7 +96,7 @@ public class TestComponentsAndLayouts extends Application implements Listener, main.addComponent(eventListenerFeedback); // ////////////////////////////////////////////////////////////////////////// - if (true) { + if (false) { window = new Window("Components inside Window (TEST: Window)"); if (false) { @@ -110,7 +110,7 @@ public class TestComponentsAndLayouts extends Application implements Listener, } // ////////////////////////////////////////////////////////////////////////// - if (true) { + if (false) { target .addComponent(new Label( "<hr /><h1>Components inside horizontal OrderedLayout</h3>", @@ -122,7 +122,7 @@ public class TestComponentsAndLayouts extends Application implements Listener, } // ////////////////////////////////////////////////////////////////////////// - if (true) { + if (false) { target .addComponent(new Label( "<br/><br/><br/><hr /><h1>Components inside vertical OrderedLayout</h3>", @@ -134,7 +134,7 @@ public class TestComponentsAndLayouts extends Application implements Listener, } // ////////////////////////////////////////////////////////////////////////// - if (true) { + if (false) { target.addComponent(new Label( "<hr /><h1>Components inside TabSheet</h3>", Label.CONTENT_XHTML)); @@ -160,6 +160,7 @@ public class TestComponentsAndLayouts extends Application implements Listener, "<hr /><h1>Components inside Accordion</h3>", Label.CONTENT_XHTML)); final Accordion accordion = new Accordion(); + accordion.setHeight(500); final OrderedLayout acc1 = new OrderedLayout(); acc1.addComponent(new Label("try acc2")); final OrderedLayout acc2 = new OrderedLayout(); @@ -176,7 +177,7 @@ public class TestComponentsAndLayouts extends Application implements Listener, } // ////////////////////////////////////////////////////////////////////////// - if (true) { + if (false) { target.addComponent(new Label( "<hr /><h1>Components inside GridLayout</h3>", Label.CONTENT_XHTML)); @@ -187,7 +188,7 @@ public class TestComponentsAndLayouts extends Application implements Listener, } // ////////////////////////////////////////////////////////////////////////// - if (true) { + if (false) { target .addComponent(new Label( "<hr /><h1>Components inside ExpandLayout (height 250px)</h3>", @@ -200,7 +201,7 @@ public class TestComponentsAndLayouts extends Application implements Listener, } // ////////////////////////////////////////////////////////////////////////// - if (true) { + if (false) { target.addComponent(new Label( "<hr /><h1>Components inside Panel</h3>", Label.CONTENT_XHTML)); @@ -210,7 +211,7 @@ public class TestComponentsAndLayouts extends Application implements Listener, } // ////////////////////////////////////////////////////////////////////////// - if (true) { + if (false) { target .addComponent(new Label( "<hr /><h1>Components inside vertical SplitPanel (splitpanel is under 250height ExpandLayout)</h3>", @@ -230,7 +231,7 @@ public class TestComponentsAndLayouts extends Application implements Listener, } // ////////////////////////////////////////////////////////////////////////// - if (true) { + if (false) { target .addComponent(new Label( "<hr /><h1>Components inside horizontal SplitPanel (splitpanel is under 250px height ExpandLayout)</h3>", @@ -408,7 +409,7 @@ public class TestComponentsAndLayouts extends Application implements Listener, // TWEAK these // c.setEnabled(false); // c.setVisible(false); - c.setStyleName("testStyleName"); + // c.setStyleName("testStyleName"); // c.setReadOnly(true); // try to add listener @@ -427,7 +428,7 @@ public class TestComponentsAndLayouts extends Application implements Listener, */ void test(AbstractComponent c) { // configure common component properties - setComponentProperties(c); + // setComponentProperties(c); // AbstractComponent specific configuration final ClassResource res = new ClassResource("m.gif", this); @@ -437,12 +438,12 @@ public class TestComponentsAndLayouts extends Application implements Listener, } // TWEAK these - c.setComponentError(errorMsg); - c.setIcon(res); - c.setImmediate(true); - c.addStyleName("addedTestStyleName"); + // c.setComponentError(errorMsg); + // c.setIcon(res); + // c.setImmediate(true); + // c.addStyleName("addedTestStyleName"); // c.setStyleName("singleTestStyleName"); - c.setDescription("Description here.."); + // c.setDescription("Description here.."); } void test(CustomComponent c) { diff --git a/src/com/itmill/toolkit/tests/robustness/Robustness.java b/src/com/itmill/toolkit/tests/robustness/Robustness.java index 075e3f2db4..03c1b57aeb 100644 --- a/src/com/itmill/toolkit/tests/robustness/Robustness.java +++ b/src/com/itmill/toolkit/tests/robustness/Robustness.java @@ -1,6 +1,6 @@ package com.itmill.toolkit.tests.robustness; -import com.itmill.toolkit.tests.util.Log; +import com.itmill.toolkit.automatedtests.util.Log; import com.itmill.toolkit.tests.util.RandomComponents; import com.itmill.toolkit.ui.Button; import com.itmill.toolkit.ui.ComponentContainer; diff --git a/src/com/itmill/toolkit/tests/robustness/RobustnessSimple.java b/src/com/itmill/toolkit/tests/robustness/RobustnessSimple.java index 755e6c4225..04d64bb972 100644 --- a/src/com/itmill/toolkit/tests/robustness/RobustnessSimple.java +++ b/src/com/itmill/toolkit/tests/robustness/RobustnessSimple.java @@ -1,6 +1,6 @@ package com.itmill.toolkit.tests.robustness; -import com.itmill.toolkit.tests.util.Log; +import com.itmill.toolkit.automatedtests.util.Log; import com.itmill.toolkit.ui.Button; import com.itmill.toolkit.ui.Label; import com.itmill.toolkit.ui.OrderedLayout; diff --git a/src/com/itmill/toolkit/tests/util/RandomComponents.java b/src/com/itmill/toolkit/tests/util/RandomComponents.java index 2ead601f9f..03555b9ee0 100644 --- a/src/com/itmill/toolkit/tests/util/RandomComponents.java +++ b/src/com/itmill/toolkit/tests/util/RandomComponents.java @@ -3,6 +3,7 @@ package com.itmill.toolkit.tests.util; import java.util.ArrayList; import java.util.Random; +import com.itmill.toolkit.automatedtests.util.MultiListener; import com.itmill.toolkit.data.Container.ItemSetChangeListener; import com.itmill.toolkit.data.Container.PropertySetChangeListener; import com.itmill.toolkit.data.Property.ValueChangeListener; |