summaryrefslogtreecommitdiff
path: root/frontend/client/src/autotest/planner/TestPlannerUtils.java
blob: 6c9b6d14676c8c19f7290125454e7c154f081314 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package autotest.planner;

import com.google.gwt.gen2.table.client.FixedWidthFlexTable;
import com.google.gwt.gen2.table.client.FixedWidthGrid;
import com.google.gwt.gen2.table.client.ScrollTable;

public class TestPlannerUtils {

    private static final int HEIGHT_FUDGE = 300;

    public static String getHeightParam(int windowHeight) {
        return (windowHeight - HEIGHT_FUDGE) + "px";
    }

    public static void resizeScrollTable(ScrollTable scrollTable) {
        resizeScrollTable(scrollTable, false);
    }

    public static void resizeScrollTable(ScrollTable scrollTable, boolean hasSelectAllHeader) {
        FixedWidthGrid dataTable = scrollTable.getDataTable();
        FixedWidthFlexTable header = scrollTable.getHeaderTable();

        for (int column = 0; column < dataTable.getColumnCount(); column++) {
            int headerColumn = column;
            if (hasSelectAllHeader) {
                headerColumn++;
            }

            int width = Math.max(
                      dataTable.getIdealColumnWidth(column),
                      header.getIdealColumnWidth(headerColumn));

            header.setColumnWidth(headerColumn, width);
            dataTable.setColumnWidth(column, width);
        }
    }
}