4 * License : The MIT License
5 * Copyright(c) 2012 olyutorskii
8 package jp.sfjp.jindolf.view;
10 import java.awt.EventQueue;
11 import java.awt.Frame;
12 import java.awt.Window;
13 import java.util.LinkedList;
14 import java.util.List;
15 import javax.swing.SwingUtilities;
16 import javax.swing.UIManager;
17 import javax.swing.UnsupportedLookAndFeelException;
18 import jp.sfjp.jindolf.VerInfo;
19 import jp.sfjp.jindolf.log.LogFrame;
20 import jp.sfjp.jindolf.summary.DaySummary;
21 import jp.sfjp.jindolf.summary.VillageDigest;
26 public class WindowManager {
28 private static final String TITLE_FILTER =
29 getFrameTitle("発言フィルタ");
30 private static final String TITLE_LOGGER =
31 getFrameTitle("ログ表示");
32 private static final String TITLE_OPTION =
33 getFrameTitle("オプション設定");
34 private static final String TITLE_FIND =
35 getFrameTitle("発言検索");
36 private static final String TITLE_DIGEST =
37 getFrameTitle("村のダイジェスト");
38 private static final String TITLE_DAYSUMMARY =
39 getFrameTitle("発言集計");
40 private static final String TITLE_HELP =
43 private static final Frame NULLPARENT = null;
46 private FilterPanel filterPanel;
47 private LogFrame logFrame;
48 private OptionPanel optionPanel;
49 private FindPanel findPanel;
50 private VillageDigest villageDigest;
51 private DaySummary daySummary;
52 private HelpFrame helpFrame;
53 private TopFrame topFrame;
55 private final List<Window> windowSet = new LinkedList<>();
61 public WindowManager(){
73 private static String getFrameTitle(String text){
74 String result = VerInfo.getFrameTitle(text);
84 protected FilterPanel createFilterPanel(){
87 result = new FilterPanel(NULLPARENT);
88 result.setTitle(TITLE_FILTER);
90 result.setVisible(false);
92 this.windowSet.add(result);
100 * @return 発言フィルタウィンドウ
102 public FilterPanel getFilterPanel(){
103 if(this.filterPanel == null){
104 this.filterPanel = createFilterPanel();
106 return this.filterPanel;
114 protected LogFrame createLogFrame(){
117 result = new LogFrame(NULLPARENT);
118 result.setTitle(TITLE_LOGGER);
120 result.setSize(600, 500);
121 result.setLocationByPlatform(true);
122 result.setVisible(false);
124 this.windowSet.add(result);
134 public LogFrame getLogFrame(){
135 if(this.logFrame == null){
136 this.logFrame = createLogFrame();
138 return this.logFrame;
144 * @return オプション設定ウィンドウ
146 protected OptionPanel createOptionPanel(){
149 result = new OptionPanel(NULLPARENT);
150 result.setTitle(TITLE_OPTION);
152 result.setSize(450, 500);
153 result.setVisible(false);
155 this.windowSet.add(result);
163 * @return オプション設定ウィンドウ
165 public OptionPanel getOptionPanel(){
166 if(this.optionPanel == null){
167 this.optionPanel = createOptionPanel();
169 return this.optionPanel;
177 protected FindPanel createFindPanel(){
180 result = new FindPanel(NULLPARENT);
181 result.setTitle(TITLE_FIND);
183 result.setVisible(false);
185 this.windowSet.add(result);
195 public FindPanel getFindPanel(){
196 if(this.findPanel == null){
197 this.findPanel = createFindPanel();
199 return this.findPanel;
205 * @return 村ダイジェストウィンドウ
207 protected VillageDigest createVillageDigest(){
208 VillageDigest result;
210 result = new VillageDigest(NULLPARENT);
211 result.setTitle(TITLE_DIGEST);
213 result.setSize(600, 550);
214 result.setVisible(false);
216 this.windowSet.add(result);
224 * @return 村ダイジェストウィンドウ
226 public VillageDigest getVillageDigest(){
227 if(this.villageDigest == null){
228 this.villageDigest = createVillageDigest();
230 return this.villageDigest;
238 protected DaySummary createDaySummary(){
241 result = new DaySummary(NULLPARENT);
242 result.setTitle(TITLE_DAYSUMMARY);
244 result.setSize(400, 500);
245 result.setVisible(false);
247 this.windowSet.add(result);
257 public DaySummary getDaySummary(){
258 if(this.daySummary == null){
259 this.daySummary = createDaySummary();
261 return this.daySummary;
269 protected HelpFrame createHelpFrame(){
272 result = new HelpFrame();
273 result.setTitle(TITLE_HELP);
275 result.setSize(450, 450);
276 result.setVisible(false);
278 this.windowSet.add(result);
288 public HelpFrame getHelpFrame(){
289 if(this.helpFrame == null){
290 this.helpFrame = createHelpFrame();
292 return this.helpFrame;
300 protected TopFrame createTopFrame(){
301 TopFrame result = new TopFrame();
302 result.setVisible(false);
303 this.windowSet.add(result);
312 public TopFrame getTopFrame(){
313 if(this.topFrame == null){
314 this.topFrame = createTopFrame();
316 return this.topFrame;
320 * 管理下にある全ウィンドウのLookAndFeelを更新する。
322 * <p>必要に応じて再パッキングが行われる。
324 * @param className Look and Feel
325 * @throws java.lang.ReflectiveOperationException reflection error
326 * @throws javax.swing.UnsupportedLookAndFeelException Unsupported LAF
328 public void changeAllWindowUI(String className)
329 throws ReflectiveOperationException,
330 UnsupportedLookAndFeelException {
331 assert EventQueue.isDispatchThread();
333 UIManager.setLookAndFeel(className);
335 this.windowSet.forEach((window) -> {
336 SwingUtilities.updateComponentTreeUI(window);
339 if(this.filterPanel != null) this.filterPanel.pack();
340 if(this.findPanel != null) this.findPanel.pack();