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 File: DecisionFlowValueChangeListenerTest.java    From cia with 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 File: RuleViolationPageItemRendererClickListenerTest.java    From cia with 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 File: RuleViolationPageItemRendererClickListenerTest.java    From cia with 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 File: PageItemPropertyClickListenerTest.java    From cia with 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 File: ComplianceCheckPageItemRendererClickListenerTest.java    From cia with 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 File: ComplianceCheckPageItemRendererClickListenerTest.java    From cia with 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 File: MainLayout.java    From designer-tutorials with 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 File: QuestionnairesUI.java    From gazpachoquest with 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 File: SimpleApplicationUI.java    From jdal with 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 File: MainLayout.java    From designer-tutorials with 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 File: NavigatorAction.java    From jdal with 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);
}