Java Code Examples for com.vaadin.ui.Panel

The following examples show how to use com.vaadin.ui.Panel. These examples are extracted from open source projects. 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   Source File: LogoutClickListenerTest.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Show notification failure test.
 */
@Test
public void showNotificationFailureTest() {
	final LogoutRequest request = new LogoutRequest();		
	final LogoutClickListener listener = Mockito.spy(new LogoutClickListener(request));
	final ApplicationManager applicationManager = Mockito.mock(ApplicationManager.class);
	Mockito.doReturn(applicationManager).when(listener).getApplicationManager();
	
	final LogoutResponse response = new LogoutResponse(ServiceResult.FAILURE);
	response.setErrorMessage("errorMessage");
	Mockito.when(applicationManager.service(request)).thenReturn(response);
	
	Mockito.doNothing().when(listener).showNotification(ArgumentMatchers.anyString(), ArgumentMatchers.anyString(), ArgumentMatchers.any(Type.class));
	listener.buttonClick(new ClickEvent(new Panel()));
	Mockito.verify(listener).showNotification(ArgumentMatchers.anyString(), ArgumentMatchers.anyString(), ArgumentMatchers.any(Type.class));
}
 
Example 2
@Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
@Override
public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
	final VerticalLayout panelContent = createPanelContent();

	final String pageId = getPageId(parameters);
	getDocumentMenuItemFactory().createDocumentMenuBar(menuBar, pageId);

	createPageVisitHistory(NAME, pageId, panelContent);

	panel.setContent(panelContent);
	getPageActionEventHelper().createPageEvent(ViewAction.VISIT_DOCUMENT_VIEW, ApplicationEventGroup.USER, NAME,
			parameters, pageId);

	return panelContent;

}
 
Example 3
@Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
@Override
public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
	final VerticalLayout panelContent = createPanelContent();

	final String pageId = getPageId(parameters);
	final ViewRiksdagenPolitician viewRiksdagenPolitician = getItem(parameters);
	getPoliticianMenuItemFactory().createPoliticianMenuBar(menuBar, pageId);

	LabelFactory.createHeader2Label(panelContent, INDICATORS);

	politicianChartDataManager.createPersonLineChart(panelContent, viewRiksdagenPolitician.getPersonId());

	pageCompleted(parameters, panel, pageId, viewRiksdagenPolitician);
	return panelContent;

}
 
Example 4
/**
 * Creates the change password button.
 *
 * @return the vertical layout
 */
private VerticalLayout createChangePasswordButton() {

	final VerticalLayout formLayout = new VerticalLayout();
	formLayout.setSizeFull();

	final Panel formPanel = new Panel();
	formPanel.setSizeFull();

	formLayout.addComponent(formPanel);

	final FormLayout formContent = new FormLayout();
	formPanel.setContent(formContent);

	final ChangePasswordRequest request = new ChangePasswordRequest();
	request.setSessionId(RequestContextHolder.currentRequestAttributes().getSessionId());
	request.setCurrentPassword("");
	request.setNewPassword("");
	request.setRepeatNewPassword("");
	
	final ClickListener listener = new ChangePasswordClickListener(request);
	getFormFactory().addRequestInputFormFields(formContent, request,
			ChangePasswordRequest.class, Arrays.asList("currentPassword","newPassword","repeatNewPassword"), "Change password", listener);

	return formLayout;
}
 
Example 5
/**
 * Creates the enable google auth button.
 *
 * @return the vertical layout
 */
private VerticalLayout createEnableGoogleAuthButton() {
	final VerticalLayout formLayout = new VerticalLayout();
	formLayout.setSizeFull();

	final Panel formPanel = new Panel();
	formPanel.setSizeFull();

	formLayout.addComponent(formPanel);

	final FormLayout formContent = new FormLayout();
	formPanel.setContent(formContent);

	final SetGoogleAuthenticatorCredentialRequest request = new SetGoogleAuthenticatorCredentialRequest();
	request.setSessionId(RequestContextHolder.currentRequestAttributes().getSessionId());
	request.setUserpassword("");
	final ClickListener listener = new SetGoogleAuthenticatorCredentialClickListener(request);
	getFormFactory().addRequestInputFormFields(formContent, request, SetGoogleAuthenticatorCredentialRequest.class,
			AS_LIST, ENABLE_GOOGLE_AUTHENTICATOR, listener);

	return formLayout;
}
 
