Example usage for com.google.gwt.gen2.table.client FixedWidthGrid FixedWidthGrid

List of usage examples for com.google.gwt.gen2.table.client FixedWidthGrid FixedWidthGrid

Introduction

In this page you can find the example usage for com.google.gwt.gen2.table.client FixedWidthGrid FixedWidthGrid.

Prototype

public FixedWidthGrid(int rows, int columns) 

Source Link

Document

Constructs a FixedWidthGrid with the requested size.

Usage

From source file:edu.caltech.ipac.firefly.ui.table.BasicTable.java

protected static FixedWidthGrid makeDataTable(DataSet data) {
    FixedWidthGrid table = new FixedWidthGrid(0, data.getColumns().size()) {
        @Override/*from   w  w  w  .  j a v  a  2 s. co  m*/
        public ColumnSorter getColumnSorter() {
            return super.getColumnSorter(true);
        }
    };
    // TG commented the line below to get RowSelectionEvents in GWT2.7 (when selection is enabled)
    // table.unsinkEvents(Event.ONMOUSEOVER | Event.ONMOUSEDOWN | Event.ONCLICK);
    table.setSelectionEnabled(false);

    return table;
}

From source file:edu.caltech.ipac.firefly.ui.table.TableOptions.java

private ScrollTable makeColsTable(final BasicPagingTable table) {

    final FixedWidthFlexTable header = new FixedWidthFlexTable();
    header.setHTML(0, 0, "Column");
    header.setWidget(0, 1, selectAllCheckBox);
    selectAllCheckBox.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent ev) {
            boolean hasSel = false;
            for (Map.Entry<ColDef, CheckBox> entry : checkBoxes.entrySet()) {
                if (entry.getValue().getValue()) {
                    hasSel = true;//w w w .  j a  v a  2s .  co m
                    break;
                }
            }

            if (selectAllCheckBox.getValue() && !hasSel) {
                for (Map.Entry<ColDef, CheckBox> entry : checkBoxes.entrySet()) {
                    entry.getValue().setValue(true);
                }
            } else {
                for (Map.Entry<ColDef, CheckBox> entry : checkBoxes.entrySet()) {
                    entry.getValue().setValue(false);
                }
                selectAllCheckBox.setValue(false);
            }
            applyChanges();
        }
    });

    //        final SortableGrid.ColumnSorter[] origSorter = new SortableGrid.ColumnSorter[1];
    @SuppressWarnings("deprecation")
    final FixedWidthGrid data = new FixedWidthGrid(0, 2);
    data.unsinkEvents(Event.ONMOUSEOVER);
    data.setSelectionEnabled(false);

    final ScrollTable view = new ScrollTable(data, header, new BasicTable.Images());
    FlexTable.FlexCellFormatter formatter = header.getFlexCellFormatter();
    formatter.setHorizontalAlignment(0, 1, HasHorizontalAlignment.ALIGN_CENTER);
    view.setMaximumColumnWidth(1, 35);
    view.setMinimumColumnWidth(1, 35);
    view.setColumnSortable(1, false);

    final DefaultTableDefinition<TableData.Row> tdef = (DefaultTableDefinition<TableData.Row>) table
            .getTableDefinition();
    int cRowIdx = 0;
    for (int i = 0; i < tdef.getColumnDefinitionCount(); i++) {
        final ColDef col = (ColDef) tdef.getColumnDefinition(i);
        if (!col.isImmutable()) {
            data.insertRow(cRowIdx);
            data.setHTML(cRowIdx, 0, col.getTitle());

            CheckBox cb = new CheckBox();
            cb.setValue(tdef.isColumnVisible(col));
            checkBoxes.put(col, cb);
            data.setWidget(cRowIdx, 1, cb);
            data.getCellFormatter().setAlignment(cRowIdx, 1, HasHorizontalAlignment.ALIGN_CENTER,
                    HasVerticalAlignment.ALIGN_MIDDLE);
            cRowIdx++;

            cb.addClickHandler(new ClickHandler() {
                public void onClick(ClickEvent event) {
                    applyChanges();
                }
            });
        }
    }

    return view;
}

From source file:org.gwtaf.widgets.expanding.gin.ScrollTableGinModule.java

License:Apache License

/**
 * Small hack to bypass Gin complaining about no default constructors of
 * ScrollTable./*from   w ww  . j av a2 s  .  co  m*/
 * 
 * @return dummy {@link ScrollTable}
 */
@Provides
public ScrollTable scrollTableProvider() {
    FixedWidthFlexTable headingsTable = new FixedWidthFlexTable();
    FixedWidthGrid grid = new FixedWidthGrid(1, 1);
    ScrollTable table = new ScrollTable(grid, headingsTable);
    return table;
}

From source file:org.pentaho.gwt.widgets.client.table.BaseTable.java

License:Open Source License

/**
 * Creates and initializes the data grid.
 */// ww  w .  j ava 2 s .c  o m
private void createDataGrid(SelectionGrid.SelectionPolicy selectionPolicy, int numOfColumns) {

    dataGrid = new FixedWidthGrid(0, numOfColumns) {
        @Override
        public void onBrowserEvent(Event event) {
            Element td = this.getEventTargetCell(event);
            if (td == null) {
                return;
            }
            Element tr = DOM.getParent(td);
            Element body = DOM.getParent(tr);
            int row = DOM.getChildIndex(body, tr) - 1;
            int column = DOM.getChildIndex(tr, td);

            switch (DOM.eventGetType(event)) {
            case Event.ONDBLCLICK: {
                internalDoubleClickListener.onCellClicked(dataGrid, row, column);
            }
            default: {
                break;
            }
            }

            super.onBrowserEvent(event);
        }
    };

    // disable text highlighting on dataGrid
    ElementUtils.killAllTextSelection(dataGrid.getElement());

    // Set style
    if (selectionPolicy == null) {
        dataGrid.setSelectionPolicy(SelectionGrid.SelectionPolicy.ONE_ROW);
    } else {
        dataGrid.setSelectionPolicy(selectionPolicy);
    }

    // Add table listeners
    dataGrid.addTableListener(internalTableListener);

    // Add table selection listeners
    dataGrid.sinkEvents(Event.ONDBLCLICK);
    baseTableColumnSorter = new BaseTableColumnSorter();
    dataGrid.setColumnSorter(baseTableColumnSorter);

    if (this.selectionPolicy == null) {
        dataGrid.setStylePrimaryName("disabled"); //$NON-NLS-1$
    }

}