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.

ExtraWindowShownWaiAria.java 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. package com.vaadin.tests.components.window;
  2. import com.vaadin.server.ThemeResource;
  3. import com.vaadin.server.VaadinRequest;
  4. import com.vaadin.shared.ui.window.WindowRole;
  5. import com.vaadin.tests.components.AbstractReindeerTestUI;
  6. import com.vaadin.ui.Button;
  7. import com.vaadin.ui.CheckBox;
  8. import com.vaadin.ui.CssLayout;
  9. import com.vaadin.ui.FormLayout;
  10. import com.vaadin.ui.Label;
  11. import com.vaadin.ui.TextField;
  12. import com.vaadin.ui.Window;
  13. public class ExtraWindowShownWaiAria extends AbstractReindeerTestUI {
  14. @Override
  15. protected void setup(VaadinRequest request) {
  16. final CheckBox modal = new CheckBox("Modal dialog");
  17. modal.setTabIndex(7);
  18. final CheckBox additionalDescription = new CheckBox(
  19. "Additional Description");
  20. final CheckBox tabStop = new CheckBox(
  21. "Prevent leaving window with Tab key");
  22. final CheckBox tabOrder = new CheckBox("Change Taborder");
  23. final TextField prefix = new TextField("Prefix: ");
  24. final TextField postfix = new TextField("Postfix: ");
  25. final TextField topTabStopMessage = new TextField(
  26. "Top Tab Stop Message");
  27. final TextField bottomTabStopMessage = new TextField(
  28. "Bottom Tab Stop Message");
  29. Button simple = new Button("Open Alert Dialog", event -> {
  30. CssLayout layout = new CssLayout();
  31. final Window w = new Window("Sub window", layout);
  32. w.center();
  33. w.setModal(modal.getValue());
  34. w.setAssistiveRole(WindowRole.ALERTDIALOG);
  35. w.setAssistivePrefix(prefix.getValue());
  36. w.setAssistivePostfix(postfix.getValue());
  37. Label description1 = new Label("Simple alert dialog.");
  38. layout.addComponent(description1);
  39. if (!additionalDescription.getValue()) {
  40. w.setAssistiveDescription(description1);
  41. } else {
  42. Label description2 = new Label("Please select what to do!");
  43. layout.addComponent(description2);
  44. w.setAssistiveDescription(description1, description2);
  45. }
  46. w.setTabStopEnabled(tabStop.getValue());
  47. w.setTabStopTopAssistiveText(topTabStopMessage.getValue());
  48. w.setTabStopBottomAssistiveText(bottomTabStopMessage.getValue());
  49. Button close = new Button("Close", clickEvent -> w.close());
  50. layout.addComponent(close);
  51. Button iconButton = new Button("A button with icon");
  52. iconButton.setIcon(new ThemeResource("../runo/icons/16/ok.png"));
  53. layout.addComponent(iconButton);
  54. event.getButton().getUI().addWindow(w);
  55. iconButton.focus();
  56. if (tabOrder.getValue()) {
  57. close.setTabIndex(5);
  58. }
  59. });
  60. getLayout().addComponent(simple);
  61. Button complex = new Button("Open Entry Dialog", event -> {
  62. FormLayout form = new FormLayout();
  63. final Window w = new Window("Form Window", form);
  64. w.center();
  65. w.setModal(modal.getValue());
  66. w.setAssistivePrefix(prefix.getValue());
  67. w.setAssistivePostfix(postfix.getValue());
  68. Label description1 = new Label("Please fill in your data");
  69. form.addComponent(description1);
  70. if (!additionalDescription.getValue()) {
  71. w.setAssistiveDescription(description1);
  72. } else {
  73. Label description2 = new Label("and press the button save.");
  74. form.addComponent(description2);
  75. w.setAssistiveDescription(description1, description2);
  76. }
  77. w.setTabStopEnabled(tabStop.getValue());
  78. w.setTabStopTopAssistiveText(topTabStopMessage.getValue());
  79. w.setTabStopBottomAssistiveText(bottomTabStopMessage.getValue());
  80. TextField name = new TextField("Name:");
  81. form.addComponent(name);
  82. form.addComponent(new TextField("Address"));
  83. Button saveButton = new Button("Save", clickEvent -> w.close());
  84. form.addComponent(saveButton);
  85. event.getButton().getUI().addWindow(w);
  86. name.focus();
  87. if (tabOrder.getValue()) {
  88. name.setTabIndex(5);
  89. }
  90. });
  91. getLayout().addComponent(complex);
  92. getLayout().addComponent(modal);
  93. getLayout().addComponent(additionalDescription);
  94. getLayout().addComponent(tabStop);
  95. getLayout().addComponent(tabOrder);
  96. getLayout().addComponent(prefix);
  97. getLayout().addComponent(postfix);
  98. getLayout().addComponent(topTabStopMessage);
  99. getLayout().addComponent(bottomTabStopMessage);
  100. }
  101. @Override
  102. protected String getTestDescription() {
  103. return "Test for WAI-ARIA implementation";
  104. }
  105. @Override
  106. protected Integer getTicketNumber() {
  107. return 11821;
  108. }
  109. }