Example 6
Source Project: cia   Source File: SearchDocumentClickListenerTest.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Show notification failure test.
 */
@Test
public void showNotificationFailureTest() {
	final SearchDocumentRequest request = new SearchDocumentRequest();		
	final SearchDocumentClickListener listener = Mockito.spy(new SearchDocumentClickListener(request,null));
	final ApplicationManager applicationManager = Mockito.mock(ApplicationManager.class);
	Mockito.doReturn(applicationManager).when(listener).getApplicationManager();
	
	final SearchDocumentResponse response = new SearchDocumentResponse(ServiceResult.FAILURE);
	response.setErrorMessage("errorMessage");
	Mockito.when(applicationManager.service(request)).thenReturn(response);
	
	Mockito.doNothing().when(listener).showNotification(ArgumentMatchers.anyString(), ArgumentMatchers.anyString(), ArgumentMatchers.any(Type.class));
	listener.buttonClick(new ClickEvent(new Panel()));
	Mockito.verify(listener).showNotification(ArgumentMatchers.anyString(), ArgumentMatchers.anyString(), ArgumentMatchers.any(Type.class));
}
 
Example 7
@Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
@Override
public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
	final VerticalLayout panelContent = createPanelContent();

	final String pageId = getPageId(parameters);
	final ViewRiksdagenParty viewRiksdagenParty = getItem(parameters);
	getPartyMenuItemFactory().createPartyMenuBar(menuBar, pageId);

	LabelFactory.createHeader2Label(panelContent, CURRENT_MEMBERS);

	final DataContainer<ViewRiksdagenPolitician, String> politicianDataContainer = getApplicationManager()
			.getDataContainer(ViewRiksdagenPolitician.class);

	getGridFactory().createBasicBeanItemGrid(panelContent, ViewRiksdagenPolitician.class,
			politicianDataContainer.findListByProperty(
					new Object[] { viewRiksdagenParty.getPartyId(), Boolean.TRUE }, ViewRiksdagenPolitician_.party,
					ViewRiksdagenPolitician_.active),
			POLITICIANS, COLUMN_ORDER, HIDE_COLUMNS, LISTENER, null, null);

	pageCompleted(parameters, panel, pageId, viewRiksdagenParty);
	return panelContent;

}
 
Example 8
@Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
@Override
public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
	final VerticalLayout panelContent = createPanelContent();

	final String pageId = getPageId(parameters);
	final ViewRiksdagenParty viewRiksdagenParty = getItem(parameters);

	getPartyMenuItemFactory().createPartyMenuBar(menuBar, pageId);

	LabelFactory.createHeader2Label(panelContent, COMMITTEE_ROLES);

	final DataContainer<ViewRiksdagenCommitteeRoleMember, String> committeeRoleMemberDataContainer = getApplicationManager()
			.getDataContainer(ViewRiksdagenCommitteeRoleMember.class);

	getGridFactory().createBasicBeanItemGrid(panelContent, ViewRiksdagenCommitteeRoleMember.class,
			committeeRoleMemberDataContainer.findListByProperty(
					new Object[] { viewRiksdagenParty.getPartyId(), Boolean.TRUE },
					ViewRiksdagenCommitteeRoleMember_.party, ViewRiksdagenCommitteeRoleMember_.active),
			COMMITTEE_ROLES, COLUMN_ORDER, HIDE_COLUMNS, LISTENER, null, null);

	pageCompleted(parameters, panel, pageId, viewRiksdagenParty);
	return panelContent;

}
 
