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.5KB

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