123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243 |
- /* *************************************************************************
-
- 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 Component welcome;
-
- private boolean initialized = false;
-
- private Select themeSelector = new Select();
-
- private static final String WELCOME_TEXT = "<h3>Welcome to the IT Mill Toolkit feature tour!</h3>"
- + "In this application you may view and play with some features of IT Mill Toolkit.<br/>"
- + "Most of the features can be tested online and include simple example of their "
- + "usage associated with it.<br/><br/>"
- + "Start your tour by selecting features from the list on the left.<br/><br/>"
- + "For more information, point your browser to: <a href=\"http://www.itmill.com\""
- + " target=\"_new\">www.itmill.com</a>";
-
- public void attach() {
-
- if (initialized)
- return;
- initialized = true;
-
- // Configure tree
- features = new Tree();
- features.setStyle("menu");
- features.addContainerProperty("name", String.class, "");
- features.addContainerProperty("feature", Feature.class, null);
- features.setItemCaptionPropertyId("name");
- features.addListener(this);
- features.setImmediate(true);
-
- // 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);
-
- // Welcome temporarily disabled
- // Label greeting = new Label(WELCOME_TEXT, Label.CONTENT_XHTML);
- // OrderedLayout welcomePanel = new OrderedLayout();
- // welcome =
- // new Embedded(
- // "",
- // new ClassResource(
- // getClass(),
- // "itmill.gif",
- // getApplication()));
- // welcomePanel.addComponent(welcome);
- // welcomePanel.addComponent(greeting);
- // layout.addComponent(welcomePanel);
-
- // 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("/UI Components", new UIComponents());
- 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/Select",
- new FeatureSelect());
- registerFeature("/UI Components/Item Containers/Table",
- new FeatureTable());
- registerFeature("/UI Components/Item Containers/Tree",
- new FeatureTree());
- 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());
- registerFeature("/UI Components/Layouts/Frame Window",
- new FeatureFrameWindow());
- registerFeature("/UI Components/Data handling/Embedded Objects",
- new FeatureEmbedded());
- registerFeature("/UI Components/Data handling/Upload",
- new FeatureUpload());
- 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/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 FeatureButton();
- 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) {
- properties.setVisible(((Boolean) propertiesSelect.getValue())
- .booleanValue());
- }
- }
|