Example 9
@Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
@Override
public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
	final VerticalLayout panelContent = createPanelContent();

	final String pageId = getPageId(parameters);

	final ViewRiksdagenParty viewRiksdagenParty = getItem(parameters);
	getPartyMenuItemFactory().createPartyMenuBar(menuBar, pageId);

	LabelFactory.createHeader2Label(panelContent, MEMBER_HISTORY);

	final DataContainer<ViewRiksdagenPolitician, String> politicianDataContainer = getApplicationManager()
			.getDataContainer(ViewRiksdagenPolitician.class);

	getGridFactory().createBasicBeanItemGrid(panelContent, ViewRiksdagenPolitician.class,
			politicianDataContainer.getAllBy(ViewRiksdagenPolitician_.party, viewRiksdagenParty.getPartyId()),
			POLITICIANS, COLUMN_ORDER, HIDE_COLUMNS, LISTENER, null, null);

	pageCompleted(parameters, panel, pageId, viewRiksdagenParty);
	return panelContent;

}
 
Example 10
@Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
@Override
public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
	final VerticalLayout panelContent = createPanelContent();

	final String pageId = getPageId(parameters);
	final ViewRiksdagenParty viewRiksdagenParty = getItem(parameters);
	getPartyMenuItemFactory().createPartyMenuBar(menuBar, pageId);

	LabelFactory.createHeader2Label(panelContent, LEADER_HISTORY);

	final DataContainer<ViewRiksdagenPartyRoleMember, String> partyRoleMemberDataContainer = getApplicationManager()
			.getDataContainer(ViewRiksdagenPartyRoleMember.class);

	getGridFactory().createBasicBeanItemGrid(panelContent, ViewRiksdagenPartyRoleMember.class,
			partyRoleMemberDataContainer.getAllBy(ViewRiksdagenPartyRoleMember_.party,
					viewRiksdagenParty.getPartyId()),
			LEADER_HISTORY2, COLUMN_ORDER, HIDE_COLUMNS, LISTENER, null, null);

	pageCompleted(parameters, panel, pageId, viewRiksdagenParty);
	return panelContent;

}
 
Example 11
@Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
@Override
public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
	final VerticalLayout panelContent = createPanelContent();

	final String pageId = getPageId(parameters);

	final ViewRiksdagenParty viewRiksdagenParty = getItem(parameters);
	getPartyMenuItemFactory().createPartyMenuBar(menuBar, pageId);

	LabelFactory.createHeader2Label(panelContent, VOTE_HISTORY);

	getGridFactory().createBasicBeanItemNestedPropertiesGrid(panelContent,
			ViewRiksdagenVoteDataBallotPartySummary.class,
			viewRiksdagenVoteDataBallotPartySummaryChartDataManager.findByValue(pageId), BALLOTS, NESTED_PROPERTIES,
			COLUMN_ORDER, HIDE_COLUMNS, LISTENER, EMBEDDED_ID_BALLOT_ID, null);

	pageCompleted(parameters, panel, pageId, viewRiksdagenParty);
	return panelContent;

}
 
Example 12
@Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
@Override
public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
	final VerticalLayout panelContent = createPanelContent();

	final String pageId = getPageId(parameters);
	final ViewRiksdagenPolitician viewRiksdagenPolitician = getItem(parameters);
	getPoliticianMenuItemFactory().createPoliticianMenuBar(menuBar, pageId);

	LabelFactory.createHeader2Label(panelContent, PoliticianPageMode.VOTEHISTORY.toString());

	getGridFactory().createBasicBeanItemNestedPropertiesGrid(panelContent,
			ViewRiksdagenVoteDataBallotPoliticianSummary.class,
			viewRiksdagenVoteDataBallotPoliticianSummaryChartDataManager
					.findByValue(viewRiksdagenPolitician.getPersonId()),
			BALLOTS, NESTED_PROPERTIES, COLUMN_ORDER, HIDE_COLUMNS, LISTENER, EMBEDDED_ID_BALLOT_ID, null);

	pageCompleted(parameters, panel, pageId, viewRiksdagenPolitician);
	return panelContent;

}
 
