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

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