com.vaadin.ui.MenuBar Java Examples

The following examples show how to use com.vaadin.ui.MenuBar. 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: PartySupportAnnualSummaryChartPageModContentFactoryImpl.java    From cia with Apache License 2.0 6 votes vote down vote up
@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 #2
Source File: GovernmentBodyHeadcountPageModContentFactoryImpl.java    From cia with Apache License 2.0 6 votes vote down vote up
@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.createGovernmentBodyHeadcountSummaryChart(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 #3
Source File: PartyCurrentLeadersPageModContentFactoryImpl.java    From cia with Apache License 2.0 6 votes vote down vote up
@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_LEADERS);

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

	getGridFactory().createBasicBeanItemGrid(panelContent, ViewRiksdagenPartyRoleMember.class,
			partyRoleMemberDataContainer.findListByProperty(
					new Object[] { viewRiksdagenParty.getPartyId(), Boolean.TRUE },
					ViewRiksdagenPartyRoleMember_.party, ViewRiksdagenPartyRoleMember_.active),
			CURRENT_LEADERS, COLUMN_ORDER, HIDE_COLUMNS, LISTENER, null, null);

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

}
 
Example #4
Source File: DemoUI.java    From gantt with 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 #5
Source File: PoliticianVotesHistoryPageModContentFactoryImpl.java    From cia with Apache License 2.0 6 votes vote down vote up
@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 #6
Source File: AbstractMenuItemFactoryImpl.java    From cia with Apache License 2.0 6 votes vote down vote up
/**
 * Inits the application menu bar.
 *
 * @param menuBar
 *            the menu bar
 */
protected final void initApplicationMenuBar(final MenuBar menuBar) {
	menuBar.removeItems();
	menuBar.setWidth(MENU_BAR_WIDTH);
	menuBar.setStyleName(HEADER_STYLE_NAME);
	final MenuItem mainViewItem = menuBar.addItem(APPLICATION, VaadinIcons.SERVER, null);

	mainViewItem.addItem(START_TEXT, VaadinIcons.STAR, COMMAND_MAINVIEW_OVERVIEW);

	final MenuItem mainItem = mainViewItem.addItem(MAIN, VaadinIcons.STAR, null);

	mainItem.addItem(PAGE_VISIT_HISTORY_TEXT, VaadinIcons.LINE_CHART, COMMAND_MAINVIEW_PAGEVISITHISTORY);


	if (UserContextUtil.allowRoleInSecurityContext(ROLE_ADMIN) || UserContextUtil.allowRoleInSecurityContext(ROLE_USER)) {
		mainViewItem.addItem(USERHOME, VaadinIcons.USER,COMMAND_USERHOME);
		createAdminMenu(mainViewItem);
		mainViewItem.addItem(LOGOUT, VaadinIcons.SIGN_OUT, COMMAND_LOGOUT);
	} else {
		mainViewItem.addItem(LOGIN, VaadinIcons.SIGN_IN, COMMAND_LOGIN);
		mainViewItem.addItem(REGISTER, VaadinIcons.FILE_ADD, COMMAND_REGISTER);
	}

}
 
Example #7
Source File: PoliticianRoleListPageModContentFactoryImpl.java    From cia with Apache License 2.0 6 votes vote down vote up
@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 #8
Source File: WebAppMenu.java    From cuba with Apache License 2.0 6 votes vote down vote up
@Override
public void addChildItem(MenuItem menuItem, int index) {
    MenuBar.MenuItem childItem = ((MenuItemImpl) menuItem).getDelegateItem();
    if (childItem.getText() == null) {
        throw new IllegalArgumentException("Caption cannot be null");
    }

    MenuBar.MenuItem delegateItem = this.getDelegateItem();

    childItem.setParent(delegateItem);

    delegateItem.getChildren().add(index, childItem);
    menu.registerMenuItem(menuItem);

    menu.getComponent().markAsDirty();
}
 