Example 13
Source Project: gantt   Source File: DemoUI.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void init(VaadinRequest request) {
    ganttListener = null;
    createGantt();

    MenuBar menu = controlsMenuBar();
    Panel controls = createControls();

    Component wrapper = UriFragmentWrapperFactory.wrapByUriFragment(UI.getCurrent().getPage().getUriFragment(),
            gantt);
    if (wrapper instanceof GanttListener) {
        ganttListener = (GanttListener) wrapper;
    }

    final VerticalLayout layout = new VerticalLayout();
    layout.setStyleName("demoContentLayout");
    layout.setMargin(false);
    layout.setSizeFull();
    layout.addComponent(menu);
    layout.addComponent(controls);
    layout.addComponent(wrapper);
    layout.setExpandRatio(wrapper, 1);

    setContent(layout);
}
 
Example 14
@Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
@Override
public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
	final VerticalLayout panelContent = createPanelContent();

	final String pageId = getPageId(parameters);
	final ViewRiksdagenPolitician viewRiksdagenPolitician = getItem(parameters);
	getPoliticianMenuItemFactory().createPoliticianMenuBar(menuBar, pageId);
	LabelFactory.createHeader2Label(panelContent, PoliticianPageMode.ROLELIST.toString());

	final PersonData personData = getApplicationManager().getDataContainer(PersonData.class)
			.load(viewRiksdagenPolitician.getPersonId());

	final List<AssignmentData> assignmentList = personData.getPersonAssignmentData().getAssignmentList();

	createRoleList(panelContent, assignmentList);

	pageCompleted(parameters, panel, pageId, viewRiksdagenPolitician);
	return panelContent;

}
 
Example 15
Source Project: cia   Source File: ManageUserAccountClickListenerTest.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Show notification failure test.
 */
@Test
public void showNotificationFailureTest() {
	final ManageUserAccountRequest request = new ManageUserAccountRequest();		
	final ManageUserAccountClickListener listener = Mockito.spy(new ManageUserAccountClickListener(request));
	final ApplicationManager applicationManager = Mockito.mock(ApplicationManager.class);
	Mockito.doReturn(applicationManager).when(listener).getApplicationManager();
	
	final ManageUserAccountResponse response = new ManageUserAccountResponse(ServiceResult.FAILURE);
	response.setErrorMessage("errorMessage");
	Mockito.when(applicationManager.service(request)).thenReturn(response);
	
	Mockito.doNothing().when(listener).showNotification(ArgumentMatchers.anyString(), ArgumentMatchers.anyString(), ArgumentMatchers.any(Type.class));
	listener.buttonClick(new ClickEvent(new Panel()));
	Mockito.verify(listener).showNotification(ArgumentMatchers.anyString(), ArgumentMatchers.anyString(), ArgumentMatchers.any(Type.class));
}
 
Example 16
@Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
@Override
public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
	final VerticalLayout panelContent = createPanelContent();

	final String pageId = getPageId(parameters);

	final ViewRiksdagenParty viewRiksdagenParty = getItem(parameters);
	getPartyMenuItemFactory().createPartyMenuBar(menuBar, pageId);

	LabelFactory.createHeader2Label(panelContent, TITLE);
	chartDataManager.createPartyChart(panelContent,pageId);

	pageCompleted(parameters, panel, pageId, viewRiksdagenParty);
	return panelContent;

}
 
Example 17
@Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
@Override
public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
	final VerticalLayout panelContent = createPanelContent();

	final String pageId = getPageId(parameters);

	final ViewRiksdagenCommittee viewRiksdagenCommittee = getItem(parameters);
	getCommitteeMenuItemFactory().createCommitteeeMenuBar(menuBar, pageId);

	LabelFactory.createHeader2Label(panelContent, DECISION_TYPE_DAILY_SUMMARY);

	chartDataManager.createDecisionTypeChart(panelContent, viewRiksdagenCommittee.getEmbeddedId().getOrgCode());

	panel.setCaption(NAME + "::" + COMMITTEE + viewRiksdagenCommittee.getEmbeddedId().getDetail());
	getPageActionEventHelper().createPageEvent(ViewAction.VISIT_COMMITTEE_VIEW, ApplicationEventGroup.USER, NAME,
			parameters, pageId);
	return panelContent;

}
 
