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.

FeatureDateField.java 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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 java.util.Locale;
  20. import com.itmill.toolkit.data.util.IndexedContainer;
  21. import com.itmill.toolkit.data.util.MethodProperty;
  22. import com.itmill.toolkit.ui.*;
  23. public class FeatureDateField extends Feature {
  24. static private IndexedContainer localeContainer;
  25. static {
  26. localeContainer = new IndexedContainer();
  27. localeContainer.addContainerProperty("name", String.class, "");
  28. Locale[] locales = Locale.getAvailableLocales();
  29. for (int i = 0; i < locales.length; i++)
  30. localeContainer.addItem(locales[i]).getItemProperty("name").setValue(
  31. locales[i].getDisplayName());
  32. }
  33. public FeatureDateField() {
  34. super();
  35. }
  36. protected Component getDemoComponent() {
  37. OrderedLayout l = new OrderedLayout();
  38. // Example panel
  39. Panel show = new Panel("DateField component");
  40. DateField df = new DateField("Caption");
  41. df.setValue(new java.util.Date());
  42. show.addComponent(df);
  43. l.addComponent(show);
  44. // Create locale selector
  45. Select selector = new Select("Application Locale",localeContainer);
  46. selector.setItemCaptionPropertyId("name");
  47. selector.setImmediate(true);
  48. selector.setPropertyDataSource(
  49. new MethodProperty(this.getApplication(), "locale"));
  50. l.addComponent(selector);
  51. // Properties
  52. PropertyPanel p = new PropertyPanel(df);
  53. Form ap = p.createBeanPropertySet(new String[] { "resolution" });
  54. ap.replaceWithSelect(
  55. "resolution",
  56. new Object[] {
  57. new Integer(DateField.RESOLUTION_YEAR),
  58. new Integer(DateField.RESOLUTION_MONTH),
  59. new Integer(DateField.RESOLUTION_DAY),
  60. new Integer(DateField.RESOLUTION_HOUR),
  61. new Integer(DateField.RESOLUTION_MIN),
  62. new Integer(DateField.RESOLUTION_SEC),
  63. new Integer(DateField.RESOLUTION_MSEC)},
  64. new Object[] {
  65. "Year",
  66. "Month",
  67. "Day",
  68. "Hour",
  69. "Minute",
  70. "Second",
  71. "Millisecond" });
  72. Select themes = (Select) p.getField("style");
  73. themes
  74. .addItem("text")
  75. .getItemProperty(themes.getItemCaptionPropertyId())
  76. .setValue("text");
  77. themes
  78. .addItem("calendar")
  79. .getItemProperty(themes.getItemCaptionPropertyId())
  80. .setValue("calendar");
  81. p.addProperties("DateField Properties", ap);
  82. l.addComponent(p);
  83. return l;
  84. }
  85. protected String getExampleSrc() {
  86. return "DateField df = new DateField(\"Caption\");\n"
  87. + "df.setValue(new java.util.Date());\n";
  88. }
  89. protected String getDescriptionXHTML() {
  90. return "<p>Representing Dates and times and providing a way to select "
  91. + "or enter some specific date and/or time is an typical need in "
  92. + "data-entry userinterfaces. IT Mill Toolkit provides a DateField "
  93. + "component that is intuitive to use and yet controllable through "
  94. + "its properties.</p>"
  95. + "<p>The calendar-style allows point-and-click selection "+
  96. "of dates while text-style shows only minimalistic user interface."
  97. + "Validators may be bound to the component to check and "
  98. + "validate the given input.</p>"
  99. + "<p>On the demo tab you can try out how the different properties affect the "
  100. + "presentation of the component.</p>";
  101. }
  102. protected String getImage() {
  103. return "datefield.jpg";
  104. }
  105. protected String getTitle() {
  106. return "DateField";
  107. }
  108. }