Example #9
Source File: PoliticianDocumentActivityPageModContentFactoryImpl.java    From cia with Apache License 2.0 6 votes vote down vote up
@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.DOCUMENTACTIVITY.toString());

	documentChartDataManager.createPersonDocumentHistoryChart(panelContent, viewRiksdagenPolitician.getPersonId());

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

}
 
Example #10
Source File: CommitteeRoleGhantPageModContentFactoryImpl.java    From cia with Apache License 2.0 6 votes vote down vote up
@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, ROLE_GHANT);

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

	final List<ViewRiksdagenCommitteeRoleMember> allMembers = committeeRoleMemberDataContainer
			.getAllBy(ViewRiksdagenCommitteeRoleMember_.detail, viewRiksdagenCommittee.getEmbeddedId().getDetail());

	committeeGhantChartManager.createRoleGhant(panelContent, allMembers);

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

}
 
Example #11
Source File: CommitteeDecisionTypeDailySummaryPageModContentFactoryImpl2.java    From cia with Apache License 2.0 6 votes vote down vote up
@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 #12
Source File: DashboardMenu.java    From hawkbit with Eclipse Public License 1.0 6 votes vote down vote up
private Component buildUserMenu(final UiProperties uiProperties) {
    final MenuBar settings = new MenuBar();
    settings.addStyleName("user-menu");
    settings.setHtmlContentAllowed(true);

    final MenuItem settingsItem = settings.addItem("", getImage(uiProperties.isGravatar()), null);

    final String formattedTenant = UserDetailsFormatter.formatCurrentTenant();
    if (!StringUtils.isEmpty(formattedTenant)) {
        settingsItem.setText(formattedTenant);
        UserDetailsFormatter.getCurrentTenant().ifPresent(tenant -> settingsItem.setDescription(i18n
                .getMessage("menu.user.description", tenant, UserDetailsFormatter.getCurrentUser().getUsername())));
    } else {
        settingsItem.setText("...");
    }

    settingsItem.setStyleName("user-menuitem");

    final String logoutUrl = generateLogoutUrl();

    settingsItem.addItem(i18n.getMessage("label.sign.out"),
            selectedItem -> Page.getCurrent().setLocation(logoutUrl));
    return settings;
}
 
Example #13
Source File: PoliticianDocumentHistoryPageModContentFactoryImpl.java    From cia with Apache License 2.0 6 votes vote down vote up
@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.DOCUMENTHISTORY.toString());

	final DataContainer<ViewRiksdagenPoliticianDocument, String> politicianDocumentDataContainer = getApplicationManager()
			.getDataContainer(ViewRiksdagenPoliticianDocument.class);

	getGridFactory().createBasicBeanItemGrid(panelContent, ViewRiksdagenPoliticianDocument.class,
			politicianDocumentDataContainer.findOrderedListByProperty(
					ViewRiksdagenPoliticianDocument_.personReferenceId, viewRiksdagenPolitician.getPersonId(),
					ViewRiksdagenPoliticianDocument_.madePublicDate),
			DOCUMENTS, COLUMN_ORDER, HIDE_COLUMNS, LISTENER, null, null);

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

}
 
Example #14
Source File: PartyCommitteeRolesPageModContentFactoryImpl.java    From cia with Apache License 2.0 6 votes vote down vote up
@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 #15
Source File: DataSummaryAuthorPageModContentFactoryImpl.java    From cia with Apache License 2.0 5 votes vote down vote up
@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_AUTHOR_SUMMARY);

	final HorizontalLayout horizontalLayout = new HorizontalLayout();
	horizontalLayout.setSizeFull();

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

	final DataContainer<ViewAuditAuthorSummary, Long> dataContainer = getApplicationManager()
			.getDataContainer(ViewAuditAuthorSummary.class);
	
	getGridFactory()
	.createBasicBeanItemNestedPropertiesGrid(horizontalLayout, ViewAuditAuthorSummary.class, dataContainer.getAll(),
			ADMIN_AUTHOR_SUMMARY,null,
			COLUMN_ORDER, HIDE_COLUMNS,
			null, null, null);
	
	return content;

}
 