Example 18
@Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
@Override
public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
	final VerticalLayout panelContent = createPanelContent();

	final String pageId = getPageId(parameters);

	final ViewRiksdagenCommittee viewRiksdagenCommittee = getItem(parameters);
	getCommitteeMenuItemFactory().createCommitteeeMenuBar(menuBar, pageId);

	LabelFactory.createHeader2Label(panelContent, DOCUMENT_ACTIVITY);

	chartDataManager.createDocumentHistoryChartByOrg(panelContent,
			viewRiksdagenCommittee.getEmbeddedId().getOrgCode());

	panel.setCaption(NAME + "::" + COMMITTEE + viewRiksdagenCommittee.getEmbeddedId().getDetail());
	getPageActionEventHelper().createPageEvent(ViewAction.VISIT_COMMITTEE_VIEW, ApplicationEventGroup.USER, NAME,
			parameters, pageId);
	return panelContent;

}
 
Example 19
/**
 * Init method adds all Configuration Views to the list of Views.
 */
@PostConstruct
public void init() {
    if (defaultDistributionSetTypeLayout.getComponentCount() > 0) {
        configurationViews.add(defaultDistributionSetTypeLayout);
    }
    configurationViews.add(repositoryConfigurationView);
    configurationViews.add(rolloutConfigurationView);
    configurationViews.add(authenticationConfigurationView);
    configurationViews.add(pollingConfigurationView);
    if (customConfigurationViews != null) {
        configurationViews.addAll(
                customConfigurationViews.stream().filter(ConfigurationGroup::show).collect(Collectors.toList()));
    }

    final Panel rootPanel = new Panel();
    rootPanel.setStyleName("tenantconfig-root");

    final VerticalLayout rootLayout = new VerticalLayout();
    rootLayout.setSizeFull();
    rootLayout.setMargin(true);
    rootLayout.setSpacing(true);

    configurationViews.forEach(rootLayout::addComponent);

    final HorizontalLayout buttonContent = saveConfigurationButtonsLayout();
    rootLayout.addComponent(buttonContent);
    rootLayout.setComponentAlignment(buttonContent, Alignment.BOTTOM_LEFT);
    rootPanel.setContent(rootLayout);
    setCompositionRoot(rootPanel);

    configurationViews.forEach(view -> view.addChangeListener(this));
}
 
Example 20
@Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
@Override
public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
	final VerticalLayout panelContent = createPanelContent();

	final String pageId = getPageId(parameters);
	
	final List<GovernmentBodyAnnualSummary> list = getItem(parameters);
	
	if (list != null && !list.isEmpty()) {
		final Optional<GovernmentBodyAnnualSummary> governmentBodyAnnualSummary = list.stream().findFirst();
		
		if (governmentBodyAnnualSummary.isPresent()) {			
			getGovernmentBodyMenuItemFactory().createGovernmentBodyMenuBar(menuBar, pageId);
			LabelFactory.createHeader2Label(panelContent,GOVERNMENT_BODIES);
			governmentBodyChartDataManager.createGovernmentBodyIncomeSummaryChart(panelContent, governmentBodyAnnualSummary.get().getName());
			panel.setCaption(NAME + "::" + GOVERNMENT_BODY + governmentBodyAnnualSummary.get().getName());
		}
		
		getPageActionEventHelper().createPageEvent(ViewAction.VISIT_MINISTRY_VIEW, ApplicationEventGroup.USER, NAME,
				parameters, pageId);

	}

	return panelContent;

}
 
Example 21
/**
 * Show notification failure test.
 */
