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.

VWindowOverlay.java 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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.client.ui;
  17. import com.google.gwt.dom.client.Element;
  18. import com.google.gwt.user.client.DOM;
  19. import com.google.gwt.user.client.ui.RootPanel;
  20. import com.vaadin.client.ApplicationConnection;
  21. public class VWindowOverlay extends VOverlay {
  22. public VWindowOverlay() {
  23. }
  24. public VWindowOverlay(boolean autoHide, boolean modal, boolean showShadow) {
  25. super(autoHide, modal, showShadow);
  26. }
  27. /**
  28. * Gets the 'overlay container' element. Tries to find the current
  29. * {@link ApplicationConnection} using {@link #getApplicationConnection()}.
  30. *
  31. * @return the overlay container element for the current
  32. * {@link ApplicationConnection} or another element if the current
  33. * {@link ApplicationConnection} cannot be determined.
  34. */
  35. @Override
  36. public com.google.gwt.user.client.Element getOverlayContainer() {
  37. ApplicationConnection ac = getApplicationConnection();
  38. if (ac == null) {
  39. return super.getOverlayContainer();
  40. } else {
  41. Element overlayContainer = getOverlayContainer(ac);
  42. return DOM.asOld(overlayContainer);
  43. }
  44. }
  45. /**
  46. * Gets the 'overlay container' element pertaining to the given
  47. * {@link ApplicationConnection}. Each overlay should be created in a
  48. * overlay container element, so that the correct theme and styles can be
  49. * applied.
  50. *
  51. * @param ac
  52. * A reference to {@link ApplicationConnection}
  53. * @return The overlay container
  54. */
  55. public static com.google.gwt.user.client.Element getOverlayContainer(
  56. ApplicationConnection ac) {
  57. String id = ac.getConfiguration().getRootPanelId();
  58. id = id += "-window-overlays";
  59. Element container = DOM.getElementById(id);
  60. if (container == null) {
  61. container = DOM.createDiv();
  62. container.setId(id);
  63. String styles = ac.getUIConnector().getWidget().getParent()
  64. .getStyleName();
  65. container.addClassName(styles);
  66. container.addClassName(CLASSNAME_CONTAINER);
  67. RootPanel.get().getElement().appendChild(container);
  68. }
  69. return DOM.asOld(container);
  70. }
  71. }