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.

TestDateField.java 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * Copyright 2000-2014 Vaadin Ltd.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.vaadin.tests;
  17. import java.util.Locale;
  18. import com.vaadin.server.ClassResource;
  19. import com.vaadin.server.ErrorMessage;
  20. import com.vaadin.server.UserError;
  21. import com.vaadin.ui.CustomComponent;
  22. import com.vaadin.ui.DateField;
  23. import com.vaadin.ui.Label;
  24. import com.vaadin.ui.VerticalLayout;
  25. /**
  26. *
  27. * @author Vaadin Ltd.
  28. */
  29. public class TestDateField extends CustomComponent {
  30. VerticalLayout main = new VerticalLayout();
  31. DateField df;
  32. public TestDateField() {
  33. setCompositionRoot(main);
  34. createNewView();
  35. }
  36. public void createNewView() {
  37. main.removeAllComponents();
  38. main.addComponent(new Label("DateField"));
  39. df = new DateField();
  40. main.addComponent(df);
  41. final ErrorMessage errorMsg = new UserError("User error " + df);
  42. df.setCaption("DateField caption " + df);
  43. df.setDescription("DateField description " + df);
  44. df.setComponentError(errorMsg);
  45. df.setImmediate(true);
  46. // FIXME: bug #1138 this makes datefield to render with unknown
  47. // component (UIDL tree debug)
  48. df.addStyleName("thisShouldBeHarmless");
  49. // Another test: locale
  50. final DateField df1 = new DateField("US locale");
  51. main.addComponent(df1);
  52. df1.setLocale(new Locale("en", "US"));
  53. final DateField df2 = new DateField("DE locale");
  54. main.addComponent(df2);
  55. df2.setLocale(new Locale("de", "DE"));
  56. final DateField df3 = new DateField("RU locale");
  57. main.addComponent(df3);
  58. df3.setLocale(new Locale("ru", "RU"));
  59. final DateField df4 = new DateField("FI locale");
  60. main.addComponent(df4);
  61. df4.setLocale(new Locale("fi", "FI"));
  62. }
  63. @Override
  64. public void attach() {
  65. final ClassResource res = new ClassResource("m.gif");
  66. df.setIcon(res);
  67. super.attach();
  68. }
  69. }