@Test
public void showNotificationFailureTest() {
	final UpdateApplicationConfigurationRequest request = new UpdateApplicationConfigurationRequest();		
	final UpdateApplicationConfigurationClickListener listener = Mockito.spy(new UpdateApplicationConfigurationClickListener(request));
	final ApplicationManager applicationManager = Mockito.mock(ApplicationManager.class);
	Mockito.doReturn(applicationManager).when(listener).getApplicationManager();
	
	Mockito.when(applicationManager.service(request)).thenReturn(new UpdateApplicationConfigurationResponse(ServiceResult.FAILURE));
	
	Mockito.doNothing().when(listener).showNotification(ArgumentMatchers.anyString(), ArgumentMatchers.anyString(), ArgumentMatchers.any(Type.class));
	listener.buttonClick(new ClickEvent(new Panel()));
	Mockito.verify(listener).showNotification(ArgumentMatchers.anyString(), ArgumentMatchers.anyString(), ArgumentMatchers.any(Type.class));
}
 
Example 22
@Secured({ "ROLE_ADMIN" })
@Override
public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
	final VerticalLayout content = createPanelContent();

	getMenuItemFactory().createMainPageMenuBar(menuBar);

	LabelFactory.createHeader2Label(content,ADMIN_AGENT_OPERATION);
			
	final VerticalLayout overviewLayout = new VerticalLayout();
	overviewLayout.setSizeFull();
	content.addComponent(overviewLayout);
	content.setExpandRatio(overviewLayout, ContentRatio.LARGE);

	final ResponsiveRow grid = RowUtil.createGridLayout(overviewLayout);

	for (final DataAgentTarget dataAgentTarget : DataAgentTarget.values()) {
		final Button importDataButton = new Button(MessageFormat.format(BUTTON_PATTERN, DataAgentOperation.IMPORT, dataAgentTarget) , VaadinIcons.BULLSEYE);
		importDataButton.addClickListener(new StartAgentClickListener(dataAgentTarget, DataAgentOperation.IMPORT));
		importDataButton.setId(MessageFormat.format(BUTTON_ID_PATTERN, ViewAction.START_AGENT_BUTTON, DataAgentOperation.IMPORT, dataAgentTarget));
		RowUtil.createRowItem(grid, importDataButton, WILL_FETCH_DATA_FROM_SOURCE);
	}
	
	final String pageId = getPageId(parameters);
	getPageActionEventHelper().createPageEvent(ViewAction.VISIT_ADMIN_AGENT_OPERATION_VIEW, ApplicationEventGroup.ADMIN,
			NAME, null, pageId);


	return content;
}
 
Example 23
/**
 * Show notification success test.
 */
@Test
public void showNotificationSuccessTest() {
	final DisableGoogleAuthenticatorCredentialRequest request = new DisableGoogleAuthenticatorCredentialRequest();		
	final DisableGoogleAuthenticatorCredentialClickListener listener = Mockito.spy(new DisableGoogleAuthenticatorCredentialClickListener(request));
	final ApplicationManager applicationManager = Mockito.mock(ApplicationManager.class);
	Mockito.doReturn(applicationManager).when(listener).getApplicationManager();
	
	final DisableGoogleAuthenticatorCredentialResponse response = new DisableGoogleAuthenticatorCredentialResponse(ServiceResult.SUCCESS);
	Mockito.when(applicationManager.service(request)).thenReturn(response);
	listener.buttonClick(new ClickEvent(new Panel()));
	Mockito.verify(applicationManager,times(1)).service(request);
}
 
Example 24
Source Project: sensorhub   Source File: StorageAdminPanel.java    License: Mozilla Public License 2.0 5 votes vote down vote up
protected Panel newPanel(String title)
{
    Panel panel = new Panel(title);
    GridLayout layout = new GridLayout(2, 2);
    layout.setWidth(100.0f, Unit.PERCENTAGE);
    layout.setMargin(true);
    layout.setSpacing(true);
    layout.setColumnExpandRatio(0, 0.2f);
    layout.setColumnExpandRatio(1, 0.8f);
    layout.setDefaultComponentAlignment(Alignment.TOP_LEFT);
    panel.setContent(layout);
    return panel;
}
 
