Browse Source

Declarative support and tests for Grid's 7.5 features (#17481)

- Grid.Column.hidden and Grid.Column.hidable
- Grid.columnReorderingAllowed

Change-Id: Iee2e3ff7472bceef314403b750549c99e26a9546
tags/7.5.0.beta1
Pekka Hyvönen 9 years ago
parent
commit
ebd18795aa

+ 12
- 1
server/src/com/vaadin/ui/Grid.java View File

getMaximumWidth(), def.maxWidth, Double.class); getMaximumWidth(), def.maxWidth, Double.class);
DesignAttributeHandler.writeAttribute("expand", attributes, DesignAttributeHandler.writeAttribute("expand", attributes,
getExpandRatio(), def.expandRatio, Integer.class); getExpandRatio(), def.expandRatio, Integer.class);
DesignAttributeHandler.writeAttribute("hidable", attributes,
isHidable(), def.hidable, boolean.class);
DesignAttributeHandler.writeAttribute("hidden", attributes,
isHidden(), def.hidden, boolean.class);
DesignAttributeHandler.writeAttribute("property-id", attributes, DesignAttributeHandler.writeAttribute("property-id", attributes,
getPropertyId(), null, Object.class); getPropertyId(), null, Object.class);
} }
setEditable(DesignAttributeHandler.readAttribute("editable", setEditable(DesignAttributeHandler.readAttribute("editable",
attributes, boolean.class)); attributes, boolean.class));
} }

if (design.hasAttr("hidable")) {
setHidable(DesignAttributeHandler.readAttribute("hidable",
attributes, boolean.class));
}
if (design.hasAttr("hidden")) {
setHidden(DesignAttributeHandler.readAttribute("hidden",
attributes, boolean.class));
}
// Read size info where necessary. // Read size info where necessary.
if (design.hasAttr("width")) { if (design.hasAttr("width")) {
setWidth(DesignAttributeHandler.readAttribute("width", setWidth(DesignAttributeHandler.readAttribute("width",

+ 4
- 0
server/tests/src/com/vaadin/tests/server/component/grid/declarative/GridColumnDeclarativeTest.java View File

+ " <col sortable=true width='100' property-id='Column1'>" + " <col sortable=true width='100' property-id='Column1'>"
+ " <col sortable=false max-width='200' expand='2' property-id='Column2'>" + " <col sortable=false max-width='200' expand='2' property-id='Column2'>"
+ " <col sortable=true editable=false min-width='15' expand='1' property-id='Column3'>" + " <col sortable=true editable=false min-width='15' expand='1' property-id='Column3'>"
+ " <col sortable=true hidable=true property-id='Column4'>"
+ " <col sortable=true hidden=true property-id='Column5'>"
+ "</colgroup>" // + "</colgroup>" //
+ "<thead />" // + "<thead />" //
+ "</table></v-grid>"; + "</table></v-grid>";
.setExpandRatio(2).setSortable(false); .setExpandRatio(2).setSortable(false);
grid.addColumn("Column3", String.class).setMinimumWidth(15) grid.addColumn("Column3", String.class).setMinimumWidth(15)
.setExpandRatio(1).setEditable(false); .setExpandRatio(1).setEditable(false);
grid.addColumn("Column4", String.class).setHidable(true);
grid.addColumn("Column5", String.class).setHidden(true);


// Remove the default header // Remove the default header
grid.removeHeaderRow(grid.getDefaultHeaderRow()); grid.removeHeaderRow(grid.getDefaultHeaderRow());

+ 2
- 1
server/tests/src/com/vaadin/tests/server/component/grid/declarative/GridDeclarativeAttributeTest.java View File

public void testBasicAttributes() { public void testBasicAttributes() {


String design = "<v-grid editable='true' rows=20 frozen-columns=-1 " String design = "<v-grid editable='true' rows=20 frozen-columns=-1 "
+ "editor-save-caption='Tallenna' editor-cancel-caption='Peruuta'>";
+ "editor-save-caption='Tallenna' editor-cancel-caption='Peruuta' column-reordering-allowed=true>";


Grid grid = new Grid(); Grid grid = new Grid();
grid.setEditorEnabled(true); grid.setEditorEnabled(true);
grid.setFrozenColumnCount(-1); grid.setFrozenColumnCount(-1);
grid.setEditorSaveCaption("Tallenna"); grid.setEditorSaveCaption("Tallenna");
grid.setEditorCancelCaption("Peruuta"); grid.setEditorCancelCaption("Peruuta");
grid.setColumnReorderingAllowed(true);


testRead(design, grid); testRead(design, grid);
testWrite(design, grid); testWrite(design, grid);

Loading…
Cancel
Save