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.

VPopupViewPaintable.java 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. @VaadinApache2LicenseForJavaFiles@
  3. */
  4. package com.vaadin.terminal.gwt.client.ui;
  5. import com.google.gwt.core.client.GWT;
  6. import com.google.gwt.user.client.ui.Widget;
  7. import com.vaadin.terminal.gwt.client.ApplicationConnection;
  8. import com.vaadin.terminal.gwt.client.UIDL;
  9. import com.vaadin.terminal.gwt.client.VCaption;
  10. import com.vaadin.terminal.gwt.client.VCaptionWrapper;
  11. import com.vaadin.terminal.gwt.client.VPaintableWidget;
  12. public class VPopupViewPaintable extends VAbstractPaintableWidgetContainer {
  13. @Override
  14. protected boolean delegateCaptionHandling() {
  15. return false;
  16. }
  17. /**
  18. *
  19. *
  20. * @see com.vaadin.terminal.gwt.client.VPaintableWidget#updateFromUIDL(com.vaadin.terminal.gwt.client.UIDL,
  21. * com.vaadin.terminal.gwt.client.ApplicationConnection)
  22. */
  23. @Override
  24. public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
  25. // This call should be made first. Ensure correct implementation,
  26. // and don't let the containing layout manage caption.
  27. super.updateFromUIDL(uidl, client);
  28. if (!isRealUpdate(uidl)) {
  29. return;
  30. }
  31. // These are for future server connections
  32. getWidgetForPaintable().client = client;
  33. getWidgetForPaintable().uidlId = uidl.getId();
  34. getWidgetForPaintable().hostPopupVisible = uidl
  35. .getBooleanVariable("popupVisibility");
  36. getWidgetForPaintable().setHTML(uidl.getStringAttribute("html"));
  37. if (uidl.hasAttribute("hideOnMouseOut")) {
  38. getWidgetForPaintable().popup.setHideOnMouseOut(uidl
  39. .getBooleanAttribute("hideOnMouseOut"));
  40. }
  41. // Render the popup if visible and show it.
  42. if (getWidgetForPaintable().hostPopupVisible) {
  43. UIDL popupUIDL = uidl.getChildUIDL(0);
  44. // showPopupOnTop(popup, hostReference);
  45. getWidgetForPaintable().preparePopup(getWidgetForPaintable().popup);
  46. getWidgetForPaintable().popup.updateFromUIDL(popupUIDL, client);
  47. if (getState().hasStyles()) {
  48. final String[] styles = getState().getStyle().split(" ");
  49. final StringBuffer styleBuf = new StringBuffer();
  50. final String primaryName = getWidgetForPaintable().popup
  51. .getStylePrimaryName();
  52. styleBuf.append(primaryName);
  53. for (int i = 0; i < styles.length; i++) {
  54. styleBuf.append(" ");
  55. styleBuf.append(primaryName);
  56. styleBuf.append("-");
  57. styleBuf.append(styles[i]);
  58. }
  59. getWidgetForPaintable().popup.setStyleName(styleBuf.toString());
  60. } else {
  61. getWidgetForPaintable().popup
  62. .setStyleName(getWidgetForPaintable().popup
  63. .getStylePrimaryName());
  64. }
  65. getWidgetForPaintable().showPopup(getWidgetForPaintable().popup);
  66. // The popup shouldn't be visible, try to hide it.
  67. } else {
  68. getWidgetForPaintable().popup.hide();
  69. }
  70. }// updateFromUIDL
  71. public void updateCaption(VPaintableWidget component, UIDL uidl) {
  72. if (VCaption.isNeeded(uidl, component.getState())) {
  73. if (getWidgetForPaintable().popup.captionWrapper != null) {
  74. getWidgetForPaintable().popup.captionWrapper
  75. .updateCaption(uidl);
  76. } else {
  77. getWidgetForPaintable().popup.captionWrapper = new VCaptionWrapper(
  78. component, getConnection());
  79. getWidgetForPaintable().popup
  80. .setWidget(getWidgetForPaintable().popup.captionWrapper);
  81. getWidgetForPaintable().popup.captionWrapper
  82. .updateCaption(uidl);
  83. }
  84. } else {
  85. if (getWidgetForPaintable().popup.captionWrapper != null) {
  86. getWidgetForPaintable().popup
  87. .setWidget(getWidgetForPaintable().popup.popupComponentWidget);
  88. }
  89. }
  90. }
  91. @Override
  92. public VPopupView getWidgetForPaintable() {
  93. return (VPopupView) super.getWidgetForPaintable();
  94. }
  95. @Override
  96. protected Widget createWidget() {
  97. return GWT.create(VPopupView.class);
  98. }
  99. }