Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

AddRemoveSetStyleNamesTest.java 2.4KB

vor 12 Jahren
vor 12 Jahren
vor 12 Jahren
vor 12 Jahren
vor 12 Jahren
vor 12 Jahren
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. package com.vaadin.tests.components;
  2. import com.vaadin.ui.Button;
  3. import com.vaadin.v7.ui.PopupDateField;
  4. public class AddRemoveSetStyleNamesTest extends TestBase {
  5. private String style1 = "style1";
  6. private String style2 = "style2";
  7. private String thestyle = "thestyle";
  8. private PopupDateField popupDateField;
  9. private Button button1;
  10. private Button button2;
  11. private Button button3;
  12. private Button.ClickListener listener;
  13. @Override
  14. protected void setup() {
  15. popupDateField = new PopupDateField("PopupDateField");
  16. popupDateField.setRequired(true);
  17. popupDateField.setRequiredError("abcd");
  18. addComponent(popupDateField);
  19. listener = event -> {
  20. String style = (String) event.getButton().getData();
  21. setComponentsStyle(style,
  22. !popupDateField.getStyleName().contains(style),
  23. event.getButton());
  24. };
  25. button1 = new Button("Add style1", listener);
  26. button1.setData(style1);
  27. addComponent(button1);
  28. button2 = new Button("Add style2", listener);
  29. button2.setData(style2);
  30. addComponent(button2);
  31. button3 = new Button("Set thestyle", event -> {
  32. if (popupDateField.getStyleName().contains(thestyle)) {
  33. popupDateField.removeStyleName(thestyle);
  34. button3.setCaption("Set thestyle");
  35. } else {
  36. popupDateField.setStyleName(thestyle);
  37. button1.setCaption("Add style1");
  38. button2.setCaption("Add style2");
  39. button3.setCaption("Remove thestyle");
  40. }
  41. });
  42. addComponent(button3);
  43. }
  44. private void setComponentsStyle(String style, boolean add, Button button) {
  45. if (add) {
  46. popupDateField.addStyleName(style);
  47. button.setCaption("Remove " + style);
  48. } else {
  49. popupDateField.removeStyleName(style);
  50. button.setCaption("Add " + style);
  51. }
  52. }
  53. @Override
  54. protected String getDescription() {
  55. return "If a widget has set multiple css class names, AbtractComponentConnector.getStyleNames() removes all but first one of them. This is not acceptable, because we should be able to create connector for any existing GWT component and thus we do not know it it depends on multiple css class names.";
  56. }
  57. @Override
  58. protected Integer getTicketNumber() {
  59. return 8664;
  60. }
  61. }