From: Matti Tahvonen Date: Wed, 11 Apr 2007 09:57:28 +0000 (+0000) Subject: svn changeset:1193/svn branch:trunk X-Git-Tag: 6.7.0.beta1~6456 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=438d057599325feecdba3fa1e90157eb4892619e;p=vaadin-framework.git svn changeset:1193/svn branch:trunk --- diff --git a/src/com/itmill/toolkit/demo/demo/Calc.java b/src/com/itmill/toolkit/demo/demo/Calc.java new file mode 100644 index 0000000000..fb6f7272d5 --- /dev/null +++ b/src/com/itmill/toolkit/demo/demo/Calc.java @@ -0,0 +1,111 @@ +package com.itmill.toolkit.demo; + +import com.itmill.toolkit.ui.*; + +/**

An example application implementing a simple web-based calculator + * using IT Mill Toolkit. The application opens up a window and + * places the needed UI components (display label, buttons etc.) on it, and + * registers a button click listener for them.

+ * + *

When any of the buttons are pressed the application finds out which + * button was pressed, figures what that button does, and updates the user + * interface accordingly.

+ * + * @see com.itmill.toolkit.Application + * @see com.itmill.toolkit.ui.Button.ClickListener + */ +public class Calc + extends com.itmill.toolkit.Application + implements Button.ClickListener { + + /** The label used as the display */ + private Label display = null; + + /** Last completed result */ + private double stored = 0.0; + + /** The number being currently edited. */ + private double current = 0.0; + + /** Last activated operation. */ + private String operation = "C"; + + /** Button captions. */ + private static String[] captions = // Captions for the buttons + {"7","8","9","/","4","5","6","*","1","2","3","-","0","=","C","+" }; + + /**

Initializes the application. This is the only method an + * application is required to implement. It's called by the framework + * and it should perform whatever initialization tasks the application + * needs to perform.

+ * + *

In this case we create the main window, the display, the grid to + * hold the buttons, and the buttons themselves.

+ */ + public void init() { + + //Create a new layout for the components used by the calculator + GridLayout layout = new GridLayout(4, 5); + + //Create a new label component for displaying the result + display = new Label(Double.toString(current)); + display.setCaption("Result"); + + // Place the label to the top of the previously created grid. + layout.addComponent(display, 0, 0, 3, 0); + + // Create the buttons and place them in the grid + for (int i = 0; i < captions.length; i++) { + layout.addComponent(new Button(captions[i], this)); + } + + // Create the main window with a caption and add it to the application. + addWindow(new Window("Calculator", layout)); + + //Set the application to use Corporate -theme + setTheme("corporate"); + + } + + /**

The button listener method called any time a button is pressed. + * This method catches all button presses, figures out what the user + * wanted the application to do, and updates the UI accordingly.

+ * + *

The button click event passed to this method contains information + * about which button was pressed. If it was a number, the currently + * edited number is updated. If it was something else, the requested + * operation is performed. In either case the display label is updated + * to include the outcome of the button click.

+ * + * @param event the button click event specifying which button was + * pressed + */ + public void buttonClick(Button.ClickEvent event) { + + try { + // Number button pressed + current = + current * 10 + + Double.parseDouble(event.getButton().getCaption()); + display.setValue(Double.toString(current)); + } catch (java.lang.NumberFormatException e) { + + // Operation button pressed + if (operation.equals("+")) + stored += current; + if (operation.equals("-")) + stored -= current; + if (operation.equals("*")) + stored *= current; + if (operation.equals("/")) + stored /= current; + if (operation.equals("C")) + stored = current; + if (event.getButton().getCaption().equals("C")) + stored = 0.0; + operation = event.getButton().getCaption(); + current = 0.0; + display.setValue(Double.toString(stored)); + } + } +} diff --git a/src/com/itmill/toolkit/demo/demo/HelloWorld.java b/src/com/itmill/toolkit/demo/demo/HelloWorld.java new file mode 100644 index 0000000000..435a56e5a0 --- /dev/null +++ b/src/com/itmill/toolkit/demo/demo/HelloWorld.java @@ -0,0 +1,43 @@ +package com.itmill.toolkit.demo; + +import com.itmill.toolkit.ui.*; + +/** The classic "hello, world!" example for IT Mill Toolkit. The + * class simply implements the abstract + * {@link com.itmill.toolkit.Application#init() init()} method + * in which it creates a Window and adds a Label to it. + * + * @author IT Mill Ltd. + * @see com.itmill.toolkit.Application + * @see com.itmill.toolkit.ui.Window + * @see com.itmill.toolkit.ui.Label + */ +public class HelloWorld extends com.itmill.toolkit.Application { + + /** The initialization method that is the only requirement for + * inheriting the com.itmill.toolkit.service.Application class. It will + * be automatically called by the framework when a user accesses the + * application. + */ + public void init() { + + /* + * - Create new window for the application + * - Give the window a visible title + * - Set the window to be the main window of the application + */ + Window main = new Window("Hello window"); + setMainWindow(main); + + /* + * - Create a label with the classic text + * - Add the label to the main window + */ + main.addComponent(new Label("Hello World!")); + + /* + * And that's it! The framework will display the main window and its + * contents when the application is accessed with the terminal. + */ + } +} diff --git a/src/com/itmill/toolkit/demo/demo/features/Feature.java b/src/com/itmill/toolkit/demo/demo/features/Feature.java new file mode 100644 index 0000000000..235ca6366e --- /dev/null +++ b/src/com/itmill/toolkit/demo/demo/features/Feature.java @@ -0,0 +1,182 @@ +/* ************************************************************************* + + IT Mill Toolkit + + Development of Browser User Interfaces Made Easy + + Copyright (C) 2000-2006 IT Mill Ltd + + ************************************************************************* + + This product is distributed under commercial license that can be found + from the product package on license.pdf. Use of this product might + require purchasing a commercial license from IT Mill Ltd. For guidelines + on usage, see licensing-guidelines.html + + ************************************************************************* + + For more information, contact: + + IT Mill Ltd phone: +358 2 4802 7180 + Ruukinkatu 2-4 fax: +358 2 4802 7181 + 20540, Turku email: info@itmill.com + Finland company www: www.itmill.com + + Primary source for information and releases: www.itmill.com + + ********************************************************************** */ + +package com.itmill.toolkit.demo.features; + +import com.itmill.toolkit.terminal.ClassResource; +import com.itmill.toolkit.terminal.Resource; +import com.itmill.toolkit.ui.*; + +public abstract class Feature extends CustomComponent { + + private static final String PROP_REMINDER_TEXT = "" + + "

Note: Use Properties panel located at the top" + + " right corner to try out how different properties affect" + + " the presentation or functionality of currently selected component."; + + private boolean propsReminder = true; + + private OrderedLayout layout; + + private TabSheet ts; + + private boolean initialized = false; + + private static Resource sampleIcon; + + protected PropertyPanel propertyPanel; + + private Label javadoc; + + /** Constuctor for the feature component */ + public Feature() { + layout = new OrderedLayout(OrderedLayout.ORIENTATION_VERTICAL); + setCompositionRoot(layout); + } + + /** + * Actual URL consists of "/doc/api/com/itmill/toolkit/"+url + * + * @param url + */ + public void setJavadocURL(String url) { + javadoc + .setValue(""); + } + + /** + * Feature component initialization is lazily done when the feature is + * attached to application + */ + public void attach() { + super.attach(); + + // Check if the feature is already initialized + if (initialized) + return; + initialized = true; + + // Javadoc + javadoc = new Label(); + javadoc.setContentMode(Label.CONTENT_RAW); + + // Demo + Component demo = getDemoComponent(); + if (demo != null) + layout.addComponent(demo); + + ts = new TabSheet(); + + // Description tab + String desc = getDescriptionXHTML(); + String title = getTitle(); + if (desc != null) { + OrderedLayout mainLayout = new OrderedLayout( + OrderedLayout.ORIENTATION_VERTICAL); + OrderedLayout layout = new OrderedLayout( + OrderedLayout.ORIENTATION_HORIZONTAL); + mainLayout.addComponent(layout); + if (getImage() != null) + layout.addComponent(new Embedded("", new ClassResource( + getImage(), this.getApplication()))); + String label = ""; + label += desc; + if (propsReminder) + label += PROP_REMINDER_TEXT; + if (title != null) { + layout.addComponent(new Label("

" + title + "

", + Label.CONTENT_XHTML)); + } + mainLayout.addComponent(new Label(label, Label.CONTENT_XHTML)); + + ts.addTab(mainLayout, "Description", null); + } + + // Javadoc tab + if (!javadoc.getValue().equals("")) + ts.addTab(javadoc, "Javadoc", null); + + // Code Sample tab + String example = getExampleSrc(); + if (example != null) { + OrderedLayout l = new OrderedLayout(); + if (getTitle() != null) + l.addComponent(new Label( + "// " + getTitle() + " example", + Label.CONTENT_XHTML)); + l.addComponent(new Label(example, + Label.CONTENT_PREFORMATTED)); + ts.addTab(l, "Code Sample", null); + } + + layout.addComponent(ts); + + } + + /** Get the desctiption of the feature as XHTML fragment */ + protected String getDescriptionXHTML() { + return "

Feature description is under construction

"; + } + + /** Get the title of the feature */ + protected String getTitle() { + return this.getClass().getName(); + } + + /** Get the name of the image file that will be put on description page */ + protected String getImage() { + return null; + } + + /** Get the example application source code */ + protected String getExampleSrc() { + return null; + } + + /** Get the feature demo component */ + protected Component getDemoComponent() { + return null; + } + + /** Get sample icon resource */ + protected Resource getSampleIcon() { + if (sampleIcon == null) + sampleIcon = new ClassResource("m.gif", this.getApplication()); + return sampleIcon; + } + + public PropertyPanel getPropertyPanel() { + return propertyPanel; + } + + public void setPropsReminder(boolean propsReminder) { + this.propsReminder = propsReminder; + } + +} \ No newline at end of file diff --git a/src/com/itmill/toolkit/demo/demo/features/FeatureBrowser.java b/src/com/itmill/toolkit/demo/demo/features/FeatureBrowser.java new file mode 100644 index 0000000000..8d63a162d0 --- /dev/null +++ b/src/com/itmill/toolkit/demo/demo/features/FeatureBrowser.java @@ -0,0 +1,231 @@ +/* ************************************************************************* + + IT Mill Toolkit + + Development of Browser User Interfaces Made Easy + + Copyright (C) 2000-2006 IT Mill Ltd + + ************************************************************************* + + This product is distributed under commercial license that can be found + from the product package on license.pdf. Use of this product might + require purchasing a commercial license from IT Mill Ltd. For guidelines + on usage, see licensing-guidelines.html + + ************************************************************************* + + For more information, contact: + + IT Mill Ltd phone: +358 2 4802 7180 + Ruukinkatu 2-4 fax: +358 2 4802 7181 + 20540, Turku email: info@itmill.com + Finland company www: www.itmill.com + + Primary source for information and releases: www.itmill.com + + ********************************************************************** */ + +package com.itmill.toolkit.demo.features; + +import java.util.Iterator; +import java.util.StringTokenizer; + +import com.itmill.toolkit.data.*; +import com.itmill.toolkit.ui.*; +import com.itmill.toolkit.ui.Button.ClickEvent; +import com.itmill.toolkit.ui.Button.ClickListener; + +public class FeatureBrowser extends CustomComponent implements + Property.ValueChangeListener, ClickListener { + + private Tree features; + + private Feature currentFeature = null; + + private OrderedLayout layout; + + private Button propertiesSelect; + + private OrderedLayout right; + + private PropertyPanel properties; + + private boolean initialized = false; + + private Select themeSelector = new Select(); + + public void attach() { + + if (initialized) + return; + initialized = true; + + // Configure tree + features = new Tree(); + // TODO see #321 + // features.setStyle("default"); + features.addContainerProperty("name", String.class, ""); + features.addContainerProperty("feature", Feature.class, null); + features.setItemCaptionPropertyId("name"); + features.addListener(this); + features.setImmediate(true); + features.setStyle("menu"); + + // Configure component layout + layout = new OrderedLayout(OrderedLayout.ORIENTATION_HORIZONTAL); + layout.setStyle("featurebrowser-mainlayout"); + setCompositionRoot(layout); + OrderedLayout left = new OrderedLayout( + OrderedLayout.ORIENTATION_VERTICAL); + left.addComponent(features); + layout.addComponent(left); + + // Theme selector + left.addComponent(themeSelector); + themeSelector.addItem("demo"); + themeSelector.addItem("corporate"); + themeSelector.addItem("base"); + themeSelector.addListener(this); + themeSelector.select("demo"); + themeSelector.setImmediate(true); + + // Restart button + Button close = new Button("restart", getApplication(), "close"); + close.setStyle("link"); + left.addComponent(close); + + // Test component + registerFeature("/Welcome", new IntroWelcome()); + registerFeature("/UI Components", new IntroComponents()); + registerFeature("/UI Components/Basic", new IntroBasic()); + registerFeature("/UI Components/Basic/Text Field", + new FeatureTextField()); + registerFeature("/UI Components/Basic/Date Field", + new FeatureDateField()); + registerFeature("/UI Components/Basic/Button", new FeatureButton()); + registerFeature("/UI Components/Basic/Form", new FeatureForm()); + registerFeature("/UI Components/Basic/Label", new FeatureLabel()); + registerFeature("/UI Components/Basic/Link", new FeatureLink()); + registerFeature("/UI Components/Item Containers", + new IntroItemContainers()); + registerFeature("/UI Components/Item Containers/Select", + new FeatureSelect()); + registerFeature("/UI Components/Item Containers/Table", + new FeatureTable()); + registerFeature("/UI Components/Item Containers/Tree", + new FeatureTree()); + registerFeature("/UI Components/Layouts", new IntroLayouts()); + registerFeature("/UI Components/Layouts/Ordered Layout", + new FeatureOrderedLayout()); + registerFeature("/UI Components/Layouts/Grid Layout", + new FeatureGridLayout()); + registerFeature("/UI Components/Layouts/Custom Layout", + new FeatureCustomLayout()); + registerFeature("/UI Components/Layouts/Panel", new FeaturePanel()); + registerFeature("/UI Components/Layouts/Tab Sheet", + new FeatureTabSheet()); + registerFeature("/UI Components/Layouts/Window", new FeatureWindow()); + // Disabled for now + // registerFeature("/UI Components/Layouts/Frame Window", + // new FeatureFrameWindow()); + registerFeature("/UI Components/Data handling", new IntroDataHandling()); + registerFeature("/UI Components/Data handling/Embedded Objects", + new FeatureEmbedded()); + registerFeature("/UI Components/Data handling/Upload", + new FeatureUpload()); + registerFeature("/Data Model", new IntroDataModel()); + registerFeature("/Data Model/Properties", new FeatureProperties()); + registerFeature("/Data Model/Items", new FeatureItems()); + registerFeature("/Data Model/Containers", new FeatureContainers()); + registerFeature("/Data Model/Validators", new FeatureValidators()); + registerFeature("/Data Model/Buffering", new FeatureBuffering()); + // registerFeature("/Terminal", new IntroTerminal()); + // registerFeature("/Terminal/Parameters and URI Handling", + // new FeatureParameters()); + + // Pre-open all menus + for (Iterator i = features.getItemIds().iterator(); i.hasNext();) + features.expandItem(i.next()); + + // Add demo component and tabs + currentFeature = new IntroWelcome(); + layout.addComponent(currentFeature); + + // Add properties + right = new OrderedLayout(OrderedLayout.ORIENTATION_VERTICAL); + layout.addComponent(right); + + propertiesSelect = new Button("Show properties", this); + propertiesSelect.setSwitchMode(true); + right.addComponent(propertiesSelect); + properties = currentFeature.getPropertyPanel(); + properties.setVisible(false); + right.addComponent(properties); + } + + public void registerFeature(String path, Feature feature) { + StringTokenizer st = new StringTokenizer(path, "/"); + String id = ""; + String parentId = null; + while (st.hasMoreTokens()) { + String token = st.nextToken(); + id += "/" + token; + if (!features.containsId(id)) { + features.addItem(id); + features.setChildrenAllowed(id, false); + } + features.getContainerProperty(id, "name").setValue(token); + if (parentId != null) { + features.setChildrenAllowed(parentId, true); + features.setParent(id, parentId); + } + if (!st.hasMoreTokens()) + features.getContainerProperty(id, "feature").setValue(feature); + parentId = id; + } + } + + public void valueChange(Property.ValueChangeEvent event) { + + // Change feature + if (event.getProperty() == features) { + Object id = features.getValue(); + if (id != null) { + if (features.areChildrenAllowed(id)) + features.expandItem(id); + Property p = features.getContainerProperty(id, "feature"); + Feature feature = p != null ? ((Feature) p.getValue()) : null; + if (feature != null) { + layout.replaceComponent(currentFeature, feature); + currentFeature = feature; + properties = feature.getPropertyPanel(); + if (properties != null) { + Iterator i = right.getComponentIterator(); + i.next(); + PropertyPanel oldProps = (PropertyPanel) i.next(); + if (oldProps != null) + right.replaceComponent(oldProps, properties); + else + right.addComponent(properties); + properties.setVisible(((Boolean) propertiesSelect + .getValue()).booleanValue()); + } + getWindow() + .setCaption( + "IT Mill Toolkit Features / " + + features.getContainerProperty(id, + "name")); + } + } + } else if (event.getProperty() == themeSelector) { + getApplication().setTheme(themeSelector.toString()); + } + } + + public void buttonClick(ClickEvent event) { + if (properties != null) + properties.setVisible(((Boolean) propertiesSelect.getValue()) + .booleanValue()); + } +} diff --git a/src/com/itmill/toolkit/demo/demo/features/FeatureBuffering.java b/src/com/itmill/toolkit/demo/demo/features/FeatureBuffering.java new file mode 100644 index 0000000000..da345e5a5a --- /dev/null +++ b/src/com/itmill/toolkit/demo/demo/features/FeatureBuffering.java @@ -0,0 +1,110 @@ +/* ************************************************************************* + + IT Mill Toolkit + + Development of Browser User Interfaces Made Easy + + Copyright (C) 2000-2006 IT Mill Ltd + + ************************************************************************* + + This product is distributed under commercial license that can be found + from the product package on license.pdf. Use of this product might + require purchasing a commercial license from IT Mill Ltd. For guidelines + on usage, see licensing-guidelines.html + + ************************************************************************* + + For more information, contact: + + IT Mill Ltd phone: +358 2 4802 7180 + Ruukinkatu 2-4 fax: +358 2 4802 7181 + 20540, Turku email: info@itmill.com + Finland company www: www.itmill.com + + Primary source for information and releases: www.itmill.com + + ********************************************************************** */ + +package com.itmill.toolkit.demo.features; + +import com.itmill.toolkit.ui.Component; +import com.itmill.toolkit.ui.Form; +import com.itmill.toolkit.ui.Label; +import com.itmill.toolkit.ui.OrderedLayout; +import com.itmill.toolkit.ui.Panel; +import com.itmill.toolkit.ui.Select; + +public class FeatureBuffering extends Feature { + + private static final String INTRO_TEXT = "" + + "IT Mill Toolkit data model provides interface for implementing " + + "buffering in data components. The basic idea is that a component " + + "reading their state from data source can implement " + + "Buffered-interface, for storing the value internally. " + + "Buffering provides transactional access " + + "for setting data: data can be put to a component's buffer and " + + "afterwards committed to or discarded by re-reding it from the data source. " + + "The buffering can be used for creating interactive interfaces " + + "as well as caching the data for performance reasons." + + "

Buffered interface contains methods for committing and discarding " + + "changes to an object and support for controlling buffering mode " + + "with read-through and write-through modes. " + + "Read-through mode means that the value read from the buffered " + + "object is constantly up to date with the data source. " + + "Respectively the write-through mode means that all changes to the object are " + + "immediately updated to the data source."; + + public FeatureBuffering() { + super(); + } + + protected Component getDemoComponent() { + + OrderedLayout l = new OrderedLayout(); + Panel panel = new Panel(); + panel.setCaption("Buffering"); + l.addComponent(panel); + + Label label = new Label(); + panel.addComponent(label); + + label.setContentMode(Label.CONTENT_XHTML); + label.setValue(INTRO_TEXT); + + // Properties + propertyPanel = new PropertyPanel(panel); + Form ap = propertyPanel.createBeanPropertySet(new String[] { "width", + "height" }); + Select themes = (Select) propertyPanel.getField("style"); + themes.addItem("light").getItemProperty( + themes.getItemCaptionPropertyId()).setValue("light"); + themes.addItem("strong").getItemProperty( + themes.getItemCaptionPropertyId()).setValue("strong"); + propertyPanel.addProperties("Panel Properties", ap); + + setJavadocURL("data/Buffered.html"); + + return l; + } + + protected String getExampleSrc() { + return null; + } + + /** + * @see com.itmill.toolkit.demo.features.Feature#getDescriptionXHTML() + */ + protected String getDescriptionXHTML() { + return null; + } + + protected String getImage() { + return null; + } + + protected String getTitle() { + return null; + } + +} diff --git a/src/com/itmill/toolkit/demo/demo/features/FeatureButton.java b/src/com/itmill/toolkit/demo/demo/features/FeatureButton.java new file mode 100644 index 0000000000..15e2865d04 --- /dev/null +++ b/src/com/itmill/toolkit/demo/demo/features/FeatureButton.java @@ -0,0 +1,87 @@ +/* ************************************************************************* + + IT Mill Toolkit + + Development of Browser User Interfaces Made Easy + + Copyright (C) 2000-2006 IT Mill Ltd + + ************************************************************************* + + This product is distributed under commercial license that can be found + from the product package on license.pdf. Use of this product might + require purchasing a commercial license from IT Mill Ltd. For guidelines + on usage, see licensing-guidelines.html + + ************************************************************************* + + For more information, contact: + + IT Mill Ltd phone: +358 2 4802 7180 + Ruukinkatu 2-4 fax: +358 2 4802 7181 + 20540, Turku email: info@itmill.com + Finland company www: www.itmill.com + + Primary source for information and releases: www.itmill.com + + ********************************************************************** */ + +package com.itmill.toolkit.demo.features; + +import com.itmill.toolkit.ui.*; + +public class FeatureButton extends Feature { + + public FeatureButton() { + super(); + } + + protected Component getDemoComponent() { + + OrderedLayout l = new OrderedLayout(); + + Button b = new Button("Caption"); + l.addComponent(b); + + // Properties + propertyPanel = new PropertyPanel(b); + Select themes = (Select) propertyPanel.getField("style"); + themes.addItem("link").getItemProperty( + themes.getItemCaptionPropertyId()).setValue("link"); + Form ap = propertyPanel + .createBeanPropertySet(new String[] { "switchMode" }); + propertyPanel.addProperties("Button Properties", ap); + + setJavadocURL("ui/Button.html"); + + return l; + } + + protected String getExampleSrc() { + return "Button b = new Button(\"Caption\");\n"; + + } + + /** + * @see com.itmill.toolkit.demo.features.Feature#getDescriptionXHTML() + */ + protected String getDescriptionXHTML() { + return "In IT Mill Toolkit, boolean input values are represented by buttons. " + + "Buttons may function either as a push buttons or switches. (checkboxes)

" + + "Button can be directly connected to any method of an object, which " + + "is an easy way to trigger events: new Button(\"Play\", myPiano \"playIt\"). " + + "Or in checkbox-mode they can be bound to a boolean proterties and create " + + " simple selectors.

" + + "See the demo and try out how the different properties affect " + + "the presentation of the component."; + } + + protected String getImage() { + return "icon_demo.png"; + } + + protected String getTitle() { + return "Button"; + } + +} diff --git a/src/com/itmill/toolkit/demo/demo/features/FeatureContainers.java b/src/com/itmill/toolkit/demo/demo/features/FeatureContainers.java new file mode 100644 index 0000000000..5b3f5fe134 --- /dev/null +++ b/src/com/itmill/toolkit/demo/demo/features/FeatureContainers.java @@ -0,0 +1,113 @@ +/* ************************************************************************* + + IT Mill Toolkit + + Development of Browser User Interfaces Made Easy + + Copyright (C) 2000-2006 IT Mill Ltd + + ************************************************************************* + + This product is distributed under commercial license that can be found + from the product package on license.pdf. Use of this product might + require purchasing a commercial license from IT Mill Ltd. For guidelines + on usage, see licensing-guidelines.html + + ************************************************************************* + + For more information, contact: + + IT Mill Ltd phone: +358 2 4802 7180 + Ruukinkatu 2-4 fax: +358 2 4802 7181 + 20540, Turku email: info@itmill.com + Finland company www: www.itmill.com + + Primary source for information and releases: www.itmill.com + + ********************************************************************** */ + +package com.itmill.toolkit.demo.features; + +import com.itmill.toolkit.ui.Component; +import com.itmill.toolkit.ui.Form; +import com.itmill.toolkit.ui.Label; +import com.itmill.toolkit.ui.OrderedLayout; +import com.itmill.toolkit.ui.Panel; +import com.itmill.toolkit.ui.Select; + +public class FeatureContainers extends Feature { + + private static final String INTRO_TEXT = "" + + "Container is the most advanced of the data " + + "model supported by IT Mill Toolkit. It provides a very flexible " + + "way of managing set of items that share common properties. Each " + + "item is identified by an item id. " + + "Properties can be requested from container with item " + + "and property ids. Other way of accessing properties is to first " + + "request an item from container and then request its properties " + + "from it." + + "

Container interface was designed with flexibility and " + + "efficiency in mind. It contains inner interfaces for ordering " + + "the items sequentially, indexing the items and accessing them " + + "hierarchically. Those ordering models provide basis for " + + "Table, Tree and Select UI components. As with other data " + + "models, the containers support events for notifying about the " + + "changes." + + "

Set of utilities for converting between container models by " + + "adding external indexing or hierarchy into existing containers. " + + "In memory containers implementing indexed and hierarchical " + + "models provide easy to use tools for setting up in memory data " + + "storages. There is even a hierarchical container for direct " + + "file system access."; + + public FeatureContainers() { + super(); + } + + protected Component getDemoComponent() { + + OrderedLayout l = new OrderedLayout(); + + Panel panel = new Panel(); + panel.setCaption("Containers"); + l.addComponent(panel); + + Label label = new Label(); + panel.addComponent(label); + + label.setContentMode(Label.CONTENT_XHTML); + label.setValue(INTRO_TEXT); + + // Properties + propertyPanel = new PropertyPanel(panel); + Form ap = propertyPanel.createBeanPropertySet(new String[] { "width", + "height" }); + Select themes = (Select) propertyPanel.getField("style"); + themes.addItem("light").getItemProperty( + themes.getItemCaptionPropertyId()).setValue("light"); + themes.addItem("strong").getItemProperty( + themes.getItemCaptionPropertyId()).setValue("strong"); + propertyPanel.addProperties("Panel Properties", ap); + + setJavadocURL("data/Container.html"); + + return l; + } + + protected String getExampleSrc() { + return null; + } + + protected String getDescriptionXHTML() { + return null; + } + + protected String getImage() { + return null; + } + + protected String getTitle() { + return null; + } + +} diff --git a/src/com/itmill/toolkit/demo/demo/features/FeatureCustomLayout.java b/src/com/itmill/toolkit/demo/demo/features/FeatureCustomLayout.java new file mode 100644 index 0000000000..b491f406d7 --- /dev/null +++ b/src/com/itmill/toolkit/demo/demo/features/FeatureCustomLayout.java @@ -0,0 +1,96 @@ +/* ************************************************************************* + + IT Mill Toolkit + + Development of Browser User Interfaces Made Easy + + Copyright (C) 2000-2006 IT Mill Ltd + + ************************************************************************* + + This product is distributed under commercial license that can be found + from the product package on license.pdf. Use of this product might + require purchasing a commercial license from IT Mill Ltd. For guidelines + on usage, see licensing-guidelines.html + + ************************************************************************* + + For more information, contact: + + IT Mill Ltd phone: +358 2 4802 7180 + Ruukinkatu 2-4 fax: +358 2 4802 7181 + 20540, Turku email: info@itmill.com + Finland company www: www.itmill.com + + Primary source for information and releases: www.itmill.com + + ********************************************************************** */ + +package com.itmill.toolkit.demo.features; + +import com.itmill.toolkit.ui.*; + +public class FeatureCustomLayout extends Feature { + + private static final String INTRO_TEXT = "" + + "A container component with freely designed layout and style. The " + + "container consists of items with textually represented locations. Each " + + "item contains one sub-component. The adapter and theme are resposible " + + "for rendering the layout with given style by placing the items on the " + + "screen in defined locations." + + "

The definition of locations is not fixed - the each style can define its " + + "locations in a way that is suitable for it. One typical example would be " + + "to create visual design for a website as a custom layout: the visual design " + + "could define locations for \"menu\", \"body\" and \"title\" for example. " + + "The layout would then be implemented e.g. as plain HTML file." + + "

The default theme handles the styles that are not defined by just drawing " + + "the subcomponents with flowlayout."; + + protected Component getDemoComponent() { + OrderedLayout l = new OrderedLayout(); + + Panel panel = new Panel(); + panel.setCaption("Custom Layout"); + l.addComponent(panel); + + Label label = new Label(); + panel.addComponent(label); + + label.setContentMode(Label.CONTENT_XHTML); + label.setValue(INTRO_TEXT); + + // Properties + propertyPanel = new PropertyPanel(panel); + Form ap = propertyPanel.createBeanPropertySet(new String[] { "width", + "height" }); + Select themes = (Select) propertyPanel.getField("style"); + themes.addItem("light").getItemProperty( + themes.getItemCaptionPropertyId()).setValue("light"); + themes.addItem("strong").getItemProperty( + themes.getItemCaptionPropertyId()).setValue("strong"); + propertyPanel.addProperties("Panel Properties", ap); + + setJavadocURL("ui/CustomLayout.html"); + + return l; + } + + protected String getDescriptionXHTML() { + return null; + } + + protected String getExampleSrc() { + return "CustomLayout c = new CustomLayout(\"mystyle\");\n" + + "c.addComponent(new Label(\"Example description\"),\"label1-location\");\n" + + "c.addComponent(new Button(\"Example action\"),\"example-action-location\");\n"; + } + + protected String getImage() { + return null; + } + + protected String getTitle() { + return "Custom Layout"; + } + +} diff --git a/src/com/itmill/toolkit/demo/demo/features/FeatureDateField.java b/src/com/itmill/toolkit/demo/demo/features/FeatureDateField.java new file mode 100644 index 0000000000..5aa2eadf18 --- /dev/null +++ b/src/com/itmill/toolkit/demo/demo/features/FeatureDateField.java @@ -0,0 +1,126 @@ +/* ************************************************************************* + + IT Mill Toolkit + + Development of Browser User Interfaces Made Easy + + Copyright (C) 2000-2006 IT Mill Ltd + + ************************************************************************* + + This product is distributed under commercial license that can be found + from the product package on license.pdf. Use of this product might + require purchasing a commercial license from IT Mill Ltd. For guidelines + on usage, see licensing-guidelines.html + + ************************************************************************* + + For more information, contact: + + IT Mill Ltd phone: +358 2 4802 7180 + Ruukinkatu 2-4 fax: +358 2 4802 7181 + 20540, Turku email: info@itmill.com + Finland company www: www.itmill.com + + Primary source for information and releases: www.itmill.com + + ********************************************************************** */ + +package com.itmill.toolkit.demo.features; + +import java.util.Locale; + +import com.itmill.toolkit.data.util.IndexedContainer; +import com.itmill.toolkit.ui.*; + +public class FeatureDateField extends Feature { + + static private IndexedContainer localeContainer; + static { + localeContainer = new IndexedContainer(); + localeContainer.addContainerProperty("name", String.class, ""); + Locale[] locales = Locale.getAvailableLocales(); + for (int i = 0; i < locales.length; i++) + localeContainer.addItem(locales[i]).getItemProperty("name") + .setValue(locales[i].getDisplayName()); + } + + public FeatureDateField() { + super(); + } + + protected Component getDemoComponent() { + + OrderedLayout l = new OrderedLayout(); + + // Example panel + DateField df = new DateField(); + df.setValue(new java.util.Date()); + l.addComponent(df); + + // Create locale selector + // TODO: see #244 (broken for AJAX mode), known issue exists + /* + * DISABLE UNTIL WORKS Select selector = new Select("Application + * Locale", localeContainer); selector.setItemCaptionPropertyId("name"); + * selector.setImmediate(true); selector.setPropertyDataSource(new + * MethodProperty( this.getApplication(), "locale")); + * l.addComponent(selector); + */ + + // Properties + propertyPanel = new PropertyPanel(df); + Form ap = propertyPanel + .createBeanPropertySet(new String[] { "resolution" }); + ap.replaceWithSelect("resolution", new Object[] { + new Integer(DateField.RESOLUTION_YEAR), + new Integer(DateField.RESOLUTION_MONTH), + new Integer(DateField.RESOLUTION_DAY), + new Integer(DateField.RESOLUTION_HOUR), + new Integer(DateField.RESOLUTION_MIN), + new Integer(DateField.RESOLUTION_SEC), + new Integer(DateField.RESOLUTION_MSEC) }, new Object[] { + "Year", "Month", "Day", "Hour", "Minute", "Second", + "Millisecond" }); + ap.getField("resolution").setValue( + new Integer(DateField.RESOLUTION_DAY)); + Select themes = (Select) propertyPanel.getField("style"); + themes.addItem("text").getItemProperty( + themes.getItemCaptionPropertyId()).setValue("text"); + themes.addItem("calendar").getItemProperty( + themes.getItemCaptionPropertyId()).setValue("calendar"); + propertyPanel.addProperties("DateField Properties", ap); + + setJavadocURL("ui/DateField.html"); + + return l; + } + + protected String getExampleSrc() { + return "DateField df = new DateField(\"Caption\");\n" + + "df.setValue(new java.util.Date());\n"; + } + + protected String getDescriptionXHTML() { + return "Representing Dates and times and providing a way to select " + + "or enter some specific date and/or time is an typical need in " + + "data-entry user interfaces (UI). IT Mill Toolkit provides a DateField " + + "component that is intuitive to use and yet controllable through " + + "its properties." + + "

The calendar-style allows point-and-click selection " + + "of dates while text-style shows only minimalistic user interface." + + " Validators may be bound to the component to check and " + + "validate the given input." + + "

On the demo tab you can try out how the different properties affect the " + + "presentation of the component."; + } + + protected String getImage() { + return "icon_demo.png"; + } + + protected String getTitle() { + return "DateField"; + } + +} diff --git a/src/com/itmill/toolkit/demo/demo/features/FeatureEmbedded.java b/src/com/itmill/toolkit/demo/demo/features/FeatureEmbedded.java new file mode 100644 index 0000000000..f91cd00083 --- /dev/null +++ b/src/com/itmill/toolkit/demo/demo/features/FeatureEmbedded.java @@ -0,0 +1,112 @@ +/* ************************************************************************* + + IT Mill Toolkit + + Development of Browser User Interfaces Made Easy + + Copyright (C) 2000-2006 IT Mill Ltd + + ************************************************************************* + + This product is distributed under commercial license that can be found + from the product package on license.pdf. Use of this product might + require purchasing a commercial license from IT Mill Ltd. For guidelines + on usage, see licensing-guidelines.html + + ************************************************************************* + + For more information, contact: + + IT Mill Ltd phone: +358 2 4802 7180 + Ruukinkatu 2-4 fax: +358 2 4802 7181 + 20540, Turku email: info@itmill.com + Finland company www: www.itmill.com + + Primary source for information and releases: www.itmill.com + + ********************************************************************** */ + +package com.itmill.toolkit.demo.features; + +import com.itmill.toolkit.terminal.ClassResource; +import com.itmill.toolkit.terminal.Sizeable; +import com.itmill.toolkit.ui.*; + +public class FeatureEmbedded extends Feature { + + public FeatureEmbedded() { + super(); + } + + protected Component getDemoComponent() { + + OrderedLayout l = new OrderedLayout(); + + ClassResource flashResource = new ClassResource("itmill_spin.swf", + getApplication()); + Embedded emb = new Embedded("Embedded Caption", flashResource); + emb.setType(Embedded.TYPE_OBJECT); + emb.setMimeType("application/x-shockwave-flash"); + emb.setWidth(250); + emb.setHeight(100); + l.addComponent(emb); + + // Properties + propertyPanel = new PropertyPanel(emb); + Form ap = propertyPanel.createBeanPropertySet(new String[] { "type", + "source", "width", "height", "widthUnits", "heightUnits", + "codebase", "codetype", "archive", "mimeType", "standby", + "classId" }); + ap.replaceWithSelect("type", new Object[] { + new Integer(Embedded.TYPE_IMAGE), + new Integer(Embedded.TYPE_OBJECT) }, new Object[] { "Image", + "Object" }); + Object[] units = new Object[Sizeable.UNIT_SYMBOLS.length]; + Object[] symbols = new Object[Sizeable.UNIT_SYMBOLS.length]; + for (int i = 0; i < units.length; i++) { + units[i] = new Integer(i); + symbols[i] = Sizeable.UNIT_SYMBOLS[i]; + } + ap.replaceWithSelect("heightUnits", units, symbols); + ap.replaceWithSelect("widthUnits", units, symbols); + ap.replaceWithSelect("source", new Object[] { flashResource }, + new Object[] { "itmill_spin.swf" }); + propertyPanel.addProperties("Embedded Properties", ap); + propertyPanel.getField("standby").setDescription( + "The text to display while loading the object."); + propertyPanel.getField("codebase").setDescription( + "root-path used to access resources with relative paths."); + propertyPanel.getField("codetype").setDescription( + "MIME-type of the code."); + propertyPanel + .getField("classId") + .setDescription( + "Unique object id. This can be used for example to identify windows components."); + + setJavadocURL("ui/Embedded.html"); + + return l; + } + + protected String getExampleSrc() { + return "// LOad image from jpg-file, that is in the same package with the application\n" + + "Embedded e = new Embedded(\"Image title\",\n" + + " new ClassResource(\"image.jpg\", getApplication()));"; + } + + protected String getDescriptionXHTML() { + return "The embedding feature allows for adding images, multimedia and other non-specified " + + "content to your application. " + + "The feature has provisions for embedding both applets and Active X controls. " + + "Actual support for embedded media types is left to the terminal."; + } + + protected String getImage() { + return "icon_demo.png"; + } + + protected String getTitle() { + return "Embedded"; + } + +} diff --git a/src/com/itmill/toolkit/demo/demo/features/FeatureForm.java b/src/com/itmill/toolkit/demo/demo/features/FeatureForm.java new file mode 100644 index 0000000000..52bdc589da --- /dev/null +++ b/src/com/itmill/toolkit/demo/demo/features/FeatureForm.java @@ -0,0 +1,191 @@ +/* ************************************************************************* + + IT Mill Toolkit + + Development of Browser User Interfaces Made Easy + + Copyright (C) 2000-2006 IT Mill Ltd + + ************************************************************************* + + This product is distributed under commercial license that can be found + from the product package on license.pdf. Use of this product might + require purchasing a commercial license from IT Mill Ltd. For guidelines + on usage, see licensing-guidelines.html + + ************************************************************************* + + For more information, contact: + + IT Mill Ltd phone: +358 2 4802 7180 + Ruukinkatu 2-4 fax: +358 2 4802 7181 + 20540, Turku email: info@itmill.com + Finland company www: www.itmill.com + + Primary source for information and releases: www.itmill.com + + ********************************************************************** */ + +package com.itmill.toolkit.demo.features; + +import java.util.Date; + +import com.itmill.toolkit.data.Property; +import com.itmill.toolkit.ui.*; + +public class FeatureForm extends Feature implements + Property.ValueChangeListener { + + OrderedLayout demo = null; + + Form test; + + Layout formLayout = null; + + Select addField = new Select("Add field"); + + Select resetLayout = new Select("Restart"); + + protected Component getDemoComponent() { + + if (demo == null) { + demo = new OrderedLayout(); + createDemo(); + } + + setJavadocURL("ui/Form.html"); + + return demo; + } + + private void createDemo() { + + demo.removeAllComponents(); + + // Test form + if (formLayout == null) + test = new Form(); + else + test = new Form(formLayout); + + demo.addComponent(test); + OrderedLayout actions = new OrderedLayout( + OrderedLayout.ORIENTATION_HORIZONTAL); + demo.addComponent(actions); + + // form adder + addField.setImmediate(true); + addField.addItem("Add field"); + addField.setNullSelectionItemId("Add field"); + addField.addItem("Text field"); + addField.addItem("Time"); + addField.addItem("Option group"); + addField.addItem("Calendar"); + addField.addListener(this); + actions.addComponent(addField); + + // Layout reset + resetLayout.setImmediate(true); + resetLayout.addItem("Select layout example"); + resetLayout.setNullSelectionItemId("Select layout example"); + resetLayout.addItem("Vertical form (OrderedLayout form-style)"); + resetLayout.addItem("Two columns (2x1 GridLayout)"); + resetLayout.addItem("Flow (OrderedLayout flow-orientation)"); + resetLayout.addListener(this); + actions.addComponent(resetLayout); + + // Properties + propertyPanel = new PropertyPanel(test); + propertyPanel.addProperties("Form special properties", new Form()); + } + + public void valueChange(Property.ValueChangeEvent event) { + + if (event.getProperty() == resetLayout) { + + String value = (String) resetLayout.getValue(); + + if (value != null) { + formLayout = null; + + if (value.equals("Two columns (2x1 GridLayout)")) + formLayout = new GridLayout(2, 1); + if (value.equals("Horizontal (OrderedLayout)")) + formLayout = new OrderedLayout( + OrderedLayout.ORIENTATION_HORIZONTAL); + + createDemo(); + resetLayout.setValue(null); + } + } + + if (event.getProperty() == addField) { + + String value = (String) addField.getValue(); + + if (value != null) { + if (value.equals("Text field")) + test.addField(new Object(), new TextField("Test field")); + if (value.equals("Time")) { + DateField d = new DateField("Time", new Date()); + d + .setDescription("This is a DateField-component with text-style"); + d.setResolution(DateField.RESOLUTION_MIN); + d.setStyle("text"); + test.addField(new Object(), d); + } + if (value.equals("Calendar")) { + DateField c = new DateField("Calendar", new Date()); + c + .setDescription("DateField-component with calendar-style and day-resolution"); + c.setStyle("calendar"); + c.setResolution(DateField.RESOLUTION_DAY); + test.addField(new Object(), c); + } + if (value.equals("Option group")) { + Select s = new Select("Options"); + s.setDescription("Select-component with optiongroup-style"); + s.addItem("Linux"); + s.addItem("Windows"); + s.addItem("Solaris"); + s.addItem("Symbian"); + s.setStyle("optiongroup"); + + test.addField(new Object(), s); + } + + addField.setValue(null); + } + } + } + + protected String getDescriptionXHTML() { + return "Form is a flexible, yet simple container for fields. " + + " It provides support for any layouts and provides buffering interface for" + + " easy connection of commit- and discard buttons. All the form" + + " fields can be customized by adding validators, setting captions and icons, " + + " setting immediateness, etc. Also direct mechanism for replacing existing" + + " fields with selections is given." + + "

Form provides customizable editor for classes implementing" + + " Item-interface. Also the form itself" + + " implements this interface for easier connectivity to other items." + + " To use the form as editor for an item, just connect the item to" + + " form.After the item has been connected to the form," + + " the automatically created fields can be customized and new fields can" + + " be added. If you need to connect a class that does not implement" + + " Item-interface, most properties of any" + + " class following bean pattern, can be accessed trough" + + " BeanItem." + + "

The best example of Form usage is the this feature browser itself; " + + " all the Property-panels in demos are composed of Form-components."; + } + + protected String getTitle() { + return "Form"; + } + + protected String getImage() { + return "icon_demo.png"; + } + +} diff --git a/src/com/itmill/toolkit/demo/demo/features/FeatureFrameWindow.java b/src/com/itmill/toolkit/demo/demo/features/FeatureFrameWindow.java new file mode 100644 index 0000000000..c68235c36e --- /dev/null +++ b/src/com/itmill/toolkit/demo/demo/features/FeatureFrameWindow.java @@ -0,0 +1,166 @@ +/* ************************************************************************* + + IT Mill Toolkit + + Development of Browser User Interfaces Made Easy + + Copyright (C) 2000-2006 IT Mill Ltd + + ************************************************************************* + + This product is distributed under commercial license that can be found + from the product package on license.pdf. Use of this product might + require purchasing a commercial license from IT Mill Ltd. For guidelines + on usage, see licensing-guidelines.html + + ************************************************************************* + + For more information, contact: + + IT Mill Ltd phone: +358 2 4802 7180 + Ruukinkatu 2-4 fax: +358 2 4802 7181 + 20540, Turku email: info@itmill.com + Finland company www: www.itmill.com + + Primary source for information and releases: www.itmill.com + + ********************************************************************** */ + +package com.itmill.toolkit.demo.features; + +import java.util.HashMap; +import java.util.List; + +import com.itmill.toolkit.ui.*; +import com.itmill.toolkit.ui.Button.ClickEvent; + +public class FeatureFrameWindow extends Feature implements Button.ClickListener { + + private Button addButton = new Button("Add to application", this, "addWin"); + + private Button removeButton = new Button("Remove from application", this, + "delWin"); + + private FrameWindow demoWindow; + + private HashMap windowToFramesetMap = new HashMap(); + + private int count = 0; + + protected Component getDemoComponent() { + OrderedLayout l = new OrderedLayout(); + demoWindow = new FrameWindow("Feature Test Window"); + demoWindow.getFrameset() + .newFrame(createFrame(demoWindow.getFrameset())); + + l.addComponent(addButton); + l.addComponent(removeButton); + updateWinStatus(); + + // Properties + propertyPanel = new PropertyPanel(demoWindow); + propertyPanel.dependsOn(addButton); + propertyPanel.dependsOn(removeButton); + Form ap = propertyPanel.createBeanPropertySet(new String[] { "width", + "height", "name", "border", "theme" }); + ap.replaceWithSelect("border", new Object[] { + new Integer(Window.BORDER_DEFAULT), + new Integer(Window.BORDER_NONE), + new Integer(Window.BORDER_MINIMAL) }, new Object[] { "Default", + "None", "Minimal" }); + + propertyPanel.addProperties("FrameWindow Properties", ap); + + setJavadocURL("ui/FrameWindow.html"); + + return l; + } + + protected String getDescriptionXHTML() { + return "

This component implements a window that contains a hierarchical set of frames. " + + "Each frame can contain a web-page, window or a set of frames that divides the space " + + "horizontally or vertically.

"; + } + + protected String getExampleSrc() { + return "FrameWindow f = new FrameWindow(\"Frame example\");\n" + + "f.getFrameset().newFrame(window);\n" + + "f.getFrameset().newFrame(resource,\"targetName\");\n"; + } + + protected String getImage() { + return "icon_demo.png"; + } + + protected String getTitle() { + return "FrameWindow"; + } + + public void addWin() { + getApplication().addWindow(demoWindow); + updateWinStatus(); + } + + public void delWin() { + getApplication().removeWindow(demoWindow); + updateWinStatus(); + } + + private void updateWinStatus() { + if (demoWindow.getApplication() == null) { + addButton.setEnabled(true); + removeButton.setEnabled(false); + } else { + addButton.setEnabled(false); + removeButton.setEnabled(true); + } + } + + public void buttonClick(ClickEvent event) { + + if (event.getButton().getCaption().equals("Remove")) { + Window w = event.getButton().getWindow(); + FrameWindow.Frameset fs = (FrameWindow.Frameset) windowToFramesetMap + .get(w); + if (fs == demoWindow.getFrameset() && fs.size() <= 1) { + // Do not remove the last frame + } else if (fs.size() > 1) { + fs.removeFrame(fs.getFrame(w.getName())); + windowToFramesetMap.remove(w); + } else { + FrameWindow.Frameset p = fs.getParentFrameset(); + if (p != demoWindow.getFrameset() || p.size() > 1) + p.removeFrame(fs); + if (p.size() == 0) + p.newFrame(createFrame(p)); + } + } + + if (event.getButton().getCaption().equals("Split")) { + Window w = event.getButton().getWindow(); + FrameWindow.Frameset fs = (FrameWindow.Frameset) windowToFramesetMap + .get(w); + int index = 0; + List l = fs.getFrames(); + while (index < l.size() && fs.getFrame(index).getWindow() != w) + index++; + fs.removeFrame(fs.getFrame(w.getName())); + windowToFramesetMap.remove(w); + if (index > fs.size()) + index = fs.size(); + fs = fs.newFrameset((Math.random() > 0.5), index); + for (int i = 2 + (int) (Math.random() * 2.0); i > 0; i--) + fs.newFrame(createFrame(fs)); + } + } + + private Window createFrame(FrameWindow.Frameset fs) { + Window w = new Window(); + w.addComponent(new Label("Frame: " + (++count) + "", + Label.CONTENT_UIDL)); + w.addComponent(new Button("Split", this)); + w.addComponent(new Button("Remove", this)); + windowToFramesetMap.put(w, fs); + return w; + } +} diff --git a/src/com/itmill/toolkit/demo/demo/features/FeatureGridLayout.java b/src/com/itmill/toolkit/demo/demo/features/FeatureGridLayout.java new file mode 100644 index 0000000000..3ef95bd711 --- /dev/null +++ b/src/com/itmill/toolkit/demo/demo/features/FeatureGridLayout.java @@ -0,0 +1,93 @@ +/* ************************************************************************* + + IT Mill Toolkit + + Development of Browser User Interfaces Made Easy + + Copyright (C) 2000-2006 IT Mill Ltd + + ************************************************************************* + + This product is distributed under commercial license that can be found + from the product package on license.pdf. Use of this product might + require purchasing a commercial license from IT Mill Ltd. For guidelines + on usage, see licensing-guidelines.html + + ************************************************************************* + + For more information, contact: + + IT Mill Ltd phone: +358 2 4802 7180 + Ruukinkatu 2-4 fax: +358 2 4802 7181 + 20540, Turku email: info@itmill.com + Finland company www: www.itmill.com + + Primary source for information and releases: www.itmill.com + + ********************************************************************** */ + +package com.itmill.toolkit.demo.features; + +import java.util.Date; + +import com.itmill.toolkit.ui.*; + +public class FeatureGridLayout extends Feature { + + public FeatureGridLayout() { + super(); + } + + protected Component getDemoComponent() { + + OrderedLayout l = new OrderedLayout(); + + GridLayout gl = new GridLayout(3, 3); + DateField cal = new DateField("Test component 1", new Date()); + cal.setStyle("calendar"); + gl.addComponent(cal, 1, 0, 2, 1); + for (int i = 2; i < 7; i++) + gl.addComponent(new TextField("Test component " + i)); + l.addComponent(gl); + + // Properties + propertyPanel = new PropertyPanel(gl); + Form ap = propertyPanel.createBeanPropertySet(new String[] { "width", + "height" }); + ap.addField("new line", new Button("New Line", gl, "newLine")); + ap.addField("space", new Button("Space", gl, "space")); + propertyPanel.addProperties("GridLayout Features", ap); + propertyPanel.getField("height").dependsOn( + propertyPanel.getField("add component")); + + setJavadocURL("ui/GridLayout.html"); + + return l; + } + + protected String getExampleSrc() { + return "GridLayout gl = new GridLayout(2,2);\n" + + "gl.addComponent(new Label(\"Label 1 in GridLayout\"));\n" + + "gl.addComponent(new Label(\"Label 2 in GridLayout\"));\n" + + "gl.addComponent(new Label(\"Label 3 in GridLayout\"));\n" + + "gl.addComponent(new Label(\"Label 4 in GridLayout\"));\n"; + } + + /** + * @see com.itmill.toolkit.demo.features.Feature#getDescriptionXHTML() + */ + protected String getDescriptionXHTML() { + return "This feature provides a container that lays out components " + + "into a grid of given width and height." + + "

On the demo tab you can try out how the different " + + "properties affect the presentation of the component."; + } + + protected String getImage() { + return "icon_demo.png"; + } + + protected String getTitle() { + return "GridLayout"; + } +} \ No newline at end of file diff --git a/src/com/itmill/toolkit/demo/demo/features/FeatureItems.java b/src/com/itmill/toolkit/demo/demo/features/FeatureItems.java new file mode 100644 index 0000000000..c3d604f48d --- /dev/null +++ b/src/com/itmill/toolkit/demo/demo/features/FeatureItems.java @@ -0,0 +1,106 @@ +/* ************************************************************************* + + IT Mill Toolkit + + Development of Browser User Interfaces Made Easy + + Copyright (C) 2000-2006 IT Mill Ltd + + ************************************************************************* + + This product is distributed under commercial license that can be found + from the product package on license.pdf. Use of this product might + require purchasing a commercial license from IT Mill Ltd. For guidelines + on usage, see licensing-guidelines.html + + ************************************************************************* + + For more information, contact: + + IT Mill Ltd phone: +358 2 4802 7180 + Ruukinkatu 2-4 fax: +358 2 4802 7181 + 20540, Turku email: info@itmill.com + Finland company www: www.itmill.com + + Primary source for information and releases: www.itmill.com + + ********************************************************************** */ + +package com.itmill.toolkit.demo.features; + +import com.itmill.toolkit.ui.Component; +import com.itmill.toolkit.ui.Form; +import com.itmill.toolkit.ui.Label; +import com.itmill.toolkit.ui.OrderedLayout; +import com.itmill.toolkit.ui.Panel; +import com.itmill.toolkit.ui.Select; + +public class FeatureItems extends Feature { + + private static final String INTRO_TEXT = "" + + "Item is an object, which contains a set of named " + + "properties. Each property is identified by an " + + "id and a reference to the property can be queried from the Item. " + + "Item defines inner-interfaces for maintaining the item property " + + "set and listening the item property set changes." + + "

Items generally represent objects in the object-oriented " + + "model, but with the exception that they are configurable " + + "and provide an event mechanism. The simplest way of utilizing " + + "Item interface is to use existing Item implementations. " + + "Provided utility classes include configurable property set," + + " bean to item adapter and Form UI component."; + + public FeatureItems() { + super(); + } + + protected Component getDemoComponent() { + + OrderedLayout l = new OrderedLayout(); + + Panel panel = new Panel(); + panel.setCaption("Items"); + l.addComponent(panel); + + Label label = new Label(); + panel.addComponent(label); + + label.setContentMode(Label.CONTENT_XHTML); + label.setValue(INTRO_TEXT); + + // Properties + propertyPanel = new PropertyPanel(panel); + Form ap = propertyPanel.createBeanPropertySet(new String[] { "width", + "height" }); + Select themes = (Select) propertyPanel.getField("style"); + themes.addItem("light").getItemProperty( + themes.getItemCaptionPropertyId()).setValue("light"); + themes.addItem("strong").getItemProperty( + themes.getItemCaptionPropertyId()).setValue("strong"); + propertyPanel.addProperties("Panel Properties", ap); + + setJavadocURL("data/Item.html"); + + return l; + } + + protected String getExampleSrc() { + return null; + } + + /** + * @see com.itmill.toolkit.demo.features.Feature#getDescriptionXHTML() + */ + protected String getDescriptionXHTML() { + return null; + } + + protected String getImage() { + return "icon_demo.png"; + } + + protected String getTitle() { + return "Introduction of Data Model Item"; + } + +} diff --git a/src/com/itmill/toolkit/demo/demo/features/FeatureLabel.java b/src/com/itmill/toolkit/demo/demo/features/FeatureLabel.java new file mode 100644 index 0000000000..742e90e45c --- /dev/null +++ b/src/com/itmill/toolkit/demo/demo/features/FeatureLabel.java @@ -0,0 +1,95 @@ +/* ************************************************************************* + + IT Mill Toolkit + + Development of Browser User Interfaces Made Easy + + Copyright (C) 2000-2006 IT Mill Ltd + + ************************************************************************* + + This product is distributed under commercial license that can be found + from the product package on license.pdf. Use of this product might + require purchasing a commercial license from IT Mill Ltd. For guidelines + on usage, see licensing-guidelines.html + + ************************************************************************* + + For more information, contact: + + IT Mill Ltd phone: +358 2 4802 7180 + Ruukinkatu 2-4 fax: +358 2 4802 7181 + 20540, Turku email: info@itmill.com + Finland company www: www.itmill.com + + Primary source for information and releases: www.itmill.com + + ********************************************************************** */ + +package com.itmill.toolkit.demo.features; + +import com.itmill.toolkit.ui.*; + +public class FeatureLabel extends Feature { + + public FeatureLabel() { + super(); + } + + protected Component getDemoComponent() { + + OrderedLayout l = new OrderedLayout(); + + Label lab = new Label("Label text"); + l.addComponent(lab); + + // Properties + propertyPanel = new PropertyPanel(lab); + Form ap = propertyPanel.createBeanPropertySet(new String[] { + "contentMode", "value" }); + ap.replaceWithSelect("contentMode", new Object[] { + new Integer(Label.CONTENT_PREFORMATTED), + new Integer(Label.CONTENT_TEXT), + new Integer(Label.CONTENT_UIDL), + new Integer(Label.CONTENT_XHTML), + new Integer(Label.CONTENT_XML) }, + new Object[] { "Preformatted", "Text", "UIDL (Must be valid)", + "XHTML Fragment(Must be valid)", + "XML (Subtree with namespace)" }); + propertyPanel.addProperties("Label Properties", ap); + + setJavadocURL("ui/Label.html"); + + return l; + } + + protected String getExampleSrc() { + return "Label l = new Label(\"Caption\");\n"; + } + + /** + * @see com.itmill.toolkit.demo.features.Feature#getDescriptionXHTML() + */ + protected String getDescriptionXHTML() { + return "Labels components are for captions and plain text. " + + "By default, it is a light-weight component for presenting " + + "text content in application, but it can be also used to present " + + "formatted information and even XML." + + "

" + + "Label can also be directly associated with data property to display " + + "information from different data sources automatically. This makes it " + + "trivial to present the current user in the corner of applications main window. " + + "

" + + "On the demo tab you can try out how the different properties affect " + + "the presentation of the component."; + } + + protected String getImage() { + return "icon_demo.png"; + } + + protected String getTitle() { + return "Label"; + } + +} diff --git a/src/com/itmill/toolkit/demo/demo/features/FeatureLink.java b/src/com/itmill/toolkit/demo/demo/features/FeatureLink.java new file mode 100644 index 0000000000..350ec604a6 --- /dev/null +++ b/src/com/itmill/toolkit/demo/demo/features/FeatureLink.java @@ -0,0 +1,84 @@ +/* ************************************************************************* + + IT Mill Toolkit + + Development of Browser User Interfaces Made Easy + + Copyright (C) 2000-2006 IT Mill Ltd + + ************************************************************************* + + This product is distributed under commercial license that can be found + from the product package on license.pdf. Use of this product might + require purchasing a commercial license from IT Mill Ltd. For guidelines + on usage, see licensing-guidelines.html + + ************************************************************************* + + For more information, contact: + + IT Mill Ltd phone: +358 2 4802 7180 + Ruukinkatu 2-4 fax: +358 2 4802 7181 + 20540, Turku email: info@itmill.com + Finland company www: www.itmill.com + + Primary source for information and releases: www.itmill.com + + ********************************************************************** */ + +package com.itmill.toolkit.demo.features; + +import com.itmill.toolkit.terminal.ExternalResource; +import com.itmill.toolkit.ui.*; + +public class FeatureLink extends Feature { + + public FeatureLink() { + super(); + } + + protected Component getDemoComponent() { + + OrderedLayout l = new OrderedLayout(); + + Link lnk = new Link("Link caption", new ExternalResource( + "http://www.itmill.com")); + l.addComponent(lnk); + + // Properties + propertyPanel = new PropertyPanel(lnk); + Form ap = propertyPanel.createBeanPropertySet(new String[] { + "targetName", "targetWidth", "targetHeight", "targetBorder" }); + ap.replaceWithSelect("targetBorder", new Object[] { + new Integer(Link.TARGET_BORDER_DEFAULT), + new Integer(Link.TARGET_BORDER_MINIMAL), + new Integer(Link.TARGET_BORDER_NONE) }, new Object[] { + "Default", "Minimal", "None" }); + propertyPanel.addProperties("Link Properties", ap); + + setJavadocURL("ui/Link.html"); + + return l; + } + + protected String getExampleSrc() { + return "Link link = new Link(\"Link caption\",new ExternalResource(\"http://www.itmill.com\"));\n"; + } + + protected String getDescriptionXHTML() { + return "The link feature allows for making refences to both internal and external resources. " + + "The link can open the new resource in a new window, allowing for control of the newly " + + "opened windows attributes, such as size and border. " + + "

" + + " For example you can create an application pop-up or create link to external resources."; + + } + + protected String getImage() { + return "icon_demo.png"; + } + + protected String getTitle() { + return "Link"; + } +} diff --git a/src/com/itmill/toolkit/demo/demo/features/FeatureOrderedLayout.java b/src/com/itmill/toolkit/demo/demo/features/FeatureOrderedLayout.java new file mode 100644 index 0000000000..c36e459261 --- /dev/null +++ b/src/com/itmill/toolkit/demo/demo/features/FeatureOrderedLayout.java @@ -0,0 +1,95 @@ +/* ************************************************************************* + + IT Mill Toolkit + + Development of Browser User Interfaces Made Easy + + Copyright (C) 2000-2006 IT Mill Ltd + + ************************************************************************* + + This product is distributed under commercial license that can be found + from the product package on license.pdf. Use of this product might + require purchasing a commercial license from IT Mill Ltd. For guidelines + on usage, see licensing-guidelines.html + + ************************************************************************* + + For more information, contact: + + IT Mill Ltd phone: +358 2 4802 7180 + Ruukinkatu 2-4 fax: +358 2 4802 7181 + 20540, Turku email: info@itmill.com + Finland company www: www.itmill.com + + Primary source for information and releases: www.itmill.com + + ********************************************************************** */ + +package com.itmill.toolkit.demo.features; + +import com.itmill.toolkit.ui.*; + +public class FeatureOrderedLayout extends Feature { + + public FeatureOrderedLayout() { + super(); + } + + protected Component getDemoComponent() { + + OrderedLayout l = new OrderedLayout(); + + OrderedLayout ol = new OrderedLayout(); + for (int i = 1; i < 5; i++) + ol.addComponent(new TextField("Test component " + i)); + l.addComponent(ol); + + // Properties + propertyPanel = new PropertyPanel(ol); + Form ap = propertyPanel + .createBeanPropertySet(new String[] { "orientation" }); + ap.replaceWithSelect("orientation", new Object[] { + new Integer(OrderedLayout.ORIENTATION_HORIZONTAL), + new Integer(OrderedLayout.ORIENTATION_VERTICAL) }, + new Object[] { "Horizontal", "Vertical" }); + Select themes = (Select) propertyPanel.getField("style"); + themes.addItem("form").getItemProperty( + themes.getItemCaptionPropertyId()).setValue("form"); + propertyPanel.addProperties("OrderedLayout Properties", ap); + + setJavadocURL("ui/OrderedLayout.html"); + + return l; + } + + protected String getExampleSrc() { + return "OrderedLayout ol = new OrderedLayout(OrderedLayout.ORIENTATION_FLOW);\n" + + "ol.addComponent(new TextField(\"Textfield caption\"));\n" + + "ol.addComponent(new Label(\"Label\"));\n"; + + } + + /** + * @see com.itmill.toolkit.demo.features.Feature#getDescriptionXHTML() + */ + protected String getDescriptionXHTML() { + return "This feature provides a container for laying out components either " + + "vertically, horizontally or flowingly. The orientation may be changed " + + "during runtime. It also defines a special style for themes to implement called \"form\"" + + "that is used for input forms where the components are laid-out side-by-side " + + "with their captions." + + "

" + + "On the demo tab you can try out how the different properties " + + "affect the presentation of the component."; + } + + protected String getImage() { + return "icon_demo.png"; + } + + protected String getTitle() { + return "OrderedLayout"; + } + +} diff --git a/src/com/itmill/toolkit/demo/demo/features/FeaturePanel.java b/src/com/itmill/toolkit/demo/demo/features/FeaturePanel.java new file mode 100644 index 0000000000..1213a04e41 --- /dev/null +++ b/src/com/itmill/toolkit/demo/demo/features/FeaturePanel.java @@ -0,0 +1,87 @@ +/* ************************************************************************* + + IT Mill Toolkit + + Development of Browser User Interfaces Made Easy + + Copyright (C) 2000-2006 IT Mill Ltd + + ************************************************************************* + + This product is distributed under commercial license that can be found + from the product package on license.pdf. Use of this product might + require purchasing a commercial license from IT Mill Ltd. For guidelines + on usage, see licensing-guidelines.html + + ************************************************************************* + + For more information, contact: + + IT Mill Ltd phone: +358 2 4802 7180 + Ruukinkatu 2-4 fax: +358 2 4802 7181 + 20540, Turku email: info@itmill.com + Finland company www: www.itmill.com + + Primary source for information and releases: www.itmill.com + + ********************************************************************** */ + +package com.itmill.toolkit.demo.features; + +import com.itmill.toolkit.ui.*; + +public class FeaturePanel extends Feature { + + public FeaturePanel() { + super(); + } + + protected Component getDemoComponent() { + + OrderedLayout l = new OrderedLayout(); + + // Example panel + Panel show = new Panel("Panel caption"); + show + .addComponent(new Label( + "This is an example Label component that is added into Panel.")); + l.addComponent(show); + + // Properties + propertyPanel = new PropertyPanel(show); + Form ap = propertyPanel.createBeanPropertySet(new String[] { "width", + "height" }); + Select themes = (Select) propertyPanel.getField("style"); + themes.addItem("light").getItemProperty( + themes.getItemCaptionPropertyId()).setValue("light"); + themes.addItem("strong").getItemProperty( + themes.getItemCaptionPropertyId()).setValue("strong"); + propertyPanel.addProperties("Panel Properties", ap); + + setJavadocURL("ui/Panel.html"); + + return l; + } + + protected String getExampleSrc() { + return "Panel show = new Panel(\"Panel caption\");\n" + + "show.addComponent(new Label(\"This is an example Label component that is added into Panel.\"));"; + + } + + protected String getDescriptionXHTML() { + return "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."; + } + + protected String getImage() { + return "icon_demo.png"; + } + + protected String getTitle() { + return "Panel"; + } + +} diff --git a/src/com/itmill/toolkit/demo/demo/features/FeatureParameters.java b/src/com/itmill/toolkit/demo/demo/features/FeatureParameters.java new file mode 100644 index 0000000000..f98de4ca17 --- /dev/null +++ b/src/com/itmill/toolkit/demo/demo/features/FeatureParameters.java @@ -0,0 +1,164 @@ +/* ************************************************************************* + + IT Mill Toolkit + + Development of Browser User Interfaces Made Easy + + Copyright (C) 2000-2006 IT Mill Ltd + + ************************************************************************* + + This product is distributed under commercial license that can be found + from the product package on license.pdf. Use of this product might + require purchasing a commercial license from IT Mill Ltd. For guidelines + on usage, see licensing-guidelines.html + + ************************************************************************* + + For more information, contact: + + IT Mill Ltd phone: +358 2 4802 7180 + Ruukinkatu 2-4 fax: +358 2 4802 7181 + 20540, Turku email: info@itmill.com + Finland company www: www.itmill.com + + Primary source for information and releases: www.itmill.com + + ********************************************************************** */ + +package com.itmill.toolkit.demo.features; + +import java.net.URL; +import java.util.Iterator; +import java.util.Map; + +import com.itmill.toolkit.terminal.DownloadStream; +import com.itmill.toolkit.terminal.ExternalResource; +import com.itmill.toolkit.terminal.ParameterHandler; +import com.itmill.toolkit.terminal.URIHandler; +import com.itmill.toolkit.ui.*; + +public class FeatureParameters extends Feature implements URIHandler, + ParameterHandler { + + private Label context = new Label(); + + private Label relative = new Label(); + + private Table params = new Table(); + + public FeatureParameters() { + super(); + params.addContainerProperty("Values", String.class, ""); + } + + protected Component getDemoComponent() { + + OrderedLayout l = new OrderedLayout(); + + Label info = new Label("To test this feature, try to " + + "add some get parameters to URL. For example if you have " + + "the feature browser installed in your local host, try url: "); + info.setCaption("Usage info"); + l.addComponent(info); + try { + URL u1 = new URL(getApplication().getURL(), + "test/uri?test=1&test=2"); + URL u2 = new URL(getApplication().getURL(), + "foo/bar?mary=john&count=3"); + + l.addComponent(new Link(u1.toString(), new ExternalResource(u1))); + l.addComponent(new Label("Or this: ")); + l.addComponent(new Link(u2.toString(), new ExternalResource(u2))); + } catch (Exception e) { + System.out.println("Couldn't get hostname for this machine: " + + e.toString()); + e.printStackTrace(); + } + + // URI + Panel p1 = new Panel("URI Handler"); + context.setCaption("Last URI handler context"); + p1.addComponent(context); + relative.setCaption("Last relative URI"); + p1.addComponent(relative); + l.addComponent(p1); + + // Parameters + Panel p2 = new Panel("Parameter Handler"); + params.setCaption("Last parameters"); + params.setColumnHeaderMode(Table.COLUMN_HEADER_MODE_ID); + params.setRowHeaderMode(Table.ROW_HEADER_MODE_ID); + p2.addComponent(params); + l.addComponent(p2); + + return l; + } + + protected String getDescriptionXHTML() { + return "This is a demonstration of how URL parameters can be recieved and handled." + + "Parameters and URL:s can be received trough the windows by registering " + + "URIHandler and ParameterHandler classes window."; + } + + protected String getImage() { + return "parameters.jpg"; + } + + protected String getTitle() { + return "Parameters"; + } + + /** + * Add URI and parametes handlers to window. + * + * @see com.itmill.toolkit.ui.Component#attach() + */ + public void attach() { + super.attach(); + getWindow().addURIHandler(this); + getWindow().addParameterHandler(this); + } + + /** + * Remove all handlers from window + * + * @see com.itmill.toolkit.ui.Component#detach() + */ + public void detach() { + super.detach(); + getWindow().removeURIHandler(this); + getWindow().removeParameterHandler(this); + } + + /** + * Update URI + * + * @see com.itmill.toolkit.terminal.URIHandler#handleURI(URL, String) + */ + public DownloadStream handleURI(URL context, String relativeUri) { + this.context.setValue(context.toString()); + this.relative.setValue(relativeUri); + return null; + } + + /** + * Update parameters table + * + * @see com.itmill.toolkit.terminal.ParameterHandler#handleParameters(Map) + */ + public void handleParameters(Map parameters) { + params.removeAllItems(); + for (Iterator i = parameters.keySet().iterator(); i.hasNext();) { + String name = (String) i.next(); + String[] values = (String[]) parameters.get(name); + String v = ""; + for (int j = 0; j < values.length; j++) { + if (v.length() > 0) + v += ", "; + v += "'" + values[j] + "'"; + } + params.addItem(new Object[] { v }, name); + } + } +} diff --git a/src/com/itmill/toolkit/demo/demo/features/FeatureProperties.java b/src/com/itmill/toolkit/demo/demo/features/FeatureProperties.java new file mode 100644 index 0000000000..4d6b013378 --- /dev/null +++ b/src/com/itmill/toolkit/demo/demo/features/FeatureProperties.java @@ -0,0 +1,111 @@ +/* ************************************************************************* + + IT Mill Toolkit + + Development of Browser User Interfaces Made Easy + + Copyright (C) 2000-2006 IT Mill Ltd + + ************************************************************************* + + This product is distributed under commercial license that can be found + from the product package on license.pdf. Use of this product might + require purchasing a commercial license from IT Mill Ltd. For guidelines + on usage, see licensing-guidelines.html + + ************************************************************************* + + For more information, contact: + + IT Mill Ltd phone: +358 2 4802 7180 + Ruukinkatu 2-4 fax: +358 2 4802 7181 + 20540, Turku email: info@itmill.com + Finland company www: www.itmill.com + + Primary source for information and releases: www.itmill.com + + ********************************************************************** */ + +package com.itmill.toolkit.demo.features; + +import com.itmill.toolkit.ui.Component; +import com.itmill.toolkit.ui.Form; +import com.itmill.toolkit.ui.Label; +import com.itmill.toolkit.ui.OrderedLayout; +import com.itmill.toolkit.ui.Panel; +import com.itmill.toolkit.ui.Select; + +public class FeatureProperties extends Feature { + + private static final String INTRO_TEXT = "" + + "IT Mill Toolkit data model is one of the core concepts " + + "in the library and Property-interface is the base of that " + + "model. Property provides standardized API for a single data object " + + "that can be read (get) and written (set). A property is always typed, but can optionally " + + "support data type conversions. Optionally properties can provide " + + "value change events for following the state changes." + + "

The most important function of the Property as well as other " + + "data models is to connect classes implementing the interface directly to " + + "editor and viewer classes. Typically this is used to connect different " + + "data sources to UI components for editing and viewing their contents." + + "

Properties can be utilized either by implementing the interface " + + "or by using some of the existing property implementations. IT Mill Toolkit " + + "includes Property interface implementations for " + + "arbitrary function pairs or Bean-properties as well as simple object " + + "properties." + + "

Many of the UI components also implement Property interface and allow " + + "setting of other components as their data-source. These UI-components " + + "include TextField, DateField, Select, Table, Button, " + + "Label and Tree."; + + public FeatureProperties() { + super(); + } + + protected Component getDemoComponent() { + + OrderedLayout l = new OrderedLayout(); + + Panel panel = new Panel(); + panel.setCaption("Data Model"); + l.addComponent(panel); + + Label label = new Label(); + panel.addComponent(label); + + label.setContentMode(Label.CONTENT_XHTML); + label.setValue(INTRO_TEXT); + + // Properties + propertyPanel = new PropertyPanel(panel); + Form ap = propertyPanel.createBeanPropertySet(new String[] { "width", + "height" }); + Select themes = (Select) propertyPanel.getField("style"); + themes.addItem("light").getItemProperty( + themes.getItemCaptionPropertyId()).setValue("light"); + themes.addItem("strong").getItemProperty( + themes.getItemCaptionPropertyId()).setValue("strong"); + propertyPanel.addProperties("Panel Properties", ap); + + setJavadocURL("data/Property.html"); + + return l; + } + + protected String getExampleSrc() { + return null; + } + + protected String getDescriptionXHTML() { + return null; + } + + protected String getImage() { + return null; + } + + protected String getTitle() { + return null; + } + +} diff --git a/src/com/itmill/toolkit/demo/demo/features/FeatureSelect.java b/src/com/itmill/toolkit/demo/demo/features/FeatureSelect.java new file mode 100644 index 0000000000..b2e74bf3b9 --- /dev/null +++ b/src/com/itmill/toolkit/demo/demo/features/FeatureSelect.java @@ -0,0 +1,106 @@ +/* ************************************************************************* + + IT Mill Toolkit + + Development of Browser User Interfaces Made Easy + + Copyright (C) 2000-2006 IT Mill Ltd + + ************************************************************************* + + This product is distributed under commercial license that can be found + from the product package on license.pdf. Use of this product might + require purchasing a commercial license from IT Mill Ltd. For guidelines + on usage, see licensing-guidelines.html + + ************************************************************************* + + For more information, contact: + + IT Mill Ltd phone: +358 2 4802 7180 + Ruukinkatu 2-4 fax: +358 2 4802 7181 + 20540, Turku email: info@itmill.com + Finland company www: www.itmill.com + + Primary source for information and releases: www.itmill.com + + ********************************************************************** */ + +package com.itmill.toolkit.demo.features; + +import com.itmill.toolkit.ui.*; + +public class FeatureSelect extends Feature { + + 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 FeatureSelect() { + super(); + } + + protected Component getDemoComponent() { + + OrderedLayout l = new OrderedLayout(); + + Select s = new Select("Select Person"); + for (int i = 0; i < 50; i++) + s + .addItem(firstnames[(int) (Math.random() * (firstnames.length - 1))] + + " " + + lastnames[(int) (Math.random() * (lastnames.length - 1))]); + l.addComponent(s); + + // Properties + propertyPanel = new PropertyPanel(s); + Select themes = (Select) propertyPanel.getField("style"); + themes.addItem("optiongroup").getItemProperty( + themes.getItemCaptionPropertyId()).setValue("optiongroup"); + themes.addItem("twincol").getItemProperty( + themes.getItemCaptionPropertyId()).setValue("twincol"); + + setJavadocURL("ui/Select.html"); + + return l; + } + + protected String getExampleSrc() { + return "Select s = new Select(\"Select Car\");\n" + + "s.addItem(\"Audi\");\n" + "s.addItem(\"BMW\");\n" + + "s.addItem(\"Chrysler\");\n" + "s.addItem(\"Volvo\");\n"; + + } + + /** + * @see com.itmill.toolkit.demo.features.Feature#getDescriptionXHTML() + */ + protected String getDescriptionXHTML() { + return "The select component combines two different modes of item selection. " + + "Firstly it presents the single selection mode, which is usually represented as " + + "either a drop-down menu or a radio-group of switches, secondly it " + + "allows for multiple item selection, this is usually represented as either a " + + "listbox of selectable items or as a group of checkboxes." + + "

" + + "Data source can be associated both with selected item and the list of selections. " + + "This way you can easily present a selection based on items specified elsewhere in application. " + + "

" + + "On the demo tab you can try out how the different properties affect the" + + " presentation of the component."; + } + + protected String getImage() { + return "icon_demo.png"; + } + + protected String getTitle() { + return "Select"; + } + +} diff --git a/src/com/itmill/toolkit/demo/demo/features/FeatureTabSheet.java b/src/com/itmill/toolkit/demo/demo/features/FeatureTabSheet.java new file mode 100644 index 0000000000..0e23d820bc --- /dev/null +++ b/src/com/itmill/toolkit/demo/demo/features/FeatureTabSheet.java @@ -0,0 +1,91 @@ +/* ************************************************************************* + + IT Mill Toolkit + + Development of Browser User Interfaces Made Easy + + Copyright (C) 2000-2006 IT Mill Ltd + + ************************************************************************* + + This product is distributed under commercial license that can be found + from the product package on license.pdf. Use of this product might + require purchasing a commercial license from IT Mill Ltd. For guidelines + on usage, see licensing-guidelines.html + + ************************************************************************* + + For more information, contact: + + IT Mill Ltd phone: +358 2 4802 7180 + Ruukinkatu 2-4 fax: +358 2 4802 7181 + 20540, Turku email: info@itmill.com + Finland company www: www.itmill.com + + Primary source for information and releases: www.itmill.com + + ********************************************************************** */ + +package com.itmill.toolkit.demo.features; + +import com.itmill.toolkit.ui.*; + +public class FeatureTabSheet extends Feature { + + public FeatureTabSheet() { + super(); + } + + protected Component getDemoComponent() { + + OrderedLayout l = new OrderedLayout(); + + TabSheet ts = new TabSheet(); + ts + .addTab( + new Label( + "This is an example Label component that is added into Tab 1."), + "Tab 1 caption", null); + ts + .addTab( + new Label( + "This is an example Label component that is added into Tab 2."), + "Tab 2 caption", null); + ts + .addTab( + new Label( + "This is an example Label component that is added into Tab 3."), + "Tab 3 caption", null); + l.addComponent(ts); + + // Properties + propertyPanel = new PropertyPanel(ts); + + setJavadocURL("ui/TabSheet.html"); + + return l; + } + + protected String getExampleSrc() { + return "TabSheet ts = new TabSheet();\n" + + "ts.addTab(new Label(\"This is an example Label component that is added into Tab 1.\"),\"Tab 1 caption\",null);\n" + + "ts.addTab(new Label(\"This is an example Label component that is added into Tab 2.\"),\"Tab 2 caption\",null);\n" + + "ts.addTab(new Label(\"This is an example Label component that is added into Tab 3.\"),\"Tab 3 caption\",null);"; + } + + protected String getDescriptionXHTML() { + return "A multicomponent container with tabs for switching between them.
" + + "In the normal case, one would place a layout component on each tab.

" + + "On the demo tab you can try out how the different properties affect " + + "the presentation of the component."; + } + + protected String getImage() { + return "icon_demo.png"; + } + + protected String getTitle() { + return "TabSheet"; + } + +} diff --git a/src/com/itmill/toolkit/demo/demo/features/FeatureTable.java b/src/com/itmill/toolkit/demo/demo/features/FeatureTable.java new file mode 100644 index 0000000000..966733c1f8 --- /dev/null +++ b/src/com/itmill/toolkit/demo/demo/features/FeatureTable.java @@ -0,0 +1,218 @@ +/* ************************************************************************* + + IT Mill Toolkit + + Development of Browser User Interfaces Made Easy + + Copyright (C) 2000-2006 IT Mill Ltd + + ************************************************************************* + + This product is distributed under commercial license that can be found + from the product package on license.pdf. Use of this product might + require purchasing a commercial license from IT Mill Ltd. For guidelines + on usage, see licensing-guidelines.html + + ************************************************************************* + + For more information, contact: + + IT Mill Ltd phone: +358 2 4802 7180 + Ruukinkatu 2-4 fax: +358 2 4802 7181 + 20540, Turku email: info@itmill.com + Finland company www: www.itmill.com + + Primary source for information and releases: www.itmill.com + + ********************************************************************** */ + +package com.itmill.toolkit.demo.features; + +import com.itmill.toolkit.event.Action; +import com.itmill.toolkit.ui.Button; +import com.itmill.toolkit.ui.Component; +import com.itmill.toolkit.ui.Form; +import com.itmill.toolkit.ui.OrderedLayout; +import com.itmill.toolkit.ui.Select; +import com.itmill.toolkit.ui.Table; + +public class FeatureTable extends Feature implements Action.Handler { + + private static final String[] firstnames = new String[] { "John", "Mary", + "Joe", "Sarah", "Jeff", "Jane", "Peter", "Marc", "Josie", "Linus" }; + + private static final String[] lastnames = new String[] { "Torvalds", + "Smith", "Jones", "Beck", "Sheridan", "Picard", "Hill", "Fielding", + "Einstein" }; + + private static final String[] eyecolors = new String[] { "Blue", "Green", + "Brown" }; + + private static final String[] haircolors = new String[] { "Brown", "Black", + "Red", "Blonde" }; + + private Table t; + + private boolean actionsActive = false; + + private Button actionHandlerSwitch = new Button("Activate actions", this, + "toggleActions"); + + public void toggleActions() { + if (actionsActive) { + t.removeActionHandler(this); + actionsActive = false; + actionHandlerSwitch.setCaption("Activate Actions"); + } else { + t.addActionHandler(this); + actionsActive = true; + actionHandlerSwitch.setCaption("Deactivate Actions"); + } + } + + protected Component getDemoComponent() { + + OrderedLayout l = new OrderedLayout(); + + // Sample table + t = new Table("Most Wanted Persons List"); + t.setPageLength(10); + l.addComponent(t); + + // Add columns to table + t.addContainerProperty("Firstname", String.class, ""); + t.addContainerProperty("Lastname", String.class, ""); + t.addContainerProperty("Age", String.class, ""); + t.addContainerProperty("Eyecolor", String.class, ""); + t.addContainerProperty("Haircolor", String.class, ""); + + // set alignments to demonstrate features + t.setColumnAlignment("Age", Table.ALIGN_CENTER); + t.setColumnAlignment("Haircolor", Table.ALIGN_RIGHT); + + // Add random rows to table + for (int j = 0; j < 300; j++) { + t + .addItem( + new Object[] { + firstnames[(int) (Math.random() * (firstnames.length - 1))], + lastnames[(int) (Math.random() * (lastnames.length - 1))], + new Integer((int) (Math.random() * 80)), + eyecolors[(int) (Math.random() * 3)], + haircolors[(int) (Math.random() * 4)] }, + new Integer(j)); + } + + // Actions + l.addComponent(this.actionHandlerSwitch); + + // Properties + propertyPanel = new PropertyPanel(t); + Form ap = propertyPanel.createBeanPropertySet(new String[] { + "pageLength", "rowHeaderMode", "selectable", + "columnHeaderMode", "columnCollapsingAllowed", + "columnReorderingAllowed", "width", "height" }); + ap.replaceWithSelect("columnHeaderMode", new Object[] { + new Integer(Table.COLUMN_HEADER_MODE_EXPLICIT), + new Integer(Table.COLUMN_HEADER_MODE_EXPLICIT_DEFAULTS_ID), + new Integer(Table.COLUMN_HEADER_MODE_HIDDEN), + new Integer(Table.COLUMN_HEADER_MODE_ID) }, new Object[] { + "Explicit", "Explicit defaults ID", "Hidden", "ID" }); + ap.replaceWithSelect("rowHeaderMode", new Object[] { + new Integer(Table.ROW_HEADER_MODE_EXPLICIT), + new Integer(Table.ROW_HEADER_MODE_EXPLICIT_DEFAULTS_ID), + new Integer(Table.ROW_HEADER_MODE_HIDDEN), + new Integer(Table.ROW_HEADER_MODE_ICON_ONLY), + new Integer(Table.ROW_HEADER_MODE_ID), + new Integer(Table.ROW_HEADER_MODE_INDEX), + new Integer(Table.ROW_HEADER_MODE_ITEM), + new Integer(Table.ROW_HEADER_MODE_PROPERTY) }, new Object[] { + "Explicit", "Explicit defaults ID", "Hidden", "Icon only", + "ID", "Index", "Item", "Property" }); + + Select themes = (Select) propertyPanel.getField("style"); + themes.addItem("list").getItemProperty( + themes.getItemCaptionPropertyId()).setValue("list"); + themes.addItem("paging").getItemProperty( + themes.getItemCaptionPropertyId()).setValue("paging"); + + propertyPanel.addProperties("Table Properties", ap); + + // Set first name as item caption propertyId in cas somebody selecs it + t.setItemCaptionPropertyId("Firstname"); + + // this overrides previous + t.setRowHeaderMode(Table.ROW_HEADER_MODE_INDEX); + t.setColumnHeaderMode(Table.COLUMN_HEADER_MODE_EXPLICIT_DEFAULTS_ID); + + + t.setColumnCollapsingAllowed(true); + t.setColumnReorderingAllowed(true); + t.setSelectable(true); + + setJavadocURL("ui/Table.html"); + + return l; + } + + protected String getExampleSrc() { + return "// Sample table\n" + + "t = new Table(\"Most Wanted Persons List\");\n" + + "t.setPageLength(10);\n\n" + + "// Add columns to table\n" + + "t.addContainerProperty(\"Firstname\", String.class, \"\");\n" + + "t.addContainerProperty(\"Lastname\", String.class, \"\");\n" + + "t.addContainerProperty(\"Age\", String.class, \"\");\n" + + "t.addContainerProperty(\"Eyecolor\", String.class, \"\");\n" + + "t.addContainerProperty(\"Haircolor\", String.class, \"\");\n\n" + + "// Add random rows to table\n" + + "for (int j = 0; j < 50; j++) {\n" + " t.addItem(\n" + + " new Object[] {\n" + + " firstnames[(int) (Math.random() * 9)],\n" + + " lastnames[(int) (Math.random() * 9)],\n" + + " new Integer((int) (Math.random() * 80)),\n" + + " eyecolors[(int) (Math.random() * 3)],\n" + + " haircolors[(int) (Math.random() * 4)] },\n" + + " new Integer(j));\n" + "}\n"; + } + + protected String getDescriptionXHTML() { + + return "The Table component is designed for displaying large volumes of tabular data, " + + "in multiple pages whenever needed." + + "

Selection of the displayed data is supported both in selecting exclusively one row " + + "or multiple rows at the same time. For each row, there may be a set of actions associated, " + + "depending on the theme these actions may be displayed either as a drop-down " + + "menu for each row or a set of command buttons." + + "

Table may be connected to any datasource implementing the Container interface." + + "This way data found in external datasources can be directly presented in the table component." + + "

" + + "Table implements a number of features and you can test most of them in the table demo tab."; + } + + protected String getImage() { + return "icon_demo.png"; + } + + protected String getTitle() { + return "Table"; + } + + private Action ACTION1 = new Action("Action 1"); + + private Action ACTION2 = new Action("Action 2"); + + private Action ACTION3 = new Action("Action 3"); + + private Action[] actions = new Action[] { ACTION1, ACTION2, ACTION3 }; + + public Action[] getActions(Object target, Object sender) { + return actions; + } + + public void handleAction(Action action, Object sender, Object target) { + t.setDescription("Last action clicked was '" + action.getCaption() + + "' on item '" + t.getItem(target).toString() + "'"); + } + +} diff --git a/src/com/itmill/toolkit/demo/demo/features/FeatureTextField.java b/src/com/itmill/toolkit/demo/demo/features/FeatureTextField.java new file mode 100644 index 0000000000..512a4e87d9 --- /dev/null +++ b/src/com/itmill/toolkit/demo/demo/features/FeatureTextField.java @@ -0,0 +1,89 @@ +/* ************************************************************************* + + IT Mill Toolkit + + Development of Browser User Interfaces Made Easy + + Copyright (C) 2000-2006 IT Mill Ltd + + ************************************************************************* + + This product is distributed under commercial license that can be found + from the product package on license.pdf. Use of this product might + require purchasing a commercial license from IT Mill Ltd. For guidelines + on usage, see licensing-guidelines.html + + ************************************************************************* + + For more information, contact: + + IT Mill Ltd phone: +358 2 4802 7180 + Ruukinkatu 2-4 fax: +358 2 4802 7181 + 20540, Turku email: info@itmill.com + Finland company www: www.itmill.com + + Primary source for information and releases: www.itmill.com + + ********************************************************************** */ + +package com.itmill.toolkit.demo.features; + +import com.itmill.toolkit.ui.*; + +public class FeatureTextField extends Feature { + + public FeatureTextField() { + super(); + } + + protected Component getDemoComponent() { + + OrderedLayout l = new OrderedLayout( + OrderedLayout.ORIENTATION_HORIZONTAL); + + // Test component + TextField tf = new TextField("Caption"); + l.addComponent(tf); + + // Properties + propertyPanel = new PropertyPanel(tf); + Form f = propertyPanel.createBeanPropertySet(new String[] { "columns", + "rows", "wordwrap", "writeThrough", "readThrough", + "nullRepresentation", "nullSettingAllowed", "secret" }); + propertyPanel.addProperties("Text field properties", f); + + setJavadocURL("ui/TextField.html"); + + return l; + } + + protected String getExampleSrc() { + return "TextField tf = new TextField(\"Caption\");\n" + + "tf.setValue(\"Contents\");"; + } + + /** + * @see com.itmill.toolkit.demo.features.Feature#getDescriptionXHTML() + */ + protected String getDescriptionXHTML() { + return "TextField combines the logic of both the single line text-entry field and the multi-line " + + "text-area into one component. " + + "As with all Data-components of IT Mill Toolkit, the TextField can also be bound to an " + + "underlying data source, both directly or in a buffered (asynchronous) " + + "mode. In buffered mode its background color will change to indicate " + + "that the value has changed but is not committed." + + "

Furthermore a validators may be bound to the component to " + + "check and validate the given input before it is actually committed." + + "

On the demo tab you can try out how the different properties affect the " + + "presentation of the component."; + } + + protected String getImage() { + return "icon_demo.png"; + } + + protected String getTitle() { + return "TextField"; + } + +} diff --git a/src/com/itmill/toolkit/demo/demo/features/FeatureTree.java b/src/com/itmill/toolkit/demo/demo/features/FeatureTree.java new file mode 100644 index 0000000000..b92ebfada9 --- /dev/null +++ b/src/com/itmill/toolkit/demo/demo/features/FeatureTree.java @@ -0,0 +1,184 @@ +/* ************************************************************************* + + IT Mill Toolkit + + Development of Browser User Interfaces Made Easy + + Copyright (C) 2000-2006 IT Mill Ltd + + ************************************************************************* + + This product is distributed under commercial license that can be found + from the product package on license.pdf. Use of this product might + require purchasing a commercial license from IT Mill Ltd. For guidelines + on usage, see licensing-guidelines.html + + ************************************************************************* + + For more information, contact: + + IT Mill Ltd phone: +358 2 4802 7180 + Ruukinkatu 2-4 fax: +358 2 4802 7181 + 20540, Turku email: info@itmill.com + Finland company www: www.itmill.com + + Primary source for information and releases: www.itmill.com + + ********************************************************************** */ + +package com.itmill.toolkit.demo.features; + +import java.util.Iterator; + +import com.itmill.toolkit.event.Action; +import com.itmill.toolkit.ui.*; + +public class FeatureTree extends Feature implements Action.Handler { + + private static final String[] firstnames = new String[] { "John", "Mary", + "Joe", "Sarah", "Jeff", "Jane", "Peter", "Marc", "Josie", "Linus" }; + + private static final String[] lastnames = new String[] { "Torvalds", + "Smith", "Jones", "Beck", "Sheridan", "Picard", "Hill", "Fielding", + "Einstein" }; + + private Tree t; + + private boolean actionsActive = false; + + private Button actionHandlerSwitch = new Button("Activate actions", this, + "toggleActions"); + + public FeatureTree() { + super(); + } + + public void toggleActions() { + if (actionsActive) { + t.removeActionHandler(this); + actionsActive = false; + actionHandlerSwitch.setCaption("Activate Actions"); + } else { + t.addActionHandler(this); + actionsActive = true; + actionHandlerSwitch.setCaption("Deactivate Actions"); + } + } + + public void expandAll() { + for (Iterator i = t.rootItemIds().iterator(); i.hasNext();) { + t.expandItemsRecursively(i.next()); + } + } + + public void collapseAll() { + for (Iterator i = t.rootItemIds().iterator(); i.hasNext();) { + t.collapseItemsRecursively(i.next()); + } + } + + protected Component getDemoComponent() { + + OrderedLayout l = new OrderedLayout(); + + String[] names = new String[100]; + for (int i = 0; i < names.length; i++) + names[i] = firstnames[(int) (Math.random() * (firstnames.length - 1))] + + " " + + lastnames[(int) (Math.random() * (lastnames.length - 1))]; + + // Create tree + t = new Tree("Family Tree"); + for (int i = 0; i < 100; i++) { + t.addItem(names[i]); + String parent = names[(int) (Math.random() * (names.length - 1))]; + if (t.containsId(parent)) + t.setParent(names[i], parent); + } + + // Forbid childless people to have children (makes them leaves) + for (int i = 0; i < 100; i++) + if (!t.hasChildren(names[i])) + t.setChildrenAllowed(names[i], false); + + l.addComponent(t); + + // Actions + l.addComponent(this.actionHandlerSwitch); + + // Expand and Collapse buttons + l.addComponent(new Button("Expand All", this, "expandAll")); + l.addComponent(new Button("Collapse All", this, "collapseAll")); + + // Properties + propertyPanel = new PropertyPanel(t); + Form ap = propertyPanel + .createBeanPropertySet(new String[] { "selectable" }); + Select themes = (Select) propertyPanel.getField("style"); + themes.addItem("menu").getItemProperty( + themes.getItemCaptionPropertyId()).setValue("menu"); + propertyPanel.addProperties("Tree Properties", ap); + + setJavadocURL("ui/Tree.html"); + + return l; + } + + protected String getExampleSrc() { + return "// Create tree\n" + + "t = new Tree(\"Family Tree\");\n" + + "for (int i = 0; i < 100; i++) {\n" + + " t.addItem(names[i]);\n" + + " String parent = names[(int) (Math.random() * (names.length - 1))];\n" + + " if (t.containsId(parent)) \n" + + " t.setParent(names[i],parent);\n" + + "}\n\n" + + "// Forbid childless people to have children (makes them leaves)\n" + + "for (int i = 0; i < 100; i++)\n" + + " if (!t.hasChildren(names[i]))\n" + + " t.setChildrenAllowed(names[i], false);\n"; + } + + protected String getDescriptionXHTML() { + return "A tree is a natural way to represent datasets that have" + + " hierarchical relationships, such as filesystems, message " + + "threads or, as in this example, family trees. IT Mill Toolkit features a versatile " + + "and powerful Tree component that works much like the tree components " + + "of most modern operating systems." + + "

The most prominent use of the Tree component is to " + + "use it for displaying a hierachical menu, like the " + + "menu on the left side of the screen for instance " + + "or to display filesystems or other hierarchical datasets." + + "

The tree component uses Container " + + "datasources much like the Table component, " + + "with the addition that it also utilizes the hierarchy " + + "information maintained by the container." + + "

On the demo tab you can try out how the different properties " + + "affect the presentation of the tree component."; + } + + protected String getImage() { + return "icon_demo.png"; + } + + protected String getTitle() { + return "Tree"; + } + + private Action ACTION1 = new Action("Action 1"); + + private Action ACTION2 = new Action("Action 2"); + + private Action ACTION3 = new Action("Action 3"); + + private Action[] actions = new Action[] { ACTION1, ACTION2, ACTION3 }; + + public Action[] getActions(Object target, Object sender) { + return actions; + } + + public void handleAction(Action action, Object sender, Object target) { + t.setDescription("Last action clicked was '" + action.getCaption() + + "' on item '" + target + "'"); + } +} diff --git a/src/com/itmill/toolkit/demo/demo/features/FeatureUpload.java b/src/com/itmill/toolkit/demo/demo/features/FeatureUpload.java new file mode 100644 index 0000000000..371509ad55 --- /dev/null +++ b/src/com/itmill/toolkit/demo/demo/features/FeatureUpload.java @@ -0,0 +1,167 @@ +/* ************************************************************************* + + IT Mill Toolkit + + Development of Browser User Interfaces Made Easy + + Copyright (C) 2000-2006 IT Mill Ltd + + ************************************************************************* + + This product is distributed under commercial license that can be found + from the product package on license.pdf. Use of this product might + require purchasing a commercial license from IT Mill Ltd. For guidelines + on usage, see licensing-guidelines.html + + ************************************************************************* + + For more information, contact: + + IT Mill Ltd phone: +358 2 4802 7180 + Ruukinkatu 2-4 fax: +358 2 4802 7181 + 20540, Turku email: info@itmill.com + Finland company www: www.itmill.com + + Primary source for information and releases: www.itmill.com + + ********************************************************************** */ + +package com.itmill.toolkit.demo.features; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.InputStream; +import java.io.OutputStream; + +import com.itmill.toolkit.terminal.StreamResource; +import com.itmill.toolkit.ui.Component; +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.Upload; +import com.itmill.toolkit.ui.Upload.FinishedEvent; + +public class FeatureUpload extends Feature implements Upload.FinishedListener { + Buffer buffer = new Buffer(); + + Panel status = new Panel("Uploaded file:"); + + public FeatureUpload() { + super(); + } + + protected Component getDemoComponent() { + + OrderedLayout l = new OrderedLayout(); + + Upload up = new Upload("Upload a file:", buffer); + up.addListener(this); + + status.setVisible(false); + + l.addComponent(up); + l.addComponent(status); + + // Properties + propertyPanel = new PropertyPanel(up); + + setJavadocURL("ui/Upload.html"); + + return l; + } + + protected String getExampleSrc() { + return "Upload u = new Upload(\"Upload a file:\", uploadReceiver);\n\n" + + "public class uploadReceiver \n" + + "implements Upload.receiver, Upload.FinishedListener { \n" + + "\n" + " java.io.File file;\n" + + " java.io.FileOutputStream fos;\n" + + " public uploadReceiver() {\n" + " }"; + + } + + protected String getDescriptionXHTML() { + return "This demonstrates the use of the Upload component together with the Link component. " + + "This implementation does not actually store the file to disk, it only keeps it in a buffer. " + + "The example given on the Code Sample-tab on the other hand stores the file to disk and binds the link to that file."; + } + + protected String getImage() { + return "icon_demo.png"; + } + + protected String getTitle() { + return "Upload"; + } + + public void uploadFinished(FinishedEvent event) { + status.removeAllComponents(); + if (buffer.getStream() == null) + status.addComponent(new Label( + "Upload finished, but output buffer is null!!")); + else { + status + .addComponent(new Label("Name: " + + event.getFilename(), Label.CONTENT_XHTML)); + status.addComponent(new Label("Mimetype: " + + event.getMIMEType(), Label.CONTENT_XHTML)); + status.addComponent(new Label("Size: " + event.getLength() + + " bytes.", Label.CONTENT_XHTML)); + + status.addComponent(new Link("Download " + buffer.getFileName(), + new StreamResource(buffer, buffer.getFileName(), + getApplication()))); + + status.setVisible(true); + } + } + + public class Buffer implements StreamResource.StreamSource, Upload.Receiver { + ByteArrayOutputStream outputBuffer = null; + + String mimeType; + + String fileName; + + public Buffer() { + + } + + public InputStream getStream() { + if (outputBuffer == null) + return null; + return new ByteArrayInputStream(outputBuffer.toByteArray()); + } + + /** + * @see com.itmill.toolkit.ui.Upload.Receiver#receiveUpload(String, + * String) + */ + public OutputStream receiveUpload(String filename, String MIMEType) { + fileName = filename; + mimeType = MIMEType; + outputBuffer = new ByteArrayOutputStream(); + return outputBuffer; + } + + /** + * Returns the fileName. + * + * @return String + */ + public String getFileName() { + return fileName; + } + + /** + * Returns the mimeType. + * + * @return String + */ + public String getMimeType() { + return mimeType; + } + + } +} \ No newline at end of file diff --git a/src/com/itmill/toolkit/demo/demo/features/FeatureValidators.java b/src/com/itmill/toolkit/demo/demo/features/FeatureValidators.java new file mode 100644 index 0000000000..f04bd4b998 --- /dev/null +++ b/src/com/itmill/toolkit/demo/demo/features/FeatureValidators.java @@ -0,0 +1,106 @@ +/* ************************************************************************* + + IT Mill Toolkit + + Development of Browser User Interfaces Made Easy + + Copyright (C) 2000-2006 IT Mill Ltd + + ************************************************************************* + + This product is distributed under commercial license that can be found + from the product package on license.pdf. Use of this product might + require purchasing a commercial license from IT Mill Ltd. For guidelines + on usage, see licensing-guidelines.html + + ************************************************************************* + + For more information, contact: + + IT Mill Ltd phone: +358 2 4802 7180 + Ruukinkatu 2-4 fax: +358 2 4802 7181 + 20540, Turku email: info@itmill.com + Finland company www: www.itmill.com + + Primary source for information and releases: www.itmill.com + + ********************************************************************** */ + +package com.itmill.toolkit.demo.features; + +import com.itmill.toolkit.ui.Component; +import com.itmill.toolkit.ui.Form; +import com.itmill.toolkit.ui.Label; +import com.itmill.toolkit.ui.OrderedLayout; +import com.itmill.toolkit.ui.Panel; +import com.itmill.toolkit.ui.Select; + +public class FeatureValidators extends Feature { + + private static final String INTRO_TEXT = "" + + "IT Mill Toolkit contains simple, yet powerful validation interface, " + + "that consists of two parts: Validator and Validatable. Validator is " + + "any class that can check validity of an Object. Validatable is " + + "a class with configurable validation. " + + "Validation errors are passed as special exceptions that implement " + + "ErrorMessage interface. This way the validation errors can be " + + "automatically added to components." + + "

Utilities for simple string and null validation are provided, as " + + "well as combinative validators. The validation interface can also " + + "be easily implemented by the applications for more complex " + + "validation needs."; + + public FeatureValidators() { + super(); + } + + protected Component getDemoComponent() { + + OrderedLayout l = new OrderedLayout(); + + Panel panel = new Panel(); + panel.setCaption("Validators"); + l.addComponent(panel); + + Label label = new Label(); + panel.addComponent(label); + + label.setContentMode(Label.CONTENT_XHTML); + label.setValue(INTRO_TEXT); + + // Properties + propertyPanel = new PropertyPanel(panel); + Form ap = propertyPanel.createBeanPropertySet(new String[] { "width", + "height" }); + Select themes = (Select) propertyPanel.getField("style"); + themes.addItem("light").getItemProperty( + themes.getItemCaptionPropertyId()).setValue("light"); + themes.addItem("strong").getItemProperty( + themes.getItemCaptionPropertyId()).setValue("strong"); + propertyPanel.addProperties("Panel Properties", ap); + + setJavadocURL("data/Validator.html"); + + return l; + } + + protected String getExampleSrc() { + return null; + } + + /** + * @see com.itmill.toolkit.demo.features.Feature#getDescriptionXHTML() + */ + protected String getDescriptionXHTML() { + return null; + } + + protected String getImage() { + return null; + } + + protected String getTitle() { + return null; + } + +} diff --git a/src/com/itmill/toolkit/demo/demo/features/FeatureWindow.java b/src/com/itmill/toolkit/demo/demo/features/FeatureWindow.java new file mode 100644 index 0000000000..7e2a3471f7 --- /dev/null +++ b/src/com/itmill/toolkit/demo/demo/features/FeatureWindow.java @@ -0,0 +1,148 @@ +/* ************************************************************************* + + IT Mill Toolkit + + Development of Browser User Interfaces Made Easy + + Copyright (C) 2000-2006 IT Mill Ltd + + ************************************************************************* + + This product is distributed under commercial license that can be found + from the product package on license.pdf. Use of this product might + require purchasing a commercial license from IT Mill Ltd. For guidelines + on usage, see licensing-guidelines.html + + ************************************************************************* + + For more information, contact: + + IT Mill Ltd phone: +358 2 4802 7180 + Ruukinkatu 2-4 fax: +358 2 4802 7181 + 20540, Turku email: info@itmill.com + Finland company www: www.itmill.com + + Primary source for information and releases: www.itmill.com + + ********************************************************************** */ + +package com.itmill.toolkit.demo.features; + +import com.itmill.toolkit.ui.*; + +public class FeatureWindow extends Feature { + Button addButton = new Button("Add to application", this, "addWin"); + + Button removeButton = new Button("Remove from application", this, "delWin"); + + Window demoWindow; + + Form windowProperties; + + public FeatureWindow() { + super(); + } + + protected Component getDemoComponent() { + + OrderedLayout layoutRoot = new OrderedLayout(); + OrderedLayout layoutUpper = new OrderedLayout(); + OrderedLayout layoutLower = new OrderedLayout(); + demoWindow = new Window("Feature Test Window"); + + layoutUpper.addComponent(addButton); + layoutUpper.addComponent(removeButton); + + layoutLower.addComponent(new Label( + "Note: depending on your browser, you may have to " + + "allow popups from this web site in order" + + " to get this demo to work.")); + updateWinStatus(); + + // Propertiesc + propertyPanel = new PropertyPanel(demoWindow); + propertyPanel.dependsOn(addButton); + propertyPanel.dependsOn(removeButton); + windowProperties = propertyPanel.createBeanPropertySet(new String[] { + "width", "height", "name", "border", "theme", "scrollable", + "scrollOffsetX", "scrollOffsetY" }); + windowProperties.replaceWithSelect("border", new Object[] { + new Integer(Window.BORDER_DEFAULT), + new Integer(Window.BORDER_NONE), + new Integer(Window.BORDER_MINIMAL) }, new Object[] { "Default", + "None", "Minimal" }); + propertyPanel.addProperties("Window Properties", windowProperties); + + setJavadocURL("ui/Window.html"); + + layoutRoot.addComponent(layoutUpper); + layoutRoot.addComponent(layoutLower); + return layoutRoot; + } + + protected String getExampleSrc() { + return "Window win = new Window();\n" + + "getApplication().addWindow(win);\n"; + + } + + protected String getDescriptionXHTML() { + return "The window support in IT Mill Toolkit allows for opening and closing windows, " + + "refreshing one window from another (for asynchronous terminals), " + + "resizing windows and scrolling window content. " + + "There are also a number of preset window border styles defined by " + + "this feature."; + } + + protected String getImage() { + return "icon_demo.png"; + } + + protected String getTitle() { + return "Window"; + } + + public void addWin() { + getApplication().addWindow(demoWindow); + + demoWindow.removeAllComponents(); + demoWindow.setWidth(500); + demoWindow.setHeight(200); + + // Panel panel = new Panel("New window"); + // panel.addComponent(new Label( + // "This is a new window created by selecting Add to " + // + "application.

You can close" + // + " this window by selecting Remove from" + // + " application from the Feature Browser window.", + // Label.CONTENT_XHTML)); + // demoWindow.addComponent(panel); + + demoWindow + .addComponent(new Label( + "

This is a new window created by Add to " + + "application button's event.

You may simply" + + " close this window or select Remove from" + + " application from the Feature Browser window.", + Label.CONTENT_XHTML)); + + windowProperties.getField("name").setReadOnly(true); + updateWinStatus(); + } + + public void delWin() { + getApplication().removeWindow(demoWindow); + windowProperties.getField("name").setReadOnly(false); + updateWinStatus(); + } + + private void updateWinStatus() { + if (demoWindow.getApplication() == null) { + addButton.setEnabled(true); + removeButton.setEnabled(false); + } else { + addButton.setEnabled(false); + removeButton.setEnabled(true); + } + } +} diff --git a/src/com/itmill/toolkit/demo/demo/features/FeaturesApplication.java b/src/com/itmill/toolkit/demo/demo/features/FeaturesApplication.java new file mode 100644 index 0000000000..74c61f60d7 --- /dev/null +++ b/src/com/itmill/toolkit/demo/demo/features/FeaturesApplication.java @@ -0,0 +1,50 @@ +/* ************************************************************************* + + IT Mill Toolkit + + Development of Browser User Interfaces Made Easy + + Copyright (C) 2000-2006 IT Mill Ltd + + ************************************************************************* + + This product is distributed under commercial license that can be found + from the product package on license.pdf. Use of this product might + require purchasing a commercial license from IT Mill Ltd. For guidelines + on usage, see licensing-guidelines.html + + ************************************************************************* + + For more information, contact: + + IT Mill Ltd phone: +358 2 4802 7180 + Ruukinkatu 2-4 fax: +358 2 4802 7181 + 20540, Turku email: info@itmill.com + Finland company www: www.itmill.com + + Primary source for information and releases: www.itmill.com + + ********************************************************************** */ + +package com.itmill.toolkit.demo.features; + +import com.itmill.toolkit.ui.*; + +public class FeaturesApplication extends com.itmill.toolkit.Application { + + public void init() { + Window main = new Window("IT Mill Toolkit Features Tour"); + setMainWindow(main); + main.addComponent(new FeatureBrowser()); + } + + /** + * ErrorEvents are printed to default error stream and not in GUI. + */ + public void terminalError( + com.itmill.toolkit.terminal.Terminal.ErrorEvent event) { + Throwable e = event.getThrowable(); + e.printStackTrace(); + } + +} diff --git a/src/com/itmill/toolkit/demo/demo/features/IntroBasic.java b/src/com/itmill/toolkit/demo/demo/features/IntroBasic.java new file mode 100644 index 0000000000..48afd990ca --- /dev/null +++ b/src/com/itmill/toolkit/demo/demo/features/IntroBasic.java @@ -0,0 +1,98 @@ +/* ************************************************************************* + + IT Mill Toolkit + + Development of Browser User Interfaces Made Easy + + Copyright (C) 2000-2006 IT Mill Ltd + + ************************************************************************* + + This product is distributed under commercial license that can be found + from the product package on license.pdf. Use of this product might + require purchasing a commercial license from IT Mill Ltd. For guidelines + on usage, see licensing-guidelines.html + + ************************************************************************* + + For more information, contact: + + IT Mill Ltd phone: +358 2 4802 7180 + Ruukinkatu 2-4 fax: +358 2 4802 7181 + 20540, Turku email: info@itmill.com + Finland company www: www.itmill.com + + Primary source for information and releases: www.itmill.com + + ********************************************************************** */ + +package com.itmill.toolkit.demo.features; + +import com.itmill.toolkit.ui.Component; +import com.itmill.toolkit.ui.Form; +import com.itmill.toolkit.ui.Label; +import com.itmill.toolkit.ui.OrderedLayout; +import com.itmill.toolkit.ui.Panel; +import com.itmill.toolkit.ui.Select; + +public class IntroBasic extends Feature { + + private static final String INTRO_TEXT = "" + + "Text Field, Date Field, Button, Form, Label and Link components are provided as samples" + + " for basic UI components." + + "

See the API documentation of respective components for more information."; + + public IntroBasic() { + super(); + } + + protected Component getDemoComponent() { + + OrderedLayout l = new OrderedLayout(); + + Panel panel = new Panel(); + panel.setCaption("Basic UI components"); + l.addComponent(panel); + + Label label = new Label(); + panel.addComponent(label); + + label.setContentMode(Label.CONTENT_XHTML); + label.setValue(INTRO_TEXT); + + // Properties + propertyPanel = new PropertyPanel(panel); + Form ap = propertyPanel.createBeanPropertySet(new String[] { "width", + "height" }); + Select themes = (Select) propertyPanel.getField("style"); + themes.addItem("light").getItemProperty( + themes.getItemCaptionPropertyId()).setValue("light"); + themes.addItem("strong").getItemProperty( + themes.getItemCaptionPropertyId()).setValue("strong"); + propertyPanel.addProperties("Panel Properties", ap); + + setJavadocURL("ui/package-summary.html"); + + return l; + } + + protected String getExampleSrc() { + return null; + } + + /** + * @see com.itmill.toolkit.demo.features.Feature#getDescriptionXHTML() + */ + protected String getDescriptionXHTML() { + return null; + } + + protected String getImage() { + return null; + } + + protected String getTitle() { + return "Introduction of basic UI components (TODO)"; + } + +} diff --git a/src/com/itmill/toolkit/demo/demo/features/IntroComponents.java b/src/com/itmill/toolkit/demo/demo/features/IntroComponents.java new file mode 100644 index 0000000000..2907f46b70 --- /dev/null +++ b/src/com/itmill/toolkit/demo/demo/features/IntroComponents.java @@ -0,0 +1,102 @@ +/* ************************************************************************* + + IT Mill Toolkit + + Development of Browser User Interfaces Made Easy + + Copyright (C) 2000-2006 IT Mill Ltd + + ************************************************************************* + + This product is distributed under commercial license that can be found + from the product package on license.pdf. Use of this product might + require purchasing a commercial license from IT Mill Ltd. For guidelines + on usage, see licensing-guidelines.html + + ************************************************************************* + + For more information, contact: + + IT Mill Ltd phone: +358 2 4802 7180 + Ruukinkatu 2-4 fax: +358 2 4802 7181 + 20540, Turku email: info@itmill.com + Finland company www: www.itmill.com + + Primary source for information and releases: www.itmill.com + + ********************************************************************** */ + +package com.itmill.toolkit.demo.features; + +import com.itmill.toolkit.terminal.ClassResource; +import com.itmill.toolkit.ui.Component; +import com.itmill.toolkit.ui.Embedded; +import com.itmill.toolkit.ui.Form; +import com.itmill.toolkit.ui.Label; +import com.itmill.toolkit.ui.OrderedLayout; +import com.itmill.toolkit.ui.Panel; +import com.itmill.toolkit.ui.Select; + +public class IntroComponents extends Feature { + + private static final String INTRO_TEXT = "" + + "This picture summarizes the relations between different user interface (UI) components." + + "

See API documentation below for more information."; + + public IntroComponents() { + super(); + } + + protected Component getDemoComponent() { + + OrderedLayout l = new OrderedLayout(); + + Panel panel = new Panel(); + panel.setCaption("UI component diagram"); + l.addComponent(panel); + + Label label = new Label(); + panel.addComponent(label); + + label.setContentMode(Label.CONTENT_XHTML); + label.setValue(INTRO_TEXT); + + panel.addComponent(new Embedded("", new ClassResource("components.png", + this.getApplication()))); + + // Properties + propertyPanel = new PropertyPanel(panel); + Form ap = propertyPanel.createBeanPropertySet(new String[] { "width", + "height" }); + Select themes = (Select) propertyPanel.getField("style"); + themes.addItem("light").getItemProperty( + themes.getItemCaptionPropertyId()).setValue("light"); + themes.addItem("strong").getItemProperty( + themes.getItemCaptionPropertyId()).setValue("strong"); + propertyPanel.addProperties("Panel Properties", ap); + + setJavadocURL("ui/package-summary.html"); + + return l; + } + + protected String getExampleSrc() { + return null; + } + + /** + * @see com.itmill.toolkit.demo.features.Feature#getDescriptionXHTML() + */ + protected String getDescriptionXHTML() { + return null; + } + + protected String getImage() { + return null; + } + + protected String getTitle() { + return null; + } + +} diff --git a/src/com/itmill/toolkit/demo/demo/features/IntroDataHandling.java b/src/com/itmill/toolkit/demo/demo/features/IntroDataHandling.java new file mode 100644 index 0000000000..c2c954381f --- /dev/null +++ b/src/com/itmill/toolkit/demo/demo/features/IntroDataHandling.java @@ -0,0 +1,97 @@ +/* ************************************************************************* + + IT Mill Toolkit + + Development of Browser User Interfaces Made Easy + + Copyright (C) 2000-2006 IT Mill Ltd + + ************************************************************************* + + This product is distributed under commercial license that can be found + from the product package on license.pdf. Use of this product might + require purchasing a commercial license from IT Mill Ltd. For guidelines + on usage, see licensing-guidelines.html + + ************************************************************************* + + For more information, contact: + + IT Mill Ltd phone: +358 2 4802 7180 + Ruukinkatu 2-4 fax: +358 2 4802 7181 + 20540, Turku email: info@itmill.com + Finland company www: www.itmill.com + + Primary source for information and releases: www.itmill.com + + ********************************************************************** */ + +package com.itmill.toolkit.demo.features; + +import com.itmill.toolkit.ui.Component; +import com.itmill.toolkit.ui.Form; +import com.itmill.toolkit.ui.Label; +import com.itmill.toolkit.ui.OrderedLayout; +import com.itmill.toolkit.ui.Panel; +import com.itmill.toolkit.ui.Select; + +public class IntroDataHandling extends Feature { + + private static final String INTRO_TEXT = "" + + "Embedded Objects and Upload components are provided as samples" + + " for data handling section." + + "

See the API documentation of respective components for more information."; + + public IntroDataHandling() { + super(); + } + + protected Component getDemoComponent() { + + OrderedLayout l = new OrderedLayout(); + + Panel panel = new Panel(); + panel.setCaption("Data Handling"); + l.addComponent(panel); + + Label label = new Label(); + panel.addComponent(label); + + label.setContentMode(Label.CONTENT_XHTML); + label.setValue(INTRO_TEXT); + + // Properties + propertyPanel = new PropertyPanel(panel); + Form ap = propertyPanel.createBeanPropertySet(new String[] { "width", + "height" }); + Select themes = (Select) propertyPanel.getField("style"); + themes.addItem("light").getItemProperty( + themes.getItemCaptionPropertyId()).setValue("light"); + themes.addItem("strong").getItemProperty( + themes.getItemCaptionPropertyId()).setValue("strong"); + propertyPanel.addProperties("Panel Properties", ap); + + return l; + } + + protected String getExampleSrc() { + return null; + } + + /** + * @see com.itmill.toolkit.demo.features.Feature#getDescriptionXHTML() + */ + protected String getDescriptionXHTML() { + return "Please select Embedded Objects or Upload" + + " from the menu for more information."; + } + + protected String getImage() { + return null; + } + + protected String getTitle() { + return null; + } + +} diff --git a/src/com/itmill/toolkit/demo/demo/features/IntroDataModel.java b/src/com/itmill/toolkit/demo/demo/features/IntroDataModel.java new file mode 100644 index 0000000000..5a0a677d73 --- /dev/null +++ b/src/com/itmill/toolkit/demo/demo/features/IntroDataModel.java @@ -0,0 +1,99 @@ +/* ************************************************************************* + + IT Mill Toolkit + + Development of Browser User Interfaces Made Easy + + Copyright (C) 2000-2006 IT Mill Ltd + + ************************************************************************* + + This product is distributed under commercial license that can be found + from the product package on license.pdf. Use of this product might + require purchasing a commercial license from IT Mill Ltd. For guidelines + on usage, see licensing-guidelines.html + + ************************************************************************* + + For more information, contact: + + IT Mill Ltd phone: +358 2 4802 7180 + Ruukinkatu 2-4 fax: +358 2 4802 7181 + 20540, Turku email: info@itmill.com + Finland company www: www.itmill.com + + Primary source for information and releases: www.itmill.com + + ********************************************************************** */ + +package com.itmill.toolkit.demo.features; + +import com.itmill.toolkit.ui.Component; +import com.itmill.toolkit.ui.Form; +import com.itmill.toolkit.ui.Label; +import com.itmill.toolkit.ui.OrderedLayout; +import com.itmill.toolkit.ui.Panel; +import com.itmill.toolkit.ui.Select; + +public class IntroDataModel extends Feature { + + private static final String INTRO_TEXT = "" + + "This section introduces main concepts of data model in IT Mill Toolkit." + + " It contains brief introduction to Properties, Items, Containers, Validators and" + + " Buffering classes." + + "

See the API documentation of respective area for more information."; + + public IntroDataModel() { + super(); + } + + protected Component getDemoComponent() { + + OrderedLayout l = new OrderedLayout(); + + Panel panel = new Panel(); + panel.setCaption("Data Model"); + l.addComponent(panel); + + Label label = new Label(); + panel.addComponent(label); + + label.setContentMode(Label.CONTENT_XHTML); + label.setValue(INTRO_TEXT); + + // Properties + propertyPanel = new PropertyPanel(panel); + Form ap = propertyPanel.createBeanPropertySet(new String[] { "width", + "height" }); + Select themes = (Select) propertyPanel.getField("style"); + themes.addItem("light").getItemProperty( + themes.getItemCaptionPropertyId()).setValue("light"); + themes.addItem("strong").getItemProperty( + themes.getItemCaptionPropertyId()).setValue("strong"); + propertyPanel.addProperties("Panel Properties", ap); + + setJavadocURL("data/package-summary.html"); + + return l; + } + + protected String getExampleSrc() { + return null; + } + + /** + * @see com.itmill.toolkit.demo.features.Feature#getDescriptionXHTML() + */ + protected String getDescriptionXHTML() { + return null; + } + + protected String getImage() { + return null; + } + + protected String getTitle() { + return null; + } + +} diff --git a/src/com/itmill/toolkit/demo/demo/features/IntroItemContainers.java b/src/com/itmill/toolkit/demo/demo/features/IntroItemContainers.java new file mode 100644 index 0000000000..1ee36bde35 --- /dev/null +++ b/src/com/itmill/toolkit/demo/demo/features/IntroItemContainers.java @@ -0,0 +1,98 @@ +/* ************************************************************************* + + IT Mill Toolkit + + Development of Browser User Interfaces Made Easy + + Copyright (C) 2000-2006 IT Mill Ltd + + ************************************************************************* + + This product is distributed under commercial license that can be found + from the product package on license.pdf. Use of this product might + require purchasing a commercial license from IT Mill Ltd. For guidelines + on usage, see licensing-guidelines.html + + ************************************************************************* + + For more information, contact: + + IT Mill Ltd phone: +358 2 4802 7180 + Ruukinkatu 2-4 fax: +358 2 4802 7181 + 20540, Turku email: info@itmill.com + Finland company www: www.itmill.com + + Primary source for information and releases: www.itmill.com + + ********************************************************************** */ + +package com.itmill.toolkit.demo.features; + +import com.itmill.toolkit.ui.Component; +import com.itmill.toolkit.ui.Form; +import com.itmill.toolkit.ui.Label; +import com.itmill.toolkit.ui.OrderedLayout; +import com.itmill.toolkit.ui.Panel; +import com.itmill.toolkit.ui.Select; + +public class IntroItemContainers extends Feature { + + private static final String INTRO_TEXT = "" + + "Select, Table and Tree components are provided as samples" + + " for item containers section." + + "

See the API documentation of respective components for more information."; + + public IntroItemContainers() { + super(); + } + + protected Component getDemoComponent() { + + OrderedLayout l = new OrderedLayout(); + + Panel panel = new Panel(); + panel.setCaption("Item Containers"); + l.addComponent(panel); + + Label label = new Label(); + panel.addComponent(label); + + label.setContentMode(Label.CONTENT_XHTML); + label.setValue(INTRO_TEXT); + + // Properties + propertyPanel = new PropertyPanel(panel); + Form ap = propertyPanel.createBeanPropertySet(new String[] { "width", + "height" }); + Select themes = (Select) propertyPanel.getField("style"); + themes.addItem("light").getItemProperty( + themes.getItemCaptionPropertyId()).setValue("light"); + themes.addItem("strong").getItemProperty( + themes.getItemCaptionPropertyId()).setValue("strong"); + propertyPanel.addProperties("Panel Properties", ap); + + setJavadocURL("data/Container.html"); + + return l; + } + + protected String getExampleSrc() { + return null; + } + + /** + * @see com.itmill.toolkit.demo.features.Feature#getDescriptionXHTML() + */ + protected String getDescriptionXHTML() { + return null; + } + + protected String getImage() { + return null; + } + + protected String getTitle() { + return null; + } + +} diff --git a/src/com/itmill/toolkit/demo/demo/features/IntroLayouts.java b/src/com/itmill/toolkit/demo/demo/features/IntroLayouts.java new file mode 100644 index 0000000000..d68aa720b4 --- /dev/null +++ b/src/com/itmill/toolkit/demo/demo/features/IntroLayouts.java @@ -0,0 +1,100 @@ +/* ************************************************************************* + + IT Mill Toolkit + + Development of Browser User Interfaces Made Easy + + Copyright (C) 2000-2006 IT Mill Ltd + + ************************************************************************* + + This product is distributed under commercial license that can be found + from the product package on license.pdf. Use of this product might + require purchasing a commercial license from IT Mill Ltd. For guidelines + on usage, see licensing-guidelines.html + + ************************************************************************* + + For more information, contact: + + IT Mill Ltd phone: +358 2 4802 7180 + Ruukinkatu 2-4 fax: +358 2 4802 7181 + 20540, Turku email: info@itmill.com + Finland company www: www.itmill.com + + Primary source for information and releases: www.itmill.com + + ********************************************************************** */ + +package com.itmill.toolkit.demo.features; + +import com.itmill.toolkit.ui.Component; +import com.itmill.toolkit.ui.Form; +import com.itmill.toolkit.ui.Label; +import com.itmill.toolkit.ui.OrderedLayout; +import com.itmill.toolkit.ui.Panel; +import com.itmill.toolkit.ui.Select; + +public class IntroLayouts extends Feature { + + private static final String INTRO_TEXT = "" + + "Layouts are required to place components to specific place in the UI." + + " You can use plain Java to accomplish sophisticated component layouting." + + " Other option is to use Custom Layout and let the web page designers" + + " to take responsibility of component layouting using their own set of tools." + + "

See API documentation below for more information."; + + public IntroLayouts() { + super(); + } + + protected Component getDemoComponent() { + + OrderedLayout l = new OrderedLayout(); + + Panel panel = new Panel(); + panel.setCaption("Layouts"); + l.addComponent(panel); + + Label label = new Label(); + panel.addComponent(label); + + label.setContentMode(Label.CONTENT_XHTML); + label.setValue(INTRO_TEXT); + + // Properties + propertyPanel = new PropertyPanel(panel); + Form ap = propertyPanel.createBeanPropertySet(new String[] { "width", + "height" }); + Select themes = (Select) propertyPanel.getField("style"); + themes.addItem("light").getItemProperty( + themes.getItemCaptionPropertyId()).setValue("light"); + themes.addItem("strong").getItemProperty( + themes.getItemCaptionPropertyId()).setValue("strong"); + propertyPanel.addProperties("Panel Properties", ap); + + setJavadocURL("ui/Layout.html"); + + return l; + } + + protected String getExampleSrc() { + return null; + } + + /** + * @see com.itmill.toolkit.demo.features.Feature#getDescriptionXHTML() + */ + protected String getDescriptionXHTML() { + return null; + } + + protected String getImage() { + return null; + } + + protected String getTitle() { + return null; + } + +} diff --git a/src/com/itmill/toolkit/demo/demo/features/IntroTerminal.java b/src/com/itmill/toolkit/demo/demo/features/IntroTerminal.java new file mode 100644 index 0000000000..eb7d1f1808 --- /dev/null +++ b/src/com/itmill/toolkit/demo/demo/features/IntroTerminal.java @@ -0,0 +1,74 @@ +/* ************************************************************************* + + IT Mill Toolkit + + Development of Browser User Interfaces Made Easy + + Copyright (C) 2000-2006 IT Mill Ltd + + ************************************************************************* + + This product is distributed under commercial license that can be found + from the product package on license.pdf. Use of this product might + require purchasing a commercial license from IT Mill Ltd. For guidelines + on usage, see licensing-guidelines.html + + ************************************************************************* + + For more information, contact: + + IT Mill Ltd phone: +358 2 4802 7180 + Ruukinkatu 2-4 fax: +358 2 4802 7181 + 20540, Turku email: info@itmill.com + Finland company www: www.itmill.com + + Primary source for information and releases: www.itmill.com + + ********************************************************************** */ + +package com.itmill.toolkit.demo.features; + +import com.itmill.toolkit.ui.Component; +import com.itmill.toolkit.ui.Label; +import com.itmill.toolkit.ui.OrderedLayout; + +public class IntroTerminal extends Feature { + + public IntroTerminal() { + super(); + } + + protected Component getDemoComponent() { + + OrderedLayout l = new OrderedLayout(); + + Label lab = new Label(); + lab.setStyle("featurebrowser-none"); + l.addComponent(lab); + + // Properties + propertyPanel = null; + + return l; + } + + protected String getExampleSrc() { + return null; + } + + /** + * @see com.itmill.toolkit.demo.features.Feature#getDescriptionXHTML() + */ + protected String getDescriptionXHTML() { + return ""; + } + + protected String getImage() { + return null; + } + + protected String getTitle() { + return "Introduction for terminals (TODO)"; + } + +} diff --git a/src/com/itmill/toolkit/demo/demo/features/IntroWelcome.java b/src/com/itmill/toolkit/demo/demo/features/IntroWelcome.java new file mode 100644 index 0000000000..7d974d1c4d --- /dev/null +++ b/src/com/itmill/toolkit/demo/demo/features/IntroWelcome.java @@ -0,0 +1,134 @@ +/* ************************************************************************* + + IT Mill Toolkit + + Development of Browser User Interfaces Made Easy + + Copyright (C) 2000-2006 IT Mill Ltd + + ************************************************************************* + + This product is distributed under commercial license that can be found + from the product package on license.pdf. Use of this product might + require purchasing a commercial license from IT Mill Ltd. For guidelines + on usage, see licensing-guidelines.html + + ************************************************************************* + + For more information, contact: + + IT Mill Ltd phone: +358 2 4802 7180 + Ruukinkatu 2-4 fax: +358 2 4802 7181 + 20540, Turku email: info@itmill.com + Finland company www: www.itmill.com + + Primary source for information and releases: www.itmill.com + + ********************************************************************** */ + +package com.itmill.toolkit.demo.features; + +import com.itmill.toolkit.terminal.web.ApplicationServlet; +import com.itmill.toolkit.ui.Component; +import com.itmill.toolkit.ui.Form; +import com.itmill.toolkit.ui.Label; +import com.itmill.toolkit.ui.OrderedLayout; +import com.itmill.toolkit.ui.Panel; +import com.itmill.toolkit.ui.Select; + +public class IntroWelcome extends Feature { + + private static final String WELCOME_TEXT_UPPER = "" + + "This application lets you view and play with some features of " + + "IT Mill Toolkit. Use menu on the left to select component." + + "

Note the Properties selection on the top " + + "right corner. Click it open to access component properties and" + + " feel free to edit properties at any time." + + "

The area that you are now reading is the component" + + " demo area. Lower area from here contains component description, API" + + " documentation and optional code sample. Note that not all selections" + + " contain demo, only description and API documentation is shown." + + "

You may also change application's theme from below the menu." + + " This example application is designed to work best with" + + " Demo theme, other themes are for demonstration purposes only." + + "

IT Mill Toolkit enables you to construct complex Web" + + " applications using plain Java, no knowledge of other Web technologies" + + " such as XML, HTML, DOM, JavaScript or browser differences is required." + + "

For more information, point your browser to" + + " www.itmill.com."; + + private static final String WELCOME_TEXT_LOWER = "" + + "This area contains the selected component's description, API documentation" + + " and optional code sample." + + "

To see how simple it is to create IT Mill Toolkit application," + + " click Code Sample tab." + + "

Start your tour now by selecting features from the list" + + " on the left and remember to experiment with the Properties panel" + + " located at the top right corner area."; + + public IntroWelcome() { + super(); + } + + protected Component getDemoComponent() { + + OrderedLayout l = new OrderedLayout(); + + Panel panel = new Panel(); + panel.setCaption("Welcome to the IT Mill Toolkit feature tour!"); + l.addComponent(panel); + + Label label = new Label(); + panel.addComponent(label); + + label.setContentMode(Label.CONTENT_XHTML); + label.setValue(WELCOME_TEXT_UPPER); + + // Propertiesversion.setValue("IT Mill Toolkit version: + // "+ApplicationServlet.VERSION); + propertyPanel = new PropertyPanel(panel); + Form ap = propertyPanel.createBeanPropertySet(new String[] { "width", + "height" }); + Select themes = (Select) propertyPanel.getField("style"); + themes.addItem("light").getItemProperty( + themes.getItemCaptionPropertyId()).setValue("light"); + themes.addItem("strong").getItemProperty( + themes.getItemCaptionPropertyId()).setValue("strong"); + propertyPanel.addProperties("Panel Properties", ap); + + setJavadocURL("package-summary.html"); + + setPropsReminder(false); + + return l; + } + + protected String getExampleSrc() { + return "" + + "package com.itmill.toolkit.demo;\n" + + "import com.itmill.toolkit.ui.*;\n\n" + + "public class HelloWorld extends com.itmill.toolkit.Application {\n" + + " public void init() {\n" + + " Window main = new Window(\"Hello window\");\n" + + " setMainWindow(main);\n" + + " main.addComponent(new Label(\"Hello World!\"));\n" + + " }\n" + "}\n"; + } + + /** + * @see com.itmill.toolkit.demo.features.Feature#getDescriptionXHTML() + */ + protected String getDescriptionXHTML() { + return WELCOME_TEXT_LOWER + "

IT Mill Toolkit version: " + + ApplicationServlet.VERSION; + } + + protected String getImage() { + return "icon_intro.png"; + } + + protected String getTitle() { + return "Welcome"; + } + +} diff --git a/src/com/itmill/toolkit/demo/demo/features/PropertyPanel.java b/src/com/itmill/toolkit/demo/demo/features/PropertyPanel.java new file mode 100644 index 0000000000..e59f838f5d --- /dev/null +++ b/src/com/itmill/toolkit/demo/demo/features/PropertyPanel.java @@ -0,0 +1,467 @@ +/* ************************************************************************* + + IT Mill Toolkit + + Development of Browser User Interfaces Made Easy + + Copyright (C) 2000-2006 IT Mill Ltd + + ************************************************************************* + + This product is distributed under commercial license that can be found + from the product package on license.pdf. Use of this product might + require purchasing a commercial license from IT Mill Ltd. For guidelines + on usage, see licensing-guidelines.html + + ************************************************************************* + + For more information, contact: + + IT Mill Ltd phone: +358 2 4802 7180 + Ruukinkatu 2-4 fax: +358 2 4802 7181 + 20540, Turku email: info@itmill.com + Finland company www: www.itmill.com + + Primary source for information and releases: www.itmill.com + + ********************************************************************** */ + +package com.itmill.toolkit.demo.features; + +import java.beans.BeanInfo; +import java.beans.IntrospectionException; +import java.beans.Introspector; +import java.beans.PropertyDescriptor; +import java.util.Date; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedList; + +import com.itmill.toolkit.data.*; +import com.itmill.toolkit.data.Property.ValueChangeListener; +import com.itmill.toolkit.data.util.*; +import com.itmill.toolkit.terminal.*; +import com.itmill.toolkit.ui.*; + +public class PropertyPanel extends Panel implements Button.ClickListener, + Property.ValueChangeListener { + + private Select addComponent; + + private OrderedLayout formsLayout = new OrderedLayout(); + + private LinkedList forms = new LinkedList(); + + private Button setButton = new Button("Set", this); + + private Button discardButton = new Button("Discard changes", this); + + private Button showAllProperties = new Button("List of All Properties", + this); + + private Table allProperties = new Table(); + + private Object objectToConfigure; + + private BeanItem config; + + /** Contruct new property panel for configuring given object. */ + public PropertyPanel(Object objectToConfigure) { + super(); + + // Layout + setCaption("Properties"); + addComponent(formsLayout); + + // Target object + this.objectToConfigure = objectToConfigure; + config = new BeanItem(objectToConfigure); + + // Control buttons + OrderedLayout buttons = new OrderedLayout( + OrderedLayout.ORIENTATION_VERTICAL); + buttons.addComponent(setButton); + buttons.addComponent(discardButton); + addComponent(buttons); + + // Add default properties + addBasicComponentProperties(); + if (objectToConfigure instanceof Select) + addSelectProperties(); + if (objectToConfigure instanceof AbstractField + && !(objectToConfigure instanceof Table || objectToConfigure instanceof Tree)) + addFieldProperties(); + if ((objectToConfigure instanceof AbstractComponentContainer) + && !(objectToConfigure instanceof FrameWindow)) + addComponentContainerProperties(); + + // The list of all properties + addComponent(showAllProperties); + showAllProperties.setSwitchMode(true); + allProperties.setVisible(false); + allProperties.addContainerProperty("Name", String.class, ""); + allProperties.addContainerProperty("Type", String.class, ""); + allProperties.addContainerProperty("R/W", String.class, ""); + allProperties.addContainerProperty("Demo", String.class, ""); + allProperties.setColumnAlignments(new String[] { Table.ALIGN_LEFT, + Table.ALIGN_LEFT, Table.ALIGN_CENTER, Table.ALIGN_CENTER }); + allProperties.setColumnHeaderMode(Table.COLUMN_HEADER_MODE_ID); + updatePropertyList(); + addComponent(allProperties); + } + + /** Add a formful of properties to property panel */ + public void addProperties(String propertySetCaption, Form properties) { + + // Create new panel containing the form + Panel p = new Panel(); + p.setCaption(propertySetCaption); + p.setStyle("light"); + p.addComponent(properties); + formsLayout.addComponent(p); + + // Setup buffering + setButton.dependsOn(properties); + discardButton.dependsOn(properties); + properties.setWriteThrough(false); + properties.setReadThrough(true); + + // Maintain property lists + forms.add(properties); + updatePropertyList(); + } + + /** Handle all button clicks for this panel */ + public void buttonClick(Button.ClickEvent event) { + + // Commit all changed on all forms + if (event.getButton() == setButton) { + for (Iterator i = forms.iterator(); i.hasNext();) + ((Form) i.next()).commit(); + } + + // Discard all changed on all forms + if (event.getButton() == discardButton) { + for (Iterator i = forms.iterator(); i.hasNext();) + ((Form) i.next()).discard(); + } + + // Show property list + if (event.getButton() == showAllProperties) { + allProperties.setVisible(((Boolean) showAllProperties.getValue()) + .booleanValue()); + } + } + + /** Recreate property list contents */ + public void updatePropertyList() { + + allProperties.removeAllItems(); + + // Collect demoed properties + HashSet listed = new HashSet(); + for (Iterator i = forms.iterator(); i.hasNext();) + listed.addAll(((Form) i.next()).getItemPropertyIds()); + + // Resolve all properties + BeanInfo info; + try { + info = Introspector.getBeanInfo(objectToConfigure.getClass()); + } catch (IntrospectionException e) { + throw new RuntimeException(e.toString()); + } + PropertyDescriptor[] pd = info.getPropertyDescriptors(); + + // Fill the table + for (int i = 0; i < pd.length; i++) { + allProperties.addItem(new Object[] { pd[i].getName(), + pd[i].getPropertyType().getName(), + (pd[i].getWriteMethod() == null ? "R" : "R/W"), + (listed.contains(pd[i].getName()) ? "x" : "") }, pd[i]); + } + } + + /** Add basic properties implemented most often by abstract component */ + private void addBasicComponentProperties() { + + // Set of properties + Form set = createBeanPropertySet(new String[] { "caption", "icon", + "componentError", "description", "enabled", "visible", "style", + "readOnly", "immediate" }); + + // Icon + set.replaceWithSelect("icon", new Object[] { null, + new ThemeResource("icon/files/file.gif") }, new Object[] { + "No icon", "Sample icon" }); + + // Component error + Throwable sampleException; + try { + throw new NullPointerException("sample exception"); + } catch (NullPointerException e) { + sampleException = e; + } + set + .replaceWithSelect( + "componentError", + new Object[] { + null, + new UserError("Sample text error message."), + new UserError( + "

Error message formatting

Error messages can " + + "contain any UIDL formatting, like:

", + UserError.CONTENT_UIDL, + ErrorMessage.INFORMATION), + new SystemError( + "This is an example of exception error reposting", + sampleException) }, + new Object[] { "No error", "Sample text error", + "Sample Formatted error", "Sample System Error" }); + + // Style + String currentStyle = ((Component) objectToConfigure).getStyle(); + if (currentStyle == null) + set.replaceWithSelect("style", new Object[] { null }, + new Object[] { "Default" }).setNewItemsAllowed(true); + else + set.replaceWithSelect("style", new Object[] { null, currentStyle }, + new Object[] { "Default", currentStyle }) + .setNewItemsAllowed(true); + + // Set up descriptions + set + .getField("caption") + .setDescription( + "Component caption is the title of the component. Usage of the caption is optional and the " + + "exact behavior of the propery is defined by the component. Setting caption null " + + "or empty disables the caption."); + set + .getField("enabled") + .setDescription( + "Enabled property controls the usage of the component. If the component is disabled (enabled=false)," + + " it can not receive any events from the terminal. In most cases it makes the usage" + + " of the component easier, if the component visually looks disbled (for example is grayed), " + + "when it can not be used."); + set + .getField("icon") + .setDescription( + "Icon of the component selects the main icon of the component. The usage of the icon is identical " + + "to caption and in most components caption and icon are kept together. Icons can be " + + "loaded from any resources (see Terminal/Resources for more information). Some components " + + "contain more than just the captions icon. Those icons are controlled through their " + + "own properties."); + set + .getField("visible") + .setDescription( + "Visibility property says if the component is renreded or not. Invisible components are implicitly " + + "disabled, as there is no visible user interface to send event."); + set + .getField("description") + .setDescription( + "Description is designed to allow easy addition of short tooltips, like this. Like the caption," + + " setting description null or empty disables the description."); + set + .getField("readOnly") + .setDescription( + "Those components that have internal state that can be written are settable to readOnly-mode," + + " where the object can only be read, not written."); + set + .getField("componentError") + .setDescription( + "IT Mill Toolkit supports extensive error reporting. One part of the error reporting are component" + + " errors that can be controlled by the programmer. This example only contains couple of " + + "sample errors; to get the full picture, read browse ErrorMessage-interface implementors " + + "API documentation."); + set + .getField("immediate") + .setDescription( + "Not all terminals can send the events immediately to server from all action. Web is the most " + + "typical environment where many events (like textfield changed) are not sent to server, " + + "before they are explicitly submitted. Setting immediate property true (by default this " + + "is false for most components), the programmer can assure that the application is" + + " notified as soon as possible about the value change in this component."); + set + .getField("style") + .setDescription( + "Themes specify the overall looks of the user interface. In addition component can have a set of " + + "styles, that can be visually very different (like datefield calendar- and text-styles), " + + "but contain the same logical functionality. As a rule of thumb, theme specifies if a " + + "component is blue or yellow and style determines how the component is used."); + + // Add created fields to property panel + addProperties("Component Basics", set); + } + + /** Add properties for selecting */ + private void addSelectProperties() { + Form set = createBeanPropertySet(new String[] { "newItemsAllowed", + "lazyLoading", "multiSelect" }); + addProperties("Select Properties", set); + + set.getField("multiSelect").setDescription( + "Specified if multiple items can be selected at once."); + set + .getField("newItemsAllowed") + .setDescription( + "Select component (but not Tree or Table) can allow the user to directly " + + "add new items to set of options. The new items are constrained to be " + + "strings and thus feature only applies to simple lists."); + Button ll = (Button) set.getField("lazyLoading"); + ll + .setDescription("In Ajax rendering mode select supports lazy loading and filtering of options."); + ll.addListener((ValueChangeListener) this); + ll.setImmediate(true); + if (((Boolean) ll.getValue()).booleanValue()) { + set.getField("multiSelect").setVisible(false); + set.getField("newItemsAllowed").setVisible(false); + } + if (objectToConfigure instanceof Tree + || objectToConfigure instanceof Table) { + set.removeItemProperty("newItemsAllowed"); + set.removeItemProperty("lazyLoading"); + } + } + + /** Field special properties */ + private void addFieldProperties() { + // TODO This is temporarily disabled, until bug #211 is fixed + /* + * Form set = new Form(new GridLayout(COLUMNS, 1)); + * set.addField("focus", new Button("Focus", objectToConfigure, + * "focus")); set.getField("focus").setDescription( "Focus the cursor to + * this field. Not all " + "components and/or terminals support this + * feature."); addProperties("Field Features", set); + */ + } + + /** + * Add and remove some miscellaneous example component to/from component + * container + */ + private void addComponentContainerProperties() { + Form set = new Form(new OrderedLayout( + OrderedLayout.ORIENTATION_VERTICAL)); + + addComponent = new Select(); + addComponent.setImmediate(true); + addComponent.addItem("Add component to container"); + addComponent.setNullSelectionItemId("Add component to container"); + addComponent.addItem("Text field"); + addComponent.addItem("Option group"); + addComponent.addListener(this); + + set.addField("component adder", addComponent); + set.addField("remove all components", new Button( + "Remove all components", objectToConfigure, + "removeAllComponents")); + + addProperties("ComponentContainer Features", set); + } + + /** Value change listener for listening selections */ + public void valueChange(Property.ValueChangeEvent event) { + + // Adding components to component container + if (event.getProperty() == addComponent) { + String value = (String) addComponent.getValue(); + + if (value != null) { + // TextField component + if (value.equals("Text field")) + ((AbstractComponentContainer) objectToConfigure) + .addComponent(new TextField("Test field")); + + // DateField time style + if (value.equals("Time")) { + DateField d = new DateField("Time", new Date()); + d + .setDescription("This is a DateField-component with text-style"); + d.setResolution(DateField.RESOLUTION_MIN); + d.setStyle("text"); + ((AbstractComponentContainer) objectToConfigure) + .addComponent(d); + } + + // Date field calendar style + if (value.equals("Calendar")) { + DateField c = new DateField("Calendar", new Date()); + c + .setDescription("DateField-component with calendar-style and day-resolution"); + c.setStyle("calendar"); + c.setResolution(DateField.RESOLUTION_DAY); + ((AbstractComponentContainer) objectToConfigure) + .addComponent(c); + } + + // Select option group style + if (value.equals("Option group")) { + Select s = new Select("Options"); + s.setDescription("Select-component with optiongroup-style"); + s.addItem("Linux"); + s.addItem("Windows"); + s.addItem("Solaris"); + s.addItem("Symbian"); + s.setStyle("optiongroup"); + + ((AbstractComponentContainer) objectToConfigure) + .addComponent(s); + } + + addComponent.setValue(null); + } + } else if (event.getProperty() == getField("lazyLoading")) { + boolean newValue = ((Boolean) event.getProperty().getValue()) + .booleanValue(); + Field multiselect = getField("multiSelect"); + Field newitems = getField("newItemsAllowed"); + if (newValue) { + newitems.setValue(Boolean.FALSE); + newitems.setVisible(false); + multiselect.setValue(Boolean.FALSE); + multiselect.setVisible(false); + } else { + newitems.setVisible(true); + multiselect.setVisible(true); + } + } + } + + /** + * Helper function for creating forms from array of propety names. + */ + protected Form createBeanPropertySet(String names[]) { + + Form set = new Form(new OrderedLayout( + OrderedLayout.ORIENTATION_VERTICAL)); + + for (int i = 0; i < names.length; i++) { + Property p = config.getItemProperty(names[i]); + if (p != null) { + set.addItemProperty(names[i], p); + Field f = set.getField(names[i]); + if (f instanceof TextField) { + if (Integer.class.equals(p.getType())) + ((TextField) f).setColumns(4); + else { + ((TextField) f).setNullSettingAllowed(true); + ((TextField) f).setColumns(24); + } + } + } + } + + return set; + } + + /** Find a field from all forms */ + public Field getField(Object propertyId) { + for (Iterator i = forms.iterator(); i.hasNext();) { + Form f = (Form) i.next(); + Field af = f.getField(propertyId); + if (af != null) + return af; + } + return null; + } +} diff --git a/src/com/itmill/toolkit/demo/demo/features/components.png b/src/com/itmill/toolkit/demo/demo/features/components.png new file mode 100644 index 0000000000..e5681d4d37 Binary files /dev/null and b/src/com/itmill/toolkit/demo/demo/features/components.png differ diff --git a/src/com/itmill/toolkit/demo/demo/features/icon_demo.png b/src/com/itmill/toolkit/demo/demo/features/icon_demo.png new file mode 100644 index 0000000000..6a5c295d6a Binary files /dev/null and b/src/com/itmill/toolkit/demo/demo/features/icon_demo.png differ diff --git a/src/com/itmill/toolkit/demo/demo/features/icon_intro.png b/src/com/itmill/toolkit/demo/demo/features/icon_intro.png new file mode 100644 index 0000000000..032712985c Binary files /dev/null and b/src/com/itmill/toolkit/demo/demo/features/icon_intro.png differ diff --git a/src/com/itmill/toolkit/demo/demo/features/itmill.gif b/src/com/itmill/toolkit/demo/demo/features/itmill.gif new file mode 100644 index 0000000000..b1c3e053f0 Binary files /dev/null and b/src/com/itmill/toolkit/demo/demo/features/itmill.gif differ diff --git a/src/com/itmill/toolkit/demo/demo/features/itmill_spin.swf b/src/com/itmill/toolkit/demo/demo/features/itmill_spin.swf new file mode 100644 index 0000000000..9e58ce29c6 Binary files /dev/null and b/src/com/itmill/toolkit/demo/demo/features/itmill_spin.swf differ diff --git a/src/com/itmill/toolkit/demo/demo/features/m-bullet-blue.gif b/src/com/itmill/toolkit/demo/demo/features/m-bullet-blue.gif new file mode 100644 index 0000000000..fa6b38b4c9 Binary files /dev/null and b/src/com/itmill/toolkit/demo/demo/features/m-bullet-blue.gif differ diff --git a/src/com/itmill/toolkit/demo/demo/features/m.gif b/src/com/itmill/toolkit/demo/demo/features/m.gif new file mode 100644 index 0000000000..2201bdfc1c Binary files /dev/null and b/src/com/itmill/toolkit/demo/demo/features/m.gif differ diff --git a/src/com/itmill/toolkit/demo/demo/package.html b/src/com/itmill/toolkit/demo/demo/package.html new file mode 100644 index 0000000000..d9bb6824f7 --- /dev/null +++ b/src/com/itmill/toolkit/demo/demo/package.html @@ -0,0 +1,22 @@ + + + + + + + +

Provides several fully functional IT Mill Toolkit example applications. These +highlight certain aspects of the toolkit and how it can be +used to produce simple, elegant yet powerful user interface driven +applications.

+ + + + +