summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorJohn Ahlroos <john@vaadin.com>2012-09-03 17:30:18 +0300
committerJohn Ahlroos <john@vaadin.com>2012-09-03 17:30:18 +0300
commitea82c990660756eef940b98af66d8ff89259a518 (patch)
treed52110e6be7b07bc33cc79e20130c954030e20d7 /server
parent5f6840fecf1a2b9702bff41b5f8b79c6ad8fffbf (diff)
parentb2d830d1490e762e97f23dca33a21588ab977e65 (diff)
downloadvaadin-framework-ea82c990660756eef940b98af66d8ff89259a518.tar.gz
vaadin-framework-ea82c990660756eef940b98af66d8ff89259a518.zip
Merge branch 'master' into layoutgraph
Diffstat (limited to 'server')
-rw-r--r--server/src/com/vaadin/ui/Tree.java13
-rw-r--r--server/tests/src/com/vaadin/data/util/AbstractContainerTest.java209
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/tree/TestHasChildren.java25
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/tree/TreeTest.java74
4 files changed, 193 insertions, 128 deletions
diff --git a/server/src/com/vaadin/ui/Tree.java b/server/src/com/vaadin/ui/Tree.java
index 9cf1aa3511..03895a12bb 100644
--- a/server/src/com/vaadin/ui/Tree.java
+++ b/server/src/com/vaadin/ui/Tree.java
@@ -33,7 +33,7 @@ import java.util.StringTokenizer;
import com.vaadin.data.Container;
import com.vaadin.data.Item;
import com.vaadin.data.util.ContainerHierarchicalWrapper;
-import com.vaadin.data.util.IndexedContainer;
+import com.vaadin.data.util.HierarchicalContainer;
import com.vaadin.event.Action;
import com.vaadin.event.Action.Handler;
import com.vaadin.event.DataBoundTransferable;
@@ -140,6 +140,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical,
* Creates a new empty tree.
*/
public Tree() {
+ this(null);
}
/**
@@ -148,7 +149,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical,
* @param caption
*/
public Tree(String caption) {
- setCaption(caption);
+ this(caption, new HierarchicalContainer());
}
/**
@@ -158,8 +159,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical,
* @param dataSource
*/
public Tree(String caption, Container dataSource) {
- setCaption(caption);
- setContainerDataSource(dataSource);
+ super(caption, dataSource);
}
/* Expanding and collapsing */
@@ -827,10 +827,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical,
@Override
public void setContainerDataSource(Container newDataSource) {
if (newDataSource == null) {
- // Note: using wrapped IndexedContainer to match constructor (super
- // creates an IndexedContainer, which is then wrapped).
- newDataSource = new ContainerHierarchicalWrapper(
- new IndexedContainer());
+ newDataSource = new HierarchicalContainer();
}
// Assure that the data source is ordered by making unordered
diff --git a/server/tests/src/com/vaadin/data/util/AbstractContainerTest.java b/server/tests/src/com/vaadin/data/util/AbstractContainerTest.java
index b0151a6690..88c3127cb3 100644
--- a/server/tests/src/com/vaadin/data/util/AbstractContainerTest.java
+++ b/server/tests/src/com/vaadin/data/util/AbstractContainerTest.java
@@ -318,7 +318,8 @@ public abstract class AbstractContainerTest extends TestCase {
FULLY_QUALIFIED_NAME, "ab", false, false));
validateContainer(container, "com.vaadin.data.BufferedValidatable",
- "com.vaadin.ui.TabSheet", "com.vaadin.client.Focusable",
+ "com.vaadin.ui.TabSheet",
+ "com.vaadin.terminal.gwt.client.Focusable",
"com.vaadin.data.Buffered", isFilteredOutItemNull(), 20);
// Filter by "contains da" (reversed as ad here)
@@ -329,8 +330,9 @@ public abstract class AbstractContainerTest extends TestCase {
validateContainer(container, "com.vaadin.data.Buffered",
"com.vaadin.server.ComponentSizeValidator",
"com.vaadin.data.util.IndexedContainer",
- "com.vaadin.client.ui.VUriFragmentUtility",
+ "com.vaadin.terminal.gwt.client.ui.VUriFragmentUtility",
isFilteredOutItemNull(), 37);
+
}
/**
@@ -481,98 +483,116 @@ public abstract class AbstractContainerTest extends TestCase {
"com.vaadin.server.ErrorMessage",
"com.vaadin.server.ExternalResource",
"com.vaadin.server.FileResource",
- "com.vaadin.client.ApplicationConfiguration",
- "com.vaadin.client.ApplicationConnection",
- "com.vaadin.client.BrowserInfo",
- "com.vaadin.client.ClientExceptionHandler",
- "com.vaadin.client.ComponentDetail",
- "com.vaadin.client.ComponentDetailMap",
- "com.vaadin.client.ComponentLocator", "com.vaadin.client.Console",
- "com.vaadin.client.Container",
- "com.vaadin.client.ContainerResizedListener",
- "com.vaadin.client.CSSRule", "com.vaadin.client.DateTimeService",
- "com.vaadin.client.DefaultWidgetSet",
- "com.vaadin.client.Focusable",
- "com.vaadin.client.HistoryImplIEVaadin",
- "com.vaadin.client.LocaleNotLoadedException",
- "com.vaadin.client.LocaleService",
- "com.vaadin.client.MouseEventDetails",
- "com.vaadin.client.NullConsole", "com.vaadin.client.Paintable",
- "com.vaadin.client.RenderInformation",
- "com.vaadin.client.RenderSpace",
- "com.vaadin.client.StyleConstants",
- "com.vaadin.client.TooltipInfo", "com.vaadin.client.ui.Action",
- "com.vaadin.client.ui.ActionOwner",
- "com.vaadin.client.ui.AlignmentInfo",
- "com.vaadin.client.ui.CalendarEntry",
- "com.vaadin.client.ui.ClickEventHandler",
- "com.vaadin.client.ui.Field", "com.vaadin.client.ui.Icon",
- "com.vaadin.client.ui.layout.CellBasedLayout",
- "com.vaadin.client.ui.layout.ChildComponentContainer",
- "com.vaadin.client.ui.layout.Margins",
- "com.vaadin.client.ui.LayoutClickEventHandler",
- "com.vaadin.client.ui.MenuBar", "com.vaadin.client.ui.MenuItem",
- "com.vaadin.client.ui.richtextarea.VRichTextArea",
- "com.vaadin.client.ui.richtextarea.VRichTextToolbar",
- "com.vaadin.client.ui.ShortcutActionHandler",
- "com.vaadin.client.ui.SubPartAware", "com.vaadin.client.ui.Table",
- "com.vaadin.client.ui.TreeAction",
- "com.vaadin.client.ui.TreeImages",
- "com.vaadin.client.ui.VAbsoluteLayout",
- "com.vaadin.client.ui.VAccordion", "com.vaadin.client.ui.VButton",
- "com.vaadin.client.ui.VCalendarPanel",
- "com.vaadin.client.ui.VCheckBox",
- "com.vaadin.client.ui.VContextMenu",
- "com.vaadin.client.ui.VCssLayout",
- "com.vaadin.client.ui.VCustomComponent",
- "com.vaadin.client.ui.VCustomLayout",
- "com.vaadin.client.ui.VDateField",
- "com.vaadin.client.ui.VDateFieldCalendar",
- "com.vaadin.client.ui.VEmbedded",
- "com.vaadin.client.ui.VFilterSelect", "com.vaadin.client.ui.VForm",
- "com.vaadin.client.ui.VFormLayout",
- "com.vaadin.client.ui.VGridLayout",
- "com.vaadin.client.ui.VHorizontalLayout",
- "com.vaadin.client.ui.VLabel", "com.vaadin.client.ui.VLink",
- "com.vaadin.client.ui.VListSelect",
- "com.vaadin.client.ui.VMarginInfo",
- "com.vaadin.client.ui.VMenuBar",
- "com.vaadin.client.ui.VNativeButton",
- "com.vaadin.client.ui.VNativeSelect",
- "com.vaadin.client.ui.VNotification",
- "com.vaadin.client.ui.VOptionGroup",
- "com.vaadin.client.ui.VOptionGroupBase",
- "com.vaadin.client.ui.VOrderedLayout",
- "com.vaadin.client.ui.VOverlay", "com.vaadin.client.ui.VPanel",
- "com.vaadin.client.ui.VPasswordField",
- "com.vaadin.client.ui.VPopupCalendar",
- "com.vaadin.client.ui.VPopupView",
- "com.vaadin.client.ui.VProgressIndicator",
- "com.vaadin.client.ui.VScrollTable",
- "com.vaadin.client.ui.VSlider", "com.vaadin.client.ui.VSplitPanel",
- "com.vaadin.client.ui.VSplitPanelHorizontal",
- "com.vaadin.client.ui.VSplitPanelVertical",
- "com.vaadin.client.ui.VTablePaging",
- "com.vaadin.client.ui.VTabsheet",
- "com.vaadin.client.ui.VTabsheetBase",
- "com.vaadin.client.ui.VTabsheetPanel",
- "com.vaadin.client.ui.VTextArea",
- "com.vaadin.client.ui.VTextField",
- "com.vaadin.client.ui.VTextualDate", "com.vaadin.client.ui.VTime",
- "com.vaadin.client.ui.VTree",
- "com.vaadin.client.ui.VTwinColSelect",
- "com.vaadin.client.ui.VUnknownComponent",
- "com.vaadin.client.ui.VUpload",
- "com.vaadin.client.ui.VUriFragmentUtility",
- "com.vaadin.client.ui.VVerticalLayout",
- "com.vaadin.client.ui.VView", "com.vaadin.client.ui.VWindow",
- "com.vaadin.client.UIDL", "com.vaadin.client.Util",
- "com.vaadin.client.ValueMap", "com.vaadin.client.VCaption",
- "com.vaadin.client.VCaptionWrapper",
- "com.vaadin.client.VDebugConsole",
- "com.vaadin.client.VErrorMessage", "com.vaadin.client.VTooltip",
- "com.vaadin.client.VUIDLBrowser", "com.vaadin.client.WidgetMap",
- "com.vaadin.client.WidgetSet",
+ "com.vaadin.terminal.gwt.client.ApplicationConfiguration",
+ "com.vaadin.terminal.gwt.client.ApplicationConnection",
+ "com.vaadin.terminal.gwt.client.BrowserInfo",
+ "com.vaadin.terminal.gwt.client.ClientExceptionHandler",
+ "com.vaadin.terminal.gwt.client.ComponentDetail",
+ "com.vaadin.terminal.gwt.client.ComponentDetailMap",
+ "com.vaadin.terminal.gwt.client.ComponentLocator",
+ "com.vaadin.terminal.gwt.client.Console",
+ "com.vaadin.terminal.gwt.client.Container",
+ "com.vaadin.terminal.gwt.client.ContainerResizedListener",
+ "com.vaadin.terminal.gwt.client.CSSRule",
+ "com.vaadin.terminal.gwt.client.DateTimeService",
+ "com.vaadin.terminal.gwt.client.DefaultWidgetSet",
+ "com.vaadin.terminal.gwt.client.Focusable",
+ "com.vaadin.terminal.gwt.client.HistoryImplIEVaadin",
+ "com.vaadin.terminal.gwt.client.LocaleNotLoadedException",
+ "com.vaadin.terminal.gwt.client.LocaleService",
+ "com.vaadin.terminal.gwt.client.MouseEventDetails",
+ "com.vaadin.terminal.gwt.client.NullConsole",
+ "com.vaadin.terminal.gwt.client.Paintable",
+ "com.vaadin.terminal.gwt.client.RenderInformation",
+ "com.vaadin.terminal.gwt.client.RenderSpace",
+ "com.vaadin.terminal.gwt.client.StyleConstants",
+ "com.vaadin.terminal.gwt.client.TooltipInfo",
+ "com.vaadin.terminal.gwt.client.ui.Action",
+ "com.vaadin.terminal.gwt.client.ui.ActionOwner",
+ "com.vaadin.terminal.gwt.client.ui.AlignmentInfo",
+ "com.vaadin.terminal.gwt.client.ui.CalendarEntry",
+ "com.vaadin.terminal.gwt.client.ui.ClickEventHandler",
+ "com.vaadin.terminal.gwt.client.ui.Field",
+ "com.vaadin.terminal.gwt.client.ui.Icon",
+ "com.vaadin.terminal.gwt.client.ui.layout.CellBasedLayout",
+ "com.vaadin.terminal.gwt.client.ui.layout.ChildComponentContainer",
+ "com.vaadin.terminal.gwt.client.ui.layout.Margins",
+ "com.vaadin.terminal.gwt.client.ui.LayoutClickEventHandler",
+ "com.vaadin.terminal.gwt.client.ui.MenuBar",
+ "com.vaadin.terminal.gwt.client.ui.MenuItem",
+ "com.vaadin.terminal.gwt.client.ui.richtextarea.VRichTextArea",
+ "com.vaadin.terminal.gwt.client.ui.richtextarea.VRichTextToolbar",
+ "com.vaadin.terminal.gwt.client.ui.ShortcutActionHandler",
+ "com.vaadin.terminal.gwt.client.ui.SubPartAware",
+ "com.vaadin.terminal.gwt.client.ui.Table",
+ "com.vaadin.terminal.gwt.client.ui.TreeAction",
+ "com.vaadin.terminal.gwt.client.ui.TreeImages",
+ "com.vaadin.terminal.gwt.client.ui.VAbsoluteLayout",
+ "com.vaadin.terminal.gwt.client.ui.VAccordion",
+ "com.vaadin.terminal.gwt.client.ui.VButton",
+ "com.vaadin.terminal.gwt.client.ui.VCalendarPanel",
+ "com.vaadin.terminal.gwt.client.ui.VCheckBox",
+ "com.vaadin.terminal.gwt.client.ui.VContextMenu",
+ "com.vaadin.terminal.gwt.client.ui.VCssLayout",
+ "com.vaadin.terminal.gwt.client.ui.VCustomComponent",
+ "com.vaadin.terminal.gwt.client.ui.VCustomLayout",
+ "com.vaadin.terminal.gwt.client.ui.VDateField",
+ "com.vaadin.terminal.gwt.client.ui.VDateFieldCalendar",
+ "com.vaadin.terminal.gwt.client.ui.VEmbedded",
+ "com.vaadin.terminal.gwt.client.ui.VFilterSelect",
+ "com.vaadin.terminal.gwt.client.ui.VForm",
+ "com.vaadin.terminal.gwt.client.ui.VFormLayout",
+ "com.vaadin.terminal.gwt.client.ui.VGridLayout",
+ "com.vaadin.terminal.gwt.client.ui.VHorizontalLayout",
+ "com.vaadin.terminal.gwt.client.ui.VLabel",
+ "com.vaadin.terminal.gwt.client.ui.VLink",
+ "com.vaadin.terminal.gwt.client.ui.VListSelect",
+ "com.vaadin.terminal.gwt.client.ui.VMarginInfo",
+ "com.vaadin.terminal.gwt.client.ui.VMenuBar",
+ "com.vaadin.terminal.gwt.client.ui.VNativeButton",
+ "com.vaadin.terminal.gwt.client.ui.VNativeSelect",
+ "com.vaadin.terminal.gwt.client.ui.VNotification",
+ "com.vaadin.terminal.gwt.client.ui.VOptionGroup",
+ "com.vaadin.terminal.gwt.client.ui.VOptionGroupBase",
+ "com.vaadin.terminal.gwt.client.ui.VOrderedLayout",
+ "com.vaadin.terminal.gwt.client.ui.VOverlay",
+ "com.vaadin.terminal.gwt.client.ui.VPanel",
+ "com.vaadin.terminal.gwt.client.ui.VPasswordField",
+ "com.vaadin.terminal.gwt.client.ui.VPopupCalendar",
+ "com.vaadin.terminal.gwt.client.ui.VPopupView",
+ "com.vaadin.terminal.gwt.client.ui.VProgressIndicator",
+ "com.vaadin.terminal.gwt.client.ui.VScrollTable",
+ "com.vaadin.terminal.gwt.client.ui.VSlider",
+ "com.vaadin.terminal.gwt.client.ui.VSplitPanel",
+ "com.vaadin.terminal.gwt.client.ui.VSplitPanelHorizontal",
+ "com.vaadin.terminal.gwt.client.ui.VSplitPanelVertical",
+ "com.vaadin.terminal.gwt.client.ui.VTablePaging",
+ "com.vaadin.terminal.gwt.client.ui.VTabsheet",
+ "com.vaadin.terminal.gwt.client.ui.VTabsheetBase",
+ "com.vaadin.terminal.gwt.client.ui.VTabsheetPanel",
+ "com.vaadin.terminal.gwt.client.ui.VTextArea",
+ "com.vaadin.terminal.gwt.client.ui.VTextField",
+ "com.vaadin.terminal.gwt.client.ui.VTextualDate",
+ "com.vaadin.terminal.gwt.client.ui.VTime",
+ "com.vaadin.terminal.gwt.client.ui.VTree",
+ "com.vaadin.terminal.gwt.client.ui.VTwinColSelect",
+ "com.vaadin.terminal.gwt.client.ui.VUnknownComponent",
+ "com.vaadin.terminal.gwt.client.ui.VUpload",
+ "com.vaadin.terminal.gwt.client.ui.VUriFragmentUtility",
+ "com.vaadin.terminal.gwt.client.ui.VVerticalLayout",
+ "com.vaadin.terminal.gwt.client.ui.VView",
+ "com.vaadin.terminal.gwt.client.ui.VWindow",
+ "com.vaadin.terminal.gwt.client.UIDL",
+ "com.vaadin.terminal.gwt.client.Util",
+ "com.vaadin.terminal.gwt.client.ValueMap",
+ "com.vaadin.terminal.gwt.client.VCaption",
+ "com.vaadin.terminal.gwt.client.VCaptionWrapper",
+ "com.vaadin.terminal.gwt.client.VDebugConsole",
+ "com.vaadin.terminal.gwt.client.VErrorMessage",
+ "com.vaadin.terminal.gwt.client.VTooltip",
+ "com.vaadin.terminal.gwt.client.VUIDLBrowser",
+ "com.vaadin.terminal.gwt.client.WidgetMap",
+ "com.vaadin.terminal.gwt.client.WidgetSet",
"com.vaadin.server.AbstractApplicationPortlet",
"com.vaadin.server.AbstractApplicationServlet",
"com.vaadin.server.AbstractCommunicationManager",
@@ -645,5 +665,4 @@ public abstract class AbstractContainerTest extends TestCase {
"com.vaadin.ui.Upload", "com.vaadin.ui.UriFragmentUtility",
"com.vaadin.ui.VerticalLayout", "com.vaadin.ui.Window",
"com.vaadin.util.SerializerHelper", "org.vaadin.test.LastClass" };
-
}
diff --git a/server/tests/src/com/vaadin/tests/server/component/tree/TestHasChildren.java b/server/tests/src/com/vaadin/tests/server/component/tree/TestHasChildren.java
deleted file mode 100644
index 66535d3ffb..0000000000
--- a/server/tests/src/com/vaadin/tests/server/component/tree/TestHasChildren.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package com.vaadin.tests.server.component.tree;
-
-import junit.framework.TestCase;
-
-import com.vaadin.ui.Tree;
-
-public class TestHasChildren extends TestCase {
-
- private Tree tree;
-
- @Override
- protected void setUp() {
- tree = new Tree();
- tree.addItem("parent");
- tree.addItem("child");
- tree.setChildrenAllowed("parent", true);
- tree.setParent("child", "parent");
- }
-
- public void testRemoveChildren() {
- assertTrue(tree.hasChildren("parent"));
- tree.removeItem("child");
- assertFalse(tree.hasChildren("parent"));
- }
-}
diff --git a/server/tests/src/com/vaadin/tests/server/component/tree/TreeTest.java b/server/tests/src/com/vaadin/tests/server/component/tree/TreeTest.java
new file mode 100644
index 0000000000..16a7091947
--- /dev/null
+++ b/server/tests/src/com/vaadin/tests/server/component/tree/TreeTest.java
@@ -0,0 +1,74 @@
+package com.vaadin.tests.server.component.tree;
+
+import junit.framework.TestCase;
+
+import com.vaadin.data.Container;
+import com.vaadin.data.util.HierarchicalContainer;
+import com.vaadin.data.util.IndexedContainer;
+import com.vaadin.ui.Tree;
+
+public class TreeTest extends TestCase {
+
+ private Tree tree;
+ private Tree tree2;
+ private Tree tree3;
+ private Tree tree4;
+
+ @Override
+ protected void setUp() {
+ tree = new Tree();
+ tree.addItem("parent");
+ tree.addItem("child");
+ tree.setChildrenAllowed("parent", true);
+ tree.setParent("child", "parent");
+
+ tree2 = new Tree("Caption");
+ tree2.addItem("parent");
+ tree2.addItem("child");
+ tree2.setChildrenAllowed("parent", true);
+ tree2.setParent("child", "parent");
+
+ tree3 = new Tree("Caption", null);
+ tree3.addItem("parent");
+ tree3.addItem("child");
+ tree3.setChildrenAllowed("parent", true);
+ tree3.setParent("child", "parent");
+
+ tree4 = new Tree("Caption", new IndexedContainer());
+ tree4.addItem("parent");
+ tree4.addItem("child");
+ tree4.setChildrenAllowed("parent", true);
+ tree4.setParent("child", "parent");
+ }
+
+ public void testRemoveChildren() {
+ assertTrue(tree.hasChildren("parent"));
+ tree.removeItem("child");
+ assertFalse(tree.hasChildren("parent"));
+
+ assertTrue(tree2.hasChildren("parent"));
+ tree2.removeItem("child");
+ assertFalse(tree2.hasChildren("parent"));
+
+ assertTrue(tree3.hasChildren("parent"));
+ tree3.removeItem("child");
+ assertFalse(tree3.hasChildren("parent"));
+
+ assertTrue(tree4.hasChildren("parent"));
+ tree4.removeItem("child");
+ assertFalse(tree4.hasChildren("parent"));
+ }
+
+ public void testContainerTypeIsHierarchical() {
+ assertTrue(HierarchicalContainer.class.isAssignableFrom(tree
+ .getContainerDataSource().getClass()));
+ assertTrue(HierarchicalContainer.class.isAssignableFrom(tree2
+ .getContainerDataSource().getClass()));
+ assertTrue(HierarchicalContainer.class.isAssignableFrom(tree3
+ .getContainerDataSource().getClass()));
+ assertFalse(HierarchicalContainer.class.isAssignableFrom(tree4
+ .getContainerDataSource().getClass()));
+ assertTrue(Container.Hierarchical.class.isAssignableFrom(tree4
+ .getContainerDataSource().getClass()));
+ }
+}