GovernmentBodyMenuItemFactoryImpl.java

  1. package com.hack23.cia.web.impl.ui.application.views.common.menufactory.impl;

  2. import org.springframework.beans.factory.annotation.Autowired;
  3. import org.springframework.stereotype.Service;

  4. import com.hack23.cia.web.impl.ui.application.views.common.menufactory.api.ApplicationMenuItemFactory;
  5. import com.hack23.cia.web.impl.ui.application.views.common.menufactory.api.GovernmentBodyMenuItemFactory;
  6. import com.hack23.cia.web.impl.ui.application.views.common.menufactory.api.GovernmentBodyRankingMenuItemFactory;
  7. import com.hack23.cia.web.impl.ui.application.views.common.menufactory.api.pagecommands.PageCommandGovernmentBodyConstants;
  8. import com.hack23.cia.web.impl.ui.application.views.common.rows.RowUtil;
  9. import com.jarektoro.responsivelayout.ResponsiveRow;
  10. import com.vaadin.icons.VaadinIcons;
  11. import com.vaadin.ui.MenuBar;
  12. import com.vaadin.ui.MenuBar.MenuItem;
  13. import com.vaadin.ui.VerticalLayout;

  14. /**
  15.  * The Class GovernmentBodyMenuItemFactoryImpl.
  16.  */
  17. @Service
  18. public final class GovernmentBodyMenuItemFactoryImpl extends AbstractMenuItemFactoryImpl
  19.         implements GovernmentBodyMenuItemFactory {

  20.     /** The application menu item factory. */
  21.     @Autowired
  22.     private ApplicationMenuItemFactory applicationMenuItemFactory;

  23.     /** The government body ranking menu item factory. */
  24.     @Autowired
  25.     private GovernmentBodyRankingMenuItemFactory governmentBodyRankingMenuItemFactory;

  26.     /**
  27.      * Instantiates a new government body menu item factory impl.
  28.      */
  29.     public GovernmentBodyMenuItemFactoryImpl() {
  30.         super();
  31.     }

  32.     @Override
  33.     public void createGovernmentBodyMenuBar(final MenuBar menuBar, final String pageId, final String title) {
  34.         initApplicationMenuBar(menuBar);

  35.         applicationMenuItemFactory.addRankingMenu(menuBar);

  36.         governmentBodyRankingMenuItemFactory.createGovernmentBodyRankingTopics(
  37.                 menuBar.addItem(GOVERNMENT_BODY_RANKING, VaadinIcons.BUILDING_O, null));

  38.         final MenuItem governmentBodyItem = menuBar.addItem(title, VaadinIcons.BUILDING_O, null);

  39.         governmentBodyItem.addItem(GOVERNMENT_BODY_OVERVIEW_TEXT, VaadinIcons.FILE_TEXT,
  40.                 PageCommandGovernmentBodyConstants.COMMAND_GOVERNMENT_BODY_OVERVIEW.createItemPageCommand(pageId));

  41.         governmentBodyItem.addItem(HEADCOUNT_CHART, VaadinIcons.USER,
  42.                 PageCommandGovernmentBodyConstants.COMMAND_GOVERNMENT_BODY_HEADCOUNT.createItemPageCommand(pageId));

  43.         governmentBodyItem.addItem(INCOME, VaadinIcons.MONEY,
  44.                 PageCommandGovernmentBodyConstants.COMMAND_GOVERNMENT_BODY_INCOME.createItemPageCommand(pageId));

  45.         governmentBodyItem.addItem(EXPENDITURE, VaadinIcons.CREDIT_CARD,
  46.                 PageCommandGovernmentBodyConstants.COMMAND_GOVERNMENT_BODY_EXPENDITURE.createItemPageCommand(pageId));
  47.     }

  48.     @Override
  49.     public void createOverviewPage(final VerticalLayout panelContent, final String pageId) {
  50.         final ResponsiveRow grid = RowUtil.createGridLayout(panelContent);

  51.         createButtonLink(grid, HEADCOUNT_CHART, VaadinIcons.USER,
  52.                 PageCommandGovernmentBodyConstants.COMMAND_GOVERNMENT_BODY_HEADCOUNT.createItemPageCommand(pageId),
  53.                 HEADCOUNT_DESCRIPTION);

  54.         createButtonLink(grid, INCOME, VaadinIcons.MONEY,
  55.                 PageCommandGovernmentBodyConstants.COMMAND_GOVERNMENT_BODY_INCOME.createItemPageCommand(pageId),
  56.                 INCOME_DESCRIPTION);

  57.         createButtonLink(grid, EXPENDITURE, VaadinIcons.CREDIT_CARD,
  58.                 PageCommandGovernmentBodyConstants.COMMAND_GOVERNMENT_BODY_EXPENDITURE.createItemPageCommand(pageId),
  59.                 EXPENDITURE_DESCRIPTION);
  60.     }
  61. }