* @param headerTable the header table
* @param images the images to use in the table
*/
private void init(FixedWidthGrid dataTable, FixedWidthFlexTable headerTable,
ScrollTableImages images) {
final LayoutPanel layoutPanel = getLayoutPanel();
layoutPanel.setLayout(new BorderLayout());
layoutPanel.setPadding(0);
layoutPanel.setWidgetSpacing(0);
this.dataTable = dataTable;
this.headerTable = headerTable;
this.images = images;
resizeWorker.setColumnWidget(this);
// Prepare the header and data tables
prepareTable(dataTable, "dataTable");
if (headerTable != null) {
prepareTable(headerTable, "headerTable");
}
if (dataTable.getSelectionPolicy().hasInputColumn()) {
headerTable.setColumnWidth(0, getInputColumnWidth());
}
setStylePrimaryName(DEFAULT_STYLENAME);
// Create the table wrapper and spacer
if (headerTable != null) {
headerWrapper = createWrapper("headerWrapper");
headerSpacer = createSpacer(headerWrapper.getElement());
}
dataWrapper = createWrapper("dataWrapper");
// Create image to fill width
fillWidthImage = new Image() {
@Override
public void onBrowserEvent(Event event) {
super.onBrowserEvent(event);
if (DOM.eventGetType(event) == Event.ONCLICK) {
fillWidth();
}
}
};
// Adopt the header and the data tables into the panel
if (headerTable != null) {
adoptTable(headerTable, headerWrapper, Region.NORTH);
}
adoptTable(dataTable, dataWrapper, Region.CENTER);
fillWidthImage.setTitle("Shrink/Expand to fill visible area");
images.scrollTableFillWidth().applyTo(fillWidthImage);
Element fillWidthImageElem = fillWidthImage.getElement();
DOM.setStyleAttribute(fillWidthImageElem, "cursor", "pointer");
DOM.setStyleAttribute(fillWidthImageElem, "position", "absolute");
DOM.setStyleAttribute(fillWidthImageElem, "top", "0px");
DOM.setStyleAttribute(fillWidthImageElem, "right", "0px");
DOM.setStyleAttribute(fillWidthImageElem, "zIndex", "1");
// Add after the dataTable, so that to be ignored by the layout manager!!!
layoutPanel.add(fillWidthImage);
// Create the sort indicator Image
sortedColumnWrapper = DOM.createSpan();
DOM.setInnerHTML(sortedColumnWrapper, " ");
DOM.appendChild(sortedColumnWrapper, sortedColumnIndicator.getElement());