From e16a0fb28ec04266ab01b6b9ff001b19cf32944b Mon Sep 17 00:00:00 2001
From: Henrik Paul
Date: Mon, 4 Aug 2014 12:51:37 +0300
Subject: [PATCH] Remove deprecated header/footer API (#13334)
Change-Id: I9bddef300a817fd31054515e97bc6924370d3475
---
.../ui/components/grid/ColumnGroup.java | 165 ----------
.../ui/components/grid/ColumnGroupRow.java | 303 ------------------
.../com/vaadin/ui/components/grid/Grid.java | 125 --------
.../component/grid/GridColumnGroups.java | 260 ---------------
.../shared/ui/grid/ColumnGroupRowState.java | 46 ---
.../com/vaadin/shared/ui/grid/GridState.java | 5 -
.../components/grid/GridColumnGroups.java | 106 ------
.../grid/basicfeatures/GridBasicFeatures.java | 70 ----
8 files changed, 1080 deletions(-)
delete mode 100644 server/src/com/vaadin/ui/components/grid/ColumnGroup.java
delete mode 100644 server/src/com/vaadin/ui/components/grid/ColumnGroupRow.java
delete mode 100644 server/tests/src/com/vaadin/tests/server/component/grid/GridColumnGroups.java
delete mode 100644 shared/src/com/vaadin/shared/ui/grid/ColumnGroupRowState.java
delete mode 100644 uitest/src/com/vaadin/tests/components/grid/GridColumnGroups.java
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
- *
- *
- * Example usage:
- *
- *
- * // Add a new column group row to the grid
- * ColumnGroupRow row = grid.addColumnGroupRow();
- *
- * // Group "Column1" and "Column2" together to form a header in the row
- * ColumnGroup column12 = row.addGroup("Column1", "Column2");
- *
- * // Set a common header for "Column1" and "Column2"
- * column12.setHeader("Column 1&2");
- *
- *
- *
- *
- * @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 getColumnGroupRows() {
- return Collections.unmodifiableList(new ArrayList(
- columnGroupRows));
- }
-
/**
* Used internally by the {@link Grid} to get a {@link GridColumn} by
* referencing its generated state id. Also used by {@link GridColumn} to
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 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) columnIdGeneratorField.get(grid);
- }
-
- @Test
- public void testColumnGroupRows() throws Exception {
-
- // No column group rows by default
- List 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");
-
- }
-}
diff --git a/shared/src/com/vaadin/shared/ui/grid/ColumnGroupRowState.java b/shared/src/com/vaadin/shared/ui/grid/ColumnGroupRowState.java
deleted file mode 100644
index d3d5ea2495..0000000000
--- a/shared/src/com/vaadin/shared/ui/grid/ColumnGroupRowState.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright 2000-2013 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.shared.ui.grid;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * The column group row data shared between the server and client
- *
- * @since
- * @author Vaadin Ltd
- */
-public class ColumnGroupRowState implements Serializable {
-
- /**
- * The groups that has been added to the row
- */
- public List groups = new ArrayList();
-
- /**
- * Is the header shown
- */
- public boolean headerVisible = true;
-
- /**
- * Is the footer shown
- */
- public boolean footerVisible = false;
-
-}
diff --git a/shared/src/com/vaadin/shared/ui/grid/GridState.java b/shared/src/com/vaadin/shared/ui/grid/GridState.java
index 68ee64dfe4..54acc80127 100644
--- a/shared/src/com/vaadin/shared/ui/grid/GridState.java
+++ b/shared/src/com/vaadin/shared/ui/grid/GridState.java
@@ -102,11 +102,6 @@ public class GridState extends AbstractComponentState {
public GridStaticSectionState footer = new GridStaticSectionState();
- /**
- * The column groups added to the grid
- */
- public List columnGroupRows = new ArrayList();
-
/**
* The id for the last frozen column.
*
diff --git a/uitest/src/com/vaadin/tests/components/grid/GridColumnGroups.java b/uitest/src/com/vaadin/tests/components/grid/GridColumnGroups.java
deleted file mode 100644
index f1199301d9..0000000000
--- a/uitest/src/com/vaadin/tests/components/grid/GridColumnGroups.java
+++ /dev/null
@@ -1,106 +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.components.grid;
-
-import com.vaadin.data.util.IndexedContainer;
-import com.vaadin.server.VaadinRequest;
-import com.vaadin.tests.components.AbstractTestUI;
-import com.vaadin.ui.components.grid.ColumnGroup;
-import com.vaadin.ui.components.grid.ColumnGroupRow;
-import com.vaadin.ui.components.grid.Grid;
-import com.vaadin.ui.components.grid.GridColumn;
-
-public class GridColumnGroups extends AbstractTestUI {
-
- private final int COLUMNS = 4;
-
- @Override
- protected void setup(VaadinRequest request) {
-
- // Setup grid
- IndexedContainer ds = new IndexedContainer();
- for (int col = 0; col < COLUMNS; col++) {
- ds.addContainerProperty("Column" + col, String.class, "");
- }
- Grid grid = new Grid(ds);
- addComponent(grid);
-
- /*-
- * ---------------------------------------------
- * | Header 1 | <- Auxiliary row 2
- * |-------------------------------------------|
- * | Header 2 | Header 3 | <- Auxiliary row 1
- * |-------------------------------------------|
- * | Column 1 | Column 2 | Column 3 | Column 4 | <- Column headers
- * --------------------------------------------|
- * | ... | ... | ... | ... |
- * | ... | ... | ... | ... |
- * --------------------------------------------|
- * | Column 1 | Column 2 | Column 3 | Column 4 | <- Column footers
- * --------------------------------------------|
- * | Footer 2 | Footer 3 | <- Auxiliary row 1
- * --------------------------------------------|
- * | Footer 1 | <- Auxiliary row 2
- * ---------------------------------------------
- -*/
-
- // Set column footers (headers are generated automatically)
- grid.setColumnFootersVisible(true);
- for (Object propertyId : ds.getContainerPropertyIds()) {
- GridColumn column = grid.getColumn(propertyId);
- column.setFooterCaption(String.valueOf(propertyId));
- }
-
- // First auxiliary row
- ColumnGroupRow auxRow1 = grid.addColumnGroupRow();
-
- // Using property id to create a column group
- ColumnGroup columns12 = auxRow1.addGroup("Column0", "Column1");
- columns12.setHeaderCaption("Header 2");
- columns12.setFooterCaption("Footer 2");
-
- // Using grid columns to create a column group
- GridColumn column3 = grid.getColumn("Column2");
- GridColumn column4 = grid.getColumn("Column3");
- ColumnGroup columns34 = auxRow1.addGroup(column3, column4);
- columns34.setHeaderCaption("Header 3");
- columns34.setFooterCaption("Footer 3");
-
- // Second auxiliary row
- ColumnGroupRow auxRow2 = grid.addColumnGroupRow();
-
- // Using previous groups to create a column group
- ColumnGroup columns1234 = auxRow2.addGroup(columns12, columns34);
- columns1234.setHeaderCaption("Header 1");
- columns1234.setFooterCaption("Footer 1");
-
- }
-
- @Override
- protected String getTestDescription() {
- return "Grid should support headers and footer groups";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 12894;
- }
-
-}
diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java
index bff16d8db7..9ab2c98bdb 100644
--- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java
+++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java
@@ -31,8 +31,6 @@ import com.vaadin.data.util.IndexedContainer;
import com.vaadin.shared.ui.grid.HeightMode;
import com.vaadin.shared.ui.grid.SortDirection;
import com.vaadin.tests.components.AbstractComponentTest;
-import com.vaadin.ui.components.grid.ColumnGroup;
-import com.vaadin.ui.components.grid.ColumnGroupRow;
import com.vaadin.ui.components.grid.Grid;
import com.vaadin.ui.components.grid.Grid.SelectionMode;
import com.vaadin.ui.components.grid.GridColumn;
@@ -178,8 +176,6 @@ public class GridBasicFeatures extends AbstractComponentTest {
createFooterActions();
- createColumnGroupActions();
-
createRowActions();
addHeightActions();
@@ -451,72 +447,6 @@ public class GridBasicFeatures extends AbstractComponentTest {
return "Column " + c;
}
- protected void createColumnGroupActions() {
- createCategory("Column groups", null);
-
- createClickAction("Add group row", "Column groups",
- new Command() {
-
- @Override
- public void execute(Grid grid, String value, Object data) {
- final ColumnGroupRow row = grid.addColumnGroupRow();
- columnGroupRows++;
- createCategory("Column group row " + columnGroupRows,
- "Column groups");
-
- createBooleanAction("Header Visible",
- "Column group row " + columnGroupRows, true,
- new Command() {
-
- @Override
- public void execute(Grid grid,
- Boolean value, Object columnIndex) {
- row.setHeaderVisible(value);
- }
- }, row);
-
- createBooleanAction("Footer Visible",
- "Column group row " + columnGroupRows, false,
- new Command() {
-
- @Override
- public void execute(Grid grid,
- Boolean value, Object columnIndex) {
- row.setFooterVisible(value);
- }
- }, row);
-
- for (int i = 0; i < COLUMNS; i++) {
- final int columnIndex = i;
- createClickAction("Group Column " + columnIndex
- + " & " + (columnIndex + 1),
- "Column group row " + columnGroupRows,
- new Command() {
-
- @Override
- public void execute(Grid c,
- Integer value, Object data) {
- final ColumnGroup group = row
- .addGroup(
- "Column" + value,
- "Column"
- + (value + 1));
-
- group.setHeaderCaption("Column "
- + value + " & "
- + (value + 1));
-
- group.setFooterCaption("Column "
- + value + " & "
- + (value + 1));
- }
- }, i, row);
- }
- }
- }, null, null);
-
- }
-
protected void createRowActions() {
createCategory("Body rows", null);
--
2.39.5