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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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. super.attach();
  39. // Check if the feature is already initialized
  40. if (initialized)
  41. return;
  42. initialized = true;
  43. // Demo
  44. Component demo = getDemoComponent();
  45. if (demo != null)
  46. layout.addComponent(demo);
  47. ts = new TabSheet();
  48. layout.addComponent(ts);
  49. // Description
  50. String desc = getDescriptionXHTML();
  51. String title = getTitle();
  52. if (desc != null && title != null) {
  53. GridLayout gl = new GridLayout(2, 1);
  54. if (getImage() != null)
  55. gl.addComponent(new Embedded("", new ClassResource(getImage(),
  56. this.getApplication())));
  57. gl.addComponent(new Label("<h2>" + title + "</h2>" + desc,
  58. Label.CONTENT_XHTML));
  59. ts.addTab(gl, "Description", null);
  60. }
  61. // Code Sample
  62. String example = getExampleSrc();
  63. if (example != null) {
  64. OrderedLayout l = new OrderedLayout();
  65. l.addComponent(new Label("<h2>" + getTitle() + " example</h2>",
  66. Label.CONTENT_XHTML));
  67. l.addComponent(new Label(example, Label.CONTENT_PREFORMATTED));
  68. ts.addTab(l, "Code Sample", null);
  69. }
  70. // Javadoc
  71. Label javadocPlaceholder = new Label(
  72. "This is a placeholder for Javadoc");
  73. ts.addTab(javadocPlaceholder, "Javadoc", null);
  74. // Properties tab
  75. // if (properties != null)
  76. // ts.addTab(properties, "Properties", null);
  77. }
  78. /** Get the desctiption of the feature as XHTML fragment */
  79. protected String getDescriptionXHTML() {
  80. return "<h2>Feature description is under construction</h2>";
  81. }
  82. /** Get the title of the feature */
  83. protected String getTitle() {
  84. return this.getClass().getName();
  85. }
  86. /** Get the name of the image file that will be put on description page */
  87. protected String getImage() {
  88. return null;
  89. }
  90. /** Get the example application source code */
  91. protected String getExampleSrc() {
  92. return null;
  93. }
  94. /** Get the feature demo component */
  95. protected Component getDemoComponent() {
  96. return null;
  97. }
  98. /** Get sample icon resource */
  99. protected Resource getSampleIcon() {
  100. if (sampleIcon == null)
  101. sampleIcon = new ClassResource("m.gif", this.getApplication());
  102. return sampleIcon;
  103. }
  104. public PropertyPanel getPropertyPanel() {
  105. return propertyPanel;
  106. }
  107. }