예제 #1
0
파일: Menu.java 프로젝트: mxro/osgi-maven
  /**
   * Displays this menu at a specific xy position.
   *
   * @param x the x coordinate
   * @param y the y coordinate
   */
  public void showAt(int x, int y) {
    MenuEvent me = new MenuEvent(this);
    if (fireEvent(Events.BeforeShow, me)) {
      RootPanel.get().add(this);

      el().makePositionable(true);

      onShow();
      el().updateZIndex(0);

      showing = true;
      doAutoSize();

      if (constrainViewport) {
        Point p = el().adjustForConstraints(new Point(x, y));
        x = p.x;
        y = p.y;
      }
      setPagePosition(x + XDOM.getBodyScrollLeft(), y + XDOM.getBodyScrollTop());
      if (enableScrolling) {
        constrainScroll(y);
      }

      el().show();
      eventPreview.add();

      if (focusOnShow) {
        focus();
      }

      fireEvent(Events.Show, me);
    }
  }
예제 #2
0
 protected void fitContainer() {
   if (container != null) {
     Rectangle bounds = fly(container).getBounds();
     setPagePosition(bounds.x, bounds.y);
     setSize(bounds.width, bounds.height);
   } else {
     setPosition(0, 0);
     setSize(XDOM.getViewportWidth(), XDOM.getViewportHeight());
   }
 }
예제 #3
0
  /** Removes all CSS files dynamically added with {@link #addCss(String)}.<br> */
  private void removeDynamicCss() {
    Element eHead = XDOM.getDocument().getElementsByTagName(TAG_HEAD).getItem(0);

    for (Map.Entry<String, Element> e : additionalCss.entrySet()) {
      eHead.removeChild(e.getValue());
    }
  }
예제 #4
0
 private void resizeLiveScroller() {
   int h = grid.getHeight(true) - mainHd.getHeight(true);
   if (isHorizontalScrollBarShowing()) {
     h -= XDOM.getScrollBarWidth();
   }
   if (footer != null) {
     h -= footer.getHeight();
   }
   liveScroller.setHeight(h, true);
 }
예제 #5
0
  @Override
  protected void renderUI() {
    super.renderUI();
    scroller.setStyleAttribute("overflowY", "hidden");
    liveScroller =
        grid.el()
            .insertFirst(
                "<div class=\"x-livegrid-scroller\"><div style=\"width: "
                    + XDOM.getScrollBarWidth()
                    + "px;\">&nbsp;</div></div>");
    positionLiveScroller();

    liveScroller.addEventsSunk(Event.ONSCROLL);
    mainBody.addEventsSunk(Event.ONMOUSEWHEEL);
  }
예제 #6
0
파일: Menu.java 프로젝트: mxro/osgi-maven
  protected void constrainScroll(int y) {
    int full = ul.setHeight("auto").getHeight();

    int max = maxHeight != Style.DEFAULT ? maxHeight : (XDOM.getViewHeight(false) - y);
    if (full > max && max > 0) {
      activeMax = max - 10 - scrollerHeight * 2;
      ul.setHeight(activeMax, true);
      createScrollers();
    } else {
      ul.setHeight(full, true);
      NodeList<Element> nodes = el().select(".x-menu-scroller");
      for (int i = 0; i < nodes.getLength(); i++) {
        fly(nodes.getItem(i)).hide();
      }
    }
    ul.setScrollTop(0);
  }
예제 #7
0
  /**
   * Dynamically adds the passed CSS to the document, and stores in {@link #additionalCss} the
   * resulting <code>&lt;link rel="stylesheet"&gt;</code><br>
   *
   * @param css
   */
  private void addCss(StylesheetDTO css) {

    String id = Integer.valueOf(Random.nextInt()).toString();

    Element eLink = DOM.createElement(TAG_LINK);
    eLink.setAttribute(ATTRIBUTE_ID, id);
    eLink.setAttribute(ATTRIBUTE_REL, "stylesheet");
    eLink.setAttribute(ATTRIBUTE_TYPE, "text/css");
    eLink.setAttribute(ATTRIBUTE_HREF, css.getUrl());
    if (css.getMedia() != null) {
      eLink.setAttribute(ATTRIBUTE_MEDIA, css.getMedia());
    }

    Element eHead = XDOM.getDocument().getElementsByTagName(TAG_HEAD).getItem(0);
    eHead.appendChild(eLink);

    additionalCss.put(id, eLink);
  };
예제 #8
0
 @Override
 protected void onRemove(ListStore<ModelData> ds, ModelData m, int index, boolean isUpdate) {
   super.onRemove(ds, m, index, isUpdate);
   String groupField = getGroupField();
   if (enableGrouping) {
     String id =
         getGroupId(
             grid.getId(),
             groupField,
             getGroup(m.get(groupField), m, index, cm.findColumnIndex(groupField), ds));
     Element g = XDOM.getElementById(id);
     if (g != null && !g.getChildNodes().getItem(1).hasChildNodes()) {
       fly(g).removeFromParent();
       removeGroupId(id);
     }
   }
   // apply empty text
 }
예제 #9
0
  /** Creates the underlying file input. */
  private void createFileInput() {

    if (file != null) {
      el().removeChild(file.dom);
    }

    final InputElement fileElement = Document.get().createFileInputElement();

    file = new El((Element) fileElement.cast());
    file.addEventsSunk(Event.ONCHANGE | Event.FOCUSEVENTS);
    file.setId(XDOM.getUniqueId());
    file.addStyleName("x-form-file");
    file.setTabIndex(-1);
    getFileInput().setName(name);
    getFileInput().setAccept(accept);
    file.insertInto(getElement(), 1);
    if (file != null) {
      file.setEnabled(isEnabled());
    }
  }
예제 #10
0
 /** Centers the window in the viewport. Should only be called when the window is visible. */
 public void center() {
   Point p = el().getAlignToXY(XDOM.getBody(), "c-c", null);
   setPagePosition(p.x, p.y);
 }