summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorHenrik Paul <henrik@vaadin.com>2014-08-04 12:51:37 +0300
committerHenrik Paul <henrik@vaadin.com>2014-08-04 12:51:37 +0300
commite16a0fb28ec04266ab01b6b9ff001b19cf32944b (patch)
tree23fde39a71207a9cede0d2de8edb4407f41d33e8 /server
parent27d1b5cb864cb56f41d796d552e4a1d6c2637fa8 (diff)
downloadvaadin-framework-e16a0fb28ec04266ab01b6b9ff001b19cf32944b.tar.gz
vaadin-framework-e16a0fb28ec04266ab01b6b9ff001b19cf32944b.zip
Remove deprecated header/footer API (#13334)
Change-Id: I9bddef300a817fd31054515e97bc6924370d3475
Diffstat (limited to 'server')
-rw-r--r--server/src/com/vaadin/ui/components/grid/ColumnGroup.java165
-rw-r--r--server/src/com/vaadin/ui/components/grid/ColumnGroupRow.java303
-rw-r--r--server/src/com/vaadin/ui/components/grid/Grid.java125
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/grid/GridColumnGroups.java260
4 files changed, 0 insertions, 853 deletions
diff --git a/server/src/com/vaadin/ui/components/grid/ColumnGroup.java b/server/src/com/vaadin/ui/components/grid/ColumnGroup.java
deleted file mode 100644
index ec676dfb87..0000000000
--- a/server/src/com/vaadin/ui/components/grid/ColumnGroup.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * Copyright 2000-2014 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-package com.vaadin.ui.components.grid;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import com.vaadin.shared.ui.grid.ColumnGroupState;
-
-/**
- * Column groups are used to group columns together for adding common auxiliary
- * headers and footers. Columns groups are added to {@link ColumnGroupRow}'s.
- *
- * @since
- * @author Vaadin Ltd
- */
-public class ColumnGroup implements Serializable {
-
- /**
- * List of property ids belonging to this group
- */
- private List<Object> columns;
-
- /**
- * The grid the column group is associated with
- */
- private final Grid grid;
-
- /**
- * The column group row the column group is attached to
- */
- private final ColumnGroupRow row;
-
- /**
- * The common state between the server and the client
- */
- private final ColumnGroupState state;
-
- /**
- * Constructs a new column group
- *
- * @param grid
- * the grid the column group is associated with
- * @param state
- * the state representing the data of the grid. Sent to the
- * client
- * @param propertyIds
- * the property ids of the columns that belongs to the group
- * @param groups
- * the sub groups who should be included in this group
- *
- */
- ColumnGroup(Grid grid, ColumnGroupRow row, ColumnGroupState state,
- List<Object> propertyIds) {
- if (propertyIds == null) {
- throw new IllegalArgumentException(
- "propertyIds cannot be null. Use empty list instead.");
- }
-
- this.state = state;
- this.row = row;
- columns = Collections.unmodifiableList(new ArrayList<Object>(
- propertyIds));
- this.grid = grid;
- }
-
- /**
- * Sets the text displayed in the header of the column group.
- *
- * @param header
- * the text displayed in the header of the column
- */
- public void setHeaderCaption(String header) {
- checkGroupIsAttached();
- state.header = header;
- grid.markAsDirty();
- }
-
- /**
- * Sets the text displayed in the header of the column group.
- *
- * @return the text displayed in the header of the column
- */
- public String getHeaderCaption() {
- checkGroupIsAttached();
- return state.header;
- }
-
- /**
- * Sets the text displayed in the footer of the column group.
- *
- * @param footer
- * the text displayed in the footer of the column
- */
- public void setFooterCaption(String footer) {
- checkGroupIsAttached();
- state.footer = footer;
- grid.markAsDirty();
- }
-
- /**
- * The text displayed in the footer of the column group.
- *
- * @return the text displayed in the footer of the column
- */
- public String getFooterCaption() {
- checkGroupIsAttached();
- return state.footer;
- }
-
- /**
- * Is a property id in this group or in some sub group of this group.
- *
- * @param propertyId
- * the property id to check for
- * @return <code>true</code> if the property id is included in this group.
- */
- public boolean isColumnInGroup(Object propertyId) {
- if (columns.contains(propertyId)) {
- return true;
- }
- return false;
- }
-
- /**
- * Returns a list of property ids where all also the child groups property
- * ids are included.
- *
- * @return a unmodifiable list with all the columns in the group. Includes
- * any subgroup columns as well.
- */
- public List<Object> getColumns() {
- return columns;
- }
-
- /**
- * Checks if column group is attached to a row and throws an
- * {@link IllegalStateException} if it is not.
- *
- * @throws IllegalStateException
- * if the column is no longer attached to any grid
- */
- protected void checkGroupIsAttached() throws IllegalStateException {
- if (!row.getState().groups.contains(state)) {
- throw new IllegalStateException(
- "Column Group has been removed from the row.");
- }
- }
-}
diff --git a/server/src/com/vaadin/ui/components/grid/ColumnGroupRow.java b/server/src/com/vaadin/ui/components/grid/ColumnGroupRow.java
deleted file mode 100644
index a497b5a8a8..0000000000
--- a/server/src/com/vaadin/ui/components/grid/ColumnGroupRow.java
+++ /dev/null
@@ -1,303 +0,0 @@
-/*
- * Copyright 2000-2014 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-package com.vaadin.ui.components.grid;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-import com.vaadin.server.KeyMapper;
-import com.vaadin.shared.ui.grid.ColumnGroupRowState;
-import com.vaadin.shared.ui.grid.ColumnGroupState;
-
-/**
- * A column group row represents an auxiliary header or footer row added to the
- * grid. A column group row includes column groups that group columns together.
- *
- * @since
- * @author Vaadin Ltd
- */
-public class ColumnGroupRow implements Serializable {
-
- /**
- * The common state shared between the client and server
- */
- private final ColumnGroupRowState state;
-
- /**
- * The column groups in this row
- */
- private List<ColumnGroup> groups = new ArrayList<ColumnGroup>();
-
- /**
- * Grid that the group row belongs to
- */
- private final Grid grid;
-
- /**
- * The column keys used to identify the column on the client side
- */
- private final KeyMapper<Object> columnKeys;
-
- /**
- * Constructs a new column group
- *
- * @param grid
- * The grid that the column group is associated to
- * @param state
- * The shared state which contains the data shared between server
- * and client
- * @param columnKeys
- * The column key mapper for converting property ids to client
- * side column identifiers
- */
- ColumnGroupRow(Grid grid, ColumnGroupRowState state,
- KeyMapper<Object> columnKeys) {
- this.grid = grid;
- this.columnKeys = columnKeys;
- this.state = state;
- }
-
- /**
- * Gets the shared state for the column group row. Used internally to send
- * the group row to the client.
- *
- * @return The current state of the row
- */
- ColumnGroupRowState getState() {
- return state;
- }
-
- /**
- * Add a new group to the row by using property ids for the columns.
- *
- * @param propertyIds
- * The property ids of the columns that should be included in the
- * group. A column can only belong in group on a row at a time.
- * @return a column group representing the collection of columns added to
- * the group
- */
- public ColumnGroup addGroup(Object... propertyIds)
- throws IllegalArgumentException {
- assert propertyIds != null : "propertyIds cannot be null.";
-
- for (Object propertyId : propertyIds) {
- if (hasColumnBeenGrouped(propertyId)) {
- throw new IllegalArgumentException("Column "
- + String.valueOf(propertyId)
- + " already belongs to another group.");
- }
- }
-
- validateNewGroupProperties(Arrays.asList(propertyIds));
-
- ColumnGroupState state = new ColumnGroupState();
- for (Object propertyId : propertyIds) {
- assert propertyId != null : "null items in columns array not supported.";
- state.columns.add(columnKeys.key(propertyId));
- }
- this.state.groups.add(state);
-
- ColumnGroup group = new ColumnGroup(grid, this, state,
- Arrays.asList(propertyIds));
- groups.add(group);
-
- grid.markAsDirty();
- return group;
- }
-
- private void validateNewGroupProperties(List<Object> propertyIds)
- throws IllegalArgumentException {
-
- /*
- * Validate parent grouping
- */
- int rowIndex = grid.getColumnGroupRows().indexOf(this);
- int parentRowIndex = rowIndex - 1;
-
- // Get the parent row of this row.
- ColumnGroupRow parentRow = null;
- if (parentRowIndex > -1) {
- parentRow = grid.getColumnGroupRows().get(parentRowIndex);
- }
-
- if (parentRow == null) {
- // A parentless row is always valid and is usually the first row
- // added to the grid
- return;
- }
-
- for (Object id : propertyIds) {
- if (parentRow.hasColumnBeenGrouped(id)) {
- /*
- * If a property has been grouped in the parent row then all of
- * the properties in the parent group also needs to be included
- * in the child group for the groups to be valid
- */
- ColumnGroup parentGroup = parentRow.getGroupForProperty(id);
- if (!propertyIds.containsAll(parentGroup.getColumns())) {
- throw new IllegalArgumentException(
- "Grouped properties overlaps previous grouping bounderies");
- }
- }
- }
- }
-
- /**
- * Add a new group to the row by using column instances.
- *
- * @param columns
- * the columns that should belong to the group
- * @return a column group representing the collection of columns added to
- * the group
- */
- public ColumnGroup addGroup(GridColumn... columns)
- throws IllegalArgumentException {
- assert columns != null : "columns cannot be null";
-
- List<Object> propertyIds = new ArrayList<Object>();
- for (GridColumn column : columns) {
- assert column != null : "null items in columns array not supported.";
-
- String columnId = column.getState().id;
- Object propertyId = grid.getPropertyIdByColumnId(columnId);
- propertyIds.add(propertyId);
- }
- return addGroup(propertyIds.toArray());
- }
-
- /**
- * Add a new group to the row by using other already greated groups
- *
- * @param groups
- * the subgroups of the group
- * @return a column group representing the collection of columns added to
- * the group
- *
- */
- public ColumnGroup addGroup(ColumnGroup... groups)
- throws IllegalArgumentException {
- assert groups != null : "groups cannot be null";
-
- // Gather all groups columns into one list
- List<Object> propertyIds = new ArrayList<Object>();
- for (ColumnGroup group : groups) {
- propertyIds.addAll(group.getColumns());
- }
-
- validateNewGroupProperties(propertyIds);
-
- ColumnGroupState state = new ColumnGroupState();
- ColumnGroup group = new ColumnGroup(grid, this, state, propertyIds);
- this.groups.add(group);
-
- // Update state
- for (Object propertyId : group.getColumns()) {
- state.columns.add(columnKeys.key(propertyId));
- }
- this.state.groups.add(state);
-
- grid.markAsDirty();
- return group;
- }
-
- /**
- * Removes a group from the row. Does not remove the group from subgroups,
- * to remove it from the subgroup invoke removeGroup on the subgroup.
- *
- * @param group
- * the group to remove
- */
- public void removeGroup(ColumnGroup group) {
- int index = groups.indexOf(group);
- groups.remove(index);
- state.groups.remove(index);
- grid.markAsDirty();
- }
-
- /**
- * Get the groups in the row.
- *
- * @return unmodifiable list of groups in this row
- */
- public List<ColumnGroup> getGroups() {
- return Collections.unmodifiableList(groups);
- }
-
- /**
- * Checks if a property id has been added to a group in this row.
- *
- * @param propertyId
- * the property id to check for
- * @return <code>true</code> if the column is included in a group
- */
- private boolean hasColumnBeenGrouped(Object propertyId) {
- return getGroupForProperty(propertyId) != null;
- }
-
- private ColumnGroup getGroupForProperty(Object propertyId) {
- for (ColumnGroup group : groups) {
- if (group.isColumnInGroup(propertyId)) {
- return group;
- }
- }
- return null;
- }
-
- /**
- * Is the header visible for the row.
- *
- * @return <code>true</code> if header is visible
- */
- public boolean isHeaderVisible() {
- return state.headerVisible;
- }
-
- /**
- * Sets the header visible for the row.
- *
- * @param visible
- * should the header be shown
- */
- public void setHeaderVisible(boolean visible) {
- state.headerVisible = visible;
- grid.markAsDirty();
- }
-
- /**
- * Is the footer visible for the row.
- *
- * @return <code>true</code> if footer is visible
- */
- public boolean isFooterVisible() {
- return state.footerVisible;
- }
-
- /**
- * Sets the footer visible for the row.
- *
- * @param visible
- * should the footer be shown
- */
- public void setFooterVisible(boolean visible) {
- state.footerVisible = visible;
- grid.markAsDirty();
- }
-
-}
diff --git a/server/src/com/vaadin/ui/components/grid/Grid.java b/server/src/com/vaadin/ui/components/grid/Grid.java
index 514a0496e2..5e21c7b70a 100644
--- a/server/src/com/vaadin/ui/components/grid/Grid.java
+++ b/server/src/com/vaadin/ui/components/grid/Grid.java
@@ -40,7 +40,6 @@ import com.vaadin.data.Container.Sortable;
import com.vaadin.data.RpcDataProviderExtension;
import com.vaadin.data.RpcDataProviderExtension.DataProviderKeyMapper;
import com.vaadin.server.KeyMapper;
-import com.vaadin.shared.ui.grid.ColumnGroupRowState;
import com.vaadin.shared.ui.grid.GridClientRpc;
import com.vaadin.shared.ui.grid.GridColumnState;
import com.vaadin.shared.ui.grid.GridServerRpc;
@@ -139,11 +138,6 @@ public class Grid extends AbstractComponent implements SelectionChangeNotifier {
private final KeyMapper<Object> columnKeys = new KeyMapper<Object>();
/**
- * The column groups added to the grid
- */
- private final List<ColumnGroupRow> columnGroupRows = new ArrayList<ColumnGroupRow>();
-
- /**
* The current sort order
*/
private final List<SortOrder> sortOrder = new ArrayList<SortOrder>();
@@ -465,125 +459,6 @@ public class Grid extends AbstractComponent implements SelectionChangeNotifier {
}
/**
- * Sets the header rows visible.
- *
- * @param visible
- * <code>true</code> if the header rows should be visible
- */
- @Deprecated
- public void setColumnHeadersVisible(boolean visible) {
- getHeader().setVisible(visible);
- }
-
- /**
- * Are the header rows visible?
- *
- * @return <code>true</code> if the headers of the columns are visible
- */
- @Deprecated
- public boolean isColumnHeadersVisible() {
- return getHeader().isVisible();
- }
-
- /**
- * Sets the footer rows visible.
- *
- * @param visible
- * <code>true</code> if the footer rows should be visible
- */
- @Deprecated
- public void setColumnFootersVisible(boolean visible) {
- getFooter().setVisible(visible);
- }
-
- /**
- * Are the footer rows visible.
- *
- * @return <code>true</code> if the footer rows should be visible
- */
- @Deprecated
- public boolean isColumnFootersVisible() {
- return getFooter().isVisible();
- }
-
- /**
- * <p>
- * Adds a new column group to the grid.
- *
- * <p>
- * Column group rows are rendered in the header and footer of the grid.
- * Column group rows are made up of column groups which groups together
- * columns for adding a common auxiliary header or footer for the columns.
- * </p>
- * </p>
- *
- * <p>
- * Example usage:
- *
- * <pre>
- * // Add a new column group row to the grid
- * ColumnGroupRow row = grid.addColumnGroupRow();
- *
- * // Group &quot;Column1&quot; and &quot;Column2&quot; together to form a header in the row
- * ColumnGroup column12 = row.addGroup(&quot;Column1&quot;, &quot;Column2&quot;);
- *
- * // Set a common header for &quot;Column1&quot; and &quot;Column2&quot;
- * column12.setHeader(&quot;Column 1&amp;2&quot;);
- * </pre>
- *
- * </p>
- *
- * @return a column group instance you can use to add column groups
- */
- @Deprecated
- public ColumnGroupRow addColumnGroupRow() {
- ColumnGroupRowState state = new ColumnGroupRowState();
- ColumnGroupRow row = new ColumnGroupRow(this, state, columnKeys);
- columnGroupRows.add(row);
- getState().columnGroupRows.add(state);
- return row;
- }
-
- /**
- * Adds a new column group to the grid at a specific index
- *
- * @param rowIndex
- * the index of the row
- * @return a column group instance you can use to add column groups
- */
- @Deprecated
- public ColumnGroupRow addColumnGroupRow(int rowIndex) {
- ColumnGroupRowState state = new ColumnGroupRowState();
- ColumnGroupRow row = new ColumnGroupRow(this, state, columnKeys);
- columnGroupRows.add(rowIndex, row);
- getState().columnGroupRows.add(rowIndex, state);
- return row;
- }
-
- /**
- * Removes a column group.
- *
- * @param row
- * the row to remove
- */
- @Deprecated
- public void removeColumnGroupRow(ColumnGroupRow row) {
- columnGroupRows.remove(row);
- getState().columnGroupRows.remove(row.getState());
- }
-
- /**
- * Gets the column group rows.
- *
- * @return an unmodifiable list of column group rows
- */
- @Deprecated
- public List<ColumnGroupRow> getColumnGroupRows() {
- return Collections.unmodifiableList(new ArrayList<ColumnGroupRow>(
- columnGroupRows));
- }
-
- /**
* Used internally by the {@link Grid} to get a {@link GridColumn} by
* referencing its generated state id. Also used by {@link GridColumn} to
* verify if it has been detached from the {@link Grid}.
diff --git a/server/tests/src/com/vaadin/tests/server/component/grid/GridColumnGroups.java b/server/tests/src/com/vaadin/tests/server/component/grid/GridColumnGroups.java
deleted file mode 100644
index 21bfbbb37e..0000000000
--- a/server/tests/src/com/vaadin/tests/server/component/grid/GridColumnGroups.java
+++ /dev/null
@@ -1,260 +0,0 @@
-/*
- * Copyright 2000-2014 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.tests.server.component.grid;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.List;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import com.vaadin.data.util.IndexedContainer;
-import com.vaadin.server.KeyMapper;
-import com.vaadin.shared.ui.grid.GridState;
-import com.vaadin.ui.components.grid.ColumnGroup;
-import com.vaadin.ui.components.grid.ColumnGroupRow;
-import com.vaadin.ui.components.grid.Grid;
-
-public class GridColumnGroups {
-
- private Grid grid;
-
- private GridState state;
-
- private Method getStateMethod;
-
- private Field columnIdGeneratorField;
-
- private KeyMapper<Object> columnIdMapper;
-
- @Before
- public void setup() throws Exception {
- IndexedContainer ds = new IndexedContainer();
- for (int c = 0; c < 10; c++) {
- ds.addContainerProperty("column" + c, String.class, "");
- }
- grid = new Grid(ds);
-
- getStateMethod = Grid.class.getDeclaredMethod("getState");
- getStateMethod.setAccessible(true);
-
- state = (GridState) getStateMethod.invoke(grid);
-
- columnIdGeneratorField = Grid.class.getDeclaredField("columnKeys");
- columnIdGeneratorField.setAccessible(true);
-
- columnIdMapper = (KeyMapper<Object>) columnIdGeneratorField.get(grid);
- }
-
- @Test
- public void testColumnGroupRows() throws Exception {
-
- // No column group rows by default
- List<ColumnGroupRow> rows = grid.getColumnGroupRows();
- assertEquals(0, rows.size());
-
- // Add some rows
- ColumnGroupRow row1 = grid.addColumnGroupRow();
- ColumnGroupRow row3 = grid.addColumnGroupRow();
- ColumnGroupRow row2 = grid.addColumnGroupRow(1);
-
- rows = grid.getColumnGroupRows();
- assertEquals(3, rows.size());
- assertEquals(row1, rows.get(0));
- assertEquals(row2, rows.get(1));
- assertEquals(row3, rows.get(2));
-
- // Header should be visible by default, footer should not
- assertTrue(row1.isHeaderVisible());
- assertFalse(row1.isFooterVisible());
-
- row1.setHeaderVisible(false);
- assertFalse(row1.isHeaderVisible());
- row1.setHeaderVisible(true);
- assertTrue(row1.isHeaderVisible());
-
- row1.setFooterVisible(true);
- assertTrue(row1.isFooterVisible());
- row1.setFooterVisible(false);
- assertFalse(row1.isFooterVisible());
-
- row1.setHeaderVisible(true);
- row1.setFooterVisible(true);
- assertTrue(row1.isHeaderVisible());
- assertTrue(row1.isFooterVisible());
-
- row1.setHeaderVisible(false);
- row1.setFooterVisible(false);
- assertFalse(row1.isHeaderVisible());
- assertFalse(row1.isFooterVisible());
- }
-
- @Test
- public void testColumnGroupsInState() throws Exception {
-
- // Add a new row
- ColumnGroupRow row = grid.addColumnGroupRow();
- assertTrue(state.columnGroupRows.size() == 1);
-
- // Add a group by property id
- ColumnGroup columns12 = row.addGroup("column1", "column2");
- assertTrue(state.columnGroupRows.get(0).groups.size() == 1);
-
- // Set header of column
- columns12.setHeaderCaption("Column12");
- assertEquals("Column12",
- state.columnGroupRows.get(0).groups.get(0).header);
-
- // Set footer of column
- columns12.setFooterCaption("Footer12");
- assertEquals("Footer12",
- state.columnGroupRows.get(0).groups.get(0).footer);
-
- // Add another group by column instance
- ColumnGroup columns34 = row.addGroup(grid.getColumn("column3"),
- grid.getColumn("column4"));
- assertTrue(state.columnGroupRows.get(0).groups.size() == 2);
-
- // add another group row
- ColumnGroupRow row2 = grid.addColumnGroupRow();
- assertTrue(state.columnGroupRows.size() == 2);
-
- // add a group by combining the two previous groups
- ColumnGroup columns1234 = row2.addGroup(columns12, columns34);
- assertTrue(columns1234.getColumns().size() == 4);
-
- // Insert a group as the second group
- ColumnGroupRow newRow2 = grid.addColumnGroupRow(1);
- assertTrue(state.columnGroupRows.size() == 3);
- }
-
- @Test
- public void testAddingColumnGroups() throws Exception {
-
- ColumnGroupRow row = grid.addColumnGroupRow();
-
- // By property id
- ColumnGroup columns01 = row.addGroup("column0", "column1");
- assertEquals(2, columns01.getColumns().size());
- assertEquals("column0", columns01.getColumns().get(0));
- assertTrue(columns01.isColumnInGroup("column0"));
- assertEquals("column1", columns01.getColumns().get(1));
- assertTrue(columns01.isColumnInGroup("column1"));
-
- // By grid column
- ColumnGroup columns23 = row.addGroup(grid.getColumn("column2"),
- grid.getColumn("column3"));
- assertEquals(2, columns23.getColumns().size());
- assertEquals("column2", columns23.getColumns().get(0));
- assertTrue(columns23.isColumnInGroup("column2"));
- assertEquals("column3", columns23.getColumns().get(1));
- assertTrue(columns23.isColumnInGroup("column3"));
-
- // Combine groups
- ColumnGroupRow row2 = grid.addColumnGroupRow();
- ColumnGroup columns0123 = row2.addGroup(columns01, columns23);
- assertEquals(4, columns0123.getColumns().size());
- assertEquals("column0", columns0123.getColumns().get(0));
- assertTrue(columns0123.isColumnInGroup("column0"));
- assertEquals("column1", columns0123.getColumns().get(1));
- assertTrue(columns0123.isColumnInGroup("column1"));
- assertEquals("column2", columns0123.getColumns().get(2));
- assertTrue(columns0123.isColumnInGroup("column2"));
- assertEquals("column3", columns0123.getColumns().get(3));
- assertTrue(columns0123.isColumnInGroup("column3"));
- }
-
- @Test
- public void testColumnGroupHeadersAndFooters() throws Exception {
-
- ColumnGroupRow row = grid.addColumnGroupRow();
- ColumnGroup group = row.addGroup("column1", "column2");
-
- // Header
- assertNull(group.getHeaderCaption());
- group.setHeaderCaption("My header");
- assertEquals("My header", group.getHeaderCaption());
- group.setHeaderCaption(null);
- assertNull(group.getHeaderCaption());
-
- // Footer
- assertNull(group.getFooterCaption());
- group.setFooterCaption("My footer");
- assertEquals("My footer", group.getFooterCaption());
- group.setFooterCaption(null);
- assertNull(group.getFooterCaption());
- }
-
- @Test
- public void testColumnGroupDetachment() throws Exception {
-
- ColumnGroupRow row = grid.addColumnGroupRow();
- ColumnGroup group = row.addGroup("column1", "column2");
-
- // Remove group
- row.removeGroup(group);
-
- try {
- group.setHeaderCaption("Header");
- fail("Should throw exception for setting header caption on detached group");
- } catch (IllegalStateException ise) {
-
- }
-
- try {
- group.setFooterCaption("Footer");
- fail("Should throw exception for setting footer caption on detached group");
- } catch (IllegalStateException ise) {
-
- }
- }
-
- @Test
- public void testColumnGroupLimits() throws Exception {
-
- ColumnGroupRow row = grid.addColumnGroupRow();
- row.addGroup("column1", "column2");
- row.addGroup("column3", "column4");
-
- try {
- row.addGroup("column2", "column3");
- fail("Adding a group with already grouped properties should throw exception");
- } catch (IllegalArgumentException iae) {
-
- }
-
- ColumnGroupRow row2 = grid.addColumnGroupRow();
-
- try {
- row2.addGroup("column2", "column3");
- fail("Adding a group that breaks previous grouping boundaries should throw exception");
- } catch (IllegalArgumentException iae) {
-
- }
-
- // This however should not throw an exception as it spans completely
- // over the parent rows groups
- row2.addGroup("column1", "column2", "column3", "column4");
-
- }
-}