Coverage Report - org.jtheque.films.stats.view.impl.StatsView
 
Classes in this File Line Coverage Branch Coverage Complexity
StatsView
0 %
0/31
N/A
1
 
 1  
 package org.jtheque.films.stats.view.impl;
 2  
 
 3  
 /*
 4  
  * This file is part of JTheque.
 5  
  *
 6  
  * JTheque is free software: you can redistribute it and/or modify
 7  
  * it under the terms of the GNU General Public License as published by
 8  
  * the Free Software Foundation, either version 3 of the License.
 9  
  *
 10  
  * JTheque is distributed in the hope that it will be useful,
 11  
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 12  
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 13  
  * GNU General Public License for more details.
 14  
  *
 15  
  * You should have received a copy of the GNU General Public License
 16  
  * along with JTheque.  If not, see <http://www.gnu.org/licenses/>.
 17  
  */
 18  
 
 19  
 import org.jdesktop.swingx.JXHeader;
 20  
 import org.jtheque.core.managers.Managers;
 21  
 import org.jtheque.core.managers.error.JThequeError;
 22  
 import org.jtheque.core.managers.language.ILanguageManager;
 23  
 import org.jtheque.core.managers.language.TabTitleUpdater;
 24  
 import org.jtheque.core.managers.view.able.IViewManager;
 25  
 import org.jtheque.core.managers.view.impl.frame.abstraction.SwingDialogView;
 26  
 import org.jtheque.films.stats.view.able.IStatsView;
 27  
 import org.jtheque.films.stats.view.impl.panels.PanelStats;
 28  
 import org.springframework.stereotype.Component;
 29  
 
 30  
 import javax.swing.*;
 31  
 import java.awt.Container;
 32  
 import java.awt.Frame;
 33  
 import java.util.Collection;
 34  
 import java.util.HashMap;
 35  
 import java.util.Map;
 36  
 
 37  
 /**
 38  
  * A view to display the stats.
 39  
  *
 40  
  * @author Baptiste Wicht
 41  
  */
 42  
 public final class StatsView extends SwingDialogView implements IStatsView {
 43  
     private static final long serialVersionUID = 1L;
 44  
 
 45  
     /**
 46  
      * The tabbed pane of the view.
 47  
      */
 48  
     private JTabbedPane tab;
 49  
 
 50  
     private final PanelStats panelFilms;
 51  
     private final PanelStats panelActors;
 52  
     private final PanelStats panelRealizers;
 53  
 
 54  
     private static final int DEFAULT_WIDTH = 650;
 55  
     private static final int DEFAULT_HEIGHT = 600;
 56  
 
 57  
     /**
 58  
      * Construct a new StatsView modal to the parent view.
 59  
      *
 60  
      * @param parent         The parent frame.
 61  
      * @param panelFilms     The panel films.
 62  
      * @param panelActors    The panel actors.
 63  
      * @param panelRealizers The panel realizers.
 64  
      */
 65  
     public StatsView(Frame parent, PanelStats panelFilms, PanelStats panelActors, PanelStats panelRealizers) {
 66  0
         super(parent);
 67  
 
 68  0
         setJMenuBar(new JMenuBarStats());
 69  
 
 70  0
         this.panelFilms = panelFilms;
 71  0
         this.panelActors = panelActors;
 72  0
         this.panelRealizers = panelRealizers;
 73  
 
 74  0
         build();
 75  0
     }
 76  
 
 77  
     /**
 78  
      * Build the view.
 79  
      */
 80  
     private void build() {
 81  0
         setContentPane(buildContentPane());
 82  0
         setTitleKey("stats.view.title");
 83  
 
 84  0
         Managers.getManager(IViewManager.class).configureView(this, "stats", DEFAULT_WIDTH, DEFAULT_HEIGHT);
 85  0
     }
 86  
 
 87  
     /**
 88  
      * Build the content pane.
 89  
      *
 90  
      * @return The content pane.
 91  
      */
 92  
     private Container buildContentPane() {
 93  0
         tab = new JTabbedPane();
 94  0
         tab.setTabPlacement(JTabbedPane.TOP);
 95  
 
 96  0
         Map<JComponent, String> components = new HashMap<JComponent, String>(3);
 97  
 
 98  0
         addTab(components, panelFilms, "stats.view.tab.films");
 99  0
         addTab(components, panelActors, "stats.view.tab.actors");
 100  0
         addTab(components, panelRealizers, "stats.view.tab.realizers");
 101  
         
 102  0
         Managers.getManager(ILanguageManager.class).addInternationalizable(new TabTitleUpdater(tab, components));
 103  
 
 104  0
         return tab;
 105  
     }
 106  
 
 107  
     private void addTab(Map<JComponent, String> components, PanelStats panel, String key) {
 108  0
         JComponent component = new JScrollPane(panel);
 109  
 
 110  0
         components.put(component, key);
 111  0
         tab.addTab(Managers.getManager(ILanguageManager.class).getMessage(key), component);
 112  0
     }
 113  
 
 114  
     @Override
 115  
     public void closeDown() {
 116  0
         Managers.getManager(IViewManager.class).saveState(this, "main");
 117  
 
 118  0
         super.closeDown();
 119  0
     }
 120  
 
 121  
     @Override
 122  
     public JTabbedPane getTab() {
 123  0
         return tab;
 124  
     }
 125  
 
 126  
     @Override
 127  
     public JXHeader getHeaderRealizers() {
 128  0
         return panelRealizers.getHeader();
 129  
     }
 130  
 
 131  
     @Override
 132  
     public JXHeader getHeaderFilms() {
 133  0
         return panelFilms.getHeader();
 134  
     }
 135  
 
 136  
     @Override
 137  
     public JXHeader getHeaderActors() {
 138  0
         return panelActors.getHeader();
 139  
     }
 140  
 
 141  
     @Override
 142  
     protected void validate(Collection<JThequeError> errors) {
 143  0
     }
 144  
 }