Normand Briere
2018-07-07 ecaf579303705545735450cbc8b8014d7e062329
timeflow/app/TimeflowApp.java
....@@ -25,7 +25,6 @@
2525
2626 public class TimeflowApp extends JFrame
2727 {
28
-
2928 public TFModel model = new TFModel();
3029 public JFileChooser fileChooser;
3130 AboutWindow splash;
....@@ -39,7 +38,6 @@
3938 LinkTabPane leftPanel;
4039 TFListener filterMenuMaker = new TFListener()
4140 {
42
-
4341 @Override
4442 public void note(TFEvent e)
4543 {
....@@ -70,35 +68,8 @@
7068 }
7169 };
7270
73
- void splash(boolean visible)
71
+ public void TimeFlowWindow(Container container, JFrame frame) throws HeadlessException
7472 {
75
- splash.setVisible(visible);
76
- }
77
-
78
- public void init() throws Exception
79
- {
80
- Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
81
- setBounds(0, 0, Math.min(d.width, 1200), Math.min(d.height, 900));
82
- setTitle(Display.version());
83
- setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
84
- final QuitAction quitAction = new QuitAction(this, model);
85
- addWindowListener(new WindowAdapter()
86
- {
87
-
88
- @Override
89
- public void windowClosing(WindowEvent e)
90
- {
91
- quitAction.quit();
92
- }
93
-
94
- public void windowStateChanged(WindowEvent e)
95
- {
96
- repaint();
97
- }
98
- });
99
- Image icon = Toolkit.getDefaultToolkit().getImage("images/icon.gif");
100
- setIconImage(icon);
101
-
10273 // read example directory
10374 String[] ex = getVisibleFiles("settings/examples");
10475 int n = ex.length;
....@@ -115,11 +86,11 @@
11586 templates = getVisibleFiles("settings/templates");
11687 fileChooser = new JFileChooser(state.getCurrentFile());
11788
118
- getContentPane().setLayout(new BorderLayout());
89
+ container.setLayout(new BorderLayout());
11990
12091 // left tab area, with vertical gray divider.
12192 JPanel leftHolder = new JPanel();
122
- getContentPane().add(leftHolder, BorderLayout.WEST);
93
+ container.add(leftHolder, BorderLayout.WEST);
12394
12495 leftHolder.setLayout(new BorderLayout());
12596 JPanel pad = new Pad(3, 3);
....@@ -148,11 +119,10 @@
148119 // center tab area
149120
150121 final LinkTabPane center = new LinkTabPane();
151
- getContentPane().add(center, BorderLayout.CENTER);
122
+ container.add(center, BorderLayout.CENTER);
152123
153124 center.addPropertyChangeListener(new PropertyChangeListener()
154125 {
155
-
156126 @Override
157127 public void propertyChange(PropertyChangeEvent evt)
158128 {
....@@ -187,7 +157,6 @@
187157 // but then, once data is loaded, switch directly to the timeline view.
188158 model.addListener(new TFListener()
189159 {
190
-
191160 @Override
192161 public void note(TFEvent e)
193162 {
....@@ -203,7 +172,7 @@
203172 });
204173
205174 JMenuBar menubar = new JMenuBar();
206
- setJMenuBar(menubar);
175
+ frame.setJMenuBar(menubar);
207176
208177 JMenu fileMenu = new JMenu("File");
209178 menubar.add(fileMenu);
....@@ -236,7 +205,6 @@
236205 fileMenu.add(open);
237206 open.addActionListener(new ActionListener()
238207 {
239
-
240208 @Override
241209 public void actionPerformed(ActionEvent e)
242210 {
....@@ -254,7 +222,6 @@
254222 fileMenu.add(impDel);
255223 impDel.addActionListener(new ActionListener()
256224 {
257
-
258225 @Override
259226 public void actionPerformed(ActionEvent e)
260227 {
....@@ -273,7 +240,6 @@
273240 save.setEnabled(false);
274241 save.addActionListener(new ActionListener()
275242 {
276
-
277243 @Override
278244 public void actionPerformed(ActionEvent e)
279245 {
....@@ -283,7 +249,6 @@
283249 });
284250 model.addListener(new TFListener()
285251 {
286
-
287252 @Override
288253 public void note(TFEvent e)
289254 {
....@@ -295,7 +260,6 @@
295260 fileMenu.add(saveAs);
296261 saveAs.addActionListener(new ActionListener()
297262 {
298
-
299263 @Override
300264 public void actionPerformed(ActionEvent e)
301265 {
....@@ -309,7 +273,6 @@
309273 fileMenu.add(exportTSV);
310274 exportTSV.addActionListener(new ActionListener()
311275 {
312
-
313276 @Override
314277 public void actionPerformed(ActionEvent e)
315278 {
....@@ -320,7 +283,6 @@
320283 fileMenu.add(exportCSV);
321284 exportCSV.addActionListener(new ActionListener()
322285 {
323
-
324286 @Override
325287 public void actionPerformed(ActionEvent e)
326288 {
....@@ -331,15 +293,14 @@
331293 fileMenu.add(exportHTML);
332294 exportHTML.addActionListener(new ActionListener()
333295 {
334
-
335296 @Override
336297 public void actionPerformed(ActionEvent e)
337298 {
338299 exportHtml();
339300 }
340301 });
341
- fileMenu.addSeparator();
342
- fileMenu.add(quitAction);
302
+// fileMenu.addSeparator();
303
+// fileMenu.add(quitAction);
343304
344305 JMenu editMenu = new JMenu("Edit");
345306 menubar.add(editMenu);
....@@ -370,7 +331,6 @@
370331 final String file = examples[i][1];
371332 example.addActionListener(new ActionListener()
372333 {
373
-
374334 @Override
375335 public void actionPerformed(ActionEvent e)
376336 {
....@@ -388,7 +348,6 @@
388348 helpMenu.add(about);
389349 about.addActionListener(new ActionListener()
390350 {
391
-
392351 @Override
393352 public void actionPerformed(ActionEvent e)
394353 {
....@@ -398,7 +357,6 @@
398357
399358 model.addListener(new TFListener()
400359 {
401
-
402360 @Override
403361 public void note(TFEvent e)
404362 {
....@@ -416,6 +374,39 @@
416374 });
417375 }
418376
377
+ void splash(boolean visible)
378
+ {
379
+ splash.setVisible(visible);
380
+ }
381
+
382
+ public void init() throws Exception
383
+ {
384
+ Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
385
+ setBounds(0, 0, Math.min(d.width, 1200), Math.min(d.height, 900));
386
+ setTitle(Display.version());
387
+ setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
388
+// final QuitAction quitAction = new QuitAction(this, model);
389
+// addWindowListener(new WindowAdapter()
390
+// {
391
+// @Override
392
+// public void windowClosing(WindowEvent e)
393
+// {
394
+// quitAction.quit();
395
+// }
396
+//
397
+// public void windowStateChanged(WindowEvent e)
398
+// {
399
+// repaint();
400
+// }
401
+// });
402
+ Image icon = Toolkit.getDefaultToolkit().getImage("images/icon.gif");
403
+ setIconImage(icon);
404
+
405
+ Container container = getContentPane();
406
+
407
+ TimeFlowWindow(container, this);
408
+ }
409
+
419410 void makeRecentFileMenu()
420411 {
421412 openRecent.removeAll();