Example 25
@Secured({ "ROLE_USER", "ROLE_ADMIN" })
@Override
public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
	final VerticalLayout panelContent = createPanelContent();
	final String pageId = getPageId(parameters);
	final Optional<UserAccount> userAccount = getActiveUserAccount();

	if (userAccount.isPresent()) {

		userHomeMenuItemFactory.createUserHomeMenuBar(menuBar, pageId);

		LabelFactory.createHeader2Label(panelContent, USER_EVENTS);

		final DataContainer<ApplicationActionEvent, Long> eventDataContainer = getApplicationManager()
				.getDataContainer(ApplicationActionEvent.class);

		getGridFactory().createBasicBeanItemGrid(panelContent, ApplicationActionEvent.class,
				eventDataContainer.findOrderedListByProperty(ApplicationActionEvent_.userId,
						userAccount.get().getUserId(), ApplicationActionEvent_.createdDate),
				APPLICATION_ACTION_EVENT, COLUMN_ORDER, HIDE_COLUMNS, LISTENER, null, null);

		panel.setCaption(NAME + "::" + USERHOME + USER_EVENTS);
	}

	getPageActionEventHelper().createPageEvent(ViewAction.VISIT_USER_HOME_VIEW, ApplicationEventGroup.USER, NAME,
			parameters, pageId);

	return panelContent;

}
 
Example 26
@Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
@Override
public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
	final VerticalLayout panelContent = createPanelContent();

	final String pageId = getPageId(parameters);

	getDocumentMenuItemFactory().createDocumentMenuBar(menuBar, pageId);

	final DataContainer<DocumentStatusContainer, String> documentStatusContainerDataContainer = getApplicationManager()
			.getDataContainer(DocumentStatusContainer.class);

	final DocumentStatusContainer documentStatusContainer = documentStatusContainerDataContainer
			.findByQueryProperty(DocumentStatusContainer.class, DocumentStatusContainer_.document,
					DocumentData.class, DocumentData_.id, pageId);

	LabelFactory.createHeader2Label(panelContent, DOCUMENT_ATTACHMENTS);

	if (documentStatusContainer != null && documentStatusContainer.getDocumentAttachmentContainer() != null
			&& documentStatusContainer.getDocumentAttachmentContainer().getDocumentAttachmentList() != null) {

		getGridFactory().createBasicBeanItemGrid(panelContent, DocumentAttachment.class,
				documentStatusContainer.getDocumentAttachmentContainer().getDocumentAttachmentList(),
				DOCUMENT_ATTACHMENTS, COLUMN_ORDER, HIDE_COLUMNS, null, null, null);

		displayDocumentAttachements(panelContent,
				documentStatusContainer.getDocumentAttachmentContainer().getDocumentAttachmentList());
	}

	panel.setContent(panelContent);
	getPageActionEventHelper().createPageEvent(ViewAction.VISIT_DOCUMENT_VIEW, ApplicationEventGroup.USER, NAME,
			parameters, pageId);
	return panelContent;

}
 
Example 27
@Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
@Override
public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
	final VerticalLayout panelContent = createPanelContent();

	final String pageId = getPageId(parameters);

	final ViewRiksdagenMinistry viewRiksdagenMinistry = getItem(parameters);

	getMinistryMenuItemFactory().createMinistryMenuBar(menuBar, pageId);

	LabelFactory.createHeader2Label(panelContent, CURRENT_MEMBERS);

	final DataContainer<ViewRiksdagenGovermentRoleMember, String> govermentRoleMemberDataContainer = getApplicationManager()
			.getDataContainer(ViewRiksdagenGovermentRoleMember.class);

	getGridFactory().createBasicBeanItemGrid(panelContent, ViewRiksdagenGovermentRoleMember.class,
			govermentRoleMemberDataContainer.findListByProperty(
					new Object[] { viewRiksdagenMinistry.getNameId(), Boolean.TRUE },
					ViewRiksdagenGovermentRoleMember_.detail, ViewRiksdagenGovermentRoleMember_.active),
			CURRENT_MEMBERS, COLUMN_ORDER, HIDE_COLUMNS, LISTENER, null, null);

	panel.setCaption(NAME + "::" + MINISTRY + viewRiksdagenMinistry.getNameId());
	getPageActionEventHelper().createPageEvent(ViewAction.VISIT_MINISTRY_VIEW, ApplicationEventGroup.USER, NAME,
			parameters, pageId);

	return panelContent;

}
 
