HorizontalLayout visibilities = new HorizontalLayout();
visibilities.setSpacing(true);
addComponent(visibilities);
final Table tbl = new Table("", createDataSource());
tbl.setImmediate(true);
tbl.setColumnCollapsingAllowed(true);
log = new Log(5);
controls.addComponent(new Button("Fixed size (200x200)",
new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
tbl.setWidth("200px");
tbl.setHeight("200px");
log.log("Size 200x200 pixels");
}
}));
controls.addComponent(new Button("Fixed size (600x200)",
new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
tbl.setWidth("600px");
tbl.setHeight("200px");
log.log("Size 600x200 pixels");
}
}));
controls.addComponent(new Button("Undefined size",
new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
tbl.setSizeUndefined();
log.log("Size undefined");
}
}));
NativeSelect pageLength = new NativeSelect("PageLength", Arrays.asList(
0, 1, 2, 4, 8, 10));
pageLength.setImmediate(true);
pageLength.setNullSelectionAllowed(false);
pageLength.addListener(new Property.ValueChangeListener() {
@Override
public void valueChange(ValueChangeEvent event) {
int pageLength = Integer.valueOf(event.getProperty().getValue()
.toString());
tbl.setPageLength(pageLength);
log.log("Page length: " + pageLength);
}
});
controls.addComponent(pageLength);
CheckBox cb = new CheckBox("Column 1");
cb.setValue(true);
cb.addListener(new ValueChangeListener() {
@Override
public void valueChange(ValueChangeEvent event) {
Boolean value = (Boolean) event.getProperty().getValue();
tbl.setColumnCollapsed("Column 1", !value);
if (value) {
log.log("Column 1 visible");
} else {
log.log("Column 1 hidden");
}
}
});
cb.setImmediate(true);
visibilities.addComponent(cb);
cb = new CheckBox("Column 2");
cb.setValue(true);
cb.addListener(new ValueChangeListener() {
@Override
public void valueChange(ValueChangeEvent event) {
Boolean value = (Boolean) event.getProperty().getValue();
tbl.setColumnCollapsed("Column 2", !value);
if (value) {
log.log("Column 2 visible");
} else {
log.log("Column 2 hidden");
}
}
});
cb.setImmediate(true);
visibilities.addComponent(cb);
cb = new CheckBox("Column 3");
cb.setValue(true);
cb.addListener(new ValueChangeListener() {
@Override
public void valueChange(ValueChangeEvent event) {
Boolean value = (Boolean) event.getProperty().getValue();
tbl.setColumnCollapsed("Column 3", !value);
if (value) {
log.log("Column 3 visible");
} else {
log.log("Column 3 hidden");