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

  30. /**
  31.  * The Class UserHomeMenuItemFactoryImpl.
  32.  */
  33. @Service
  34. public final class UserHomeMenuItemFactoryImpl extends AbstractMenuItemFactoryImpl implements UserHomeMenuItemFactory {

  35.     /** The application menu item factory. */
  36.     @Autowired
  37.     private ApplicationMenuItemFactory applicationMenuItemFactory;

  38.     @Override
  39.     public void createOverviewPage(final VerticalLayout overviewLayout) {
  40.         final ResponsiveRow grid = RowUtil.createGridLayout(overviewLayout);

  41.         createButtonLink(grid, SECURITY_SETTING_TEXT, VaadinIcons.SHIELD,
  42.                 COMMAND_USERHOME_SECURITY_SETTINGS,
  43.                 SECURITY_SETTINGS_DESCRIPTION);

  44.         createButtonLink(grid, USER_VISITS, VaadinIcons.EYE,
  45.                 COMMAND_USERHOME_USER_VISITS,
  46.                 USER_VISITS_DESCRIPTION);

  47.         createButtonLink(grid, USER_EVENTS, VaadinIcons.CALENDAR,
  48.                 COMMAND_USERHOME_USER_EVENTS,
  49.                 USER_EVENTS_DESCRIPTION);
  50.     }

  51.     @Override
  52.     public void createUserHomeMenuBar(final MenuBar menuBar, final String pageId) {
  53.         initApplicationMenuBar(menuBar);

  54.         applicationMenuItemFactory.addRankingMenu(menuBar);
  55.         final MenuItem accountItem = menuBar.addItem(USERACCOUNT, VaadinIcons.USER, null);

  56.         accountItem.addItem(USER_HOME_OVERVIEW_TEXT, VaadinIcons.USER,
  57.                 COMMAND_USERHOME_OVERVIEW);

  58.         accountItem.addItem(SECURITY_SETTING_TEXT, VaadinIcons.SHIELD,
  59.                 COMMAND_USERHOME_SECURITY_SETTINGS);

  60.         accountItem.addItem(USER_VISITS, VaadinIcons.EYE,
  61.                 COMMAND_USERHOME_USER_VISITS);

  62.         accountItem.addItem(USER_EVENTS, VaadinIcons.CALENDAR,
  63.                 COMMAND_USERHOME_USER_EVENTS);
  64.     }
  65. }