Example usage for com.google.gwt.gen2.table.client ScrollTable setMinimumColumnWidth

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

Introduction

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

Prototype

public void setMinimumColumnWidth(int column, int minWidth) 

Source Link

Document

Set the minimum width of the column.

Usage

From source file:com.google.gwt.gen2.demo.scrolltable.client.ScrollTableDemo.java

License:Apache License

/**
 * Setup the scroll table.//from  ww w  . j  a  v  a  2s  . c  o m
 */
protected AbstractScrollTable createScrollTable() {
    // Create the three component tables
    FixedWidthFlexTable headerTable = createHeaderTable();
    FixedWidthFlexTable footerTable = createFooterTable();
    FixedWidthGrid dataTable = createDataTable();

    // Create the scroll table
    ScrollTable theScrollTable = new ScrollTable(dataTable, headerTable);
    theScrollTable.setFooterTable(footerTable);

    // Setup the formatting
    theScrollTable.setCellPadding(3);
    theScrollTable.setCellSpacing(0);
    theScrollTable.setResizePolicy(ScrollTable.ResizePolicy.FILL_WIDTH);

    // first name
    theScrollTable.setMinimumColumnWidth(0, 50);
    theScrollTable.setPreferredColumnWidth(0, 100);
    theScrollTable.setColumnTruncatable(0, false);

    // last name
    theScrollTable.setMinimumColumnWidth(1, 50);
    theScrollTable.setPreferredColumnWidth(1, 100);
    theScrollTable.setColumnTruncatable(1, false);

    // age
    theScrollTable.setMinimumColumnWidth(2, 35);
    theScrollTable.setPreferredColumnWidth(2, 35);
    theScrollTable.setMaximumColumnWidth(2, 35);

    // gender
    theScrollTable.setMinimumColumnWidth(3, 45);
    theScrollTable.setPreferredColumnWidth(3, 45);
    theScrollTable.setMaximumColumnWidth(3, 45);

    // race
    theScrollTable.setMinimumColumnWidth(4, 45);
    theScrollTable.setPreferredColumnWidth(4, 45);
    theScrollTable.setMaximumColumnWidth(4, 45);

    // color
    theScrollTable.setPreferredColumnWidth(5, 80);

    // sport
    theScrollTable.setMinimumColumnWidth(6, 40);
    theScrollTable.setPreferredColumnWidth(6, 110);

    // college
    theScrollTable.setMinimumColumnWidth(7, 50);
    theScrollTable.setPreferredColumnWidth(7, 180);
    theScrollTable.setMaximumColumnWidth(7, 250);

    // year
    theScrollTable.setPreferredColumnWidth(8, 25);
    theScrollTable.setColumnTruncatable(8, false);

    // gpa
    theScrollTable.setPreferredColumnWidth(9, 35);
    theScrollTable.setColumnTruncatable(9, false);

    // id
    theScrollTable.setPreferredColumnWidth(10, 55);
    theScrollTable.setColumnTruncatable(10, false);

    // pin
    theScrollTable.setPreferredColumnWidth(11, 45);
    theScrollTable.setColumnTruncatable(11, false);

    return theScrollTable;
}

From source file:com.openkm.frontend.client.util.ScrollTableHelper.java

License:Open Source License

/**
 * setColumnWidth// www.ja v a  2  s . c  o  m
 */
public static void setColumnWidth(ScrollTable table, int col, int width, int type, boolean isMin,
        boolean isMax) {
    table.setColumnWidth(col, width);
    table.setPreferredColumnWidth(col, width);
    int min = 0;
    int max = 0;
    switch (type) {
    case LOW:
        min = width - 15;
        max = width + 25;
        break;
    case MEDIUM:
        min = width - 35;
        max = width + 70;
        break;
    case GREAT:
        min = width - 150;
        max = width + 250;
        break;
    }
    // Correction to min always >=25 except in fixed case
    if (type == FIXED) {
        min = width;
        max = width;
    } else if (min < 25) {
        min = 25;
    }
    // Set min and max values
    if (isMin) {
        table.setMinimumColumnWidth(col, min);
    }
    if (isMax) {
        table.setMaximumColumnWidth(col, max);
    }
}

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;/*from   w  w w . jav a2  s. c  om*/
                    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;
}