com.vaadin.navigator.Navigator Java Examples

The following examples show how to use com.vaadin.navigator.Navigator. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: cia   Author: Hack23   File: DecisionFlowValueChangeListenerTest.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Selection value change test.
 */
@Test
public void selectionValueChangeTest() {
	final String pageName = "pageName";
	final String pageId = "pageId";
	final DecisionFlowValueChangeListener listener = new DecisionFlowValueChangeListener(pageName, pageId);
	final UI uiMock = Mockito.mock(UI.class);
	UI.setCurrent(uiMock);
	
	final Navigator navigatorMock = Mockito.mock(Navigator.class);
	Mockito.when(uiMock.getNavigator()).thenReturn(navigatorMock);		
			
	final ValueChangeEvent event = Mockito.mock(ValueChangeEvent.class);
	
	final HasValue hasValue = Mockito.mock(HasValue.class);
	Mockito.when(hasValue.isEmpty()).thenReturn(false);
	
	Mockito.when(event.getSource()).thenReturn(hasValue);
	
	final String value = "value";
	Mockito.when(event.getValue()).thenReturn("value");
		
	listener.valueChange(event);
	
	Mockito.verify(navigatorMock, times(1)).navigateTo(pageName + "/CHARTS/DECISION_FLOW_CHART/" + pageId + "[" +value + "]");
}
 
Example #2
Source Project: cia   Author: Hack23   File: RuleViolationPageItemRendererClickListenerTest.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Click party test.
 */
@Test
public void clickPartyTest() {
	final RuleViolationPageItemRendererClickListener listener = new RuleViolationPageItemRendererClickListener();
	final UI uiMock = Mockito.mock(UI.class);
	UI.setCurrent(uiMock);
	
	final Navigator navigatorMock = Mockito.mock(Navigator.class);
	Mockito.when(uiMock.getNavigator()).thenReturn(navigatorMock);		
			
	final RendererClickEvent event = Mockito.mock(RendererClickEvent.class);
	Mockito.when(event.getItem()).thenReturn(new RuleViolation("partyid", null, ResourceType.PARTY, null, null, null, null, null));
		
	listener.click(event);
	
	Mockito.verify(navigatorMock, times(1)).navigateTo("party/partyid");
}
 
Example #3
Source Project: cia   Author: Hack23   File: RuleViolationPageItemRendererClickListenerTest.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Click politician test.
 */
@Test
public void clickPoliticianTest() {
	final RuleViolationPageItemRendererClickListener listener = new RuleViolationPageItemRendererClickListener();
	final UI uiMock = Mockito.mock(UI.class);
	UI.setCurrent(uiMock);
	
	final Navigator navigatorMock = Mockito.mock(Navigator.class);
	Mockito.when(uiMock.getNavigator()).thenReturn(navigatorMock);		
			
	final RendererClickEvent event = Mockito.mock(RendererClickEvent.class);
	Mockito.when(event.getItem()).thenReturn(new RuleViolation("personid", null, ResourceType.POLITICIAN, null, null, null, null, null));
		
	listener.click(event);
	
	Mockito.verify(navigatorMock, times(1)).navigateTo("politician/personid");
}
 
Example #4
Source Project: cia   Author: Hack23   File: PageItemPropertyClickListenerTest.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Check correct page id click success test.
 */
@Test
public void checkCorrectPageIdClickSuccessTest() {
	final PageItemPropertyClickListener pageItemPropertyClickListener = new PageItemPropertyClickListener(UserViews.POLITICIAN_VIEW_NAME,"personId");

	final String personIdValue = "personId";
	final ViewRiksdagenPolitician riksdagenPolitician = new ViewRiksdagenPolitician().withPersonId(personIdValue);
	final String pageId = pageItemPropertyClickListener.getPageId(riksdagenPolitician);

	assertEquals(personIdValue, pageId);
	
	final UI uiMock = Mockito.mock(UI.class);
	UI.setCurrent(uiMock);
	
	final Navigator navigatorMock = Mockito.mock(Navigator.class);
	Mockito.when(uiMock.getNavigator()).thenReturn(navigatorMock);		
			
	pageItemPropertyClickListener.click(new RendererClickEvent(new Grid(), riksdagenPolitician, null, null) {

		/**
		 * 
		 */
		private static final long serialVersionUID = 1L;});
	
	Mockito.verify(navigatorMock, times(1)).navigateTo(UserViews.POLITICIAN_VIEW_NAME + "/personId");
}
 
Example #5
Source Project: cia   Author: Hack23   File: ComplianceCheckPageItemRendererClickListenerTest.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Click party test.
 */
