GovernmentBodyRankingMenuItemFactoryImpl.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.GovernmentBodyRankingMenuItemFactory;
  24. import com.hack23.cia.web.impl.ui.application.views.common.menufactory.api.pagecommands.PageCommandGovernmentBodyRankingConstants;
  25. import com.hack23.cia.web.impl.ui.application.views.common.rows.RowUtil;
  26. import com.jarektoro.responsivelayout.ResponsiveRow;
  27. import com.vaadin.icons.VaadinIcons;
  28. import com.vaadin.ui.MenuBar;
  29. import com.vaadin.ui.VerticalLayout;

  30. /**
  31.  * The Class GovernmentBodyRankingMenuItemFactoryImpl.
  32.  *
  33.  * <p>
  34.  * This class builds menus and overview pages for government body rankings,
  35.  * enabling users to navigate through institutional staffing, revenue streams,
  36.  * expenditure focus, and historical engagement patterns. Through integration
  37.  * with {@link ApplicationMenuItemFactory}, it ensures a coherent experience
  38.  * within the main menu structure.
  39.  * </p>
  40.  */
  41. @Service
  42. public final class GovernmentBodyRankingMenuItemFactoryImpl extends AbstractMenuItemFactoryImpl
  43.                 implements GovernmentBodyRankingMenuItemFactory {

  44.         /** The application menu item factory, used to integrate into the main menu. */
  45.         @Autowired
  46.         private ApplicationMenuItemFactory applicationMenuItemFactory;

  47.         /**
  48.          * Instantiates a new government body ranking menu item factory implementation.
  49.          */
  50.         public GovernmentBodyRankingMenuItemFactoryImpl() {
  51.                 super();
  52.         }

  53.         /**
  54.          * Creates the government body ranking menu bar and integrates it into the main
  55.          * application menu. Adds government body ranking topics as sub-items.
  56.          *
  57.          * @param menuBar the main application {@link MenuBar} to which the government
  58.          *                body ranking menu will be added.
  59.          */
  60.         @Override
  61.         public void createGovernmentBodyRankingMenuBar(final MenuBar menuBar) {
  62.                 initApplicationMenuBar(menuBar);
  63.                 applicationMenuItemFactory.addRankingMenu(menuBar);
  64.                 createGovernmentBodyRankingTopics(
  65.                                 menuBar.addItem(GOVERNMENT_BODY_RANKING, VaadinIcons.BUILDING_O, null));
  66.         }

  67.         /**
  68.          * Adds menu items for various government body ranking topics:
  69.          * <ul>
  70.          * <li>Overview: General dashboard icon</li>
  71.          * <li>Government Bodies: Building icon for institutions</li>
  72.          * <li>Headcount: Multiple users for staffing</li>
  73.          * <li>Income: Money deposit icon for revenues</li>
  74.          * <li>Expenditure: Money withdraw icon for spending</li>
  75.          * <li>Page Visit History: History icon for past engagement</li>
  76.          * </ul>
  77.          *
  78.          * @param menuItem the {@link MenuBar.MenuItem} representing "GovernmentBody
  79.          *                 Ranking"
  80.          *                 under which these topics will be added.
  81.          */
  82.         @Override
  83.         public void createGovernmentBodyRankingTopics(final MenuBar.MenuItem menuItem) {
  84.                 menuItem.addItem(OVERVIEW_TEXT, VaadinIcons.DASHBOARD, COMMAND_GOVERNMENT_BODY_RANKING_OVERVIEW);
  85.                 menuItem.addItem(GOVERNMENT_BODIES, VaadinIcons.BUILDING_O, PageCommandGovernmentBodyRankingConstants.COMMAND_GOVERNMENT_BODY_RANKING_DATAGRID);
  86.                 menuItem.addItem(GOVERNMENT_BODIES_HEADCOUNT, VaadinIcons.USER_CHECK,
  87.                 PageCommandGovernmentBodyRankingConstants.COMMAND_GOVERNMENT_BODIES_HEADCOUNT);
  88.                 menuItem.addItem(GOVERNMENT_BODIES_INCOME, VaadinIcons.MONEY, PageCommandGovernmentBodyRankingConstants.COMMAND_GOVERNMENT_BODIES_INCOME);
  89.                 menuItem.addItem(GOVERNMENT_BODIES_EXPENDITURE, VaadinIcons.MONEY_WITHDRAW,
  90.                         PageCommandGovernmentBodyRankingConstants.COMMAND_GOVERNMENT_BODIES_EXPENDITURE);

  91.                 menuItem.addItem(HEADCOUNT, VaadinIcons.USERS, PageCommandGovernmentBodyRankingConstants.COMMAND_GOVERNMENT_BODIES_HEADCOUNT);
  92.                 menuItem.addItem(INCOME, VaadinIcons.MONEY_DEPOSIT, PageCommandGovernmentBodyRankingConstants.COMMAND_GOVERNMENT_BODIES_INCOME);
  93.                 menuItem.addItem(EXPENDITURE, VaadinIcons.MONEY_WITHDRAW, PageCommandGovernmentBodyRankingConstants.COMMAND_GOVERNMENT_BODIES_EXPENDITURE);
  94.                 menuItem.addItem(RANKING_PAGE_VISIT_TEXT, VaadinIcons.CHART,
  95.                         GOVERNMENT_RANKING_COMMAND_PAGEVISIT_HISTORY);
  96.         }

  97.         /**
  98.          * Creates the overview page with quick-access links to government body ranking
  99.          * topics.
  100.          * Each button uses an icon and a brief description to guide the user:
  101.          * <ul>
  102.          * <li>Government Bodies: Building icon, structural roles</li>
  103.          * <li>Headcount: Users icon, staffing influence</li>
  104.          * <li>Income: Money deposit icon, revenue streams</li>
  105.          * <li>Expenditure: Money withdraw icon, spending focus</li>
  106.          * <li>Page Visit History: History icon, past engagement</li>
  107.          * </ul>
  108.          *
  109.          * @param panelContent the {@link VerticalLayout} container that holds the
  110.          *                     overview
  111.          *                     content. New UI components will be added here.
  112.          */
  113.         @Override
  114.         public void createOverviewPage(final VerticalLayout panelContent) {
  115.                 final ResponsiveRow grid = RowUtil.createGridLayout(panelContent);

  116.                 createButtonLink(grid, GOVERNMENT_BODIES, VaadinIcons.BUILDING_O, PageCommandGovernmentBodyRankingConstants.COMMAND_GOVERNMENT_BODY_RANKING_DATAGRID,
  117.                                 GOVERNMENT_BODIES_DESCRIPTION);
  118.                 createButtonLink(grid, GOVERNMENT_BODIES_HEADCOUNT, VaadinIcons.USER_CHECK,
  119.                         PageCommandGovernmentBodyRankingConstants.COMMAND_GOVERNMENT_BODIES_HEADCOUNT, GOVERNMENT_BODIES_HEADCOUNT_DESCRIPTION);
  120.                 createButtonLink(grid, GOVERNMENT_BODIES_INCOME, VaadinIcons.MONEY, PageCommandGovernmentBodyRankingConstants.COMMAND_GOVERNMENT_BODIES_INCOME,
  121.                                 GOVERNMENT_BODIES_INCOME_DESCRIPTION);
  122.                 createButtonLink(grid, GOVERNMENT_BODIES_EXPENDITURE, VaadinIcons.MONEY_WITHDRAW,
  123.                         PageCommandGovernmentBodyRankingConstants.COMMAND_GOVERNMENT_BODIES_EXPENDITURE, GOVERNMENT_BODIES_EXPENDITURE_DESCRIPTION);

  124.                 createButtonLink(grid, HEADCOUNT, VaadinIcons.USERS, PageCommandGovernmentBodyRankingConstants.COMMAND_GOVERNMENT_BODIES_HEADCOUNT,
  125.                                 HEADCOUNT_DESCRIPTION);
  126.                 createButtonLink(grid, INCOME, VaadinIcons.MONEY_DEPOSIT, PageCommandGovernmentBodyRankingConstants.COMMAND_GOVERNMENT_BODIES_INCOME,
  127.                                 INCOME_DESCRIPTION);
  128.                 createButtonLink(grid, EXPENDITURE, VaadinIcons.MONEY_WITHDRAW, PageCommandGovernmentBodyRankingConstants.COMMAND_GOVERNMENT_BODIES_EXPENDITURE,
  129.                                 EXPENDITURE_DESCRIPTION);
  130.                 createButtonLink(grid, RANKING_PAGE_VISIT_TEXT, VaadinIcons.CHART,
  131.                         GOVERNMENT_RANKING_COMMAND_PAGEVISIT_HISTORY, RANKING_PAGE_VISIT_DESC);
  132.         }
  133. }