]> source.dussan.org Git - vaadin-framework.git/commitdiff
#7129 Properly clean up "filteredParent" when removing filters
authorArtur Signell <artur.signell@itmill.com>
Tue, 7 Jun 2011 06:09:33 +0000 (06:09 +0000)
committerArtur Signell <artur.signell@itmill.com>
Tue, 7 Jun 2011 06:09:33 +0000 (06:09 +0000)
svn changeset:19247/svn branch:6.6

src/com/vaadin/data/util/HierarchicalContainer.java
tests/src/com/vaadin/tests/server/container/TestHierarchicalContainer.java

index e208d07dc68cdd06a32a0b0e46c8fe7817e17ae5..21f7d046030504e256a332892b404673e32f19ef 100644 (file)
@@ -650,6 +650,7 @@ public class HierarchicalContainer extends IndexedContainer implements
             // All filters removed
             filteredRoots = null;
             filteredChildren = null;
+            filteredParent = null;
 
             return super.doFilterContainer(hasFilters);
         }
index 12255ad83547548e05f9855ea7764e47453aaf99..8f77b25e688fb8aa5f0576f011a5ceb5edad1502 100644 (file)
@@ -49,6 +49,49 @@ public class TestHierarchicalContainer extends
 \r
     }\r
 \r
+    public void testParentWhenRemovingFilterFromContainer() {\r
+        HierarchicalContainer container = new HierarchicalContainer();\r
+        initializeContainer(container);\r
+        container.setIncludeParentsWhenFiltering(true);\r
+        container.addContainerFilter(FULLY_QUALIFIED_NAME, "ab", false, false);\r
+        Object p1 = container.getParent("com.vaadin.ui.TabSheet");\r
+        assertEquals("com.vaadin.ui", p1);\r
+        p1 = container\r
+                .getParent("com.vaadin.terminal.gwt.client.ui.VPopupCalendar");\r
+        assertNull(p1);\r
+        container.removeAllContainerFilters();\r
+        p1 = container\r
+                .getParent("com.vaadin.terminal.gwt.client.ui.VPopupCalendar");\r
+        assertEquals("com.vaadin.terminal.gwt.client.ui", p1);\r
+\r
+    }\r
+\r
+    public void testChangeParentInFilteredContainer() {\r
+        HierarchicalContainer container = new HierarchicalContainer();\r
+        initializeContainer(container);\r
+        container.setIncludeParentsWhenFiltering(true);\r
+        container.addContainerFilter(FULLY_QUALIFIED_NAME, "Tab", false, false);\r
+\r
+        // Change parent of filtered item\r
+        Object p1 = container.getParent("com.vaadin.ui.TabSheet");\r
+        assertEquals("com.vaadin.ui", p1);\r
+        container.setParent("com.vaadin.ui.TabSheet", "com.vaadin");\r
+        p1 = container.getParent("com.vaadin.ui.TabSheet");\r
+        assertEquals("com.vaadin", p1);\r
+        container.setParent("com.vaadin.ui.TabSheet", "com");\r
+        p1 = container.getParent("com.vaadin.ui.TabSheet");\r
+        assertEquals("com", p1);\r
+        container.setParent("com.vaadin.ui.TabSheet", null);\r
+        p1 = container.getParent("com.vaadin.ui.TabSheet");\r
+        assertNull(p1);\r
+\r
+        // root -> non-root\r
+        container.setParent("com.vaadin.ui.TabSheet", "com");\r
+        p1 = container.getParent("com.vaadin.ui.TabSheet");\r
+        assertEquals("com", p1);\r
+\r
+    }\r
+\r
     public void testHierarchicalFilteringWithParents() {\r
         HierarchicalContainer container = new HierarchicalContainer();\r
         initializeContainer(container);\r