CommitteeRankingMenuItemFactoryImpl.java

  1. /*
  2.  * Copyright 2010-2025 James Pether Sörling
  3.  *
  4.  * Licensed under the Apache License, Version 2.0 (the "License");
  5.  * you may not use this file except in compliance with the License.
  6.  * You may obtain a copy of the License at
  7.  *
  8.  *   http://www.apache.org/licenses/LICENSE-2.0
  9.  *
  10.  * Unless required by applicable law or agreed to in writing, software
  11.  * distributed under the License is distributed on an "AS IS" BASIS,
  12.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13.  * See the License for the specific language governing permissions and
  14.  * limitations under the License.
  15.  *
  16.  *  $Id$
  17.  *  $HeadURL$
  18. */
  19. package com.hack23.cia.web.impl.ui.application.views.common.menufactory.impl;

  20. import org.springframework.beans.factory.annotation.Autowired;
  21. import org.springframework.stereotype.Service;

  22. import com.hack23.cia.web.impl.ui.application.views.common.menufactory.api.ApplicationMenuItemFactory;
  23. import com.hack23.cia.web.impl.ui.application.views.common.menufactory.api.CommitteeRankingMenuItemFactory;
  24. import com.hack23.cia.web.impl.ui.application.views.common.menufactory.api.pagecommands.PageCommandCommitteeRankingConstants;
  25. import com.hack23.cia.web.impl.ui.application.views.common.menufactory.api.text.MenuItemRankingPageVisitHistoryConstants;
  26. import com.hack23.cia.web.impl.ui.application.views.common.rows.RowUtil;
  27. import com.jarektoro.responsivelayout.ResponsiveRow;
  28. import com.vaadin.icons.VaadinIcons;
  29. import com.vaadin.ui.MenuBar;
  30. import com.vaadin.ui.MenuBar.MenuItem;
  31. import com.vaadin.ui.VerticalLayout;

  32. /**
  33.  * The Class CommitteeRankingMenuItemFactoryImpl.
  34.  */
  35. @Service
  36. public final class CommitteeRankingMenuItemFactoryImpl extends AbstractMenuItemFactoryImpl
  37.         implements CommitteeRankingMenuItemFactory {

  38.     /** The application menu item factory. */
  39.     @Autowired
  40.     private ApplicationMenuItemFactory applicationMenuItemFactory;

  41.     /**
  42.      * Instantiates a new committee ranking menu item factory impl.
  43.      */
  44.     public CommitteeRankingMenuItemFactoryImpl() {
  45.         super();
  46.     }

  47.     /**
  48.      * Creates the committeee ranking menu bar.
  49.      *
  50.      * @param menuBar
  51.      *                the menu bar
  52.      */
  53.     @Override
  54.     public void createCommitteeeRankingMenuBar(final MenuBar menuBar) {
  55.         initApplicationMenuBar(menuBar);

  56.         applicationMenuItemFactory.addRankingMenu(menuBar);

  57.         createCommitteeRankingTopics(menuBar.addItem(COMMITTEE_RANKING_TEXT, VaadinIcons.GROUP, null));
  58.     }

  59.     /**
  60.      * Creates the committee ranking topics.
  61.      *
  62.      * @param committeeMenuItem
  63.      *                          the committee menu item
  64.      */
  65.     @Override
  66.     public void createCommitteeRankingTopics(final MenuItem committeeMenuItem) {
  67.         committeeMenuItem.addItem(OVERVIEW_TEXT, VaadinIcons.GROUP, PageCommandCommitteeRankingConstants.COMMAND_COMMITTEE_RANKING_OVERVIEW);

  68.         final MenuItem listItem = committeeMenuItem.addItem(POLITICAL_WORK_SUMMARY_TEXT, VaadinIcons.GROUP,
  69.                 PageCommandCommitteeRankingConstants.COMMAND_COMMITTEE_RANKING_DATAGRID);
  70.         listItem.setDescription(CURRENT_AND_PAST_MEMBER_AND_SUMMARY_OF_POLTICIAL_DAYS);

  71.         final MenuItem chartByTopic = committeeMenuItem.addItem(CHART_BY_TOPIC_TEXT, VaadinIcons.GROUP, null);

  72.         chartByTopic.addItem(CURRENT_COMMITTEES_CURRENT_MEMBERS_TEXT, VaadinIcons.GROUP,
  73.                 COMMAND_CURRENT_COMMITTEES_BY_HEADCOUNT);
  74.         chartByTopic.addItem(CURRENT_PARTIES_ACTIVE_IN_COMMITTEES_CURRENT_ASSIGNMENTS, VaadinIcons.GROUP,
  75.                 COMMAND_CURRENT_COMMITTEES_BY_PARTY_DAYS_SERVED);
  76.         chartByTopic.addItem(CURRENT_PARTIES_ACTIVE_IN_COMMITTEES_TOTAL_DAYS_SERVED_IN_COMMITTEES, VaadinIcons.GROUP,
  77.                 COMMAND_CURRENT_COMMITTEES_BY_PARTY_DAYS_SERVED);

  78.         chartByTopic.addItem(ALL_COMMITTEES_TOTAL_MEMBERS, VaadinIcons.GROUP, COMMAND_ALL_COMMITTEES_BY_HEADCOUNT);

  79.         committeeMenuItem.addItem(RANKING_PAGE_VISIT_TEXT, VaadinIcons.CHART,
  80.                 COMMITTEE_RANKING_COMMAND_PAGEVISIT_HISTORY);

  81.     }

  82.     /**
  83.      * Creates the overview page.
  84.      *
  85.      * @param panelContent
  86.      *                     the panel content
  87.      */
  88.     @Override
  89.     public void createOverviewPage(final VerticalLayout panelContent) {
  90.         final ResponsiveRow grid = RowUtil.createGridLayout(panelContent);

  91.         createButtonLink(grid, POLITICAL_WORK_SUMMARY_TEXT, VaadinIcons.GROUP, PageCommandCommitteeRankingConstants.COMMAND_COMMITTEE_RANKING_DATAGRID,
  92.                 POLITICAL_WORK_SUMMARY_DESCRIPTION);
  93.         createButtonLink(grid, CURRENT_COMMITTEES_CURRENT_MEMBERS_TEXT, VaadinIcons.GROUP,
  94.                 COMMAND_CURRENT_COMMITTEES_BY_HEADCOUNT, CURRENT_COMMITTEES_CURRENT_MEMBERS_DESCRIPTION);

  95.         createButtonLink(grid, CURRENT_PARTIES_ACTIVE_IN_COMMITTEES_CURRENT_ASSIGNMENTS, VaadinIcons.GROUP,
  96.                 COMMAND_CURRENT_COMMITTEES_BY_PARTY_DAYS_SERVED, CURRENT_PARTIES_ACTIVE_IN_COMMITTEES_CURRENT_ASSIGNMENTS_DESCRIPTION);
  97.         createButtonLink(grid, CURRENT_PARTIES_ACTIVE_IN_COMMITTEES_TOTAL_DAYS_SERVED_IN_COMMITTEES, VaadinIcons.GROUP,
  98.                 COMMAND_CURRENT_COMMITTEES_BY_PARTY_DAYS_SERVED,
  99.                 CURRENT_PARTIES_ACTIVE_IN_COMMITTEES_TOTAL_DAYS_SERVED_IN_COMMITTEES_DESCRIPTION);
  100.         createButtonLink(grid, ALL_COMMITTEES_TOTAL_MEMBERS, VaadinIcons.GROUP, COMMAND_ALL_COMMITTEES_BY_HEADCOUNT,
  101.                 ALL_COMMITTEES_TOTAL_MEMBERS_DESCRIPTION);

  102.         createButtonLink(grid, RANKING_PAGE_VISIT_TEXT, VaadinIcons.CHART,
  103.                 PageCommandCommitteeRankingConstants.COMMITTEE_RANKING_COMMAND_PAGEVISIT_HISTORY,
  104.                 MenuItemRankingPageVisitHistoryConstants.PAGE_VISIT_HISTORY_DESCRIPTION);

  105.     }

  106. }