Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

WindowWaiAriaRoles.java 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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.accessibility;
  17. import java.util.Stack;
  18. import com.vaadin.server.VaadinRequest;
  19. import com.vaadin.shared.ui.window.WindowRole;
  20. import com.vaadin.tests.components.AbstractTestUI;
  21. import com.vaadin.ui.Button;
  22. import com.vaadin.ui.Button.ClickEvent;
  23. import com.vaadin.ui.Button.ClickListener;
  24. import com.vaadin.ui.Window;
  25. /**
  26. * UI to test if subwindows get the correct assistive roles.
  27. *
  28. * @author Vaadin Ltd
  29. */
  30. public class WindowWaiAriaRoles extends AbstractTestUI {
  31. Stack<Window> windows = new Stack<Window>();
  32. /*
  33. * (non-Javadoc)
  34. *
  35. * @see com.vaadin.tests.components.AbstractTestUI#setup(com.vaadin.server.
  36. * VaadinRequest)
  37. */
  38. @Override
  39. protected void setup(VaadinRequest request) {
  40. Button closeButton = new Button("Close windows");
  41. closeButton.addClickListener(new ClickListener() {
  42. @Override
  43. public void buttonClick(ClickEvent event) {
  44. while (!windows.isEmpty()) {
  45. Window window = windows.pop();
  46. removeWindow(window);
  47. }
  48. }
  49. });
  50. Button regularButton = new Button("Regular");
  51. regularButton.addClickListener(new ClickListener() {
  52. @Override
  53. public void buttonClick(ClickEvent event) {
  54. Window regularWindow = new Window("Regular window");
  55. openWindow(regularWindow);
  56. }
  57. });
  58. Button alertButton = new Button("Alert");
  59. alertButton.addClickListener(new ClickListener() {
  60. @Override
  61. public void buttonClick(ClickEvent event) {
  62. Window alertWindow = new Window("Alert window");
  63. alertWindow.setAssistiveRole(WindowRole.ALERTDIALOG);
  64. openWindow(alertWindow);
  65. }
  66. });
  67. addComponent(closeButton);
  68. addComponent(regularButton);
  69. addComponent(alertButton);
  70. }
  71. void openWindow(Window window) {
  72. windows.push(window);
  73. window.center();
  74. addWindow(window);
  75. }
  76. /*
  77. * (non-Javadoc)
  78. *
  79. * @see com.vaadin.tests.components.AbstractTestUI#getTestDescription()
  80. */
  81. @Override
  82. protected String getTestDescription() {
  83. return "The alert window should have the role 'alertdialog' and the regular window should have the role 'dialog'";
  84. }
  85. /*
  86. * (non-Javadoc)
  87. *
  88. * @see com.vaadin.tests.components.AbstractTestUI#getTicketNumber()
  89. */
  90. @Override
  91. protected Integer getTicketNumber() {
  92. return 14289;
  93. }
  94. }