| 1 | |
package org.jtheque.films.stats.view.impl; |
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 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 | |
|
| 39 | |
|
| 40 | |
|
| 41 | |
|
| 42 | |
public final class StatsView extends SwingDialogView implements IStatsView { |
| 43 | |
private static final long serialVersionUID = 1L; |
| 44 | |
|
| 45 | |
|
| 46 | |
|
| 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 | |
|
| 59 | |
|
| 60 | |
|
| 61 | |
|
| 62 | |
|
| 63 | |
|
| 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 | |
|
| 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 | |
|
| 89 | |
|
| 90 | |
|
| 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 | |
} |