@Test
public void clickPartyTest() {
	final ComplianceCheckPageItemRendererClickListener listener = new ComplianceCheckPageItemRendererClickListener();
	final UI uiMock = Mockito.mock(UI.class);
	UI.setCurrent(uiMock);
	
	final Navigator navigatorMock = Mockito.mock(Navigator.class);
	Mockito.when(uiMock.getNavigator()).thenReturn(navigatorMock);		
			
	final RendererClickEvent event = Mockito.mock(RendererClickEvent.class);
	Mockito.when(event.getItem()).thenReturn(new PartyComplianceCheckImpl(new ViewRiksdagenPartySummary().withParty("partyid"), null, null, null));
		
	listener.click(event);
	
	Mockito.verify(navigatorMock, times(1)).navigateTo("party/partyid");
}
 
Example #6
Source Project: cia   Author: Hack23   File: ComplianceCheckPageItemRendererClickListenerTest.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Click politician test.
 */
@Test
public void clickPoliticianTest() {
	final ComplianceCheckPageItemRendererClickListener listener = new ComplianceCheckPageItemRendererClickListener();
	final UI uiMock = Mockito.mock(UI.class);
	UI.setCurrent(uiMock);
	
	final Navigator navigatorMock = Mockito.mock(Navigator.class);
	Mockito.when(uiMock.getNavigator()).thenReturn(navigatorMock);		
			
	final RendererClickEvent event = Mockito.mock(RendererClickEvent.class);
	Mockito.when(event.getItem()).thenReturn(new PoliticianComplianceCheckImpl(new ViewRiksdagenPolitician().withPersonId("personid"), null, null, null));
		
	listener.click(event);
	
	Mockito.verify(navigatorMock, times(1)).navigateTo("politician/personid");
}
 
Example #7
Source Project: designer-tutorials   Author: vaadin   File: MainLayout.java    License: Apache License 2.0 6 votes vote down vote up
public MainLayout() {
    Navigator navigator = new Navigator(UI.getCurrent(), contentPanel);
    navigator.addView(StatsView.VIEW_NAME, StatsView.class);
    navigator.addView(PluginsView.VIEW_NAME, PluginsView.class);
    navigator.addView(PermissionsView.VIEW_NAME, PermissionsView.class);

    menuButton1.addClickListener(event -> doNavigate(StatsView.VIEW_NAME));
    menuButton2
            .addClickListener(event -> doNavigate(PluginsView.VIEW_NAME));
    menuButton3.addClickListener(
            event -> doNavigate(PermissionsView.VIEW_NAME));

    if (navigator.getState().isEmpty()) {
        navigator.navigateTo(StatsView.VIEW_NAME);
    } else {
        navigator.navigateTo(navigator.getState());
    }
}
 
Example #8
Source Project: gazpachoquest   Author: antoniomaria   File: QuestionnairesUI.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public void init(VaadinRequest request) {
    logger.info("New Vaadin UI created");
    String invitation = request.getParameter("invitation");
    logger.info("Invitation: {} of sessions : {}", invitation);
    setSizeFull();
    GazpachoViewDisplay viewDisplay = new GazpachoViewDisplay();
    setContent(viewDisplay);

    navigator = new Navigator(this, (ViewDisplay) viewDisplay);
    navigator.addProvider(viewProvider);
    navigator.setErrorProvider(new GazpachoErrorViewProvider());

    if (isUserSignedIn()) {
        navigator.navigateTo(QuestionnaireView.NAME);
    } else {
        navigator.navigateTo(LoginView.NAME);
    }
}
 
Example #9
Source Project: jdal   Author: chelu   File: SimpleApplicationUI.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Build application main window
 */
protected void buildMain() {
	this.root.removeAllComponents();
	this.top.setWidth(100, Unit.PERCENTAGE);
	this.top.setSpacing(false);
	this.top.setMargin(false);
	this.top.addComponent(buttonBar);
	this.root.addComponent(top);
	this.root.addComponent(mainView);
	this.root.setSpacing(false);
	this.root.setMargin(false);
	this.root.setExpandRatio(top, 0);
	this.root.setExpandRatio(mainView, 1);
	Navigator navigator = new Navigator(this, mainView);
	navigator.addProvider(viewProvider);
}
 
Example #10
Source Project: designer-tutorials   Author: vaadin   File: MainLayout.java    License: Apache License 2.0 5 votes vote down vote up
public MainLayout() {
    navigator = new Navigator(UI.getCurrent(), (ViewDisplay) this);
    addNavigatorView(DashboardView.VIEW_NAME, DashboardView.class,
            menuButton1);
    addNavigatorView(OrderView.VIEW_NAME, OrderView.class, menuButton2);
    addNavigatorView(AboutView.VIEW_NAME, AboutView.class, menuButton3);
    if (navigator.getState().isEmpty()) {
        navigator.navigateTo(DashboardView.VIEW_NAME);
    }
}
 
Example #11
Source Project: jdal   Author: chelu   File: NavigatorAction.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void buttonClick(ClickEvent event) {
	Navigator navigator = UI.getCurrent().getNavigator();
	
	if (navigator != null)
		navigator.navigateTo(viewName);
}