Example usage for com.google.gwt.user.client.ui HeaderPanel HeaderPanel

List of usage examples for com.google.gwt.user.client.ui HeaderPanel HeaderPanel

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui HeaderPanel HeaderPanel.

Prototype

public HeaderPanel() 

Source Link

Usage

From source file:com.ponysdk.core.terminal.ui.PTHeaderPanel.java

License:Apache License

@Override
protected HeaderPanel createUIObject() {
    return new HeaderPanel();
}

From source file:com.ponysdk.ui.terminal.ui.PTHeaderPanel.java

License:Apache License

@Override
public void create(final PTInstruction create, final UIService uiService) {
    init(create, uiService, new HeaderPanel());
}

From source file:sonumina.b4oweb.client.gwt.DataGrid.java

License:Apache License

/**
 * Constructs a table with the given page size, the specified
 * {@link Resources}, and the given key provider.
 * // ww  w  .ja  va 2 s . c  om
 * @param pageSize the page size
 * @param resources the resources to use for this widget
 * @param keyProvider an instance of ProvidesKey<T>, or null if the record
 *          object should act as its own key
 * @param loadingIndicator the widget to use as a loading indicator, or null
 *          to disable
 */
public DataGrid(int pageSize, Resources resources, ProvidesKey<T> keyProvider, Widget loadingIndicator) {
    super(new HeaderPanel(), pageSize, new ResourcesAdapter(resources), keyProvider);
    headerPanel = (HeaderPanel) getWidget();

    // Inject the stylesheet.
    this.style = resources.dataGridStyle();
    this.style.ensureInjected();

    // Create the header and footer widgets..
    tableHeader = new TableWidget();
    tableHeader.section = tableHeader.tableElem.createTHead();
    tableFooter = new TableWidget();
    tableFooter.section = tableFooter.tableElem.createTFoot();

    /*
     * Wrap the header and footer widgets in a div because we cannot set the
     * min-width of a table element. We set the width/min-width of the div
     * container instead.
     */
    tableHeaderContainer = new SimplePanel(tableHeader);
    tableFooterContainer = new SimplePanel(tableFooter);

    /*
     * Get the element that wraps the container so we can adjust its scroll
     * position.
     */
    headerPanel.setHeaderWidget(tableHeaderContainer);
    tableHeaderScroller = tableHeaderContainer.getElement().getParentElement();
    headerPanel.setFooterWidget(tableFooterContainer);
    tableFooterScroller = tableFooterContainer.getElement().getParentElement();

    /*
     * Set overflow to hidden on the scrollable elements so we can change the
     * scrollLeft position.
     */
    tableHeaderScroller.getStyle().setOverflow(Overflow.HIDDEN);
    tableFooterScroller.getStyle().setOverflow(Overflow.HIDDEN);

    // Create the body.
    tableData = new TableWidget();
    if (tableData.tableElem.getTBodies().getLength() > 0) {
        tableData.section = tableData.tableElem.getTBodies().getItem(0);
    } else {
        tableData.section = Document.get().createTBodyElement();
        tableData.tableElem.appendChild(tableData.section);
    }
    tableDataScroller = new MyCustomScrollPanel(tableData);
    tableDataScroller.setHeight("100%");
    headerPanel.setContentWidget(tableDataScroller);
    tableDataContainer = tableData.getElement().getParentElement();

    /*
     * CustomScrollPanel applies the inline block style to the container
     * element, but we want the container to fill the available width.
     */
    tableDataContainer.getStyle().setDisplay(Display.BLOCK);

    /*
     * Create the containers for the empty table message and loading indicator.
     * The containers are centered tables that contain one cell, which aligns
     * the widget in the center of the panel.
     */
    emptyTableWidgetContainer = new FlexTable();
    emptyTableWidgetContainer.getElement().setAttribute("align", "center");
    loadingIndicatorContainer = new FlexTable();
    loadingIndicatorContainer.getElement().setAttribute("align", "center");

    // Set the loading indicator.
    setLoadingIndicator(loadingIndicator); // Can be null.

    // Synchronize the scroll positions of the three tables.
    tableDataScroller.addScrollHandler(new ScrollHandler() {
        @Override
        public void onScroll(ScrollEvent event) {
            int scrollLeft = tableDataScroller.getHorizontalScrollPosition();
            tableHeaderScroller.setScrollLeft(scrollLeft);
            tableFooterScroller.setScrollLeft(scrollLeft);

            int ypos = tableDataScroller.getVerticalScrollPosition();
            int totalHeight = tableDataScroller.getScrollableElement().getScrollHeight();
            int visibleHeight = getElement().getClientHeight();
            int numberOfElements = getPageSize();

            int rowHeight = totalHeight / numberOfElements;
            if (totalHeight % numberOfElements != 0)
                GWT.log("The row height couldn't be determined properly");

            if (rowHeight == 0) {
                GWT.log("Row height is 0");
                return;
            }

            verticalClientTopRow = ypos / rowHeight;
            verticalClientVisibleElements = visibleHeight / rowHeight + 1;
        }
    });
}