DataSummaryOverviewPageModContentFactoryImpl.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.admin.datasummary.pagemode;

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

  23. import com.hack23.cia.web.impl.ui.application.views.common.labelfactory.LabelFactory;
  24. import com.hack23.cia.web.impl.ui.application.views.common.sizing.ContentRatio;
  25. import com.hack23.cia.web.impl.ui.application.views.common.tablefactory.TableFactory;
  26. import com.hack23.cia.web.impl.ui.application.views.common.viewnames.AdminViews;
  27. import com.hack23.cia.web.impl.ui.application.views.pageclicklistener.RefreshDataViewsClickListener;
  28. import com.hack23.cia.web.impl.ui.application.views.pageclicklistener.UpdateSearchIndexClickListener;
  29. import com.vaadin.server.FontAwesome;
  30. import com.vaadin.ui.Button;
  31. import com.vaadin.ui.Layout;
  32. import com.vaadin.ui.MenuBar;
  33. import com.vaadin.ui.Panel;
  34. import com.vaadin.ui.Table;
  35. import com.vaadin.ui.VerticalLayout;

  36. /**
  37.  * The Class DataSummaryOverviewPageModContentFactoryImpl.
  38.  */
  39. @Component
  40. public final class DataSummaryOverviewPageModContentFactoryImpl extends AbstractDataSummaryPageModContentFactoryImpl {

  41.     /** The Constant NAME. */
  42.     public static final String NAME = AdminViews.ADMIN_DATA_SUMMARY_VIEW_NAME;

  43.     /** The Constant UPDATE_SEARCH_INDEX. */
  44.     private static final String UPDATE_SEARCH_INDEX = "Update Search Index";

  45.     /** The Constant REFRESH_VIEWS. */
  46.     private static final String REFRESH_VIEWS = "Refresh Views";

  47.     /** The Constant ADMIN_DATA_SUMMARY. */
  48.     private static final String ADMIN_DATA_SUMMARY = "Admin Data Summary";

  49.     /** The table factory. */
  50.     @Autowired
  51.     private TableFactory tableFactory;

  52.     /**
  53.      * Instantiates a new data summary overview page mod content factory impl.
  54.      */
  55.     public DataSummaryOverviewPageModContentFactoryImpl() {
  56.         super();
  57.     }

  58.     @Override
  59.     public boolean matches(final String page, final String parameters) {
  60.         return NAME.equals(page);
  61.     }

  62.     @Secured({ "ROLE_ADMIN" })
  63.     @Override
  64.     public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
  65.         final VerticalLayout content = createPanelContent();

  66.         getMenuItemFactory().createMainPageMenuBar(menuBar);

  67.         LabelFactory.createHeader2Label(content,ADMIN_DATA_SUMMARY);

  68.         final Table createDataSummaryTable = tableFactory.createDataSummaryTable();
  69.         content.addComponent(createDataSummaryTable);
  70.         content.setExpandRatio(createDataSummaryTable, ContentRatio.LARGE);

  71.         content.setSizeFull();
  72.         content.setMargin(false);
  73.         content.setSpacing(true);

  74.         final Button refreshViewsButton = new Button(REFRESH_VIEWS,FontAwesome.REFRESH);

  75.         refreshViewsButton.addClickListener(new RefreshDataViewsClickListener());

  76.         content.addComponent(refreshViewsButton);
  77.         content.setExpandRatio(refreshViewsButton, ContentRatio.SMALL);

  78.         final Button updateSearchIndexButton = new Button(UPDATE_SEARCH_INDEX,FontAwesome.REFRESH);

  79.         updateSearchIndexButton.addClickListener(new UpdateSearchIndexClickListener());

  80.         content.addComponent(updateSearchIndexButton);
  81.         content.setExpandRatio(updateSearchIndexButton, ContentRatio.SMALL);

  82.         return content;

  83.     }

  84. }