예제 #1
0
  /**
   * Shows the window, rendering it first if necessary, or activates it and brings it to front if
   * hidden.
   */
  public void show() {
    if (!hidden || !fireEvent(Events.BeforeShow, new WindowEvent(this))) {
      return;
    }
    // remove hide style, else layout fails
    removeStyleName(getHideMode().value());
    addStyleName(HideMode.VISIBILITY.value());
    if (!isAttached()) {
      RootPanel.get().add(this);
    }

    el().makePositionable(true);
    onShow();
    manager.register(this);

    afterShow();
    notifyShow();
  }
예제 #2
0
  protected void afterShow() {
    hidden = false;

    // layout early to render window's content for size calcs
    if (!layoutExecuted || isLayoutNeeded()) {
      layout();
    }

    if (restorePos != null) {
      setPosition(restorePos.x, restorePos.y);
      if (restoreSize != null) {
        setSize(restoreSize.width, restoreSize.height);
      }
    }
    if (restoreWindowScrolling != null) {
      com.google.gwt.dom.client.Document.get().enableScrolling(false);
    }

    int h = getHeight();
    int w = getWidth();
    if (h < minHeight && w < minWidth) {
      setSize(minWidth, minHeight);
    } else if (h < minHeight) {
      setHeight(minHeight);
    } else if (w < minWidth) {
      setWidth(minWidth);
    }

    // not positioned, then center
    if (!positioned) {
      el().center(true);
    }

    el().updateZIndex(0);
    if (modal) {
      modalPreview =
          Event.addNativePreviewHandler(
              new NativePreviewHandler() {
                public void onPreviewNativeEvent(NativePreviewEvent event) {
                  if (Element.is(event.getNativeEvent().getEventTarget())) {
                    Element target = (Element) Element.as(event.getNativeEvent().getEventTarget());

                    String tag = target.getTagName();
                    // ignore html and body because of frames
                    if (!resizing
                        && !dragging
                        && !tag.equalsIgnoreCase("html")
                        && !tag.equalsIgnoreCase("body")
                        && event.getTypeInt() != Event.ONLOAD
                        && manager.getActive() == Window.this
                        && (modalPanel == null
                            || (modalPanel != null
                                && !modalPanel.getElement().isOrHasChild(target)))
                        && !Window.this.getElement().isOrHasChild(target)
                        && fly(target).findParent(".x-ignore", -1) == null) {
                      ArrayList<Component> col =
                          new ArrayList<Component>(ComponentManager.get().getAll());
                      for (Component c : col) {
                        if (c instanceof TriggerField<?>) {
                          triggerBlur((TriggerField<?>) c);
                        } else if (c instanceof Menu) {
                          ((Menu) c).hide(true);
                        }
                      }
                      Window.this.focus();
                    }
                  }
                }

                private native void triggerBlur(TriggerField<?> field) /*-{
    [email protected]::triggerBlur(Lcom/extjs/gxt/ui/client/event/ComponentEvent;)(null);
  }-*/;
              });
    }

    // missing cursor workaround
    if (GXT.isGecko) {
      El e = el().selectNode(".x-window-bwrap");
      if (e != null) {
        e.dom.getStyle().setProperty("overflow", "auto");
        e.dom.getStyle().setProperty("position", "static");
      }
    }

    eventPreview.add();

    if (maximized) {
      maximize();
    }
    removeStyleName(HideMode.VISIBILITY.value());

    if (GXT.isAriaEnabled()) {
      Accessibility.setState(getElement(), "aria-hidden", "false");
    }

    fireEvent(Events.Show, new WindowEvent(this));
    toFront();
  }