You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

IntroWelcome.java 6.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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.net.URL;
  20. import java.util.Date;
  21. import java.util.Iterator;
  22. import java.util.Map;
  23. import com.itmill.toolkit.terminal.DownloadStream;
  24. import com.itmill.toolkit.terminal.ExternalResource;
  25. import com.itmill.toolkit.terminal.PaintException;
  26. import com.itmill.toolkit.terminal.PaintTarget;
  27. import com.itmill.toolkit.terminal.ParameterHandler;
  28. import com.itmill.toolkit.terminal.URIHandler;
  29. import com.itmill.toolkit.terminal.web.ApplicationServlet;
  30. import com.itmill.toolkit.terminal.web.WebBrowser;
  31. import com.itmill.toolkit.ui.Component;
  32. import com.itmill.toolkit.ui.Form;
  33. import com.itmill.toolkit.ui.Label;
  34. import com.itmill.toolkit.ui.Link;
  35. import com.itmill.toolkit.ui.OrderedLayout;
  36. import com.itmill.toolkit.ui.Panel;
  37. import com.itmill.toolkit.ui.Select;
  38. public class IntroWelcome extends Feature implements URIHandler,
  39. ParameterHandler {
  40. private WebBrowser webBrowser = null;
  41. Panel panel = new Panel();
  42. private static final String WELCOME_TEXT_UPPER = ""
  43. + "This application lets you view and play with some features of "
  44. + "IT Mill Toolkit. Use menu on the left to select component."
  45. + "<br /><br />Note the <b>Properties selection</b> on the top "
  46. + "right corner. Click it open to access component properties and"
  47. + " feel free to edit properties at any time."
  48. + "<br /><br />The area that you are now reading is the component"
  49. + " demo area. Lower area from here contains component description, API"
  50. + " documentation and optional code sample. Note that not all selections"
  51. + " contain demo, only description and API documentation is shown."
  52. + "<br /><br />You may also change application's theme from below the menu."
  53. + " This example application is designed to work best with"
  54. + " <em>Demo</em> theme, other themes are for demonstration purposes only."
  55. + "<br /><br />IT Mill Toolkit enables you to construct complex Web"
  56. + " applications using plain Java, no knowledge of other Web technologies"
  57. + " such as XML, HTML, DOM, JavaScript or browser differences is required."
  58. + "<br /><br />For more information, point your browser to"
  59. + " <a href=\"http://www.itmill.com\" target=\"_new\">www.itmill.com</a>.";
  60. private static final String WELCOME_TEXT_LOWER = ""
  61. + "This area contains the selected component's description, list of properties, javadoc"
  62. + " and optional code sample. "
  63. + "Start your tour now by selecting features from the list"
  64. + " on the left and remember to experiment with the <b>Properties panel</b>"
  65. + " located at the top right corner area.";
  66. private String description = WELCOME_TEXT_LOWER
  67. + "<br /><br />IT Mill Toolkit version: "
  68. + ApplicationServlet.VERSION;
  69. public IntroWelcome() {
  70. super();
  71. }
  72. protected Component getDemoComponent() {
  73. OrderedLayout l = new OrderedLayout();
  74. panel.setCaption("Welcome to the IT Mill Toolkit feature tour!");
  75. l.addComponent(panel);
  76. Label label = new Label();
  77. panel.addComponent(label);
  78. label.setContentMode(Label.CONTENT_XHTML);
  79. label.setValue(WELCOME_TEXT_UPPER);
  80. propertyPanel = new PropertyPanel(panel);
  81. Form ap = propertyPanel.createBeanPropertySet(new String[] { "width",
  82. "height" });
  83. Select themes = (Select) propertyPanel.getField("style");
  84. themes.addItem("light").getItemProperty(
  85. themes.getItemCaptionPropertyId()).setValue("light");
  86. themes.addItem("strong").getItemProperty(
  87. themes.getItemCaptionPropertyId()).setValue("strong");
  88. propertyPanel.addProperties("Panel Properties", ap);
  89. setJavadocURL("package-summary.html");
  90. setPropsReminder(false);
  91. return l;
  92. }
  93. protected String getExampleSrc() {
  94. return ""
  95. + "package com.itmill.toolkit.demo;\n"
  96. + "import com.itmill.toolkit.ui.*;\n\n"
  97. + "public class HelloWorld extends com.itmill.toolkit.Application {\n"
  98. + " public void init() {\n"
  99. + " Window main = new Window(\"Hello window\");\n"
  100. + " setMainWindow(main);\n"
  101. + " main.addComponent(new Label(\"Hello World!\"));\n"
  102. + " }\n" + "}\n";
  103. }
  104. // not ready yet to give description, see paint instead
  105. protected String getDescriptionXHTML() {
  106. return description;
  107. }
  108. // Hack for #512: set description right (WebBrowser now exists)
  109. public void paint(PaintTarget target) throws PaintException {
  110. if (webBrowser == null) {
  111. webBrowser = (WebBrowser) getWindow().getTerminal();
  112. if (webBrowser != null) {
  113. super.getDescription().setValue(
  114. description + "<br />Browser: "
  115. + webBrowser.getBrowserApplication());
  116. }
  117. }
  118. super.paint(target);
  119. }
  120. protected String getImage() {
  121. return "icon_intro.png";
  122. }
  123. protected String getTitle() {
  124. return "Welcome";
  125. }
  126. /**
  127. * Add URI and parametes handlers to window.
  128. *
  129. * @see com.itmill.toolkit.ui.Component#attach()
  130. */
  131. public void attach() {
  132. super.attach();
  133. getWindow().addURIHandler(this);
  134. getWindow().addParameterHandler(this);
  135. }
  136. /**
  137. * Remove all handlers from window
  138. *
  139. * @see com.itmill.toolkit.ui.Component#detach()
  140. */
  141. public void detach() {
  142. super.detach();
  143. getWindow().removeURIHandler(this);
  144. getWindow().removeParameterHandler(this);
  145. }
  146. /**
  147. * Update URI
  148. *
  149. * @see com.itmill.toolkit.terminal.URIHandler#handleURI(URL, String)
  150. */
  151. public DownloadStream handleURI(URL context, String relativeUri) {
  152. return null;
  153. }
  154. /**
  155. * Show system status if systemStatus is given on URL
  156. *
  157. * @see com.itmill.toolkit.terminal.ParameterHandler#handleParameters(Map)
  158. */
  159. public void handleParameters(Map parameters) {
  160. for (Iterator i = parameters.keySet().iterator(); i.hasNext();) {
  161. String name = (String) i.next();
  162. if (name.equals("systemStatus")) {
  163. String status = "";
  164. status += "timestamp=" + new Date() + " ";
  165. status += "free=" + Runtime.getRuntime().freeMemory() + ", ";
  166. status += "total=" + Runtime.getRuntime().totalMemory() + ", ";
  167. status += "max=" + Runtime.getRuntime().maxMemory() + "\n";
  168. System.out.println(status);
  169. }
  170. }
  171. }
  172. }