PartyRankingCurrentCommitteeChartsPageModContentFactoryImpl.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.user.partyranking.pagemode;

  20. import org.springframework.beans.factory.annotation.Autowired;
  21. import org.springframework.security.access.annotation.Secured;
  22. import org.springframework.stereotype.Service;

  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.chartfactory.api.ChartDataManager;
  26. import com.hack23.cia.web.impl.ui.application.views.common.dataseriesfactory.api.PartyDataSeriesFactory;
  27. import com.hack23.cia.web.impl.ui.application.views.common.menufactory.api.pagecommands.PageCommandPartyRankingConstants;
  28. import com.hack23.cia.web.impl.ui.application.views.common.pagemode.CardInfoRowUtil;
  29. import com.hack23.cia.web.impl.ui.application.views.common.sizing.ContentRatio;
  30. import com.hack23.cia.web.impl.ui.application.views.common.viewnames.UserViews;
  31. import com.vaadin.ui.HorizontalLayout;
  32. import com.vaadin.ui.Layout;
  33. import com.vaadin.ui.MenuBar;
  34. import com.vaadin.ui.Panel;
  35. import com.vaadin.ui.VerticalLayout;

  36. /**
  37.  * The Class PartyRankingCurrentCommitteeChartsPageModContentFactoryImpl.
  38.  */
  39. @Service
  40. public final class PartyRankingCurrentCommitteeChartsPageModContentFactoryImpl extends AbstractPartyRankingPageModContentFactoryImpl {

  41.     /** The Constant NAME. */
  42.     public static final String NAME = UserViews.PARTY_RANKING_VIEW_NAME;

  43.     /** The chart data manager. */
  44.     @Autowired
  45.     private ChartDataManager chartDataManager;

  46.     /** The data series factory. */
  47.     @Autowired
  48.     private PartyDataSeriesFactory dataSeriesFactory;

  49.     /**
  50.      * Instantiates a new party ranking current committee charts page mod
  51.      * content factory impl.
  52.      */
  53.     public PartyRankingCurrentCommitteeChartsPageModContentFactoryImpl() {
  54.         super();
  55.     }

  56.     @Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
  57.     @Override
  58.     public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
  59.         final VerticalLayout panelContent = createPanelContent();

  60.         final String pageId = getPageId(parameters);

  61.         getPartyRankingMenuItemFactory().createPartyRankingMenuBar(menuBar);

  62.         CardInfoRowUtil.createPageHeader(panel, panelContent,
  63.             PartyRankingViewConstants.CURRENT_COMMITTEE_TITLE,
  64.             PartyRankingViewConstants.TITLE_PARTY_RANKINGS,
  65.             PartyRankingViewConstants.CURRENT_COMMITTEE_DESC);

  66.         final HorizontalLayout chartLayout = new HorizontalLayout();
  67.         chartLayout.setSizeFull();

  68.         chartDataManager.createChartPanel(chartLayout,
  69.             dataSeriesFactory.createChartTimeSeriesCurrentCommitteeByParty(),
  70.             PartyRankingViewConstants.CHART_LABEL_CURRENT_COMMITTEE);

  71.         panelContent.addComponent(chartLayout);
  72.         panelContent.setExpandRatio(chartLayout,ContentRatio.LARGE_FORM);


  73.         getPageActionEventHelper().createPageEvent(ViewAction.VISIT_PARTY_RANKING_VIEW, ApplicationEventGroup.USER, NAME,
  74.                 parameters, pageId);

  75.         return panelContent;

  76.     }

  77.     @Override
  78.     public boolean matches(final String page, final String parameters) {
  79.         return PageCommandPartyRankingConstants.COMMAND_PARTY_RANKING_CHARTS_CURRENT_COMMITTEES.matches(page, parameters);
  80.     }


  81. }