View Javadoc
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.common.menufactory.impl;
20  
21  import org.springframework.stereotype.Service;
22  
23  import com.hack23.cia.web.impl.ui.application.views.common.menufactory.api.BallotMenuItemFactory;
24  import com.hack23.cia.web.impl.ui.application.views.common.pagelinks.api.PageModeMenuCommand;
25  import com.hack23.cia.web.impl.ui.application.views.common.viewnames.PageMode;
26  import com.hack23.cia.web.impl.ui.application.views.common.viewnames.UserViews;
27  import com.vaadin.server.FontAwesome;
28  import com.vaadin.ui.GridLayout;
29  import com.vaadin.ui.MenuBar;
30  import com.vaadin.ui.VerticalLayout;
31  
32  /**
33   * The Class BallotMenuItemFactoryImpl.
34   */
35  @Service
36  public final class BallotMenuItemFactoryImpl extends AbstractMenuItemFactoryImpl implements BallotMenuItemFactory {
37  
38  
39  	/** The Constant INDICATORS_TEXT. */
40  	private static final String INDICATORS_TEXT = "Indicators";
41  
42  	/** The Constant CHARTS_TEXT. */
43  	private static final String CHARTS_TEXT = "Charts";
44  
45  	/** The Constant OVERVIEW_TEXT. */
46  	private static final String OVERVIEW_TEXT = "Overview";
47  
48  
49  	/**
50  	 * Instantiates a new ballot menu item factory impl.
51  	 */
52  	public BallotMenuItemFactoryImpl() {
53  		super();
54  	}
55  
56  	@Override
57  	public void createBallotMenuBar(final MenuBar menuBar, final String pageId) {
58  		initApplicationMenuBar(menuBar);
59  
60  		menuBar.addItem(OVERVIEW_TEXT, FontAwesome.PIE_CHART,
61  				new PageModeMenuCommand(UserViews.BALLOT_VIEW_NAME, PageMode.OVERVIEW, pageId));
62  		menuBar.addItem(CHARTS_TEXT, FontAwesome.PIE_CHART,
63  				new PageModeMenuCommand(UserViews.BALLOT_VIEW_NAME, PageMode.CHARTS, pageId));
64  		menuBar.addItem(INDICATORS_TEXT, FontAwesome.PIE_CHART,
65  				new PageModeMenuCommand(UserViews.BALLOT_VIEW_NAME, PageMode.INDICATORS, pageId));
66  
67  	}
68  
69  	@Override
70  	public void createOverviewPage(final VerticalLayout panelContent, final String pageId) {
71  		final GridLayout grid = createGridLayout(panelContent);
72  
73  		createButtonLink(grid,CHARTS_TEXT, FontAwesome.PIE_CHART,
74  				new PageModeMenuCommand(UserViews.BALLOT_VIEW_NAME, PageMode.CHARTS, pageId), "Default description");
75  
76  		createButtonLink(grid,INDICATORS_TEXT, FontAwesome.PIE_CHART,
77  				new PageModeMenuCommand(UserViews.BALLOT_VIEW_NAME, PageMode.INDICATORS, pageId), "Default description");
78  
79  	}
80  
81  }