CountryRankingOverviewPageModContentFactoryImpl.java

  1. /*
  2.  * Copyright 2014 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.user.country.pagemode;

  20. import org.apache.commons.lang3.StringUtils;
  21. import org.springframework.security.access.annotation.Secured;
  22. import org.springframework.stereotype.Component;

  23. import com.hack23.cia.model.internal.application.system.impl.ApplicationEventGroup;
  24. import com.hack23.cia.web.impl.ui.application.action.ViewAction;
  25. import com.hack23.cia.web.impl.ui.application.views.common.viewnames.PageMode;
  26. import com.vaadin.ui.Label;
  27. import com.vaadin.ui.Layout;
  28. import com.vaadin.ui.MenuBar;
  29. import com.vaadin.ui.Panel;
  30. import com.vaadin.ui.VerticalLayout;

  31. /**
  32.  * The Class CountryRankingOverviewPageModContentFactoryImpl.
  33.  */
  34. @Component
  35. public final class CountryRankingOverviewPageModContentFactoryImpl extends AbstractCountryPageModContentFactoryImpl {

  36.     /** The Constant OVERVIEW. */
  37.     private static final String OVERVIEW = "overview";

  38.     /**
  39.      * Instantiates a new country ranking overview page mod content factory
  40.      * impl.
  41.      */
  42.     public CountryRankingOverviewPageModContentFactoryImpl() {
  43.         super();
  44.     }

  45.     @Override
  46.     public boolean matches(final String page, final String parameters) {
  47.         final String pageId = getPageId(parameters);
  48.         return NAME.equals(page) && (StringUtils.isEmpty(parameters) || parameters.equals(pageId)
  49.                 || parameters.contains(PageMode.OVERVIEW.toString()));
  50.     }

  51.     @Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
  52.     @Override
  53.     public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
  54.         final VerticalLayout panelContent = createPanelContent();
  55.         getCountryMenuItemFactory().createCountryTopicMenu(menuBar);

  56.         final String pageId = getPageId(parameters);

  57.         panelContent.addComponent(new Label(OVERVIEW));

  58.         getCountryMenuItemFactory().createOverviewPage(panelContent);

  59.         getPageActionEventHelper().createPageEvent(ViewAction.VISIT_TEST_CHART_VIEW, ApplicationEventGroup.USER, NAME, parameters, pageId);
  60.         panel.setCaption(OVERVIEW);

  61.         return panelContent;

  62.     }

  63. }