]> source.dussan.org Git - vaadin-framework.git/commitdiff
Remove Navigator.SimpleViewDisplay (#9936) 27/127/2
authorJohannes Dahlström <johannesd@vaadin.com>
Tue, 16 Oct 2012 10:03:08 +0000 (13:03 +0300)
committerJohannes Dahlström <johannesd@vaadin.com>
Tue, 16 Oct 2012 10:25:39 +0000 (13:25 +0300)
Change-Id: I4c7e9ae14d7a50981d8da4909e6832d337fdf059

server/src/com/vaadin/navigator/Navigator.java
server/tests/src/com/vaadin/tests/server/navigator/NavigatorTest.java

index e4704bce6a5b52478198410f3c8b5bc8278042f0..72d6c65fd231829df96d17721abf7435f09519a9 100644 (file)
@@ -28,7 +28,6 @@ import com.vaadin.server.Page.FragmentChangedListener;
 import com.vaadin.ui.Component;
 import com.vaadin.ui.ComponentContainer;
 import com.vaadin.ui.CssLayout;
-import com.vaadin.ui.CustomComponent;
 import com.vaadin.ui.UI;
 
 /**
@@ -146,38 +145,6 @@ public class Navigator implements Serializable {
         }
     }
 
-    /**
-     * A ViewDisplay that is a component itself and replaces its contents with
-     * the view.
-     * <p>
-     * This display only supports views that are {@link Component}s themselves.
-     * Attempting to display a view that is not a component causes an exception
-     * to be thrown.
-     * <p>
-     * By default, the view display has full size.
-     */
-    public static class SimpleViewDisplay extends CustomComponent implements
-            ViewDisplay {
-
-        /**
-         * Create new {@link ViewDisplay} that is itself a component displaying
-         * the view.
-         */
-        public SimpleViewDisplay() {
-            setSizeFull();
-        }
-
-        @Override
-        public void showView(View view) {
-            if (view instanceof Component) {
-                setCompositionRoot((Component) view);
-            } else {
-                throw new IllegalArgumentException("View is not a component: "
-                        + view);
-            }
-        }
-    }
-
     /**
      * A ViewDisplay that replaces the contents of a {@link ComponentContainer}
      * with the active {@link View}.
index cf8a2870a9705c6f5a3c740b2d61dad32f5d0bf8..7e21b751dceec76a3413bcbb1fe76b521781b31c 100644 (file)
@@ -33,7 +33,9 @@ import com.vaadin.navigator.ViewDisplay;
 import com.vaadin.navigator.ViewProvider;
 import com.vaadin.tests.server.navigator.ClassBasedViewProviderTest.TestView;
 import com.vaadin.tests.server.navigator.ClassBasedViewProviderTest.TestView2;
+import com.vaadin.ui.Component;
 import com.vaadin.ui.UI;
+import com.vaadin.ui.VerticalLayout;
 
 public class NavigatorTest extends TestCase {
 
@@ -348,6 +350,34 @@ public class NavigatorTest extends TestCase {
         }
     }
 
+    public void testComponentContainerViewDisplay() {
+        abstract class TestView implements Component, View {
+        }
+
+        TestView tv1 = EasyMock.createNiceMock(TestView.class);
+        TestView tv2 = EasyMock.createNiceMock(TestView.class);
+        EasyMock.replay(tv1, tv2);
+
+        VerticalLayout container = new VerticalLayout();
+        ViewDisplay display = new Navigator.ComponentContainerViewDisplay(
+                container);
+        Navigator navigator = createNavigator(new NullFragmentManager(),
+                display);
+
+        navigator.addView("tv1", tv1);
+        navigator.addView("tv2", tv2);
+
+        navigator.navigateTo("tv1");
+
+        assertSame(tv1, container.getComponent(0));
+        assertEquals(1, container.getComponentCount());
+
+        navigator.navigateTo("tv2");
+
+        assertSame(tv2, container.getComponent(0));
+        assertEquals(1, container.getComponentCount());
+    }
+
     public void testBlockNavigation() {
         IMocksControl control = EasyMock.createControl();
         NavigationStateManager manager = control