Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

FeatureBrowser.java 7.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. /* *************************************************************************
  2. IT Mill Toolkit
  3. Development of Browser User Interfaces Made Easy
  4. Copyright (C) 2000-2006 IT Mill Ltd
  5. *************************************************************************
  6. This product is distributed under commercial license that can be found
  7. from the product package on license.pdf. Use of this product might
  8. require purchasing a commercial license from IT Mill Ltd. For guidelines
  9. on usage, see licensing-guidelines.html
  10. *************************************************************************
  11. For more information, contact:
  12. IT Mill Ltd phone: +358 2 4802 7180
  13. Ruukinkatu 2-4 fax: +358 2 4802 7181
  14. 20540, Turku email: info@itmill.com
  15. Finland company www: www.itmill.com
  16. Primary source for information and releases: www.itmill.com
  17. ********************************************************************** */
  18. package com.itmill.toolkit.demo.features;
  19. import java.util.Iterator;
  20. import java.util.StringTokenizer;
  21. import com.itmill.toolkit.data.*;
  22. import com.itmill.toolkit.terminal.ClassResource;
  23. import com.itmill.toolkit.ui.*;
  24. public class FeatureBrowser extends CustomComponent implements
  25. Property.ValueChangeListener {
  26. private Tree features;
  27. private Feature currentFeature = null;
  28. private OrderedLayout layout;
  29. private OrderedLayout right;
  30. private PropertyPanel properties;
  31. private Component welcome;
  32. private boolean initialized = false;
  33. private Select themeSelector = new Select("Theme");
  34. private static final String WELCOME_TEXT = "<h3>Welcome to the IT Mill Toolkit feature tour!</h3>"
  35. + "In this application you may view and play with some features of IT Mill Toolkit.<br/>"
  36. + "Most of the features can be tested online and include simple example of their "
  37. + "usage associated with it.<br/><br/>"
  38. + "Start your tour by selecting features from the list on the left.<br/><br/>"
  39. + "For more information, point your browser to: <a href=\"http://www.itmill.com\""
  40. + " target=\"_new\">www.itmill.com</a>";
  41. public void attach() {
  42. if (initialized)
  43. return;
  44. initialized = true;
  45. // Configure tree
  46. features = new Tree();
  47. features.setStyle("menu");
  48. features.addContainerProperty("name", String.class, "");
  49. features.addContainerProperty("feature", Feature.class, null);
  50. features.setItemCaptionPropertyId("name");
  51. features.addListener(this);
  52. features.setImmediate(true);
  53. // Configure component layout
  54. layout = new OrderedLayout(OrderedLayout.ORIENTATION_HORIZONTAL);
  55. setCompositionRoot(layout);
  56. OrderedLayout left = new OrderedLayout(
  57. OrderedLayout.ORIENTATION_VERTICAL);
  58. left.addComponent(features);
  59. layout.addComponent(left);
  60. // Welcome temporarily disabled
  61. // Label greeting = new Label(WELCOME_TEXT, Label.CONTENT_XHTML);
  62. // OrderedLayout welcomePanel = new OrderedLayout();
  63. // welcome =
  64. // new Embedded(
  65. // "",
  66. // new ClassResource(
  67. // getClass(),
  68. // "itmill.gif",
  69. // getApplication()));
  70. // welcomePanel.addComponent(welcome);
  71. // welcomePanel.addComponent(greeting);
  72. // layout.addComponent(welcomePanel);
  73. // Theme selector
  74. left.addComponent(themeSelector);
  75. themeSelector.addItem("corporate");
  76. themeSelector.addItem("base");
  77. themeSelector.addListener(this);
  78. themeSelector.select("corporate");
  79. themeSelector.setImmediate(true);
  80. // Restart button
  81. Button close = new Button("restart", getApplication(), "close");
  82. left.addComponent(close);
  83. close.setStyle("link");
  84. // Test component
  85. registerFeature("/UI Components", new UIComponents());
  86. registerFeature("/UI Components/Basic/Text Field",
  87. new FeatureTextField());
  88. registerFeature("/UI Components/Basic/Date Field",
  89. new FeatureDateField());
  90. registerFeature("/UI Components/Basic/Button", new FeatureButton());
  91. registerFeature("/UI Components/Basic/Form", new FeatureForm());
  92. registerFeature("/UI Components/Basic/Label", new FeatureLabel());
  93. registerFeature("/UI Components/Basic/Link", new FeatureLink());
  94. registerFeature("/UI Components/Item Containers/Select",
  95. new FeatureSelect());
  96. registerFeature("/UI Components/Item Containers/Table",
  97. new FeatureTable());
  98. registerFeature("/UI Components/Item Containers/Tree",
  99. new FeatureTree());
  100. registerFeature("/UI Components/Layouts/Ordered Layout",
  101. new FeatureOrderedLayout());
  102. registerFeature("/UI Components/Layouts/Grid Layout",
  103. new FeatureGridLayout());
  104. registerFeature("/UI Components/Layouts/Custom Layout",
  105. new FeatureCustomLayout());
  106. registerFeature("/UI Components/Layouts/Panel", new FeaturePanel());
  107. registerFeature("/UI Components/Layouts/Tab Sheet",
  108. new FeatureTabSheet());
  109. registerFeature("/UI Components/Layouts/Window", new FeatureWindow());
  110. registerFeature("/UI Components/Layouts/Frame Window",
  111. new FeatureFrameWindow());
  112. registerFeature("/UI Components/Data handling/Embedded Objects",
  113. new FeatureEmbedded());
  114. registerFeature("/UI Components/Data handling/Upload",
  115. new FeatureUpload());
  116. registerFeature("/Data Model/Properties", new FeatureProperties());
  117. registerFeature("/Data Model/Items", new FeatureItems());
  118. registerFeature("/Data Model/Containers", new FeatureContainers());
  119. registerFeature("/Data Model/Validators", new FeatureValidators());
  120. registerFeature("/Data Model/Buffering", new FeatureBuffering());
  121. registerFeature("/Terminal/Parameters and URI Handling",
  122. new FeatureParameters());
  123. // Pre-open all menus
  124. for (Iterator i = features.getItemIds().iterator(); i.hasNext();)
  125. features.expandItem(i.next());
  126. // Add demo component and tabs
  127. currentFeature = new FeatureButton();
  128. layout.addComponent(currentFeature);
  129. // Add properties
  130. right = new OrderedLayout(OrderedLayout.ORIENTATION_VERTICAL);
  131. layout.addComponent(right);
  132. Select propertiesSelect = new Select("Show properties");
  133. right.addComponent(propertiesSelect);
  134. properties = currentFeature.getPropertyPanel();
  135. right.addComponent(properties);
  136. }
  137. public void registerFeature(String path, Feature feature) {
  138. StringTokenizer st = new StringTokenizer(path, "/");
  139. String id = "";
  140. String parentId = null;
  141. while (st.hasMoreTokens()) {
  142. String token = st.nextToken();
  143. id += "/" + token;
  144. if (!features.containsId(id)) {
  145. features.addItem(id);
  146. features.setChildrenAllowed(id, false);
  147. }
  148. features.getContainerProperty(id, "name").setValue(token);
  149. if (parentId != null) {
  150. features.setChildrenAllowed(parentId, true);
  151. features.setParent(id, parentId);
  152. }
  153. if (!st.hasMoreTokens())
  154. features.getContainerProperty(id, "feature").setValue(feature);
  155. parentId = id;
  156. }
  157. }
  158. public void valueChange(Property.ValueChangeEvent event) {
  159. // Change feature
  160. if (event.getProperty() == features) {
  161. Object id = features.getValue();
  162. if (id != null) {
  163. if (features.areChildrenAllowed(id))
  164. features.expandItem(id);
  165. Property p = features.getContainerProperty(id, "feature");
  166. Feature feature = p != null ? ((Feature) p.getValue()) : null;
  167. if (feature != null) {
  168. layout.replaceComponent(currentFeature, feature);
  169. currentFeature = feature;
  170. right.replaceComponent(properties, feature
  171. .getPropertyPanel());
  172. properties = feature.getPropertyPanel();
  173. getWindow()
  174. .setCaption(
  175. "IT Mill Toolkit Features / "
  176. + features.getContainerProperty(id,
  177. "name"));
  178. }
  179. }
  180. } else if (event.getProperty() == themeSelector) {
  181. getApplication().setTheme(themeSelector.toString());
  182. }
  183. }
  184. }