Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

FeatureDateField.java 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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 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")
  31. .setValue(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();
  41. df.setValue(new java.util.Date());
  42. show.addComponent(df);
  43. l.addComponent(show);
  44. // Create locale selector
  45. /*
  46. * Hide locale selector, until this bug #244 Select selector = new
  47. * Select("Application Locale",localeContainer);
  48. * selector.setItemCaptionPropertyId("name");
  49. * selector.setImmediate(true); selector.setPropertyDataSource( new
  50. * MethodProperty(this.getApplication(), "locale"));
  51. * l.addComponent(selector);
  52. */
  53. // Properties
  54. PropertyPanel p = new PropertyPanel(df);
  55. Form ap = p.createBeanPropertySet(new String[] { "resolution" });
  56. ap.replaceWithSelect("resolution", 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) }, new Object[] {
  64. "Year", "Month", "Day", "Hour", "Minute", "Second",
  65. "Millisecond" });
  66. ap.getField("resolution").setValue(
  67. new Integer(DateField.RESOLUTION_DAY));
  68. Select themes = (Select) p.getField("style");
  69. themes.addItem("text").getItemProperty(
  70. themes.getItemCaptionPropertyId()).setValue("text");
  71. themes.addItem("calendar").getItemProperty(
  72. themes.getItemCaptionPropertyId()).setValue("calendar");
  73. df.setStyle("calendar");
  74. p.addProperties("DateField Properties", ap);
  75. return l;
  76. }
  77. protected String getExampleSrc() {
  78. return "DateField df = new DateField(\"Caption\");\n"
  79. + "df.setValue(new java.util.Date());\n";
  80. }
  81. protected String getDescriptionXHTML() {
  82. return "<p>Representing Dates and times and providing a way to select "
  83. + "or enter some specific date and/or time is an typical need in "
  84. + "data-entry userinterfaces. IT Mill Toolkit provides a DateField "
  85. + "component that is intuitive to use and yet controllable through "
  86. + "its properties.</p>"
  87. + "<p>The calendar-style allows point-and-click selection "
  88. + "of dates while text-style shows only minimalistic user interface."
  89. + "Validators may be bound to the component to check and "
  90. + "validate the given input.</p>"
  91. + "<p>On the demo tab you can try out how the different properties affect the "
  92. + "presentation of the component.</p>";
  93. }
  94. protected String getImage() {
  95. return "datefield.jpg";
  96. }
  97. protected String getTitle() {
  98. return "DateField";
  99. }
  100. }