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.

FeatureSelect.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.ui.*;
  20. public class FeatureSelect extends Feature {
  21. private static final String[] firstnames =
  22. new String[] {
  23. "John",
  24. "Mary",
  25. "Joe",
  26. "Sarah",
  27. "Jeff",
  28. "Jane",
  29. "Peter",
  30. "Marc",
  31. "Robert",
  32. "Paula",
  33. "Lenny",
  34. "Kenny",
  35. "Nathan",
  36. "Nicole",
  37. "Laura",
  38. "JosŽ",
  39. "Josie",
  40. "Linus" };
  41. private static final String[] lastnames =
  42. new String[] {
  43. "Torvalds",
  44. "Smith",
  45. "Adams",
  46. "Black",
  47. "Wilson",
  48. "Richards",
  49. "Thompson",
  50. "McGoff",
  51. "Halas",
  52. "Jones",
  53. "Beck",
  54. "Sheridan",
  55. "Picard",
  56. "Hill",
  57. "Fielding",
  58. "Einstein" };
  59. public FeatureSelect() {
  60. super();
  61. }
  62. protected Component getDemoComponent() {
  63. OrderedLayout l = new OrderedLayout();
  64. // Example panel
  65. Panel show = new Panel("Select component");
  66. Select s = new Select("Select Person");
  67. for (int i=0; i<1000; i++)
  68. s.addItem(firstnames[(int) (Math.random() * (firstnames.length-1))] + " " +
  69. lastnames[(int) (Math.random() * (lastnames.length-1))]);
  70. show.addComponent(s);
  71. l.addComponent(show);
  72. // Properties
  73. PropertyPanel p = new PropertyPanel(s);
  74. Select themes = (Select) p.getField("style");
  75. themes
  76. .addItem("optiongroup")
  77. .getItemProperty(themes.getItemCaptionPropertyId())
  78. .setValue("optiongroup");
  79. themes
  80. .addItem("twincol")
  81. .getItemProperty(themes.getItemCaptionPropertyId())
  82. .setValue("twincol");
  83. l.addComponent(p);
  84. return l;
  85. }
  86. protected String getExampleSrc() {
  87. return "Select s = new Select(\"Select Car\");\n"+
  88. "s.addItem(\"Audi\");\n"+
  89. "s.addItem(\"BMW\");\n"+
  90. "s.addItem(\"Chrysler\");\n"+
  91. "s.addItem(\"Volvo\");\n";
  92. }
  93. /**
  94. * @see com.itmill.toolkit.demo.features.Feature#getDescriptionXHTML()
  95. */
  96. protected String getDescriptionXHTML() {
  97. return "The select component combines two different modes of item selection. "
  98. + "Firstly it presents the single selection mode, which is usually represented as "
  99. + "either a drop-down menu or a radio-group of switches, secondly it "
  100. + "allows for multiple item selection, this is usually represented as either a "
  101. + "listbox of selectable items or as a group of checkboxes."
  102. + "<br/><br/>"
  103. + "Data source can be associated both with selected item and the list of selections. "+
  104. "This way you can easily present a selection based on items specified elsewhere in application. "
  105. + "<br/><br/>"
  106. + "On the demo tab you can try out how the different properties affect the"
  107. + " presentation of the component.";
  108. }
  109. protected String getImage() {
  110. return "select.jpg";
  111. }
  112. protected String getTitle() {
  113. return "Select";
  114. }
  115. }