diff options
author | Teemu Suo-Anttila <teemusa@vaadin.com> | 2016-04-15 11:06:18 +0300 |
---|---|---|
committer | Teemu Suo-Anttila <teemusa@vaadin.com> | 2016-04-15 14:00:58 +0300 |
commit | 6b8412033e680ce6e5c7827ac504adf132305726 (patch) | |
tree | 0df05d16c324b285610af8910c126b58f4c490c5 /uitest/src/com/vaadin/tests/components/tree | |
parent | 9192b0bb5e5e699b506b3d3e7df4cf295fbea44a (diff) | |
download | vaadin-framework-6b8412033e680ce6e5c7827ac504adf132305726.tar.gz vaadin-framework-6b8412033e680ce6e5c7827ac504adf132305726.zip |
Build uitest war with maven
Change-Id: I32625901ca27a282253df44c6e776cf9632bacda
Diffstat (limited to 'uitest/src/com/vaadin/tests/components/tree')
40 files changed, 0 insertions, 3249 deletions
diff --git a/uitest/src/com/vaadin/tests/components/tree/CtrlShiftMultiselect.java b/uitest/src/com/vaadin/tests/components/tree/CtrlShiftMultiselect.java deleted file mode 100644 index 3ce2e38eba..0000000000 --- a/uitest/src/com/vaadin/tests/components/tree/CtrlShiftMultiselect.java +++ /dev/null @@ -1,120 +0,0 @@ -package com.vaadin.tests.components.tree; - -import java.util.Set; - -import com.vaadin.data.Item; -import com.vaadin.data.Property; -import com.vaadin.data.Property.ValueChangeEvent; -import com.vaadin.data.util.HierarchicalContainer; -import com.vaadin.tests.components.TestBase; -import com.vaadin.ui.Label; -import com.vaadin.ui.Tree; - -public class CtrlShiftMultiselect extends TestBase { - - private final Tree tree = new Tree(); - private final Label valueLbl = new Label("No selection"); - - @Override - protected void setup() { - - getLayout().setSpacing(true); - - tree.setContainerDataSource(createContainer()); - tree.setItemCaptionPropertyId("name"); - tree.setWidth("300px"); - tree.setImmediate(true); - tree.setSelectable(true); - tree.setMultiSelect(true); - tree.expandItemsRecursively("Item 1"); - tree.expandItemsRecursively("Item 4"); - - tree.addListener(new Property.ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - if (tree.getValue() instanceof Set) { - @SuppressWarnings("unchecked") - // safe cast after instanceof check - Set<Object> itemIds = (Set<Object>) tree.getValue(); - if (itemIds.size() == 0) { - valueLbl.setValue("No selection"); - } else { - valueLbl.setValue(itemIds.toString()); - } - } else { - valueLbl.setValue(tree.getValue().toString()); - } - } - }); - - addComponent(tree); - - valueLbl.setWidth("300px"); - valueLbl.setHeight("600px"); - addComponent(valueLbl); - - } - - @Override - protected String getDescription() { - return "Add ctlr+shift multi selection in Tree"; - } - - @Override - protected Integer getTicketNumber() { - return 4259; - } - - private HierarchicalContainer createContainer() { - HierarchicalContainer cont = new HierarchicalContainer(); - cont.addContainerProperty("name", String.class, ""); - - for (int i = 0; i < 20; i++) { - Item item = cont.addItem("Item " + i); - item.getItemProperty("name").setValue("Item " + i); - cont.setChildrenAllowed("Item " + i, false); - - if (i == 1 || i == 4) { - cont.setChildrenAllowed("Item " + i, true); - } - - // Add three items to item 1 - if (i > 1 && i < 4) { - cont.setParent("Item " + i, "Item 1"); - } - - // Add 5 items to item 4 - if (i > 4 && i < 10) { - cont.setChildrenAllowed("Item " + i, true); - - if (i == 7) { - item = cont.addItem("Item 71"); - item.getItemProperty("name").setValue("Item 71"); - cont.setParent("Item 71", "Item " + i); - cont.setChildrenAllowed("Item 71", false); - - item = cont.addItem("Item 72"); - item.getItemProperty("name").setValue("Item 72"); - cont.setParent("Item 72", "Item " + i); - cont.setChildrenAllowed("Item 72", true); - - item = cont.addItem("Item 73"); - item.getItemProperty("name").setValue("Item 73"); - cont.setParent("Item 73", "Item 72"); - cont.setChildrenAllowed("Item 73", true); - - item = cont.addItem("Item 74"); - item.getItemProperty("name").setValue("Item 74"); - cont.setParent("Item 74", "Item " + i); - cont.setChildrenAllowed("Item 74", true); - } - - cont.setParent("Item " + i, "Item " + (i - 1)); - - } - } - - return cont; - } - -} diff --git a/uitest/src/com/vaadin/tests/components/tree/DndTreeTargetDetails.java b/uitest/src/com/vaadin/tests/components/tree/DndTreeTargetDetails.java deleted file mode 100644 index 443f290809..0000000000 --- a/uitest/src/com/vaadin/tests/components/tree/DndTreeTargetDetails.java +++ /dev/null @@ -1,47 +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.tests.components.tree; - -import com.vaadin.server.VaadinRequest; -import com.vaadin.tests.components.table.DndTableTargetDetails; -import com.vaadin.ui.Tree; - -/** - * Test UI for tree as a drop target: AbstractSelectTargetDetails should provide - * getMouseEvent() method. - * - * @author Vaadin Ltd - */ -public class DndTreeTargetDetails extends DndTableTargetDetails { - - @Override - protected void setup(VaadinRequest request) { - createSourceTable(); - - Tree target = new Tree(); - target.addStyleName("target"); - target.setWidth(100, Unit.PERCENTAGE); - target.addItem("treeItem"); - target.setDropHandler(new TestDropHandler()); - addComponent(target); - } - - @Override - protected String getTestDescription() { - return "Mouse details should be available for AbstractSelectTargetDetails DnD when tree is a target"; - } - -} diff --git a/uitest/src/com/vaadin/tests/components/tree/DndTreeTargetDetailsTest.java b/uitest/src/com/vaadin/tests/components/tree/DndTreeTargetDetailsTest.java deleted file mode 100644 index c1b77df5e9..0000000000 --- a/uitest/src/com/vaadin/tests/components/tree/DndTreeTargetDetailsTest.java +++ /dev/null @@ -1,36 +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.tests.components.tree; - -import org.openqa.selenium.WebElement; - -import com.vaadin.testbench.By; -import com.vaadin.tests.components.table.DndTableTargetDetailsTest; - -/** - * Test for mouse details in AbstractSelectTargetDetails class when DnD target - * is a tree. - * - * @author Vaadin Ltd - */ -public class DndTreeTargetDetailsTest extends DndTableTargetDetailsTest { - - @Override - protected WebElement getTarget() { - return findElement(By.className("target")); - } - -} diff --git a/uitest/src/com/vaadin/tests/components/tree/ExpandCollapseTree.java b/uitest/src/com/vaadin/tests/components/tree/ExpandCollapseTree.java deleted file mode 100644 index 81e177c39b..0000000000 --- a/uitest/src/com/vaadin/tests/components/tree/ExpandCollapseTree.java +++ /dev/null @@ -1,120 +0,0 @@ -package com.vaadin.tests.components.tree; - -import java.util.Set; - -import com.vaadin.data.Item; -import com.vaadin.data.Property; -import com.vaadin.data.Property.ValueChangeEvent; -import com.vaadin.data.util.HierarchicalContainer; -import com.vaadin.tests.components.TestBase; -import com.vaadin.ui.Label; -import com.vaadin.ui.Tree; - -public class ExpandCollapseTree extends TestBase { - - private final Tree tree = new Tree(); - private final Label valueLbl = new Label("No selection"); - - @Override - protected void setup() { - - getLayout().setSpacing(true); - - tree.setContainerDataSource(createContainer()); - tree.setItemCaptionPropertyId("name"); - tree.setWidth("300px"); - tree.setImmediate(true); - tree.setSelectable(true); - tree.setMultiSelect(true); - tree.expandItemsRecursively("Item 1"); - tree.expandItemsRecursively("Item 4"); - - tree.addListener(new Property.ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - if (tree.getValue() instanceof Set) { - @SuppressWarnings("unchecked") - // safe cast after instanceof check - Set<Object> itemIds = (Set<Object>) tree.getValue(); - if (itemIds.size() == 0) { - valueLbl.setValue("No selection"); - } else { - valueLbl.setValue(itemIds.toString()); - } - } else { - valueLbl.setValue(tree.getValue().toString()); - } - } - }); - - addComponent(tree); - - valueLbl.setWidth("300px"); - valueLbl.setHeight("600px"); - addComponent(valueLbl); - - } - - @Override - protected String getDescription() { - return "Test collapsing and expansion of tree nodes"; - } - - @Override - protected Integer getTicketNumber() { - return 5439; - } - - private HierarchicalContainer createContainer() { - HierarchicalContainer cont = new HierarchicalContainer(); - cont.addContainerProperty("name", String.class, ""); - - for (int i = 0; i < 20; i++) { - Item item = cont.addItem("Item " + i); - item.getItemProperty("name").setValue("Item " + i); - cont.setChildrenAllowed("Item " + i, false); - - if (i == 1 || i == 4) { - cont.setChildrenAllowed("Item " + i, true); - } - - // Add three items to item 1 - if (i > 1 && i < 4) { - cont.setParent("Item " + i, "Item 1"); - } - - // Add 5 items to item 4 - if (i > 4 && i < 10) { - cont.setChildrenAllowed("Item " + i, true); - - if (i == 7) { - item = cont.addItem("Item 71"); - item.getItemProperty("name").setValue("Item 71"); - cont.setParent("Item 71", "Item " + i); - cont.setChildrenAllowed("Item 71", false); - - item = cont.addItem("Item 72"); - item.getItemProperty("name").setValue("Item 72"); - cont.setParent("Item 72", "Item " + i); - cont.setChildrenAllowed("Item 72", true); - - item = cont.addItem("Item 73"); - item.getItemProperty("name").setValue("Item 73"); - cont.setParent("Item 73", "Item 72"); - cont.setChildrenAllowed("Item 73", true); - - item = cont.addItem("Item 74"); - item.getItemProperty("name").setValue("Item 74"); - cont.setParent("Item 74", "Item " + i); - cont.setChildrenAllowed("Item 74", true); - } - - cont.setParent("Item " + i, "Item " + (i - 1)); - - } - } - - return cont; - } - -} diff --git a/uitest/src/com/vaadin/tests/components/tree/ItemStyleGenerator.java b/uitest/src/com/vaadin/tests/components/tree/ItemStyleGenerator.java deleted file mode 100644 index c561781d2b..0000000000 --- a/uitest/src/com/vaadin/tests/components/tree/ItemStyleGenerator.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.vaadin.tests.components.tree; - -import com.vaadin.tests.components.TestBase; -import com.vaadin.ui.Component; -import com.vaadin.ui.CustomLayout; -import com.vaadin.ui.Tree; - -public class ItemStyleGenerator extends TestBase { - - private Component styles; - private String css = "<style type=\"text/css\">" - + ".v-tree-node-red {color: red;}" - + ".v-tree-node-green {color: green;}" - + ".v-tree-node-caption-blue {color:blue;}" // - + "</style>"; - - @Override - protected String getDescription() { - return "Item Style generator can be used to style items."; - } - - @Override - protected Integer getTicketNumber() { - return 3070; - } - - @Override - protected void setup() { - styles = new CustomLayout(css); - addComponent(styles); - - Tree tree = new Tree(); - - tree.setItemStyleGenerator(new Tree.ItemStyleGenerator() { - @Override - public String getStyle(Tree source, Object itemId) { - // simple return itemId as css style name - return itemId.toString(); - } - }); - - tree.addItem("red"); - tree.setChildrenAllowed("red", false); - tree.addItem("green"); - tree.addItem("green children"); - tree.setParent("green children", "green"); - tree.addItem("blue"); - tree.addItem("non-blue-childnode"); - tree.setParent("non-blue-childnode", "blue"); - - addComponent(tree); - } -} diff --git a/uitest/src/com/vaadin/tests/components/tree/PreselectedTreeVisible.java b/uitest/src/com/vaadin/tests/components/tree/PreselectedTreeVisible.java deleted file mode 100644 index b812c9e955..0000000000 --- a/uitest/src/com/vaadin/tests/components/tree/PreselectedTreeVisible.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.vaadin.tests.components.tree; - -import com.vaadin.tests.components.TestBase; -import com.vaadin.ui.Tree; - -@SuppressWarnings("serial") -public class PreselectedTreeVisible extends TestBase { - - @Override - protected void setup() { - - String itemId1 = "Item 1"; - String itemId2 = "Item 2"; - - Tree tree = new Tree(); - - tree.addItem(itemId1); - tree.addItem(itemId2); - - // Removing this line causes the tree to show normally in Firefox - tree.select(itemId1); - addComponent(tree); - - } - - @Override - protected String getDescription() { - return "Tree should be visible when a item has been selected."; - } - - @Override - protected Integer getTicketNumber() { - return 5396; - } - -} diff --git a/uitest/src/com/vaadin/tests/components/tree/SelectItemAfterRemove.java b/uitest/src/com/vaadin/tests/components/tree/SelectItemAfterRemove.java deleted file mode 100644 index 8002f5100e..0000000000 --- a/uitest/src/com/vaadin/tests/components/tree/SelectItemAfterRemove.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.vaadin.tests.components.tree; - -import com.vaadin.event.ItemClickEvent; -import com.vaadin.server.VaadinRequest; -import com.vaadin.tests.components.AbstractTestUI; -import com.vaadin.ui.Tree; - -public class SelectItemAfterRemove extends AbstractTestUI { - - @Override - protected void setup(VaadinRequest request) { - final Tree tree = new Tree(); - - tree.setImmediate(true); - tree.addItemClickListener(new ItemClickEvent.ItemClickListener() { - @Override - public void itemClick(ItemClickEvent event) { - - tree.removeItem(tree.getValue()); - tree.select(event.getItemId()); - } - }); - - tree.addItem("first"); - tree.addItem("second"); - tree.addItem("third"); - - tree.select("first"); - - addComponent(tree); - } - - @Override - protected String getTestDescription() { - return "Clicking on an item should select the clicked item and remove " - + "the previously selected item."; - } - - @Override - protected Integer getTicketNumber() { - return 15181; - } -} diff --git a/uitest/src/com/vaadin/tests/components/tree/SelectItemAfterRemoveTest.java b/uitest/src/com/vaadin/tests/components/tree/SelectItemAfterRemoveTest.java deleted file mode 100644 index b048e185ea..0000000000 --- a/uitest/src/com/vaadin/tests/components/tree/SelectItemAfterRemoveTest.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.vaadin.tests.components.tree; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.containsString; -import static org.hamcrest.Matchers.is; - -import java.util.List; - -import org.junit.Test; -import org.openqa.selenium.WebElement; - -import com.vaadin.testbench.By; -import com.vaadin.tests.tb3.MultiBrowserTest; - -public class SelectItemAfterRemoveTest extends MultiBrowserTest { - - @Test - public void selectedItemIsSelected() { - openTestURL(); - - getSecondSpan().click(); - - assertThat(getNodes().size(), is(2)); - assertThat(getFirstNode().getAttribute("class"), - containsString("v-tree-node-selected")); - } - - private WebElement getFirstNode() { - return getNodes().get(0); - } - - private List<WebElement> getNodes() { - return findElements(By.className("v-tree-node-caption")); - } - - private WebElement getSecondSpan() { - for (WebElement e : getSpans()) { - if (e.getText().equals("second")) { - return e; - } - } - - return null; - } - - private List<WebElement> getSpans() { - return findElements(By.tagName("span")); - } -}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/components/tree/SimpleTree.java b/uitest/src/com/vaadin/tests/components/tree/SimpleTree.java deleted file mode 100644 index f3e47d0996..0000000000 --- a/uitest/src/com/vaadin/tests/components/tree/SimpleTree.java +++ /dev/null @@ -1,135 +0,0 @@ -package com.vaadin.tests.components.tree; - -import java.util.Date; - -import com.vaadin.data.Item; -import com.vaadin.data.util.HierarchicalContainer; -import com.vaadin.event.Action; -import com.vaadin.server.ThemeResource; -import com.vaadin.tests.components.TestBase; -import com.vaadin.ui.AbstractSelect; -import com.vaadin.ui.AbstractSelect.ItemDescriptionGenerator; -import com.vaadin.ui.Component; -import com.vaadin.ui.Tree; - -public class SimpleTree extends TestBase implements Action.Handler { - private static final String[][] hardware = { // - { "Desktops", "Dell OptiPlex GX240", "Dell OptiPlex GX260", - "Dell OptiPlex GX280" }, - { "Monitors", "Benq T190HD", "Benq T220HD", "Benq T240HD" }, - { "Laptops", "IBM ThinkPad T40", "IBM ThinkPad T43", - "IBM ThinkPad T60" } }; - - ThemeResource notCachedFolderIconLargeOther = new ThemeResource( - "../runo/icons/16/ok.png?" + new Date().getTime()); - ThemeResource notCachedFolderIconLarge = new ThemeResource( - "../runo/icons/16/folder.png?" + new Date().getTime()); - - // Actions for the context menu - private static final Action ACTION_ADD = new Action("Add child item"); - private static final Action ACTION_DELETE = new Action("Delete"); - private static final Action[] ACTIONS = new Action[] { ACTION_ADD, - ACTION_DELETE }; - - private Tree tree; - - @Override - public void setup() { - // Create the Tree,a dd to layout - tree = new Tree("Hardware Inventory"); - addComponent(tree); - - // Contents from a (prefilled example) hierarchical container: - tree.setContainerDataSource(getHardwareContainer()); - - // Add actions (context menu) - tree.addActionHandler(this); - - // Cause valueChange immediately when the user selects - tree.setImmediate(true); - - // Set tree to show the 'name' property as caption for items - tree.setItemCaptionPropertyId("name"); - tree.setItemCaptionMode(AbstractSelect.ITEM_CAPTION_MODE_PROPERTY); - - tree.setItemIcon(9, notCachedFolderIconLargeOther, "First Choice"); - tree.setItemIcon(11, notCachedFolderIconLarge); - - tree.setItemDescriptionGenerator(new ItemDescriptionGenerator() { - @Override - public String generateDescription(Component source, Object itemId, - Object propertyId) { - if ((Integer) itemId == 3) { - return "tree item tooltip"; - } - return ""; - } - }); - - // Expand whole tree - for (Object id : tree.rootItemIds()) { - tree.expandItemsRecursively(id); - } - } - - public static HierarchicalContainer getHardwareContainer() { - Item item = null; - int itemId = 0; // Increasing numbering for itemId:s - - // Create new container - HierarchicalContainer hwContainer = new HierarchicalContainer(); - // Create containerproperty for name - hwContainer.addContainerProperty("name", String.class, null); - // Create containerproperty for icon - hwContainer.addContainerProperty("icon", ThemeResource.class, - new ThemeResource("../runo/icons/16/document.png")); - for (int i = 0; i < hardware.length; i++) { - // Add new item - item = hwContainer.addItem(itemId); - // Add name property for item - item.getItemProperty("name").setValue(hardware[i][0]); - // Allow children - hwContainer.setChildrenAllowed(itemId, true); - itemId++; - for (int j = 1; j < hardware[i].length; j++) { - if (j == 1) { - item.getItemProperty("icon").setValue( - new ThemeResource("../runo/icons/16/folder.png")); - } - - // Add child items - item = hwContainer.addItem(itemId); - item.getItemProperty("name").setValue(hardware[i][j]); - hwContainer.setParent(itemId, itemId - j); - - hwContainer.setChildrenAllowed(itemId, false); - if (j == 2) { - hwContainer.setChildrenAllowed(itemId, true); - } - - itemId++; - } - } - return hwContainer; - } - - @Override - protected String getDescription() { - return "Sample Tree for testing WAI-ARIA functionality"; - } - - @Override - protected Integer getTicketNumber() { - return 0; - } - - @Override - public Action[] getActions(Object target, Object sender) { - return ACTIONS; - } - - @Override - public void handleAction(Action action, Object sender, Object target) { - System.out.println("Action: " + action.getCaption()); - } -} diff --git a/uitest/src/com/vaadin/tests/components/tree/TreeConnectors.java b/uitest/src/com/vaadin/tests/components/tree/TreeConnectors.java deleted file mode 100644 index ab9bcd9a99..0000000000 --- a/uitest/src/com/vaadin/tests/components/tree/TreeConnectors.java +++ /dev/null @@ -1,142 +0,0 @@ -package com.vaadin.tests.components.tree; - -import com.vaadin.data.Item; -import com.vaadin.data.Property.ValueChangeEvent; -import com.vaadin.data.Property.ValueChangeListener; -import com.vaadin.data.util.HierarchicalContainer; -import com.vaadin.event.dd.DragAndDropEvent; -import com.vaadin.event.dd.DropHandler; -import com.vaadin.event.dd.acceptcriteria.AcceptAll; -import com.vaadin.event.dd.acceptcriteria.AcceptCriterion; -import com.vaadin.server.ThemeResource; -import com.vaadin.tests.components.TestBase; -import com.vaadin.ui.CheckBox; -import com.vaadin.ui.Tree; -import com.vaadin.ui.Tree.TreeDragMode; -import com.vaadin.ui.themes.BaseTheme; - -@SuppressWarnings("serial") -public class TreeConnectors extends TestBase { - - private Tree tree = createTree(); - - @Override - protected void setup() { - CheckBox cb = new CheckBox("Connectors"); - cb.setValue(false); - cb.setImmediate(true); - cb.addListener(new ValueChangeListener() { - - @Override - public void valueChange(ValueChangeEvent event) { - if ((Boolean) event.getProperty().getValue()) { - tree.addStyleName(BaseTheme.TREE_CONNECTORS); - } else { - tree.removeStyleName(BaseTheme.TREE_CONNECTORS); - } - } - }); - addComponent(cb); - addComponent(tree); - } - - private Tree createTree() { - final Tree tree = new Tree(null, createContainer()); - tree.setWidth("300px"); - for (Object rootItems : tree.rootItemIds()) { - tree.expandItemsRecursively(rootItems); - } - tree.setChildrenAllowed("Item 73", false); - - tree.setDragMode(TreeDragMode.NODE); - tree.setDropHandler(new DropHandler() { - - @Override - public void drop(DragAndDropEvent event) { - // TODO Auto-generated method stub - - } - - @Override - public AcceptCriterion getAcceptCriterion() { - return AcceptAll.get(); - } - - }); - - tree.setItemIcon("Item 1", new ThemeResource( - "../runo/icons/32/folder.png")); - tree.setItemIcon("Item 3", new ThemeResource( - "../runo/icons/32/document.png")); - tree.setItemIcon("Item 13", new ThemeResource( - "../runo/icons/64/user.png")); - tree.setItemIcon("Item 72", new ThemeResource( - "../runo/icons/64/users.png")); - tree.setItemIcon("Item 17", new ThemeResource( - "../runo/icons/16/document-pdf.png")); - - return tree; - } - - @Override - protected String getDescription() { - return "The second tree's nodes should be connected with lines indicating the hierarchy. The first tree should be without connectors."; - } - - @Override - protected Integer getTicketNumber() { - return 6745; - } - - private HierarchicalContainer createContainer() { - HierarchicalContainer cont = new HierarchicalContainer(); - cont.addContainerProperty("name", String.class, ""); - - for (int i = 0; i < 20; i++) { - Item item = cont.addItem("Item " + i); - item.getItemProperty("name").setValue("Item " + i); - cont.setChildrenAllowed("Item " + i, false); - - if (i == 1 || i == 4) { - cont.setChildrenAllowed("Item " + i, true); - } - - // Add three items to item 1 - if (i > 1 && i < 4) { - cont.setParent("Item " + i, "Item 1"); - } - - // Add 5 items to item 4 - if (i > 4 && i < 10) { - cont.setChildrenAllowed("Item " + i, true); - - if (i == 7) { - item = cont.addItem("Item 71"); - item.getItemProperty("name").setValue("Item 71"); - cont.setParent("Item 71", "Item " + i); - cont.setChildrenAllowed("Item 71", false); - - item = cont.addItem("Item 72"); - item.getItemProperty("name").setValue("Item 72"); - cont.setParent("Item 72", "Item " + i); - cont.setChildrenAllowed("Item 72", true); - - item = cont.addItem("Item 73"); - item.getItemProperty("name").setValue("Item 73"); - cont.setParent("Item 73", "Item 72"); - cont.setChildrenAllowed("Item 73", true); - - item = cont.addItem("Item 74"); - item.getItemProperty("name").setValue("Item 74"); - cont.setParent("Item 74", "Item " + i); - cont.setChildrenAllowed("Item 74", true); - } - - cont.setParent("Item " + i, "Item " + (i - 1)); - - } - } - - return cont; - } -} diff --git a/uitest/src/com/vaadin/tests/components/tree/TreeContainerChange b/uitest/src/com/vaadin/tests/components/tree/TreeContainerChange deleted file mode 100644 index 8ea2dcc107..0000000000 --- a/uitest/src/com/vaadin/tests/components/tree/TreeContainerChange +++ /dev/null @@ -1,47 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head profile="http://selenium-ide.openqa.org/profiles/test-case"> -<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> -<link rel="selenium.base" href="" /> -<title>TreeContainerChange</title> -</head> -<body> -<table cellpadding="1" cellspacing="1" border="1"> -<thead> -<tr><td rowspan="1" colspan="3">TreeContainerChange</td></tr> -</thead><tbody> -<tr> - <td>open</td> - <td>/run/com.vaadin.tests.components.tree.TreeContainerChange?restartApplication</td> - <td></td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestscomponentstreeTreeContainerChange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[3]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentstreeTreeContainerChange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VTree[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]</td> - <td>24,5</td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>ds1-selected-value-ds1-3</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestscomponentstreeTreeContainerChange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[5]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>ds2-selected-value-null</td> -</tr> - -</tbody></table> -</body> -</html> diff --git a/uitest/src/com/vaadin/tests/components/tree/TreeContainerChange.java b/uitest/src/com/vaadin/tests/components/tree/TreeContainerChange.java deleted file mode 100644 index 2dde7bbb30..0000000000 --- a/uitest/src/com/vaadin/tests/components/tree/TreeContainerChange.java +++ /dev/null @@ -1,105 +0,0 @@ -package com.vaadin.tests.components.tree; - -import com.vaadin.data.Property; -import com.vaadin.data.Property.ValueChangeEvent; -import com.vaadin.data.util.IndexedContainer; -import com.vaadin.tests.components.TestBase; -import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.HorizontalLayout; -import com.vaadin.ui.Label; -import com.vaadin.ui.Table; -import com.vaadin.ui.Tree; - -@SuppressWarnings("serial") -public class TreeContainerChange extends TestBase { - - private Tree tree; - - @Override - protected void setup() { - final IndexedContainer ds1 = new IndexedContainer(); - // ds1.addContainerProperty("caption", String.class, ""); - for (int i = 0; i < 32; i++) { - ds1.addItem("ds1-" + i); - } - - final IndexedContainer ds2 = new IndexedContainer(); - // ds2.addContainerProperty("caption", String.class, ""); - for (int i = 0; i < 32; i++) { - ds2.addItem("ds2-" + i); - } - - HorizontalLayout hl = new HorizontalLayout(); - hl.setWidth("100%"); - - tree = new Tree(); - tree.setImmediate(true); - hl.addComponent(tree); - HorizontalLayout state = new HorizontalLayout(); - state.setSpacing(true); - hl.addComponent(state); - - final Label currentValue = new Label(); - currentValue.setCaption("Current Value:"); - currentValue.setSizeUndefined(); - final Label currentDS = new Label(); - currentDS.setCaption("Current DS:"); - currentDS.setSizeUndefined(); - state.addComponent(currentValue); - state.addComponent(currentDS); - - Table t = new Table("ds1"); - t.setRowHeaderMode(Table.ROW_HEADER_MODE_ID); - t.setContainerDataSource(ds1); - state.addComponent(t); - - Button b = new Button("Use ds1"); - b.addListener(new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - tree.setContainerDataSource(ds1); - currentDS.setValue("ds1"); - } - }); - state.addComponent(b); - - t = new Table("ds2"); - t.setContainerDataSource(ds2); - t.setRowHeaderMode(Table.ROW_HEADER_MODE_ID); - state.addComponent(t); - - b = new Button("Use ds2"); - b.addListener(new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - tree.setContainerDataSource(ds2); - currentDS.setValue("ds2"); - } - }); - state.addComponent(b); - - addComponent(hl); - - tree.addListener(new Property.ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - currentValue - .setValue(event.getProperty().getValue().toString()); - } - }); - } - - @Override - protected String getDescription() { - return "A test for tree and its container changes. Value should be cleared on container change."; - } - - @Override - protected Integer getTicketNumber() { - return 5281; - } - -} diff --git a/uitest/src/com/vaadin/tests/components/tree/TreeContextMenuAndIconsTest.java b/uitest/src/com/vaadin/tests/components/tree/TreeContextMenuAndIconsTest.java deleted file mode 100644 index 81d906bec3..0000000000 --- a/uitest/src/com/vaadin/tests/components/tree/TreeContextMenuAndIconsTest.java +++ /dev/null @@ -1,130 +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.tree; - -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; -import org.openqa.selenium.Dimension; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.interactions.Actions; -import org.openqa.selenium.remote.DesiredCapabilities; - -import com.vaadin.testbench.By; -import com.vaadin.tests.tb3.MultiBrowserTest; - -public class TreeContextMenuAndIconsTest extends MultiBrowserTest { - - @Override - protected Class<?> getUIClass() { - return Trees.class; - } - - @Override - public List<DesiredCapabilities> getBrowsersToTest() { - return getBrowsersSupportingContextMenu(); - } - - @Test - public void testSimpleContextMenu() throws Exception { - openTestURL(); - - selectMenuPath("Settings", "Show event log"); - selectMenuPath("Component", "Features", "Context menu", - "Item without icon"); - - openContextMenu(getTreeNodeByCaption("Item 1")); - - compareScreen("contextmenu-noicon"); - - closeContextMenu(); - } - - @Test - public void testContextMenuWithAndWithoutIcon() throws Exception { - openTestURL(); - - selectMenuPath("Settings", "Show event log"); - selectMenuPath("Component", "Features", "Context menu", - "With and without icon"); - - openContextMenu(getTreeNodeByCaption("Item 1")); - - compareScreen("caption-only-and-has-icon"); - - closeContextMenu(); - } - - @Test - public void testContextLargeIcon() throws Exception { - openTestURL(); - - selectMenuPath("Settings", "Show event log"); - selectMenuPath("Component", "Features", "Context menu", - "Only one large icon"); - - WebElement menu = openContextMenu(getTreeNodeByCaption("Item 1")); - - // reindeer doesn't support menu with larger row height, so the - // background image contains parts of other sprites => - // just check that the menu is of correct size - Dimension size = menu.getSize(); - Assert.assertEquals("Menu height with large icons", 74, size.height); - - closeContextMenu(); - } - - @Test - public void testContextRemoveIcon() throws Exception { - openTestURL(); - - selectMenuPath("Settings", "Show event log"); - selectMenuPath("Component", "Features", "Context menu", - "Only one large icon"); - - openContextMenu(getTreeNodeByCaption("Item 1")); - closeContextMenu(); - - selectMenuPath("Component", "Features", "Context menu", - "Item without icon"); - - openContextMenu(getTreeNodeByCaption("Item 1")); - - compareScreen("contextmenu-noicon"); - - closeContextMenu(); - } - - private WebElement openContextMenu(WebElement element) { - Actions actions = new Actions(getDriver()); - // Note: on Firefox, the first menu item does not get focus; on other - // browsers it does - actions.contextClick(element); - actions.perform(); - return findElement(By.className("v-contextmenu")); - } - - private void closeContextMenu() { - findElement(By.className("v-app")).click(); - } - - private WebElement getTreeNodeByCaption(String caption) { - return getDriver().findElement( - By.xpath("//span[text() = '" + caption + "']")); - } - -} diff --git a/uitest/src/com/vaadin/tests/components/tree/TreeDragAndDropFromTable.java b/uitest/src/com/vaadin/tests/components/tree/TreeDragAndDropFromTable.java deleted file mode 100644 index 7aa3933752..0000000000 --- a/uitest/src/com/vaadin/tests/components/tree/TreeDragAndDropFromTable.java +++ /dev/null @@ -1,120 +0,0 @@ -package com.vaadin.tests.components.tree; - -import com.vaadin.data.Container; -import com.vaadin.event.DataBoundTransferable; -import com.vaadin.event.dd.DragAndDropEvent; -import com.vaadin.event.dd.DropHandler; -import com.vaadin.event.dd.acceptcriteria.AcceptCriterion; -import com.vaadin.tests.components.TestBase; -import com.vaadin.ui.AbstractSelect.AbstractSelectTargetDetails; -import com.vaadin.ui.HorizontalLayout; -import com.vaadin.ui.Table; -import com.vaadin.ui.Table.TableDragMode; -import com.vaadin.ui.Tree; -import com.vaadin.ui.Tree.TargetItemAllowsChildren; - -public class TreeDragAndDropFromTable extends TestBase { - - @Override - protected void setup() { - - HorizontalLayout h = new HorizontalLayout(); - addComponent(h); - - Table table = new Table(); - table.addContainerProperty("Column 1", String.class, "Row"); - table.setDragMode(TableDragMode.ROW); - - table.addItem("Row 1"); - table.addItem("Row 2"); - table.addItem("Row 3"); - table.addItem("Row 4"); - table.addItem("Row 5"); - table.addItem("Row 6"); - table.addItem("Row 7"); - - h.addComponent(table); - - final Tree tree = new Tree(); - tree.setDropHandler(new DropHandler() { - - @Override - public AcceptCriterion getAcceptCriterion() { - return TargetItemAllowsChildren.get(); - } - - @Override - public void drop(DragAndDropEvent dropEvent) { - // criteria verify that this is safe - DataBoundTransferable t = (DataBoundTransferable) dropEvent - .getTransferable(); - Container sourceContainer = t.getSourceContainer(); - Object sourceItemId = t.getItemId(); - System.out.println(sourceItemId); - - AbstractSelectTargetDetails dropData = ((AbstractSelectTargetDetails) dropEvent - .getTargetDetails()); - Object targetItemId = dropData.getItemIdOver(); - - // move item from table to category' - tree.addItem(sourceItemId); - tree.setParent(sourceItemId, targetItemId); - tree.setChildrenAllowed(sourceItemId, false); - sourceContainer.removeItem(sourceItemId); - - } - }); - - tree.addItem("Item 1"); - tree.addItem("Item 11"); - tree.setChildrenAllowed("Item 11", false); - tree.setParent("Item 11", "Item 1"); - tree.addItem("Item 12"); - tree.setChildrenAllowed("Item 12", false); - tree.setParent("Item 12", "Item 1"); - tree.addItem("Item 13"); - tree.setChildrenAllowed("Item 13", false); - tree.setParent("Item 13", "Item 1"); - - tree.addItem("Item 2"); - tree.addItem("Item 21"); - tree.setChildrenAllowed("Item 21", false); - tree.setParent("Item 21", "Item 2"); - tree.addItem("Item 22"); - tree.setChildrenAllowed("Item 22", false); - tree.setParent("Item 22", "Item 2"); - tree.addItem("Item 23"); - tree.setChildrenAllowed("Item 23", false); - tree.setParent("Item 23", "Item 2"); - - tree.addItem("Item 3"); - tree.addItem("Item 31"); - tree.setChildrenAllowed("Item 31", false); - tree.setParent("Item 31", "Item 3"); - tree.addItem("Item 32"); - tree.setChildrenAllowed("Item 32", false); - tree.setParent("Item 32", "Item 3"); - tree.addItem("Item 33"); - tree.setChildrenAllowed("Item 33", false); - tree.setParent("Item 33", "Item 3"); - - tree.expandItemsRecursively("Item 1"); - tree.expandItemsRecursively("Item 2"); - tree.expandItemsRecursively("Item 3"); - - h.addComponent(tree); - } - - @Override - protected String getDescription() { - return "Test that childred can be dragged " - + "from the Table to the tree and that TargetItemAllowsChildren limits " - + "the drops to nodes which allows children"; - } - - @Override - protected Integer getTicketNumber() { - return 7687; - } - -} diff --git a/uitest/src/com/vaadin/tests/components/tree/TreeFiltering.java b/uitest/src/com/vaadin/tests/components/tree/TreeFiltering.java deleted file mode 100644 index 6df69c850b..0000000000 --- a/uitest/src/com/vaadin/tests/components/tree/TreeFiltering.java +++ /dev/null @@ -1,134 +0,0 @@ -package com.vaadin.tests.components.tree; - -import com.vaadin.data.Item; -import com.vaadin.data.Property.ValueChangeEvent; -import com.vaadin.data.Property.ValueChangeListener; -import com.vaadin.data.util.HierarchicalContainer; -import com.vaadin.tests.components.TestBase; -import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; -import com.vaadin.ui.CheckBox; -import com.vaadin.ui.Tree; - -public class TreeFiltering extends TestBase { - - @Override - public void setup() { - - final Tree ccTree = new Tree(); - addComponent(ccTree); - final HierarchicalContainer cont = new HierarchicalContainer(); - cont.addContainerProperty("caption", String.class, ""); - - Item item; - for (int i = 0; i < 5; i++) { - item = cont.addItem(i); - item.getItemProperty("caption").setValue("Number " + i); - cont.setParent(i, i - 1); - } - - for (int i = 0; i < 5; i++) { - Object id = cont.addItem(); - item = cont.getItem(id); - item.getItemProperty("caption").setValue("0-" + i); - cont.setParent(id, 0); - } - - ccTree.setContainerDataSource(cont); - ccTree.setItemCaptionPropertyId("caption"); - - for (final Object o : ccTree.getItemIds()) { - ccTree.expandItem(o); - } - - final CheckBox filterType = new CheckBox( - "Include parent when filtering", true); - filterType.setImmediate(true); - filterType.addListener(new ValueChangeListener() { - - @Override - public void valueChange(ValueChangeEvent event) { - cont.setIncludeParentsWhenFiltering(((CheckBox) event - .getProperty()).getValue()); - ccTree.markAsDirty(); - } - }); - addComponent(filterType); - - final Button b = new Button("Add filter 'foo'", new ClickListener() { - @Override - public void buttonClick(final ClickEvent event) { - cont.addContainerFilter("caption", "foo", true, false); - - } - }); - addComponent(b); - final Button b2 = new Button("Add filter 'Num'", new ClickListener() { - @Override - public void buttonClick(final ClickEvent event) { - cont.addContainerFilter("caption", "Num", true, false); - - } - }); - - addComponent(b2); - final Button num = new Button("Add filter '0'", new ClickListener() { - @Override - public void buttonClick(final ClickEvent event) { - cont.addContainerFilter("caption", "0", true, false); - - } - }); - - addComponent(num); - final Button num2 = new Button("Add filter '0-'", new ClickListener() { - @Override - public void buttonClick(final ClickEvent event) { - cont.addContainerFilter("caption", "0-", true, false); - - } - }); - - addComponent(num2); - final Button num3 = new Button("Add filter 'Number 4'", - new ClickListener() { - @Override - public void buttonClick(final ClickEvent event) { - cont.addContainerFilter("caption", "Number 4", true, - false); - - } - }); - - addComponent(num3); - final Button p1 = new Button("Set Number 3 parent to Number 0", - new ClickListener() { - @Override - public void buttonClick(final ClickEvent event) { - cont.setParent(3, 0); - - } - }); - addComponent(p1); - final Button r = new Button("Remove filters", new ClickListener() { - @Override - public void buttonClick(final ClickEvent event) { - cont.removeAllContainerFilters(); - - } - }); - addComponent(r); - } - - @Override - protected String getDescription() { - return "Filtering in a tree should work as expected. Roots and their children which match the filter should be shown. Other nodes should be hidden"; - } - - @Override - protected Integer getTicketNumber() { - return 4192; - } - -} diff --git a/uitest/src/com/vaadin/tests/components/tree/TreeFocusGaining.java b/uitest/src/com/vaadin/tests/components/tree/TreeFocusGaining.java deleted file mode 100644 index dd407fd62a..0000000000 --- a/uitest/src/com/vaadin/tests/components/tree/TreeFocusGaining.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.vaadin.tests.components.tree; - -import com.vaadin.data.Property; -import com.vaadin.data.Property.ValueChangeEvent; -import com.vaadin.event.ItemClickEvent; -import com.vaadin.tests.components.TestBase; -import com.vaadin.tests.util.Log; -import com.vaadin.ui.TextField; -import com.vaadin.ui.Tree; - -@SuppressWarnings("serial") -public class TreeFocusGaining extends TestBase { - - @Override - protected void setup() { - final Log log = new Log(5); - - TextField textField = new TextField( - "My value should get to server when tree is clicked"); - addComponent(textField); - textField.addListener(new Property.ValueChangeListener() { - - @Override - public void valueChange(ValueChangeEvent event) { - log.log("TF value now:" + event.getProperty().getValue()); - } - }); - - Tree tree = new Tree("Simple selectable tree (immediate)"); - tree.addItem("Item1"); - addComponent(tree); - tree.addListener(new Property.ValueChangeListener() { - - @Override - public void valueChange(ValueChangeEvent event) { - log.log("Tree value now:" + event.getProperty().getValue()); - } - }); - tree.setImmediate(true); - - tree = new Tree("Simple tree with itemm click listener"); - tree.addItem("Item1"); - tree.addListener(new ItemClickEvent.ItemClickListener() { - @Override - public void itemClick(ItemClickEvent event) { - log.log("Item click event"); - } - }); - addComponent(tree); - - addComponent(log); - - } - - @Override - protected String getDescription() { - return "Tree should get focus before sending variables to server."; - } - - @Override - protected Integer getTicketNumber() { - return 6374; - } - -} diff --git a/uitest/src/com/vaadin/tests/components/tree/TreeHorizontalResize.java b/uitest/src/com/vaadin/tests/components/tree/TreeHorizontalResize.java deleted file mode 100644 index ef378b420a..0000000000 --- a/uitest/src/com/vaadin/tests/components/tree/TreeHorizontalResize.java +++ /dev/null @@ -1,90 +0,0 @@ -package com.vaadin.tests.components.tree; - -import java.util.Iterator; - -import com.vaadin.data.Item; -import com.vaadin.data.util.HierarchicalContainer; -import com.vaadin.server.ThemeResource; -import com.vaadin.tests.components.TestBase; -import com.vaadin.ui.Panel; -import com.vaadin.ui.Tree; -import com.vaadin.ui.VerticalLayout; - -public class TreeHorizontalResize extends TestBase { - - // copied from Sampler to eliminate dependency - public static final Object hw_PROPERTY_NAME = "name"; - public static final Object hw_PROPERTY_ICON = "icon"; - private static final String[][] hardware = { // - { "Desktops", "Dell OptiPlex GX240", "Dell OptiPlex GX260", - "Dell OptiPlex GX280" }, - { "Monitors", "Benq T190HD", "Benq T220HD", "Benq T240HD" }, - { "Laptops", "IBM ThinkPad T40", "IBM ThinkPad T43", - "IBM ThinkPad T60" } }; - - @Override - protected void setup() { - VerticalLayout treeLayout = new VerticalLayout(); - treeLayout.setMargin(true); - treeLayout.setSizeUndefined(); - Panel treePanel = new Panel(treeLayout); - treePanel.setHeight("500px"); - treePanel.setWidth(null); - addComponent(treePanel); - - Tree tree = new Tree(); - tree.setContainerDataSource(getHardwareContainer()); - tree.setItemCaptionPropertyId(hw_PROPERTY_NAME); - for (Iterator<?> it = tree.rootItemIds().iterator(); it.hasNext();) { - tree.expandItemsRecursively(it.next()); - } - treeLayout.addComponent(tree); - } - - @Override - protected String getDescription() { - return "The Tree should be properly resized horizontally when collapsing/expanding nodes. The height is fixed to 500px."; - } - - @Override - protected Integer getTicketNumber() { - return 6230; - } - - public static HierarchicalContainer getHardwareContainer() { - Item item = null; - int itemId = 0; // Increasing numbering for itemId:s - - // Create new container - HierarchicalContainer hwContainer = new HierarchicalContainer(); - // Create containerproperty for name - hwContainer.addContainerProperty(hw_PROPERTY_NAME, String.class, null); - // Create containerproperty for icon - hwContainer.addContainerProperty(hw_PROPERTY_ICON, ThemeResource.class, - new ThemeResource("../runo/icons/16/document.png")); - for (int i = 0; i < hardware.length; i++) { - // Add new item - item = hwContainer.addItem(itemId); - // Add name property for item - item.getItemProperty(hw_PROPERTY_NAME).setValue(hardware[i][0]); - // Allow children - hwContainer.setChildrenAllowed(itemId, true); - itemId++; - for (int j = 1; j < hardware[i].length; j++) { - if (j == 1) { - item.getItemProperty(hw_PROPERTY_ICON).setValue( - new ThemeResource("../runo/icons/16/folder.png")); - } - // Add child items - item = hwContainer.addItem(itemId); - item.getItemProperty(hw_PROPERTY_NAME).setValue(hardware[i][j]); - hwContainer.setParent(itemId, itemId - j); - hwContainer.setChildrenAllowed(itemId, false); - - itemId++; - } - } - return hwContainer; - } - -} diff --git a/uitest/src/com/vaadin/tests/components/tree/TreeHtmlContentAllowed.java b/uitest/src/com/vaadin/tests/components/tree/TreeHtmlContentAllowed.java deleted file mode 100644 index b20b7c3aab..0000000000 --- a/uitest/src/com/vaadin/tests/components/tree/TreeHtmlContentAllowed.java +++ /dev/null @@ -1,58 +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.tree; - -import com.vaadin.data.Property.ValueChangeEvent; -import com.vaadin.data.Property.ValueChangeListener; -import com.vaadin.server.VaadinRequest; -import com.vaadin.tests.components.AbstractTestUI; -import com.vaadin.ui.CheckBox; -import com.vaadin.ui.Tree; - -public class TreeHtmlContentAllowed extends AbstractTestUI { - - @Override - protected void setup(VaadinRequest request) { - String textParent = "Just text"; - String htmlParent = "Some <b>html</b>"; - String textChild = "Child text"; - String htmlChild = "Child <i>html</i>"; - - final Tree tree = new Tree("A tree"); - tree.addItem(textParent); - tree.addItem(htmlParent); - tree.addItem(textChild); - tree.addItem(htmlChild); - - tree.setParent(textChild, textParent); - tree.setParent(htmlChild, htmlParent); - - tree.setChildrenAllowed(textChild, false); - tree.setChildrenAllowed(htmlChild, false); - - final CheckBox toggle = new CheckBox("HTML content allowed", - tree.isHtmlContentAllowed()); - toggle.addValueChangeListener(new ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - tree.setHtmlContentAllowed(toggle.getValue().booleanValue()); - } - }); - - addComponents(tree, toggle); - } - -} diff --git a/uitest/src/com/vaadin/tests/components/tree/TreeHtmlContentAllowedTest.java b/uitest/src/com/vaadin/tests/components/tree/TreeHtmlContentAllowedTest.java deleted file mode 100644 index 351eda6c90..0000000000 --- a/uitest/src/com/vaadin/tests/components/tree/TreeHtmlContentAllowedTest.java +++ /dev/null @@ -1,66 +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.tree; - -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.WebElement; - -import com.vaadin.testbench.elements.CheckBoxElement; -import com.vaadin.testbench.elements.TreeElement; -import com.vaadin.tests.tb3.SingleBrowserTest; - -public class TreeHtmlContentAllowedTest extends SingleBrowserTest { - - @Test - public void testTreeHtmlContentAllowed() { - openTestURL(); - - CheckBoxElement toggle = $(CheckBoxElement.class).first(); - Assert.assertEquals("HTML content should be disabled by default", - "unchecked", toggle.getValue()); - - // Markup is seen as plain text - assertTreeCaptionTexts("Just text", "Some <b>html</b>"); - - toggle.click(); - assertTreeCaptionTexts("Just text", "Some html"); - - // Expand the HTML parent - findElements(By.className("v-tree-node")).get(1).click(); - - assertTreeCaptionTexts("Just text", "Some html", "Child html"); - - toggle.click(); - assertTreeCaptionTexts("Just text", "Some <b>html</b>", - "Child <i>html</i>"); - } - - private void assertTreeCaptionTexts(String... captions) { - TreeElement tree = $(TreeElement.class).first(); - List<WebElement> nodes = tree.findElements(By - .className("v-tree-node-caption")); - - Assert.assertEquals(captions.length, nodes.size()); - for (int i = 0; i < captions.length; i++) { - Assert.assertEquals(captions[i], nodes.get(i).getText()); - } - } - -} diff --git a/uitest/src/com/vaadin/tests/components/tree/TreeIconUpdate.java b/uitest/src/com/vaadin/tests/components/tree/TreeIconUpdate.java deleted file mode 100644 index 6580133645..0000000000 --- a/uitest/src/com/vaadin/tests/components/tree/TreeIconUpdate.java +++ /dev/null @@ -1,73 +0,0 @@ -package com.vaadin.tests.components.tree; - -import com.vaadin.data.Item; -import com.vaadin.data.util.HierarchicalContainer; -import com.vaadin.server.Resource; -import com.vaadin.server.ThemeResource; -import com.vaadin.tests.components.TestBase; -import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; -import com.vaadin.ui.Tree; - -public class TreeIconUpdate extends TestBase { - - private static final Resource ICON1 = new ThemeResource( - "../runo/icons/16/folder.png"); - private static final Resource ICON2 = new ThemeResource( - "../runo/icons/16/ok.png"); - - @Override - protected void setup() { - HierarchicalContainer container = new HierarchicalContainer(); - container.addContainerProperty("name", String.class, null); - container.addContainerProperty("icon", Resource.class, null); - final Tree tree = new Tree(); - tree.setContainerDataSource(container); - tree.setItemIconPropertyId("icon"); - tree.setItemCaptionPropertyId("name"); - - for (int i = 0; i < 20; i++) { - Item bar = container.addItem("bar" + i); - bar.getItemProperty("name").setValue("Bar" + i); - bar.getItemProperty("icon").setValue(ICON1); - - if (i > 3) { - container.setParent("bar" + i, "bar" + (i - 1)); - } - } - - addComponent(tree); - - Button button = new Button("Change icon", new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - tree.getItem("bar0").getItemProperty("icon").setValue(ICON2); - } - }); - - addComponent(button); - button = new Button("Change caption", new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - tree.getItem("bar0").getItemProperty("name").setValue("foo"); - } - }); - - addComponent(button); - - } - - @Override - protected String getDescription() { - return "Click the button to change the icon. The tree should be updated"; - } - - @Override - protected Integer getTicketNumber() { - return 9663; - } - -} diff --git a/uitest/src/com/vaadin/tests/components/tree/TreeItemClickListening.java b/uitest/src/com/vaadin/tests/components/tree/TreeItemClickListening.java deleted file mode 100644 index a3f2b113cd..0000000000 --- a/uitest/src/com/vaadin/tests/components/tree/TreeItemClickListening.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.vaadin.tests.components.tree; - -import com.vaadin.event.ItemClickEvent; -import com.vaadin.server.VaadinRequest; -import com.vaadin.tests.components.AbstractTestUIWithLog; -import com.vaadin.ui.Tree; - -public class TreeItemClickListening extends AbstractTestUIWithLog { - - private int clickCounter = 0; - - @Override - protected void setup(VaadinRequest request) { - - Tree tree = new Tree(); - tree.setImmediate(true); - - tree.addContainerProperty("caption", String.class, ""); - for (int i = 1; i <= 2; i++) { - String item = "Node " + i; - tree.addItem(item); - tree.getContainerProperty(item, "caption").setValue("Caption " + i); - tree.setChildrenAllowed(item, false); - } - tree.setItemCaptionMode(Tree.ITEM_CAPTION_MODE_PROPERTY); - tree.setItemCaptionPropertyId("caption"); - - tree.addListener(new ItemClickEvent.ItemClickListener() { - @Override - public void itemClick(ItemClickEvent event) { - clickCounter++; - switch (event.getButton()) { - case LEFT: - log.log("Left Click"); - break; - case RIGHT: - log.log("Right Click"); - break; - } - } - }); - - addComponent(tree); - } - - @Override - protected String getTestDescription() { - return "Item click event should be triggered from all mouse button clicks"; - } - - @Override - protected Integer getTicketNumber() { - return 6845; - } -} diff --git a/uitest/src/com/vaadin/tests/components/tree/TreeItemClickListeningTest.java b/uitest/src/com/vaadin/tests/components/tree/TreeItemClickListeningTest.java deleted file mode 100644 index 2567fdb16d..0000000000 --- a/uitest/src/com/vaadin/tests/components/tree/TreeItemClickListeningTest.java +++ /dev/null @@ -1,60 +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.tree; - -import static org.hamcrest.MatcherAssert.assertThat; - -import org.junit.Test; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.interactions.Actions; - -import com.vaadin.testbench.By; -import com.vaadin.tests.tb3.MultiBrowserTest; - -public class TreeItemClickListeningTest extends MultiBrowserTest { - - private WebElement getTreeNode(String caption) { - return getDriver().findElement( - By.xpath("//span[text() = '" + caption + "']")); - } - - @Test - public void test() throws InterruptedException { - openTestURL(); - - performLeftClick(); - assertEventFired("1. Left Click"); - - performRightClick(); - assertEventFired("2. Right Click"); - } - - private void assertEventFired(String text) { - assertThat( - String.format("Couldn't find text '%s' from the log.", text), - logContainsText(text)); - } - - private void performLeftClick() { - new Actions(driver).click(getTreeNode("Caption 1")).build().perform(); - } - - private void performRightClick() { - new Actions(driver).contextClick(getTreeNode("Caption 2")).build() - .perform(); - } - -} diff --git a/uitest/src/com/vaadin/tests/components/tree/TreeItemDoubleClick.java b/uitest/src/com/vaadin/tests/components/tree/TreeItemDoubleClick.java deleted file mode 100644 index 9031a76e66..0000000000 --- a/uitest/src/com/vaadin/tests/components/tree/TreeItemDoubleClick.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.vaadin.tests.components.tree; - -import com.vaadin.event.ItemClickEvent; -import com.vaadin.server.VaadinRequest; -import com.vaadin.tests.components.AbstractTestUIWithLog; -import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Tree; - -public class TreeItemDoubleClick extends AbstractTestUIWithLog { - - @Override - protected void setup(VaadinRequest request) { - final Tree tree = new Tree("Immediate With ItemClickListener"); - tree.setImmediate(true); - tree.setNullSelectionAllowed(false); - - for (int i = 1; i < 6; i++) { - tree.addItem("Tree Item " + i); - } - - ItemClickEvent.ItemClickListener listener = new ItemClickEvent.ItemClickListener() { - @Override - public void itemClick(ItemClickEvent event) { - if (event.isDoubleClick()) { - log.log("Double Click " + event.getItemId()); - } - } - }; - - tree.addItemClickListener(listener); - - addComponent(tree); - - addButton("Change immediate flag", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - // this wouldn't work if tree had a value change listener - tree.setImmediate(!tree.isImmediate()); - log.log("tree.isImmediate() is now " + tree.isImmediate()); - } - - }); - - } - - @Override - protected String getTestDescription() { - return "Tests that double click is fired"; - } - - @Override - protected Integer getTicketNumber() { - return 14745; - } - -} diff --git a/uitest/src/com/vaadin/tests/components/tree/TreeItemDoubleClickTest.java b/uitest/src/com/vaadin/tests/components/tree/TreeItemDoubleClickTest.java deleted file mode 100644 index 95a3f02d60..0000000000 --- a/uitest/src/com/vaadin/tests/components/tree/TreeItemDoubleClickTest.java +++ /dev/null @@ -1,65 +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.tree; - -import static org.hamcrest.MatcherAssert.assertThat; - -import org.junit.Test; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.interactions.Actions; - -import com.vaadin.testbench.By; -import com.vaadin.testbench.elements.ButtonElement; -import com.vaadin.tests.tb3.MultiBrowserTest; - -public class TreeItemDoubleClickTest extends MultiBrowserTest { - - @Test - public void test() throws InterruptedException { - openTestURL(); - String caption = "Tree Item 2"; - doubleClick(getTreeNodeByCaption(caption)); - assertLogText("Double Click " + caption); - - changeImmediate(); - - caption = "Tree Item 3"; - doubleClick(getTreeNodeByCaption(caption)); - assertLogText("Double Click " + caption); - } - - private void changeImmediate() { - $(ButtonElement.class).caption("Change immediate flag").first().click(); - assertLogText("tree.isImmediate() is now"); - } - - private WebElement getTreeNodeByCaption(String caption) { - return getDriver().findElement( - By.xpath("//span[text() = '" + caption + "']")); - } - - private void doubleClick(WebElement element) { - new Actions(getDriver()).doubleClick(element).build().perform(); - - } - - private void assertLogText(String text) { - assertThat( - String.format("Couldn't find text '%s' from the log.", text), - logContainsText(text)); - } - -} diff --git a/uitest/src/com/vaadin/tests/components/tree/TreeItemSelectionWithoutImmediate.java b/uitest/src/com/vaadin/tests/components/tree/TreeItemSelectionWithoutImmediate.java deleted file mode 100644 index 8e0f39be99..0000000000 --- a/uitest/src/com/vaadin/tests/components/tree/TreeItemSelectionWithoutImmediate.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.vaadin.tests.components.tree; - -import com.vaadin.event.ItemClickEvent; -import com.vaadin.server.VaadinRequest; -import com.vaadin.tests.components.AbstractTestUIWithLog; -import com.vaadin.ui.Tree; - -@SuppressWarnings("serial") -public class TreeItemSelectionWithoutImmediate extends AbstractTestUIWithLog { - - protected static final String TREE_ID = "TreeId"; - - protected static final String MENU_ITEM_TEMPLATE = "Menu Item %d"; - - @Override - protected void setup(VaadinRequest request) { - Tree tree = new Tree("With ItemClickListener not Immediate"); - tree.setId(TREE_ID); - tree.setImmediate(false); - - for (int i = 1; i <= 4; i++) { - tree.addItem(String.format(MENU_ITEM_TEMPLATE, i)); - } - - tree.addItemClickListener(new ItemClickEvent.ItemClickListener() { - - @Override - public void itemClick(ItemClickEvent event) { - log("ItemClickEvent = " + event.getItemId()); - } - }); - - addComponent(tree); - } - - @Override - protected String getTestDescription() { - return "Test for ensuring that selection of tree items works correctly if immediate == false " - + "and ItemClickListener is added to Tree"; - } - - @Override - protected Integer getTicketNumber() { - return 14388; - } -} diff --git a/uitest/src/com/vaadin/tests/components/tree/TreeItemSelectionWithoutImmediateTest.java b/uitest/src/com/vaadin/tests/components/tree/TreeItemSelectionWithoutImmediateTest.java deleted file mode 100644 index 2fb35b1680..0000000000 --- a/uitest/src/com/vaadin/tests/components/tree/TreeItemSelectionWithoutImmediateTest.java +++ /dev/null @@ -1,61 +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.tree; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; - -import org.junit.Test; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.interactions.Actions; - -import com.vaadin.testbench.By; -import com.vaadin.tests.tb3.MultiBrowserTest; - -public class TreeItemSelectionWithoutImmediateTest extends MultiBrowserTest { - - private static final long serialVersionUID = 1L; - - @Test - public void testSelectTreeWithItemClickListenerNotImmediate() - throws InterruptedException { - openTestURL(); - - // click on item i (in circle we select next item and check if it is - // selected in tree) - for (int i = 1; i <= 4; i++) { - WebElement treeItem = getTreeNode(String.format( - TreeItemSelectionWithoutImmediate.MENU_ITEM_TEMPLATE, i)); - - new Actions(getDriver()).moveToElement(treeItem).click().perform(); - Thread.sleep(100); - - WebElement selectedElement = driver.findElement(By - .className("v-tree-node-selected")); - - treeItem = getTreeNode(String.format( - TreeItemSelectionWithoutImmediate.MENU_ITEM_TEMPLATE, i)); - - assertThat("Clicked element should be selected", selectedElement - .getText().equals(treeItem.getText()), is(true)); - } - } - - private WebElement getTreeNode(String caption) { - return getDriver().findElement( - By.xpath("//span[text() = '" + caption + "']")); - } -} diff --git a/uitest/src/com/vaadin/tests/components/tree/TreeKeyboardNavigationScrolls.java b/uitest/src/com/vaadin/tests/components/tree/TreeKeyboardNavigationScrolls.java deleted file mode 100644 index bb7c0350f2..0000000000 --- a/uitest/src/com/vaadin/tests/components/tree/TreeKeyboardNavigationScrolls.java +++ /dev/null @@ -1,66 +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.tree; - -import com.vaadin.data.Container; -import com.vaadin.data.util.HierarchicalContainer; -import com.vaadin.tests.components.TestBase; -import com.vaadin.tests.util.AlwaysFailValidator; -import com.vaadin.ui.Tree; - -public class TreeKeyboardNavigationScrolls extends TestBase { - - @Override - protected void setup() { - Tree tree = new Tree(); - tree.setContainerDataSource(generateHierarchicalContainer()); - tree.setImmediate(true); - tree.addValidator(new AlwaysFailValidator("failed")); - addComponent(tree); - } - - private Container generateHierarchicalContainer() { - HierarchicalContainer cont = new HierarchicalContainer(); - for (int i = 1; i < 6; i++) { - cont.addItem(i); - for (int j = 1; j < 3; j++) { - String id = i - + " foo bar baz make this node really wide so that we don't have to fiddle with resizing the browser window -> " - + "what would you do if you had one of your legs on backwards? it's legs time! everybody get your legs! " - + "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore " - + "et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut " - + "aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum " - + "dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui " - + "officia deserunt mollit anim id est laborum." + j; - cont.addItem(id); - cont.setChildrenAllowed(id, false); - cont.setParent(id, i); - } - } - return cont; - } - - @Override - protected String getDescription() { - return "The tree scrolls right if the focused node is too wide when navigating with the keyboard"; - } - - @Override - protected Integer getTicketNumber() { - return 7230; - } - -} diff --git a/uitest/src/com/vaadin/tests/components/tree/TreeKeyboardNavigationToNone.java b/uitest/src/com/vaadin/tests/components/tree/TreeKeyboardNavigationToNone.java deleted file mode 100644 index dfea493281..0000000000 --- a/uitest/src/com/vaadin/tests/components/tree/TreeKeyboardNavigationToNone.java +++ /dev/null @@ -1,64 +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.tree; - -import com.vaadin.server.VaadinRequest; -import com.vaadin.tests.components.AbstractTestUI; -import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Tree; - -/** - * Test UI for keyboard navigation for first and last tree item. - * - * @author Vaadin Ltd - */ -public class TreeKeyboardNavigationToNone extends AbstractTestUI { - - @Override - protected void setup(VaadinRequest request) { - final Tree tree = new Tree(); - tree.addItem("a"); - tree.addItem("b"); - - tree.select("a"); - addComponents(tree); - tree.focus(); - - Button button = new Button("Select last item", - new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - tree.select("b"); - tree.focus(); - } - }); - addComponent(button); - } - - @Override - protected Integer getTicketNumber() { - return 15343; - } - - @Override - protected String getTestDescription() { - return "Keyboard navigation should not throw client side exception " - + "when there are no items to navigate."; - } - -} diff --git a/uitest/src/com/vaadin/tests/components/tree/TreeKeyboardNavigationToNoneTest.java b/uitest/src/com/vaadin/tests/components/tree/TreeKeyboardNavigationToNoneTest.java deleted file mode 100644 index 98f1896b82..0000000000 --- a/uitest/src/com/vaadin/tests/components/tree/TreeKeyboardNavigationToNoneTest.java +++ /dev/null @@ -1,66 +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.tree; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.Keys; -import org.openqa.selenium.interactions.Actions; - -import com.vaadin.testbench.elements.ButtonElement; -import com.vaadin.tests.tb3.MultiBrowserTest; - -/** - * Test for keyboard navigation in tree in case when there are no items to - * navigate. - * - * @author Vaadin Ltd - */ -public class TreeKeyboardNavigationToNoneTest extends MultiBrowserTest { - - @Before - public void setUp() { - setDebug(true); - openTestURL(); - } - - @Test - public void navigateUpForTheFirstItem() { - sendKey(Keys.ARROW_UP); - checkNotificationErrorAbsence("first"); - } - - @Test - public void navigateDownForTheLastItem() { - $(ButtonElement.class).first().click(); - sendKey(Keys.ARROW_DOWN); - checkNotificationErrorAbsence("last"); - } - - private void checkNotificationErrorAbsence(String item) { - Assert.assertFalse( - "Notification is found after using keyboard for navigation " - + "from " + item + " tree item", - isElementPresent(By.className("v-Notification"))); - } - - private void sendKey(Keys key) { - Actions actions = new Actions(getDriver()); - actions.sendKeys(key).build().perform(); - } -} diff --git a/uitest/src/com/vaadin/tests/components/tree/TreeKeyboardNavigationValidators.java b/uitest/src/com/vaadin/tests/components/tree/TreeKeyboardNavigationValidators.java deleted file mode 100644 index 9204f0495b..0000000000 --- a/uitest/src/com/vaadin/tests/components/tree/TreeKeyboardNavigationValidators.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.vaadin.tests.components.tree; - -import com.vaadin.data.Container; -import com.vaadin.data.util.HierarchicalContainer; -import com.vaadin.tests.components.TestBase; -import com.vaadin.tests.util.AlwaysFailValidator; -import com.vaadin.ui.Tree; - -public class TreeKeyboardNavigationValidators extends TestBase { - - @Override - protected void setup() { - addComponent(getTree()); - } - - private Tree getTree() { - Tree tree = new Tree(); - tree.setSizeFull(); - tree.setContainerDataSource(generateHierarchicalContainer()); - tree.setImmediate(true); - tree.addValidator(new AlwaysFailValidator("failed")); - return tree; - } - - private Container generateHierarchicalContainer() { - HierarchicalContainer cont = new HierarchicalContainer(); - for (int i = 1; i < 6; i++) { - cont.addItem(i); - for (int j = 1; j < 3; j++) { - String id = i + " -> " + j; - cont.addItem(id); - cont.setChildrenAllowed(id, false); - cont.setParent(id, i); - } - } - return cont; - } - - @Override - protected String getDescription() { - return "Keyboard navigation should still work in a tree with validators."; - } - - @Override - protected Integer getTicketNumber() { - return 7057; - } - -} diff --git a/uitest/src/com/vaadin/tests/components/tree/TreeNodeCaptionWrapping.java b/uitest/src/com/vaadin/tests/components/tree/TreeNodeCaptionWrapping.java deleted file mode 100644 index f885e1d1da..0000000000 --- a/uitest/src/com/vaadin/tests/components/tree/TreeNodeCaptionWrapping.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.vaadin.tests.components.tree; - -import com.vaadin.server.ThemeResource; -import com.vaadin.tests.components.TestBase; -import com.vaadin.ui.Tree; - -public class TreeNodeCaptionWrapping extends TestBase { - - @Override - protected String getDescription() { - return "The text should not wrap to the following line but instead be cut off when there is too little horizontal space."; - } - - @Override - protected Integer getTicketNumber() { - return 3098; - } - - @Override - protected void setup() { - setTheme("runo"); - Tree tree = new Tree(); - tree.setWidth("100px"); - - tree.addItem("1"); - tree.setItemIcon("1", new ThemeResource("../runo/icons/16/ok.png")); - - String mainItem = "A very long item that should not wrap"; - String subItem = "Subitem - also long"; - - tree.addItem(mainItem); - tree.setItemIcon(mainItem, new ThemeResource( - "../runo/icons/16/error.png")); - - tree.addItem(subItem); - tree.setParent(subItem, mainItem); - - tree.expandItem("1"); - tree.expandItem(mainItem); - tree.expandItem(subItem); - - addComponent(tree); - } -} diff --git a/uitest/src/com/vaadin/tests/components/tree/TreePerformanceTest.java b/uitest/src/com/vaadin/tests/components/tree/TreePerformanceTest.java deleted file mode 100644 index 45084fd57d..0000000000 --- a/uitest/src/com/vaadin/tests/components/tree/TreePerformanceTest.java +++ /dev/null @@ -1,75 +0,0 @@ -package com.vaadin.tests.components.tree; - -import com.vaadin.tests.components.AbstractTestCase; -import com.vaadin.ui.Layout; -import com.vaadin.ui.LegacyWindow; -import com.vaadin.ui.Tree; -import com.vaadin.ui.VerticalLayout; - -public class TreePerformanceTest extends AbstractTestCase { - - @Override - protected String getDescription() { - return "Trees rendering type may become slow escpecially with FF and big tree in a deep component tree."; - } - - @Override - protected Integer getTicketNumber() { - return null; - } - - @Override - public void init() { - LegacyWindow w = new LegacyWindow(); - setMainWindow(w); - - Layout layout = null; - - for (int i = 0; i < getLayoutCount(); i++) { - Layout newlayout = createLayout(); - // newlayout.setHeight("100%"); - if (i == 0) { - w.setContent(newlayout); - } else { - layout.addComponent(newlayout); - } - layout = newlayout; - } - - Tree tree = new Tree(); - - for (int i = 0; i < getItemCount(); i++) { - String text = "ITEM " + i; - tree.addItem(text); - for (int j = 0; j < getSubItemCount(); j++) { - String subtext = " SUBITEM " + j + " for " + text; - tree.addItem(subtext); - tree.setParent(subtext, text); - } - tree.expandItemsRecursively(text); - } - - // One can test that the slugginesh is actually verticallayout issue - // Table testTable = TestForTablesInitialColumnWidthLogicRendering - // .getTestTable(12, 60); - // testTable.setPageLength(0); - layout.addComponent(tree); - - } - - private Layout createLayout() { - return new VerticalLayout(); - } - - private int getLayoutCount() { - return 10; - } - - private int getSubItemCount() { - return 3; - } - - private int getItemCount() { - return 200; - } -} diff --git a/uitest/src/com/vaadin/tests/components/tree/TreeScrolling.java b/uitest/src/com/vaadin/tests/components/tree/TreeScrolling.java deleted file mode 100644 index 2311f3ec30..0000000000 --- a/uitest/src/com/vaadin/tests/components/tree/TreeScrolling.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.vaadin.tests.components.tree; - -import com.vaadin.tests.components.AbstractTestCase; -import com.vaadin.ui.LegacyWindow; -import com.vaadin.ui.RichTextArea; -import com.vaadin.ui.TextField; -import com.vaadin.ui.Tree; -import com.vaadin.ui.VerticalLayout; - -public class TreeScrolling extends AbstractTestCase { - - @Override - public void init() { - VerticalLayout layout = new VerticalLayout(); - layout.setSizeUndefined(); - LegacyWindow w = new LegacyWindow("", layout); - setMainWindow(w); - - TextField filler1 = new TextField(); - RichTextArea filler2 = new RichTextArea(); - Tree tree = new Tree(); - for (int i = 0; i < 20; i++) { - String parentId = "Item " + i; - // Item parentItem = - tree.addItem(parentId); - for (int j = 0; j < 20; j++) { - String subId = "Item " + i + " - " + j; - // Item subItem = - tree.addItem(subId); - tree.setParent(subId, parentId); - } - - } - - for (Object id : tree.rootItemIds()) { - tree.expandItemsRecursively(id); - } - - layout.addComponent(filler1); - layout.addComponent(filler2); - layout.addComponent(tree); - } - - @Override - protected String getDescription() { - return "Tests what happens when a tree is partly out of view when an item is selected"; - } - - @Override - protected Integer getTicketNumber() { - return 5400; - } - -} diff --git a/uitest/src/com/vaadin/tests/components/tree/TreeScrollingOnRightClick.java b/uitest/src/com/vaadin/tests/components/tree/TreeScrollingOnRightClick.java deleted file mode 100644 index 8a2b263006..0000000000 --- a/uitest/src/com/vaadin/tests/components/tree/TreeScrollingOnRightClick.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.vaadin.tests.components.tree; - -import com.vaadin.event.ItemClickEvent; -import com.vaadin.event.MouseEvents; -import com.vaadin.server.VaadinRequest; -import com.vaadin.tests.components.AbstractTestUI; -import com.vaadin.ui.Tree; - -/** - * Test for #12618: Trying to select item with right click in Tree causes focus - * issues. - */ -@SuppressWarnings("serial") -public class TreeScrollingOnRightClick extends AbstractTestUI { - - public static final String TREE_ID = "my-tree"; - - @Override - protected void setup(VaadinRequest request) { - final Tree tree = new Tree(); - tree.setId(TREE_ID); - tree.setSizeUndefined(); - - // Add item click listener for right click selection - tree.addItemClickListener(new ItemClickEvent.ItemClickListener() { - @SuppressWarnings("deprecation") - @Override - public void itemClick(ItemClickEvent event) { - if (event.getButton() == MouseEvents.ClickEvent.BUTTON_RIGHT) { - tree.select(event.getItemId()); - } - } - }); - - // Add some items - for (int i = 0; i < 200; i++) { - tree.addItem(String.format("Node %s", i)); - } - - addComponent(tree); - } - - @Override - protected String getTestDescription() { - return "Right clicking on items should not scroll Tree."; - } - - @Override - protected Integer getTicketNumber() { - return 12618; - } - -} diff --git a/uitest/src/com/vaadin/tests/components/tree/TreeScrollingOnRightClickTest.java b/uitest/src/com/vaadin/tests/components/tree/TreeScrollingOnRightClickTest.java deleted file mode 100644 index b8715ed505..0000000000 --- a/uitest/src/com/vaadin/tests/components/tree/TreeScrollingOnRightClickTest.java +++ /dev/null @@ -1,69 +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.tree; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.Keys; -import org.openqa.selenium.Point; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.interactions.Actions; - -import com.vaadin.tests.tb3.MultiBrowserTest; - -/** - * - * @since 7.1.9 - * @author Vaadin Ltd - */ -public class TreeScrollingOnRightClickTest extends MultiBrowserTest { - - @Test - public void testScrollingOnRightClick() throws Throwable { - openTestURL(); - - // Focus tree - WebElement tree = getDriver().findElement( - By.id(TreeScrollingOnRightClick.TREE_ID)); - tree.click(); - - // Move selection down 50 items - for (int down = 0; down < 50; down++) { - tree.sendKeys(Keys.ARROW_DOWN); - } - - Thread.sleep(1000); - - // Get location of item 40 - Point item40Location = getTreeNode("Node 40").getLocation(); - - // Right click on item 45 - WebElement item45 = getTreeNode("Node 45"); - new Actions(getDriver()).moveToElement(item45).contextClick(item45) - .perform(); - - // Ensure location of item 40 is still the same (no scrolling) - Point item40Location2 = getTreeNode("Node 40").getLocation(); - assertEquals(item40Location.getY(), item40Location2.getY()); - } - - private WebElement getTreeNode(String caption) { - return getDriver().findElement( - By.xpath("//span[text() = '" + caption + "']")); - } -} diff --git a/uitest/src/com/vaadin/tests/components/tree/TreeScrollingOnSelection.java b/uitest/src/com/vaadin/tests/components/tree/TreeScrollingOnSelection.java deleted file mode 100644 index ba128025cd..0000000000 --- a/uitest/src/com/vaadin/tests/components/tree/TreeScrollingOnSelection.java +++ /dev/null @@ -1,75 +0,0 @@ -package com.vaadin.tests.components.tree; - -import com.vaadin.data.util.HierarchicalContainer; -import com.vaadin.event.ItemClickEvent; -import com.vaadin.event.ItemClickEvent.ItemClickListener; -import com.vaadin.tests.components.TestBase; -import com.vaadin.ui.Label; -import com.vaadin.ui.Panel; -import com.vaadin.ui.Tree; -import com.vaadin.ui.VerticalLayout; - -public class TreeScrollingOnSelection extends TestBase { - private static final long serialVersionUID = 4082075610259697145L; - - private static final String GREEK_ALPHABET = "greek alphabet"; - - private static final String[] ALPHABET = { "Alpha", "Beta", "Gamma", - "Delta", "Epsilon", "Zeta", "Eta", "Theta", "Iota", "Kappa", - "Lambda", "My", "Ny", "Xi", "Omikron", "Pi", "Rho", "Sigma", "Tau", - "Ypsilon", "Phi", "Chi", "Psi", "Omega" }; - - @Override - public void setup() { - final Label charLabel = new Label(); - charLabel.setWidth("200px"); - - Tree tree = new Tree("alphabets", getContainer()); - tree.expandItem(GREEK_ALPHABET); - tree.addListener(new ItemClickListener() { - - private static final long serialVersionUID = 5955518276555388126L; - - @Override - public void itemClick(ItemClickEvent event) { - charLabel.setValue(event.getItemId().toString()); - } - }); - tree.setImmediate(true); - - VerticalLayout panelLayout = new VerticalLayout(); - panelLayout.setMargin(true); - Panel panel = new Panel(panelLayout); - panelLayout.addComponent(tree); - panel.setWidth("200px"); - panel.setHeight("300px"); - - addComponent(panel); - - addComponent(charLabel); - } - - private HierarchicalContainer getContainer() { - HierarchicalContainer container = new HierarchicalContainer(); - - container.addItem(GREEK_ALPHABET); - - for (String character : ALPHABET) { - container.addItem(character); - container.setChildrenAllowed(character, false); - container.setParent(character, GREEK_ALPHABET); - } - - return container; - } - - @Override - protected String getDescription() { - return "Selecting an item in the tree inside the Panel should not cause the panel scroll position to change."; - } - - @Override - protected Integer getTicketNumber() { - return 6731; - } -} diff --git a/uitest/src/com/vaadin/tests/components/tree/TreeToolTips.java b/uitest/src/com/vaadin/tests/components/tree/TreeToolTips.java deleted file mode 100644 index 59e3fec1f9..0000000000 --- a/uitest/src/com/vaadin/tests/components/tree/TreeToolTips.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.vaadin.tests.components.tree; - -import com.vaadin.data.Item; -import com.vaadin.data.util.HierarchicalContainer; -import com.vaadin.tests.components.TestBase; -import com.vaadin.ui.AbstractSelect; -import com.vaadin.ui.Component; -import com.vaadin.ui.Tree; - -public class TreeToolTips extends TestBase { - - @Override - protected void setup() { - final Tree tree = new Tree(null, createContainer()); - tree.setItemDescriptionGenerator(new AbstractSelect.ItemDescriptionGenerator() { - @Override - public String generateDescription(Component source, Object itemId, - Object propertyId) { - return "This is a tooltip for item id '" + itemId + "'"; - } - }); - - for (Object rootItems : tree.rootItemIds()) { - tree.expandItemsRecursively(rootItems); - } - - addComponent(tree); - } - - @Override - protected String getDescription() { - return "Tree items should have tooltips"; - } - - @Override - protected Integer getTicketNumber() { - return 6637; - } - - private HierarchicalContainer createContainer() { - HierarchicalContainer cont = new HierarchicalContainer(); - cont.addContainerProperty("name", String.class, ""); - - for (int i = 0; i < 20; i++) { - Item item = cont.addItem("Item " + i); - item.getItemProperty("name").setValue("Item " + i); - cont.setChildrenAllowed("Item " + i, false); - - if (i == 1 || i == 4) { - cont.setChildrenAllowed("Item " + i, true); - } - - // Add three items to item 1 - if (i > 1 && i < 4) { - cont.setParent("Item " + i, "Item 1"); - } - - // Add 5 items to item 4 - if (i > 4 && i < 10) { - cont.setChildrenAllowed("Item " + i, true); - - if (i == 7) { - item = cont.addItem("Item 71"); - item.getItemProperty("name").setValue("Item 71"); - cont.setParent("Item 71", "Item " + i); - cont.setChildrenAllowed("Item 71", false); - - item = cont.addItem("Item 72"); - item.getItemProperty("name").setValue("Item 72"); - cont.setParent("Item 72", "Item " + i); - cont.setChildrenAllowed("Item 72", true); - - item = cont.addItem("Item 73"); - item.getItemProperty("name").setValue("Item 73"); - cont.setParent("Item 73", "Item 72"); - cont.setChildrenAllowed("Item 73", true); - - item = cont.addItem("Item 74"); - item.getItemProperty("name").setValue("Item 74"); - cont.setParent("Item 74", "Item " + i); - cont.setChildrenAllowed("Item 74", true); - } - - cont.setParent("Item " + i, "Item " + (i - 1)); - - } - } - - return cont; - } -} diff --git a/uitest/src/com/vaadin/tests/components/tree/TreeWithIcons.java b/uitest/src/com/vaadin/tests/components/tree/TreeWithIcons.java deleted file mode 100644 index a1576ffed1..0000000000 --- a/uitest/src/com/vaadin/tests/components/tree/TreeWithIcons.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.vaadin.tests.components.tree; - -import java.util.Date; - -import com.vaadin.server.Sizeable; -import com.vaadin.server.ThemeResource; -import com.vaadin.tests.components.TestBase; -import com.vaadin.tests.util.LoremIpsum; -import com.vaadin.ui.HorizontalLayout; -import com.vaadin.ui.Panel; -import com.vaadin.ui.Tree; -import com.vaadin.ui.themes.Reindeer; - -public class TreeWithIcons extends TestBase { - - @Override - protected void setup() { - ThemeResource notCachedFolderIconHuge = new ThemeResource( - "../runo/icons/64/folder.png?" + new Date().getTime()); - ThemeResource notCachedFolderIconLarge = new ThemeResource( - "../runo/icons/32/folder.png?" + new Date().getTime()); - ThemeResource notCachedFolderIconLargeOther = new ThemeResource( - "../runo/icons/32/ok.png?" + new Date().getTime()); - Tree t = new Tree(); - t.setImmediate(true); - - t.addItem("Root 1"); - t.addItem("Root 11"); - t.addItem("Root 111"); - t.addItem("Root 1111"); - t.addItem("Sub 1"); - t.setItemIcon("Sub 1", notCachedFolderIconLargeOther); - t.setParent("Sub 1", "Root 1"); - String longItemId = LoremIpsum.get(50); - t.addItem(longItemId); - t.setItemIcon(longItemId, notCachedFolderIconHuge); - t.setParent(longItemId, "Root 11"); - t.addItem("abcdefghijklmn"); - - String first = "abcdefghijklmnop"; - String second = "abcdefghijklmnopqrst"; - t.addItem(first); - t.addItem(second); - t.setParent(second, first); - t.setItemIcon(first, notCachedFolderIconLarge); - - HorizontalLayout hlay = new HorizontalLayout(); - hlay.setStyleName(Reindeer.LAYOUT_BLUE); - hlay.addComponent(t); - hlay.setWidth(-1, Sizeable.UNITS_PIXELS); - - Panel p = new Panel(); - p.setSizeUndefined(); - p.setContent(hlay); - - addComponent(p); - } - - @Override - protected String getDescription() { - return "A tree with icons should resize itself correctly so the nodes are not cut either horizontally or vertically."; - } - - @Override - protected Integer getTicketNumber() { - return 3529; - } - -} diff --git a/uitest/src/com/vaadin/tests/components/tree/TreeWithPreselectedItemNotShown.java b/uitest/src/com/vaadin/tests/components/tree/TreeWithPreselectedItemNotShown.java deleted file mode 100644 index 8da6759b20..0000000000 --- a/uitest/src/com/vaadin/tests/components/tree/TreeWithPreselectedItemNotShown.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.vaadin.tests.components.tree; - -import com.vaadin.tests.components.TestBase; -import com.vaadin.ui.Button; -import com.vaadin.ui.Tree; -import com.vaadin.ui.Window; - -public class TreeWithPreselectedItemNotShown extends TestBase { - - @Override - protected void setup() { - Button open = new Button("Open modal window with tree", - new Button.ClickListener() { - @Override - public void buttonClick(Button.ClickEvent event) { - getMainWindow().addWindow(new SubwindowWithTree()); - } - }); - - addComponent(open); - } - - private class SubwindowWithTree extends Window { - - private SubwindowWithTree() { - super("Tree here"); - - String itemId1 = "Item 1"; - String itemId2 = "Item 2"; - - Tree tree = new Tree(); - - tree.addItem(itemId1); - tree.addItem(itemId2); - - // todo error here - tree.select(itemId1); - - addComponent(tree); - } - } - - @Override - protected String getDescription() { - return "IE8 doesn't display a tree if an item has been selected before the tree becomes visible"; - } - - @Override - protected Integer getTicketNumber() { - return 6878; - } - -} diff --git a/uitest/src/com/vaadin/tests/components/tree/Trees.java b/uitest/src/com/vaadin/tests/components/tree/Trees.java deleted file mode 100644 index f12d6adbb3..0000000000 --- a/uitest/src/com/vaadin/tests/components/tree/Trees.java +++ /dev/null @@ -1,407 +0,0 @@ -package com.vaadin.tests.components.tree; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.List; - -import com.vaadin.data.Container; -import com.vaadin.data.Container.Hierarchical; -import com.vaadin.data.util.HierarchicalContainer; -import com.vaadin.event.Action; -import com.vaadin.event.Action.Handler; -import com.vaadin.shared.ui.MultiSelectMode; -import com.vaadin.tests.components.select.AbstractSelectTestCase; -import com.vaadin.ui.Tree; -import com.vaadin.ui.Tree.CollapseEvent; -import com.vaadin.ui.Tree.CollapseListener; -import com.vaadin.ui.Tree.ExpandEvent; -import com.vaadin.ui.Tree.ExpandListener; -import com.vaadin.ui.Tree.ItemStyleGenerator; - -public class Trees extends AbstractSelectTestCase<Tree> implements - ExpandListener, CollapseListener { - - private int rootItemIds = 3; - - private ItemStyleGenerator rootGreenSecondLevelRed = new com.vaadin.ui.Tree.ItemStyleGenerator() { - - @Override - public String getStyle(Tree source, Object itemId) { - Hierarchical c = (Container.Hierarchical) getComponent() - .getContainerDataSource(); - if (c.isRoot(itemId)) { - return "green"; - } - - Object parent = c.getParent(itemId); - if (!c.isRoot(parent)) { - return "red"; - } - - return null; - } - - @Override - public String toString() { - return "Root green, second level red"; - } - - }; - - private ItemStyleGenerator evenItemsBold = new com.vaadin.ui.Tree.ItemStyleGenerator() { - - @Override - public String getStyle(Tree source, Object itemId) { - Hierarchical c = (Container.Hierarchical) getComponent() - .getContainerDataSource(); - int idx = 0; - - for (Iterator<?> i = c.getItemIds().iterator(); i.hasNext();) { - Object id = i.next(); - if (id == itemId) { - if (idx % 2 == 1) { - return "bold"; - } else { - return null; - } - } - - idx++; - } - - return null; - } - - @Override - public String toString() { - return "Even items bold"; - } - - }; - - private Command<Tree, ContextMenu> contextMenuCommand = new Command<Tree, ContextMenu>() { - - @Override - public void execute(Tree c, final ContextMenu value, Object data) { - c.removeAllActionHandlers(); - if (value != null) { - c.addActionHandler(new Handler() { - - @Override - public void handleAction(Action action, Object sender, - Object target) { - log("Action " + action.getCaption() + " performed on " - + target); - } - - @Override - public Action[] getActions(Object target, Object sender) { - return value.getActions(target, sender); - } - }); - } - } - }; - - @Override - protected Class<Tree> getTestClass() { - return Tree.class; - } - - @Override - protected void createActions() { - super.createActions(); - - // Causes container changes so doing this first.. - createRootItemSelectAction(CATEGORY_DATA_SOURCE); - - createExpandCollapseActions(CATEGORY_FEATURES); - createSelectionModeSelect(CATEGORY_SELECTION); - createChildrenAllowedAction(CATEGORY_DATA_SOURCE); - - createListeners(CATEGORY_LISTENERS); - createItemStyleGenerator(CATEGORY_FEATURES); - createContextMenuAction(CATEGORY_FEATURES); - // TODO: DropHandler - // TODO: DragMode - // TODO: ActionHandler - - } - - private void createContextMenuAction(String category) { - LinkedHashMap<String, ContextMenu> options = new LinkedHashMap<String, ContextMenu>(); - options.put("None", null); - options.put("Item without icon", new ContextMenu("No icon", null)); - ContextMenu cm = new ContextMenu(); - cm.addItem("Caption only", null); - cm.addItem("Has icon", ICON_16_USER_PNG_UNCACHEABLE); - options.put("With and without icon", cm); - options.put("Only one large icon", new ContextMenu("Icon", - ICON_64_EMAIL_REPLY_PNG_UNCACHEABLE)); - - createSelectAction("Context menu", category, options, "None", - contextMenuCommand, true); - } - - private void createItemStyleGenerator(String category) { - - LinkedHashMap<String, com.vaadin.ui.Tree.ItemStyleGenerator> options = new LinkedHashMap<String, com.vaadin.ui.Tree.ItemStyleGenerator>(); - - options.put("-", null); - options.put(rootGreenSecondLevelRed.toString(), rootGreenSecondLevelRed); - options.put(evenItemsBold.toString(), evenItemsBold); - - createSelectAction("Item Style generator", category, options, "-", - itemStyleGeneratorCommand); - - } - - private void createListeners(String category) { - createBooleanAction("Expand listener", category, false, - expandListenerCommand); - createBooleanAction("Collapse listener", category, false, - collapseListenerCommand); - createBooleanAction("Item click listener", category, false, - itemClickListenerCommand); - - } - - private enum SelectMode { - NONE, SINGLE, MULTI_SIMPLE, MULTI; - } - - protected void createSelectionModeSelect(String category) { - LinkedHashMap<String, SelectMode> options = new LinkedHashMap<String, SelectMode>(); - options.put("None", SelectMode.NONE); - options.put("Single", SelectMode.SINGLE); - options.put("Multi - simple", SelectMode.MULTI_SIMPLE); - options.put("Multi - ctrl/shift", SelectMode.MULTI); - - createSelectAction("Selection Mode", category, options, - "Multi - ctrl/shift", new Command<Tree, SelectMode>() { - - @Override - public void execute(Tree t, SelectMode value, Object data) { - switch (value) { - case NONE: - t.setSelectable(false); - break; - case SINGLE: - t.setMultiSelect(false); - t.setSelectable(true); - break; - case MULTI_SIMPLE: - t.setSelectable(true); - t.setMultiSelect(true); - t.setMultiselectMode(MultiSelectMode.SIMPLE); - break; - case MULTI: - t.setSelectable(true); - t.setMultiSelect(true); - t.setMultiselectMode(MultiSelectMode.DEFAULT); - break; - } - } - }); - } - - @Override - protected Container createContainer(int properties, int items) { - return createHierarchicalContainer(properties, items, rootItemIds); - } - - private Container.Hierarchical createHierarchicalContainer(int properties, - int items, int roots) { - Container.Hierarchical c = new HierarchicalContainer(); - - populateContainer(c, properties, items); - - if (items <= roots) { - return c; - } - - // "roots" roots, each with - // "firstLevel" children, two with no children (one with childAllowed, - // one without) - // ("firstLevel"-2)*"secondLevel" children ("secondLevel"/2 with - // childAllowed, "secondLevel"/2 without) - - // N*M+N*(M-2)*C = items - // items=N(M+MC-2C) - - // Using secondLevel=firstLevel/2 => - // items = roots*(firstLevel+firstLevel*firstLevel/2-2*firstLevel/2) - // =roots*(firstLevel+firstLevel^2/2-firstLevel) - // = roots*firstLevel^2/2 - // => firstLevel = sqrt(items/roots*2) - - int firstLevel = (int) Math.ceil(Math.sqrt(items / roots * 2.0)); - int secondLevel = firstLevel / 2; - - while (roots * (1 + 2 + (firstLevel - 2) * secondLevel) < items) { - // Increase something so we get enough items - secondLevel++; - } - - List<Object> itemIds = new ArrayList<Object>(c.getItemIds()); - - int nextItemId = roots; - for (int rootIndex = 0; rootIndex < roots; rootIndex++) { - // roots use items 0..roots-1 - Object rootItemId = itemIds.get(rootIndex); - - // force roots to be roots even though they automatically should be - c.setParent(rootItemId, null); - - for (int firstLevelIndex = 0; firstLevelIndex < firstLevel; firstLevelIndex++) { - if (nextItemId >= items) { - break; - } - Object firstLevelItemId = itemIds.get(nextItemId++); - c.setParent(firstLevelItemId, rootItemId); - - if (firstLevelIndex < 2) { - continue; - } - - // firstLevelChildren 2.. have child nodes - for (int secondLevelIndex = 0; secondLevelIndex < secondLevel; secondLevelIndex++) { - if (nextItemId >= items) { - break; - } - - Object secondLevelItemId = itemIds.get(nextItemId++); - c.setParent(secondLevelItemId, firstLevelItemId); - } - } - } - - return c; - } - - private void createRootItemSelectAction(String category) { - LinkedHashMap<String, Integer> options = new LinkedHashMap<String, Integer>(); - for (int i = 1; i <= 10; i++) { - options.put(String.valueOf(i), i); - } - options.put("20", 20); - options.put("50", 50); - options.put("100", 100); - - createSelectAction("Number of root items", category, options, "3", - rootItemIdsCommand); - } - - private void createExpandCollapseActions(String category) { - LinkedHashMap<String, Object> options = new LinkedHashMap<String, Object>(); - - for (Object id : getComponent().getItemIds()) { - options.put(id.toString(), id); - } - createMultiClickAction("Expand", category, options, expandItemCommand, - null); - createMultiClickAction("Expand recursively", category, options, - expandItemRecursivelyCommand, null); - createMultiClickAction("Collapse", category, options, - collapseItemCommand, null); - - } - - private void createChildrenAllowedAction(String category) { - LinkedHashMap<String, Object> options = new LinkedHashMap<String, Object>(); - - for (Object id : getComponent().getItemIds()) { - options.put(id.toString(), id); - } - createMultiToggleAction("Children allowed", category, options, - setChildrenAllowedCommand, true); - - } - - /* - * COMMANDS - */ - private Command<Tree, Integer> rootItemIdsCommand = new Command<Tree, Integer>() { - - @Override - public void execute(Tree c, Integer value, Object data) { - rootItemIds = value; - updateContainer(); - } - }; - - private Command<Tree, Object> expandItemCommand = new Command<Tree, Object>() { - - @Override - public void execute(Tree c, Object itemId, Object data) { - c.expandItem(itemId); - } - }; - private Command<Tree, Object> expandItemRecursivelyCommand = new Command<Tree, Object>() { - - @Override - public void execute(Tree c, Object itemId, Object data) { - c.expandItemsRecursively(itemId); - } - }; - - private Command<Tree, Object> collapseItemCommand = new Command<Tree, Object>() { - - @Override - public void execute(Tree c, Object itemId, Object data) { - c.collapseItem(itemId); - } - }; - - private Command<Tree, Boolean> setChildrenAllowedCommand = new Command<Tree, Boolean>() { - - @Override - public void execute(Tree c, Boolean areChildrenAllowed, Object itemId) { - c.setChildrenAllowed(itemId, areChildrenAllowed); - } - }; - - private Command<Tree, Boolean> expandListenerCommand = new Command<Tree, Boolean>() { - @Override - public void execute(Tree c, Boolean value, Object data) { - if (value) { - c.addListener((ExpandListener) Trees.this); - } else { - c.removeListener((ExpandListener) Trees.this); - } - } - }; - - private Command<Tree, Boolean> collapseListenerCommand = new Command<Tree, Boolean>() { - @Override - public void execute(Tree c, Boolean value, Object data) { - if (value) { - c.addListener((CollapseListener) Trees.this); - } else { - c.removeListener((CollapseListener) Trees.this); - } - } - }; - - private Command<Tree, com.vaadin.ui.Tree.ItemStyleGenerator> itemStyleGeneratorCommand = new Command<Tree, com.vaadin.ui.Tree.ItemStyleGenerator>() { - - @Override - public void execute(Tree c, - com.vaadin.ui.Tree.ItemStyleGenerator value, Object data) { - c.setItemStyleGenerator(value); - - } - }; - - @Override - public void nodeCollapse(CollapseEvent event) { - log(event.getClass().getSimpleName() + ": " + event.getItemId()); - } - - @Override - public void nodeExpand(ExpandEvent event) { - log(event.getClass().getSimpleName() + ": " + event.getItemId()); - } - -} |