選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

Feature.java 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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 com.itmill.toolkit.terminal.ClassResource;
  20. import com.itmill.toolkit.terminal.Resource;
  21. import com.itmill.toolkit.ui.*;
  22. public class Feature extends CustomComponent {
  23. private OrderedLayout layout;
  24. private TabSheet ts;
  25. private boolean initialized = false;
  26. private static Resource sampleIcon;
  27. protected PropertyPanel propertyPanel;
  28. /** Constuctor for the feature component */
  29. public Feature() {
  30. layout = new OrderedLayout(OrderedLayout.ORIENTATION_VERTICAL);
  31. setCompositionRoot(layout);
  32. }
  33. /**
  34. * Feature component initialization is lazily done when the feature is
  35. * attached to application
  36. */
  37. public void attach() {
  38. // Check if the feature is already initialized
  39. if (initialized)
  40. return;
  41. initialized = true;
  42. // Demo
  43. Component demo = getDemoComponent();
  44. if (demo != null)
  45. layout.addComponent(demo);
  46. ts = new TabSheet();
  47. layout.addComponent(ts);
  48. // Description
  49. String desc = getDescriptionXHTML();
  50. String title = getTitle();
  51. if (desc != null && title != null) {
  52. GridLayout gl = new GridLayout(2, 1);
  53. if (getImage() != null)
  54. gl.addComponent(new Embedded("", new ClassResource(getImage(),
  55. this.getApplication())));
  56. gl.addComponent(new Label("<h2>" + title + "</h2>" + desc,
  57. Label.CONTENT_XHTML));
  58. ts.addTab(gl, "Description", null);
  59. }
  60. // Code Sample
  61. String example = getExampleSrc();
  62. if (example != null) {
  63. OrderedLayout l = new OrderedLayout();
  64. l.addComponent(new Label("<h2>" + getTitle() + " example</h2>",
  65. Label.CONTENT_XHTML));
  66. l.addComponent(new Label(example, Label.CONTENT_PREFORMATTED));
  67. ts.addTab(l, "Code Sample", null);
  68. }
  69. // Javadoc
  70. Label javadocPlaceholder = new Label(
  71. "This is a placeholder for Javadoc");
  72. ts.addTab(javadocPlaceholder, "Javadoc", null);
  73. // Properties tab
  74. // if (properties != null)
  75. // ts.addTab(properties, "Properties", null);
  76. }
  77. /** Get the desctiption of the feature as XHTML fragment */
  78. protected String getDescriptionXHTML() {
  79. return "<h2>Feature description is under construction</h2>";
  80. }
  81. /** Get the title of the feature */
  82. protected String getTitle() {
  83. return this.getClass().getName();
  84. }
  85. /** Get the name of the image file that will be put on description page */
  86. protected String getImage() {
  87. return null;
  88. }
  89. /** Get the example application source code */
  90. protected String getExampleSrc() {
  91. return null;
  92. }
  93. /** Get the feature demo component */
  94. protected Component getDemoComponent() {
  95. return null;
  96. }
  97. /** Get sample icon resource */
  98. protected Resource getSampleIcon() {
  99. if (sampleIcon == null)
  100. sampleIcon = new ClassResource("m.gif", this.getApplication());
  101. return sampleIcon;
  102. }
  103. public PropertyPanel getPropertyPanel() {
  104. return propertyPanel;
  105. }
  106. }