Example #16
Source File: UserHomeApplicationSessionsPageModContentFactoryImpl.java    From cia with Apache License 2.0 5 votes vote down vote up
@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_VISITS);

		final DataContainer<ApplicationSession, Long> sessionDataContainer = getApplicationManager()
				.getDataContainer(ApplicationSession.class);

		getGridFactory().createBasicBeanItemGrid(panelContent, ApplicationSession.class,
				sessionDataContainer.findOrderedListByProperty(ApplicationSession_.userId,
						userAccount.get().getUserId(), ApplicationSession_.createdDate),
				APPLICATION_SESSION, COLUMN_ORDER, HIDE_COLUMNS, LISTENER, null, COLLECTION_PROPERTY_CONVERTERS);

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

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

	return panelContent;

}
 
Example #17
Source File: BallotMenuItemFactoryImpl.java    From cia with Apache License 2.0 5 votes vote down vote up
@Override
public void createBallotMenuBar(final MenuBar menuBar, final String pageId) {
	initApplicationMenuBar(menuBar);

	menuBar.addItem(OVERVIEW_TEXT, VaadinIcons.PIE_CHART,
			new PageModeMenuCommand(UserViews.BALLOT_VIEW_NAME, PageMode.OVERVIEW, pageId));
	menuBar.addItem(CHARTS_TEXT, VaadinIcons.PIE_CHART,
			new PageModeMenuCommand(UserViews.BALLOT_VIEW_NAME, PageMode.CHARTS, pageId));
}
 
Example #18
Source File: CommitteeCurrentMembersHistoryPageModContentFactoryImpl.java    From cia with Apache License 2.0 5 votes vote down vote up
@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, CURRENT_MEMBERS);

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

	getGridFactory().createBasicBeanItemGrid(panelContent, ViewRiksdagenCommitteeRoleMember.class,
			committeeRoleMemberDataContainer.findListByProperty(
					new Object[] { viewRiksdagenCommittee.getEmbeddedId().getDetail(), Boolean.TRUE },
					ViewRiksdagenCommitteeRoleMember_.detail, ViewRiksdagenCommitteeRoleMember_.active),
			CURRENT_MEMBERS, COLUMN_ORDER, HIDE_COLUMNS, LISTENER, null, null);

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

}
 
Example #19
Source File: CommitteeDecisionSummaryPageModContentFactoryImpl.java    From cia with Apache License 2.0 5 votes vote down vote up
@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_SUMMARY);

	final DataContainer<ViewRiksdagenCommitteeDecisions, ViewRiksdagenCommitteeDecisionsEmbeddedId> committeeDecisionDataContainer = getApplicationManager()
			.getDataContainer(ViewRiksdagenCommitteeDecisions.class);

	final List<ViewRiksdagenCommitteeDecisions> decisionPartySummaryList = committeeDecisionDataContainer
			.findOrderedListByProperty(ViewRiksdagenCommitteeDecisions_.org, pageId,
					ViewRiksdagenCommitteeDecisions_.createdDate);

	getGridFactory().createBasicBeanItemNestedPropertiesGrid(panelContent, ViewRiksdagenCommitteeDecisions.class,
			decisionPartySummaryList, DECISION_SUMMARY, NESTED_PROPERTIES, COLUMN_ORDER, HIDE_COLUMNS, LISTENER,
			BALLOT_ID, null);

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

}
 
Example #20
Source File: CountryMenuItemFactoryImpl.java    From cia with Apache License 2.0 5 votes vote down vote up
@Override
public void createOverviewPage(final VerticalLayout panelContent) {
	final MenuBar menuBar = new MenuBar();
	panelContent.addComponent(menuBar);
	panelContent.setComponentAlignment(menuBar, Alignment.TOP_LEFT);
	panelContent.setExpandRatio(menuBar, ContentRatio.LARGE);

	addSourcesAndIndicatorsToMenu(menuBar.addItem("By Topic",VaadinIcons.LINE_CHART, null), getTopicIndicatorMap());
	menuBar.setAutoOpen(true);
}
 
