Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

IntroWelcome.java 6.8KB

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