summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--server/src/com/vaadin/ui/Table.java2
-rw-r--r--server/src/com/vaadin/ui/TreeTable.java8
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/treetable/TreeTableTest.java72
-rw-r--r--uitest/src/com/vaadin/tests/components/treetable/TreeTableRowHeaderMode.java43
-rw-r--r--uitest/src/com/vaadin/tests/components/treetable/TreeTableRowHeaderModeTest.java39
5 files changed, 163 insertions, 1 deletions
diff --git a/server/src/com/vaadin/ui/Table.java b/server/src/com/vaadin/ui/Table.java
index 9da25d3e48..ec345e3fc3 100644
--- a/server/src/com/vaadin/ui/Table.java
+++ b/server/src/com/vaadin/ui/Table.java
@@ -3854,7 +3854,7 @@ public class Table extends AbstractSelect implements Action.Container,
}
}
- private boolean rowHeadersAreEnabled() {
+ protected boolean rowHeadersAreEnabled() {
return getRowHeaderMode() != ROW_HEADER_MODE_HIDDEN;
}
diff --git a/server/src/com/vaadin/ui/TreeTable.java b/server/src/com/vaadin/ui/TreeTable.java
index 9bca20587b..63b54a6ced 100644
--- a/server/src/com/vaadin/ui/TreeTable.java
+++ b/server/src/com/vaadin/ui/TreeTable.java
@@ -411,6 +411,14 @@ public class TreeTable extends Table implements Hierarchical {
}
@Override
+ protected boolean rowHeadersAreEnabled() {
+ if (getRowHeaderMode() == RowHeaderMode.ICON_ONLY) {
+ return false;
+ }
+ return super.rowHeadersAreEnabled();
+ }
+
+ @Override
public void changeVariables(Object source, Map<String, Object> variables) {
super.changeVariables(source, variables);
diff --git a/server/tests/src/com/vaadin/tests/server/component/treetable/TreeTableTest.java b/server/tests/src/com/vaadin/tests/server/component/treetable/TreeTableTest.java
new file mode 100644
index 0000000000..60f4ac5f99
--- /dev/null
+++ b/server/tests/src/com/vaadin/tests/server/component/treetable/TreeTableTest.java
@@ -0,0 +1,72 @@
+/*
+ * 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.treetable;
+
+import java.util.EnumSet;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.vaadin.ui.Table.RowHeaderMode;
+import com.vaadin.ui.TreeTable;
+
+/**
+ * Tests for {@link TreeTable}
+ *
+ * @author Vaadin Ltd
+ */
+public class TreeTableTest {
+
+ @Test
+ public void rowHeadersAreEnabled_iconRowHeaderMode_rowHeadersAreDisabled() {
+ TestTreeTable tree = new TestTreeTable();
+ tree.setRowHeaderMode(RowHeaderMode.ICON_ONLY);
+
+ Assert.assertFalse("Row headers are enabled for Icon header mode",
+ tree.rowHeadersAreEnabled());
+ }
+
+ @Test
+ public void rowHeadersAreEnabled_hiddenRowHeaderMode_rowHeadersAreDisabled() {
+ TestTreeTable tree = new TestTreeTable();
+ tree.setRowHeaderMode(RowHeaderMode.HIDDEN);
+
+ Assert.assertFalse("Row headers are enabled for Hidden header mode",
+ tree.rowHeadersAreEnabled());
+ }
+
+ @Test
+ public void rowHeadersAreEnabled_otherRowHeaderModes_rowHeadersAreEnabled() {
+ TestTreeTable tree = new TestTreeTable();
+ EnumSet<RowHeaderMode> modes = EnumSet.allOf(RowHeaderMode.class);
+ modes.remove(RowHeaderMode.ICON_ONLY);
+ modes.remove(RowHeaderMode.HIDDEN);
+
+ for (RowHeaderMode mode : modes) {
+ tree.setRowHeaderMode(mode);
+ Assert.assertTrue("Row headers are disabled for " + mode
+ + " header mode", tree.rowHeadersAreEnabled());
+ }
+ }
+
+ private static class TestTreeTable extends TreeTable {
+
+ @Override
+ protected boolean rowHeadersAreEnabled() {
+ return super.rowHeadersAreEnabled();
+ }
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/components/treetable/TreeTableRowHeaderMode.java b/uitest/src/com/vaadin/tests/components/treetable/TreeTableRowHeaderMode.java
new file mode 100644
index 0000000000..6bc6fa74c0
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/treetable/TreeTableRowHeaderMode.java
@@ -0,0 +1,43 @@
+package com.vaadin.tests.components.treetable;
+
+import com.vaadin.server.Resource;
+import com.vaadin.server.ThemeResource;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Table.RowHeaderMode;
+import com.vaadin.ui.TreeTable;
+
+/**
+ * Test UI for RowHeaderMode.ICON_ONLY in TreeTable.
+ *
+ * @author Vaadin Ltd
+ */
+public class TreeTableRowHeaderMode extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ Resource icon = new ThemeResource("../runo/icons/16/ok.png");
+
+ TreeTable tree = new TreeTable();
+ tree.addContainerProperty("Name", String.class, "");
+ tree.setRowHeaderMode(RowHeaderMode.ICON_ONLY);
+
+ Object item = tree.addItem(new Object[] { "name" }, null);
+ tree.setItemIcon(item, icon);
+
+ tree.setCollapsed(item, false);
+
+ addComponent(tree);
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "RowHeaderMode.ICON_ONLY shouldn't create an empty column in TreeTable";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 14799;
+ }
+
+} \ No newline at end of file
diff --git a/uitest/src/com/vaadin/tests/components/treetable/TreeTableRowHeaderModeTest.java b/uitest/src/com/vaadin/tests/components/treetable/TreeTableRowHeaderModeTest.java
new file mode 100644
index 0000000000..0215c14aef
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/treetable/TreeTableRowHeaderModeTest.java
@@ -0,0 +1,39 @@
+/*
+ * 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.treetable;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.openqa.selenium.By;
+
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+/**
+ * Test for absence of empty row header for RowHeaderMode.ICON_ONLY
+ *
+ * @author Vaadin Ltd
+ */
+public class TreeTableRowHeaderModeTest extends MultiBrowserTest {
+
+ @Test
+ public void testIconRowHeaderMode() {
+ openTestURL();
+
+ Assert.assertFalse(
+ "Unexpected row header for icons is found in TreeTable",
+ isElementPresent(By.className("v-table-header-cell-rowheader")));
+ }
+}