Example #21
Source File: WebAppMenu.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public MenuItem createMenuItem(String id, String caption,
                               @Nullable String icon, @Nullable Consumer<MenuItem> command) {
    checkNotNullArgument(id);
    checkItemIdDuplicate(id);

    MenuItemImpl menuItem = new MenuItemImpl(this, id);

    Resource iconResource = null;
    if (icon != null) {
        iconResource = AppBeans.get(IconResolver.class).getIconResource(icon);
    }

    MenuBar.MenuItem delegateItem = component.createMenuItem(caption, iconResource, null);
    if (command != null) {
        @SuppressWarnings("UnnecessaryLocalVariable")
        Consumer<MenuItem> nonnullCommand = command;

        delegateItem.setCommand(selectedItem ->
                nonnullCommand.accept(menuItem));
    }
    menuItem.setDelegateItem(delegateItem);

    menuItem.setCaption(caption);
    menuItem.setIcon(icon);
    menuItem.setCommand(command);

    return menuItem;
}
 
Example #22
Source File: PoliticianRankingMenuItemFactoryImpl.java    From cia with Apache License 2.0 5 votes vote down vote up
@Override
public void createPoliticianRankingMenuBar(final MenuBar menuBar) {
	initApplicationMenuBar(menuBar);

	applicationMenuItemFactory.addRankingMenu(menuBar);

	createPoliticianRankingTopics(menuBar.addItem(POLITICIAN_RANKING, VaadinIcons.BUG, null));
}
 
Example #23
Source File: DocumentAttachementsPageModContentFactoryImpl.java    From cia with Apache License 2.0 5 votes vote down vote up
@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 #24
Source File: CommitteeMemberHistoryPageModContentFactoryImpl.java    From cia with Apache License 2.0 5 votes vote down vote up
@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, MEMBER_HISTORY);

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

	getGridFactory().createBasicBeanItemGrid(panelContent, ViewRiksdagenCommitteeRoleMember.class,
			committeeRoleMemberDataContainer.getAllBy(ViewRiksdagenCommitteeRoleMember_.detail,
					viewRiksdagenCommittee.getEmbeddedId().getDetail()),
			MEMBER_HISTORY, COLUMN_ORDER, HIDE_COLUMNS, LISTENER, null, null);

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

}
 
Example #25
Source File: DocumentMenuItemFactoryImpl.java    From cia with Apache License 2.0 5 votes vote down vote up
@Override
public void createDocumentsMenuBar(final MenuBar menuBar) {
	initApplicationMenuBar(menuBar);

	applicationMenuItemFactory.addRankingMenu(menuBar);
	final MenuItem documentsItem = menuBar.addItem(DOCUMENTS, VaadinIcons.FILE, null);
	documentsItem.addItem("List all",VaadinIcons.GROUP, COMMAND_DOCUMENTS);
	documentsItem.addItem("Search Documents",VaadinIcons.GROUP, COMMAND_SEARCH_DOCUMENT);

}
 
Example #26
Source File: CommitteeRankingMenuItemFactoryImpl.java    From cia with Apache License 2.0 5 votes vote down vote up
/**
 * Creates the committeee ranking menu bar.
 *
 * @param menuBar
 *            the menu bar
 */
@Override
public void createCommitteeeRankingMenuBar(final MenuBar menuBar) {
	initApplicationMenuBar(menuBar);

	applicationMenuItemFactory.addRankingMenu(menuBar);

	createCommitteeRankingTopics(menuBar.addItem(COMMITTEE_RANKING_TEXT, null, null));
}
 
