Package com.google.gdt.eclipse.designer.model.widgets.support

Examples of com.google.gdt.eclipse.designer.model.widgets.support.DOMUtils


  /**
   * Fills {@link #m_widgetHandles}.
   */
  private void prepareWidgetHandles() throws Exception {
    GwtState state = getState();
    DOMUtils dom = state.getDomUtils();
    m_widgetHandles.clear();
    m_widgetToHandleBounds.clear();
    // prepare table row with tabs
    Object tabBarRowElement;
    {
      Object panelObject = getObject();
      Object tabBarWidget = ReflectionUtils.invokeMethod(panelObject, "getTabBar()");
      Object tabBarElement = state.getUIObjectUtils().getElement(tabBarWidget);
      Object tabBarBodyElement = dom.getChild(tabBarElement, 0);
      tabBarRowElement = dom.getChild(tabBarBodyElement, 0);
    }
    // fetch tabs bounds for each widget
    List<WidgetInfo> widgets = getChildrenWidgets();
    for (int index = 0; index < widgets.size(); index++) {
      WidgetInfo widget = widgets.get(index);
      // use "1 +" because first TD is "gwt-TabBarFirst"
      Object tabElement = dom.getChild(tabBarRowElement, 1 + index);
      tabElement = dom.getChild(tabElement, 0);
      Rectangle tabBounds = state.getAbsoluteBounds(tabElement);
      absoluteToRelative(tabBounds);
      // remember tab and bounds
      m_widgetHandles.add(new WidgetHandle(widget));
      m_widgetToHandleBounds.put(widget, tabBounds);
View Full Code Here


  /**
   * Fills {@link #m_widgetHandles}.
   */
  private void prepareWidgetHandles() throws Exception {
    GwtState state = getState();
    DOMUtils dom = state.getDomUtils();
    m_widgetHandles.clear();
    m_widgetToHandleBounds.clear();
    // prepare table row with tabs
    Object tabBarRowElement;
    {
      Object panelObject = getObject();
      Object tabBarWidget = ReflectionUtils.invokeMethod(panelObject, "getTabBar()");
      Object tabBarElement = state.getUIObjectUtils().getElement(tabBarWidget);
      Object tabBarBodyElement = dom.getChild(tabBarElement, 0);
      tabBarRowElement = dom.getChild(tabBarBodyElement, 0);
    }
    // fetch tabs bounds for each widget
    List<WidgetInfo> widgets = getChildrenWidgets();
    for (int index = 0; index < widgets.size(); index++) {
      WidgetInfo widget = widgets.get(index);
      // use "1 +" because first TD is "gwt-TabBarFirst"
      Object tabElement = dom.getChild(tabBarRowElement, 1 + index);
      tabElement = dom.getChild(tabElement, 0);
      Rectangle tabBounds = state.getAbsoluteBounds(tabElement);
      absoluteToRelative(tabBounds);
      // remember tab and bounds
      m_widgetHandles.add(new WidgetHandle(widget));
      m_widgetToHandleBounds.put(widget, tabBounds);
View Full Code Here

  /**
   * Fetch cells information.
   */
  private void fetchCells() throws Exception {
    GwtState state = getState();
    DOMUtils dom = getDOMUtils();
    m_widgetToCells.clear();
    // prepare map: Element -> Widget_Info
    Map<Object, WidgetInfo> elementToWidgetMap = Maps.newHashMap();
    for (WidgetInfo widget : getChildrenWidgets()) {
      Object widgetObject = widget.getObject();
      Object widgetElement = state.getUIObjectUtils().getElement(widgetObject);
      elementToWidgetMap.put(widgetElement, widget);
    }
    // prepare cells used by each Widget_Info
    m_columnIntervals = new Interval[m_status.getColumnCount()];
    m_rowIntervals = new Interval[m_status.getRowCount()];
    Map<Interval, Interval> spannedColumnIntervals = Maps.newHashMap();
    Map<Interval, Interval> spannedRowIntervals = Maps.newHashMap();
    for (int row = 0; row < m_status.getRowCount(); row++) {
      for (int cell = 0, column = 0; column < m_status.getColumnCount(); cell++) {
        // FlexTableHelper may remove cells in row below spanned
        if (!m_status.isExistingCell(row, cell)) {
          column++;
          continue;
        }
        // prepare cell information
        int fixedCell = m_status.fixCellAfterRowSpan(row, cell);
        Object td = m_status.getElement(row, fixedCell);
        int colSpan = m_status.getColSpan(row, cell);
        int rowSpan = m_status.getRowSpan(row, cell);
        // remember widget cells
        if (dom.getChildCount(td) == 1) {
          Object tdChild = dom.getChild(td, 0);
          tdChild = dom.unwrapElement(tdChild);
          WidgetInfo widget = elementToWidgetMap.get(tdChild);
          if (widget != null) {
            m_widgetToCells.put(widget, new Rectangle(column, row, colSpan, rowSpan));
          }
        }
        // prepare row interval
        if (m_rowIntervals[row] == null) {
          Object trElement = dom.getParent(td);
          Rectangle trBounds = state.getAbsoluteBounds(trElement);
          absoluteToRelative(trBounds);
          Interval trInterval = new Interval(trBounds.y, trBounds.height);
          if (rowSpan == 1) {
            m_rowIntervals[row] = trInterval;
View Full Code Here

  /**
   * @return the {@link List} of bounds for each <code>TD</code> element in given <code>TR</code>.
   */
  protected final List<Rectangle> getRowCellsRects(Object trElement) throws Exception {
    List<Rectangle> rects = Lists.newArrayList();
    DOMUtils dom = getDOMUtils();
    for (Object cell : dom.getChildren(trElement)) {
      Rectangle rect = getState().getAbsoluteBounds(cell);
      absoluteToRelative(rect);
      rects.add(rect);
    }
    return rects;
View Full Code Here

   *
   * @return {@link List} columns bounds, if available.
   */
  @Override
  protected List<Rectangle> getColumnBoundsByBody() throws Exception {
    DOMUtils dom = getDOMUtils();
    Object tableHeader = ReflectionUtils.getFieldObject(getObject(), "tableData");
    Object tbody = ReflectionUtils.getFieldObject(tableHeader, "section");
    Object tr = dom.getChild(tbody, 0);
    List<Rectangle> rects = getRowCellsRects(tr);
    // translate bounds to header area
    int headerHeight = getHeaderHeight();
    for (Rectangle rect : rects) {
      rect.height = headerHeight;
View Full Code Here

    return rects;
  }

  @Override
  public int getHeaderHeight() throws Exception {
    DOMUtils dom = getDOMUtils();
    Object tableHeader = ReflectionUtils.getFieldObject(getObject(), "tableHeader");
    Object tbody = ReflectionUtils.getFieldObject(tableHeader, "section");
    Object tr = dom.getChild(tbody, 0);
    if (tr == null) {
      return 0;
    }
    return getState().getAbsoluteBounds(tr).height;
  }
View Full Code Here

  // Refresh
  //
  ////////////////////////////////////////////////////////////////////////////
  @Override
  protected List<Rectangle> getColumnBoundsByBody() throws Exception {
    DOMUtils dom = getDOMUtils();
    Object tbody = ReflectionUtils.getFieldObject(getObject(), "tbody");
    Object tr = dom.getChild(tbody, 0);
    List<Rectangle> rects = getRowCellsRects(tr);
    // translate bounds to header area
    int headerHeight = getHeaderHeight();
    for (Rectangle rect : rects) {
      rect.y -= headerHeight;
View Full Code Here

  /**
   * Fills {@link #m_widgetHandles}.
   */
  private void prepareWidgetHandles() throws Exception {
    GwtState state = getState();
    DOMUtils dom = getDOMUtils();
    m_widgetHandles.clear();
    // prepare Table body
    Object bodyElement;
    {
      Object panelObject = getObject();
      Object tableElement = state.getUIObjectUtils().getElement(panelObject);
      bodyElement = dom.getChild(tableElement, 0);
    }
    // prepare handle object for each widget
    List<WidgetInfo> widgets = getChildrenWidgets();
    for (int index = 0; index < widgets.size(); index++) {
      WidgetInfo widget = widgets.get(index);
      Object headerElement = dom.getChild(bodyElement, 2 * index + 0);
      // prepare bounds
      Rectangle headerBounds = state.getAbsoluteBounds(headerElement);
      absoluteToRelative(headerBounds);
      // add handle object
      m_widgetHandles.add(new WidgetHandle(widget));
View Full Code Here

  /**
   * Fills {@link #m_widgetHandles}.
   */
  private void prepareWidgetHandles() throws Exception {
    GwtState state = getState();
    DOMUtils dom = state.getDomUtils();
    m_widgetHandles.clear();
    // prepare Table body
    Object bodyElement;
    {
      Object panelObject = getObject();
      Object tableElement = state.getUIObjectUtils().getElement(panelObject);
      bodyElement = dom.getChild(tableElement, 0);
    }
    // prepare handle object for each widget
    List<WidgetInfo> widgets = getChildrenWidgets();
    for (int index = 0; index < widgets.size(); index++) {
      WidgetInfo widget = widgets.get(index);
      Object headerElement = dom.getChild(bodyElement, 2 * index + 0);
      // prepare bounds
      Rectangle headerBounds = state.getAbsoluteBounds(headerElement);
      absoluteToRelative(headerBounds);
      // add handle object
      m_widgetHandles.add(new WidgetHandle(widget));
View Full Code Here

            "    rootPanel.add(new Button());",
            "  }",
            "}");
    frame.refresh();
    UIObjectUtils objectUtils = frame.getUIObjectUtils();
    DOMUtils domUtils = frame.getDOMUtils();
    //
    Object rootPanel = objectUtils.getRootPanel();
    Object rootPanelElement = objectUtils.getElement(rootPanel);
    // when RootPanel is live, we have much of Element's
    domUtils.appendChild(rootPanelElement, domUtils.createButton());
    {
      int count = domUtils.getChildCount(rootPanelElement);
      assertThat(count).isGreaterThan(1);
    }
    // dispose, so now RootPanel should be empty
    frame.refresh_dispose();
    // still has elements: "css wait" div, "history" frame, "layout" div
    {
      Object[] children = domUtils.getChildren(rootPanelElement);
      assertThat(children).hasSize(3);
      assertThat(children[0].toString()).contains("__gwt_historyFrame");
      assertThat(children[1].toString()).contains("wbp__wait_stylesheet");
      assertThat(children[2].toString()).contains("-20cm").contains("10cm");
    }
View Full Code Here

TOP

Related Classes of com.google.gdt.eclipse.designer.model.widgets.support.DOMUtils

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.