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.

FeatureWindow.java 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /* *************************************************************************
  2. IT Mill Toolkit
  3. Development of Browser User Intarfaces 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/license.txt. Use of this product might
  8. require purchasing a commercial license from IT Mill Ltd. For guidelines
  9. on usage, see license/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.ui.*;
  20. public class FeatureWindow extends Feature {
  21. Button addButton = new Button("Add to application", this, "addWin");
  22. Button removeButton = new Button("Remove from application", this, "delWin");
  23. Window demoWindow;
  24. Form windowProperties;
  25. public FeatureWindow() {
  26. super();
  27. }
  28. protected Component getDemoComponent() {
  29. OrderedLayout l = new OrderedLayout();
  30. demoWindow = new Window("Feature Test Window");
  31. // Example panel
  32. Panel show = new Panel("Test Window Control");
  33. ((OrderedLayout) show.getLayout()).setOrientation(
  34. OrderedLayout.ORIENTATION_HORIZONTAL);
  35. show.addComponent(addButton);
  36. show.addComponent(removeButton);
  37. updateWinStatus();
  38. l.addComponent(show);
  39. // Properties
  40. PropertyPanel p = new PropertyPanel(demoWindow);
  41. p.dependsOn(addButton);
  42. p.dependsOn(removeButton);
  43. windowProperties =
  44. p.createBeanPropertySet(
  45. new String[] {
  46. "width",
  47. "height",
  48. "name",
  49. "border",
  50. "theme",
  51. "scrollable",
  52. "scrollOffsetX",
  53. "scrollOffsetY" });
  54. windowProperties.replaceWithSelect(
  55. "border",
  56. new Object[] {
  57. new Integer(Window.BORDER_DEFAULT),
  58. new Integer(Window.BORDER_NONE),
  59. new Integer(Window.BORDER_MINIMAL)},
  60. new Object[] { "Default", "None", "Minimal" });
  61. p.addProperties("Window Properties", windowProperties);
  62. l.addComponent(p);
  63. return l;
  64. }
  65. protected String getExampleSrc() {
  66. return "Window win = new Window();\n"
  67. + "getApplication().addWindow(win);\n";
  68. }
  69. protected String getDescriptionXHTML() {
  70. return "The window support in IT Mill Toolkit allows for opening and closing windows, "
  71. + "refreshing one window from another (for asynchronous terminals), "
  72. + "resizing windows and scrolling window content. "
  73. + "There are also a number of preset window border styles defined by "
  74. + "this feature.";
  75. }
  76. protected String getImage() {
  77. return "window.jpg";
  78. }
  79. protected String getTitle() {
  80. return "Window";
  81. }
  82. public void addWin() {
  83. getApplication().addWindow(demoWindow);
  84. windowProperties.getField("name").setReadOnly(true);
  85. updateWinStatus();
  86. }
  87. public void delWin() {
  88. getApplication().removeWindow(demoWindow);
  89. windowProperties.getField("name").setReadOnly(false);
  90. updateWinStatus();
  91. }
  92. private void updateWinStatus() {
  93. if (demoWindow.getApplication() == null) {
  94. addButton.setEnabled(true);
  95. removeButton.setEnabled(false);
  96. } else {
  97. addButton.setEnabled(false);
  98. removeButton.setEnabled(true);
  99. }
  100. }
  101. }