Example #27
Source File: ParliamentDecisionFlowPageModContentFactoryImpl.java    From cia with Apache License 2.0 5 votes vote down vote up
@Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
@Override
public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
	final VerticalLayout panelContent = createPanelContent();
	getParliamentMenuItemFactory().createParliamentTopicMenu(menuBar);

	String selectedYear = "2018/19";
	if (parameters != null && parameters.contains("[") && parameters.contains("]")) {
		selectedYear = parameters.substring(parameters.indexOf('[') + 1, parameters.lastIndexOf(']'));
	} 
	
	final DataContainer<ViewRiksdagenCommittee, String> dataContainer = getApplicationManager()
			.getDataContainer(ViewRiksdagenCommittee.class);
	final List<ViewRiksdagenCommittee> allCommittess = dataContainer.getAll();

	final Map<String, List<ViewRiksdagenCommittee>> committeeMap = allCommittess.stream().collect(Collectors.groupingBy(c -> c.getEmbeddedId().getOrgCode().toUpperCase(Locale.ENGLISH)));
	
	final ComboBox<String> comboBox = new ComboBox<>("Select year", Collections.unmodifiableList(Arrays.asList("2018/19","2017/18","2016/17","2015/16","2014/15","2013/14","2012/13","2011/12","2010/11")));
	panelContent.addComponent(comboBox);
	panelContent.setExpandRatio(comboBox, ContentRatio.SMALL);
	comboBox.setSelectedItem(selectedYear);
	comboBox.addValueChangeListener(new DecisionFlowValueChangeListener(NAME,""));
	
	final SankeyChart chart = decisionFlowChartManager.createAllDecisionFlow(committeeMap,comboBox.getSelectedItem().orElse(selectedYear));
	panelContent.addComponent(chart);
	panelContent.setExpandRatio(chart, ContentRatio.LARGE);

	final TextArea textarea = decisionFlowChartManager.createCommitteeeDecisionSummary(committeeMap,comboBox.getSelectedItem().orElse(selectedYear));
	textarea.setSizeFull();
	panelContent.addComponent(textarea);
	panelContent.setExpandRatio(textarea, ContentRatio.SMALL_GRID);


	getPageActionEventHelper().createPageEvent(ViewAction.VISIT_PARLIAMENT_RANKING_VIEW, ApplicationEventGroup.USER, NAME,
			parameters, selectedYear);
	panel.setCaption(new StringBuilder().append(NAME).append("::").append(PARLIAMENT_DECISION_FLOW).toString());

	return panelContent;

}
 
Example #28
Source File: MinistryCurrentMembersPageModContentFactoryImpl.java    From cia with Apache License 2.0 5 votes vote down vote up
@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 #29
Source File: CommitteeBallotDecisionSummaryPageModContentFactoryImpl.java    From cia with Apache License 2.0 5 votes vote down vote up
@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, BALLOT_DECISION_SUMMARY);

	final DataContainer<ViewRiksdagenCommitteeBallotDecisionSummary, ViewRiksdagenCommitteeBallotDecisionPartyEmbeddedId> committeeBallotDecisionPartyDataContainer = getApplicationManager()
			.getDataContainer(ViewRiksdagenCommitteeBallotDecisionSummary.class);

	final List<ViewRiksdagenCommitteeBallotDecisionSummary> decisionPartySummaryList = committeeBallotDecisionPartyDataContainer
			.findOrderedListByProperty(ViewRiksdagenCommitteeBallotDecisionSummary_.org,
					pageId.toUpperCase(Locale.ENGLISH), ViewRiksdagenCommitteeBallotDecisionSummary_.createdDate);

	getGridFactory().createBasicBeanItemNestedPropertiesGrid(panelContent,
			ViewRiksdagenCommitteeBallotDecisionSummary.class, decisionPartySummaryList,
			COMMITTEE_BALLOT_DECISION_SUMMARY, NESTED_PROPERTIES, COLUMN_ORDER, HIDE_COLUMNS, LISTENER, BALLOT_ID,
			null);

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

}
 
Example #30
Source File: GovernmentBodyIncomePageModContentFactoryImpl.java    From cia with Apache License 2.0 5 votes vote down vote up
@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;

}