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.

PopupViewConnector.java 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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.ComponentConnector;
  9. import com.vaadin.terminal.gwt.client.UIDL;
  10. import com.vaadin.terminal.gwt.client.VCaption;
  11. import com.vaadin.terminal.gwt.client.VCaptionWrapper;
  12. public class PopupViewConnector extends AbstractComponentContainerConnector {
  13. @Override
  14. protected boolean delegateCaptionHandling() {
  15. return false;
  16. }
  17. /**
  18. *
  19. *
  20. * @see com.vaadin.terminal.gwt.client.ComponentConnector#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. getWidget().client = client;
  33. getWidget().uidlId = uidl.getId();
  34. getWidget().hostPopupVisible = uidl
  35. .getBooleanVariable("popupVisibility");
  36. getWidget().setHTML(uidl.getStringAttribute("html"));
  37. if (uidl.hasAttribute("hideOnMouseOut")) {
  38. getWidget().popup.setHideOnMouseOut(uidl
  39. .getBooleanAttribute("hideOnMouseOut"));
  40. }
  41. // Render the popup if visible and show it.
  42. if (getWidget().hostPopupVisible) {
  43. UIDL popupUIDL = uidl.getChildUIDL(0);
  44. // showPopupOnTop(popup, hostReference);
  45. getWidget().preparePopup(getWidget().popup);
  46. getWidget().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 = getWidget().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. getWidget().popup.setStyleName(styleBuf.toString());
  60. } else {
  61. getWidget().popup.setStyleName(getWidget().popup
  62. .getStylePrimaryName());
  63. }
  64. getWidget().showPopup(getWidget().popup);
  65. // The popup shouldn't be visible, try to hide it.
  66. } else {
  67. getWidget().popup.hide();
  68. }
  69. }// updateFromUIDL
  70. public void updateCaption(ComponentConnector component, UIDL uidl) {
  71. if (VCaption.isNeeded(uidl, component.getState())) {
  72. if (getWidget().popup.captionWrapper != null) {
  73. getWidget().popup.captionWrapper.updateCaption(uidl);
  74. } else {
  75. getWidget().popup.captionWrapper = new VCaptionWrapper(
  76. component, getConnection());
  77. getWidget().popup.setWidget(getWidget().popup.captionWrapper);
  78. getWidget().popup.captionWrapper.updateCaption(uidl);
  79. }
  80. } else {
  81. if (getWidget().popup.captionWrapper != null) {
  82. getWidget().popup
  83. .setWidget(getWidget().popup.popupComponentWidget);
  84. }
  85. }
  86. }
  87. @Override
  88. public VPopupView getWidget() {
  89. return (VPopupView) super.getWidget();
  90. }
  91. @Override
  92. protected Widget createWidget() {
  93. return GWT.create(VPopupView.class);
  94. }
  95. }