Example 28
Source Project: cia   Source File: FormFactoryImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public <T extends Serializable> void addFormPanelTextFields(final AbstractOrderedLayout panelContent, final T item,
		final Class<T> beanType, final List<String> displayProperties) {


	final Panel formPanel = new Panel();
	formPanel.setSizeFull();


	panelContent.addComponent(formPanel);
	if (displayProperties.size() > SIZE_FOR_GRID) {
		panelContent.setExpandRatio(formPanel, ContentRatio.GRID);
	}
	else {
		panelContent.setExpandRatio(formPanel, ContentRatio.SMALL_GRID);
	}


	final FormLayout formContent = new FormLayout();
	formPanel.setContent(formContent);
	formContent.setWidth(ContentSize.FULL_SIZE);

	final Binder<T> binder = new Binder<>(beanType);
	binder.setBean(item);
	binder.setReadOnly(true);

	PropertyDescriptor[] propertyDescriptors=null;
	try {
		final BeanInfo info = Introspector.getBeanInfo(item.getClass());
		propertyDescriptors = info.getPropertyDescriptors();
	} catch (final IntrospectionException exception) {
		LOGGER.error("No able to getfieldtypes for type:+ item.getClass()", exception);
	}

	createDisplayPropertyConverters(displayProperties, formContent, binder, propertyDescriptors);
}
 
Example 29
Source Project: XACML   Source File: RangeEditorComponent.java    License: MIT License 5 votes vote down vote up
@AutoGenerated
private Panel buildPanelTester() {
	// common part: create layout
	panelTester = new Panel();
	panelTester.setCaption("Test Range Values");
	panelTester.setImmediate(true);
	panelTester.setWidth("-1px");
	panelTester.setHeight("-1px");
	
	// verticalLayout_2
	verticalLayout_2 = buildVerticalLayout_2();
	panelTester.setContent(verticalLayout_2);
	
	return panelTester;
}
 
Example 30
Source Project: cia   Source File: AbstractChartDataManagerImpl.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Adds the chart.
 *
 * @param content
 *            the content
 * @param caption
 *            the caption
 * @param chart
 *            the chart
 * @param fullPage
 *            the full page
 */
protected final void addChart(final AbstractOrderedLayout content,final String caption, final DCharts chart, final boolean fullPage) {
	final HorizontalLayout horizontalLayout = new HorizontalLayout();

	final int browserWindowWidth = getChartWindowWidth();

	final int browserWindowHeight = getChartWindowHeight(fullPage);

	horizontalLayout.setWidth(browserWindowWidth, Unit.PIXELS);
	horizontalLayout.setHeight(browserWindowHeight, Unit.PIXELS);
	horizontalLayout.setMargin(true);
	horizontalLayout.setSpacing(false);
	horizontalLayout.addStyleName("v-layout-content-overview-panel-level1");

	final Panel formPanel = new Panel();
	formPanel.setSizeFull();
	formPanel.setContent(horizontalLayout);
	formPanel.setCaption(caption);

	content.addComponent(formPanel);
	content.setExpandRatio(formPanel, ContentRatio.LARGE);


	chart.setWidth(100, Unit.PERCENTAGE);
	chart.setHeight(100, Unit.PERCENTAGE);
	chart.setMarginRight(CHART_RIGHT_MARGIN);
	chart.setMarginLeft(CHART_LEFT_MARGIN);
	chart.setMarginBottom(CHART_BOTTOM_MARGIN_SIZE);
	chart.setMarginTop(CHART_TOP_MARGIN_SIZE);

	horizontalLayout.addComponent(chart);
	chart.setCaption(caption);
}