Package com.vaadin.navigator

Examples of com.vaadin.navigator.ViewDisplay


        final HorizontalSplitPanel rootLayout = new HorizontalSplitPanel();
        rootLayout.setStyleName(Reindeer.SPLITPANEL_SMALL);
        rootLayout.setSizeFull();
        setContent(rootLayout);

        final Navigator navigator = new Navigator(this, new ViewDisplay() {
            @Override
            public void showView(View view) {
                System.out.println("Showing view " + view);
                rootLayout.setSecondComponent((com.vaadin.ui.Component) view);
            }
View Full Code Here


    public void testBasicNavigation() {
        IMocksControl control = EasyMock.createControl();
        NavigationStateManager manager = control
                .createMock(NavigationStateManager.class);
        ViewDisplay display = control.createMock(ViewDisplay.class);
        ViewProvider provider = control.createMock(ViewProvider.class);
        View view1 = control.createMock(View.class);
        View view2 = control.createMock(View.class);

        // prepare mocks: what to expect
        manager.setNavigator(EasyMock.anyObject(Navigator.class));

        EasyMock.expect(provider.getViewName("test1")).andReturn("test1");
        EasyMock.expect(provider.getView("test1")).andReturn(view1);
        EasyMock.expect(manager.getState()).andReturn("");
        view1.enter(eventParametersEqual(""));
        display.showView(view1);
        manager.setState("test1");
        EasyMock.expect(manager.getState()).andReturn("test1");

        EasyMock.expect(provider.getViewName("test2/")).andReturn("test2");
        EasyMock.expect(provider.getView("test2")).andReturn(view2);
        EasyMock.expect(manager.getState()).andReturn("test1");
        view2.enter(eventParametersEqual(""));
        display.showView(view2);
        manager.setState("test2");
        EasyMock.expect(manager.getState()).andReturn("test2");

        EasyMock.expect(provider.getViewName("test1/params"))
                .andReturn("test1");
        EasyMock.expect(provider.getView("test1")).andReturn(view1);
        EasyMock.expect(manager.getState()).andReturn("test2");
        view1.enter(eventParametersEqual("params"));
        display.showView(view1);
        manager.setState("test1/params");
        EasyMock.expect(manager.getState()).andReturn("test1/params");

        control.replay();
View Full Code Here

    public void testMainView() {
        IMocksControl control = EasyMock.createControl();
        NavigationStateManager manager = control
                .createMock(NavigationStateManager.class);
        ViewDisplay display = control.createMock(ViewDisplay.class);
        ViewProvider provider = control.createMock(ViewProvider.class);
        View view1 = control.createMock(View.class);
        View view2 = control.createMock(View.class);

        // prepare mocks: what to expect
        manager.setNavigator(EasyMock.anyObject(Navigator.class));

        EasyMock.expect(provider.getViewName("test2")).andReturn("test2");
        EasyMock.expect(provider.getView("test2")).andReturn(view2);
        EasyMock.expect(manager.getState()).andReturn("view1");
        view2.enter(eventParametersEqual(""));
        display.showView(view2);
        manager.setState("test2");

        EasyMock.expect(provider.getViewName("")).andReturn("test1");
        EasyMock.expect(provider.getView("test1")).andReturn(view1);
        EasyMock.expect(manager.getState()).andReturn("");
        view1.enter(eventParametersEqual(""));
        display.showView(view1);
        manager.setState("test1");

        EasyMock.expect(provider.getViewName("test1/params"))
                .andReturn("test1");
        EasyMock.expect(provider.getView("test1")).andReturn(view1);
        EasyMock.expect(manager.getState()).andReturn("test2");
        view1.enter(eventParametersEqual("params"));
        display.showView(view1);
        manager.setState("test1/params");

        control.replay();

        // create and test navigator
View Full Code Here

    public void testListeners() {
        IMocksControl control = EasyMock.createControl();
        NavigationStateManager manager = control
                .createMock(NavigationStateManager.class);
        ViewDisplay display = control.createMock(ViewDisplay.class);
        ViewProvider provider = control.createMock(ViewProvider.class);
        View view1 = control.createMock(View.class);
        View view2 = control.createMock(View.class);
        ViewChangeTestListener listener = new ViewChangeTestListener();

        // create navigator to test
        Navigator navigator = createNavigator(manager, display);

        // prepare mocks: what to expect
        EasyMock.expect(provider.getViewName("test1")).andReturn("test1");
        EasyMock.expect(provider.getView("test1")).andReturn(view1);
        ViewChangeEvent event1 = new ViewChangeEvent(navigator, null, view1,
                "test1", "");
        listener.addExpectedIsViewChangeAllowed(event1, true);
        EasyMock.expect(manager.getState()).andReturn("");
        view1.enter(eventParametersEqual(""));
        display.showView(view1);
        manager.setState("test1");
        listener.addExpectedNavigatorViewChange(event1);

        EasyMock.expect(provider.getViewName("test2")).andReturn("test2");
        EasyMock.expect(provider.getView("test2")).andReturn(view2);
        ViewChangeEvent event2 = new ViewChangeEvent(navigator, view1, view2,
                "test2", "");
        listener.addExpectedIsViewChangeAllowed(event2, true);
        EasyMock.expect(manager.getState()).andReturn("test1");
        view2.enter(eventParametersEqual(""));
        display.showView(view2);
        manager.setState("test2");
        listener.addExpectedNavigatorViewChange(event2);

        control.replay();
View Full Code Here

        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);
View Full Code Here

    public void testBlockNavigation() {
        IMocksControl control = EasyMock.createControl();
        NavigationStateManager manager = control
                .createMock(NavigationStateManager.class);
        ViewDisplay display = control.createMock(ViewDisplay.class);
        ViewProvider provider = control.createMock(ViewProvider.class);
        View view1 = control.createMock(View.class);
        View view2 = control.createMock(View.class);
        ViewChangeTestListener listener1 = new ViewChangeTestListener();
        ViewChangeTestListener listener2 = new ViewChangeTestListener();

        Navigator navigator = createNavigator(manager, display);

        // prepare mocks: what to expect
        // first listener blocks first view change
        EasyMock.expect(provider.getViewName("test1")).andReturn("test1");
        EasyMock.expect(provider.getView("test1")).andReturn(view1);
        EasyMock.expect(manager.getState()).andReturn("");
        ViewChangeEvent event1 = new ViewChangeEvent(navigator, null, view1,
                "test1", "");
        listener1.addExpectedIsViewChangeAllowed(event1, false);

        // second listener blocks second view change
        EasyMock.expect(provider.getViewName("test1/test")).andReturn("test1");
        EasyMock.expect(provider.getView("test1")).andReturn(view1);
        EasyMock.expect(manager.getState()).andReturn("");
        ViewChangeEvent event2 = new ViewChangeEvent(navigator, null, view1,
                "test1", "test");
        listener1.addExpectedIsViewChangeAllowed(event2, true);
        listener2.addExpectedIsViewChangeAllowed(event2, false);

        // both listeners allow view change
        EasyMock.expect(provider.getViewName("test1/bar")).andReturn("test1");
        EasyMock.expect(provider.getView("test1")).andReturn(view1);
        EasyMock.expect(manager.getState()).andReturn("");
        ViewChangeEvent event3 = new ViewChangeEvent(navigator, null, view1,
                "test1", "bar");
        listener1.addExpectedIsViewChangeAllowed(event3, true);
        listener2.addExpectedIsViewChangeAllowed(event3, true);
        view1.enter(EasyMock.isA(ViewChangeEvent.class));
        display.showView(view1);
        manager.setState("test1/bar");
        listener1.addExpectedNavigatorViewChange(event3);
        listener2.addExpectedNavigatorViewChange(event3);

        // both listeners allow view change from non-null view
        EasyMock.expect(provider.getViewName("test2")).andReturn("test2");
        EasyMock.expect(provider.getView("test2")).andReturn(view2);
        EasyMock.expect(manager.getState()).andReturn("view1");
        ViewChangeEvent event4 = new ViewChangeEvent(navigator, view1, view2,
                "test2", "");
        listener1.addExpectedIsViewChangeAllowed(event4, true);
        listener2.addExpectedIsViewChangeAllowed(event4, true);
        view2.enter(EasyMock.isA(ViewChangeEvent.class));
        display.showView(view2);
        manager.setState("test2");
        listener1.addExpectedNavigatorViewChange(event4);
        listener2.addExpectedNavigatorViewChange(event4);

        control.replay();
View Full Code Here

    public void testShowViewEnterOrder() {
        IMocksControl control = EasyMock.createStrictControl();

        View view = control.createMock(View.class);
        ViewDisplay display = control.createMock(ViewDisplay.class);

        display.showView(view);
        view.enter(EasyMock.anyObject(ViewChangeEvent.class));

        control.replay();

        NavigationStateManager manager = EasyMock
View Full Code Here

TOP

Related Classes of com.vaadin.navigator.ViewDisplay

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.