.. | .. |
---|
1 | 1 | package timeflow.app; |
---|
2 | 2 | |
---|
| 3 | +import java.net.URL; |
---|
3 | 4 | import timeflow.app.ui.*; |
---|
4 | 5 | import timeflow.app.actions.*; |
---|
5 | 6 | import timeflow.app.ui.filter.*; |
---|
.. | .. |
---|
25 | 26 | |
---|
26 | 27 | public class TimeflowApp extends JFrame |
---|
27 | 28 | { |
---|
28 | | - public TFModel model = new TFModel(); |
---|
| 29 | + public TimeflowModel model = new TimeflowModel(); |
---|
29 | 30 | public JFileChooser fileChooser; |
---|
30 | 31 | AboutWindow splash; |
---|
31 | 32 | String[][] examples; |
---|
.. | .. |
---|
35 | 36 | public JMenu filterMenu; |
---|
36 | 37 | JMenuItem save = new JMenuItem("Save"); |
---|
37 | 38 | FilterControlPanel filterControlPanel; |
---|
38 | | - LinkTabPane leftPanel; |
---|
| 39 | + //LinkTabPane |
---|
| 40 | + JTabbedPane leftPanel; |
---|
39 | 41 | TFListener filterMenuMaker = new TFListener() |
---|
40 | 42 | { |
---|
41 | 43 | @Override |
---|
.. | .. |
---|
68 | 70 | } |
---|
69 | 71 | }; |
---|
70 | 72 | |
---|
71 | | - public void TimeFlowWindow(Container container, JFrame frame) throws HeadlessException |
---|
| 73 | + public JMenuBar TimeFlowWindow(Container container) throws HeadlessException |
---|
72 | 74 | { |
---|
73 | 75 | // read example directory |
---|
74 | | - String[] ex = getVisibleFiles("settings/examples"); |
---|
| 76 | + String[] ex = getVisibleFiles("timeflow/settings/examples"); |
---|
75 | 77 | int n = ex.length; |
---|
76 | 78 | examples = new String[n][2]; |
---|
77 | 79 | for (int i = 0; i < n; i++) |
---|
.. | .. |
---|
81 | 83 | if (dot >= 0 && dot < s.length() - 1); |
---|
82 | 84 | s = s.substring(0, dot); |
---|
83 | 85 | examples[i][0] = s; |
---|
84 | | - examples[i][1] = "settings/examples/" + ex[i]; |
---|
| 86 | + examples[i][1] = "timeflow/settings/examples/" + ex[i]; |
---|
85 | 87 | } |
---|
86 | | - templates = getVisibleFiles("settings/templates"); |
---|
| 88 | + |
---|
| 89 | + templates = getVisibleFiles("timeflow/settings/templates"); |
---|
87 | 90 | fileChooser = new JFileChooser(state.getCurrentFile()); |
---|
88 | 91 | |
---|
89 | 92 | container.setLayout(new BorderLayout()); |
---|
90 | 93 | |
---|
91 | 94 | // left tab area, with vertical gray divider. |
---|
92 | 95 | JPanel leftHolder = new JPanel(); |
---|
93 | | - container.add(leftHolder, BorderLayout.WEST); |
---|
| 96 | + container.add(leftHolder, BorderLayout.EAST); // WEST); |
---|
94 | 97 | |
---|
95 | 98 | leftHolder.setLayout(new BorderLayout()); |
---|
96 | 99 | JPanel pad = new Pad(3, 3); |
---|
97 | 100 | pad.setBackground(Color.gray); |
---|
98 | 101 | leftHolder.add(pad, BorderLayout.EAST); |
---|
99 | 102 | |
---|
100 | | - leftPanel = new LinkTabPane();//JTabbedPane(); |
---|
| 103 | + leftPanel = new //LinkTabPane(); |
---|
| 104 | + JTabbedPane(); |
---|
101 | 105 | leftHolder.add(leftPanel, BorderLayout.CENTER); |
---|
102 | 106 | |
---|
103 | 107 | JPanel configPanel = new JPanel(); |
---|
.. | .. |
---|
112 | 116 | configPanel.add(legend, BorderLayout.CENTER); |
---|
113 | 117 | legend.add(new SizeLegendPanel(model), BorderLayout.NORTH); |
---|
114 | 118 | legend.add(new ColorLegendPanel(model), BorderLayout.CENTER); |
---|
115 | | - leftPanel.addTab(configPanel, "Display", true); |
---|
| 119 | + leftPanel.add(configPanel, "Display"); //, true); |
---|
116 | 120 | |
---|
117 | | - leftPanel.addTab(filterControlPanel, "Filter", true); |
---|
| 121 | + leftPanel.add(filterControlPanel, "Filter"); //, true); |
---|
118 | 122 | |
---|
119 | 123 | // center tab area |
---|
120 | 124 | |
---|
.. | .. |
---|
135 | 139 | AbstractView[] views = |
---|
136 | 140 | { |
---|
137 | 141 | timeline, |
---|
138 | | - new CalendarView(model), |
---|
| 142 | + //new CalendarView(model), |
---|
139 | 143 | new ListView(model), |
---|
140 | 144 | new TableView(model), |
---|
141 | 145 | new BarGraphView(model), |
---|
142 | | - intro, |
---|
143 | | - new DescriptionView(model), |
---|
| 146 | + //intro, |
---|
144 | 147 | new SummaryView(model), |
---|
| 148 | + new DescriptionView(model), |
---|
145 | 149 | }; |
---|
146 | 150 | |
---|
147 | 151 | for (int i = 0; i < views.length; i++) |
---|
148 | 152 | { |
---|
149 | | - center.addTab(views[i], views[i].getName(), i < 5); |
---|
| 153 | + center.addTab(views[i], views[i].getName(), true); // i < 5); |
---|
150 | 154 | displayPanel.addLocalControl(views[i].getName(), views[i].getControls()); |
---|
151 | 155 | } |
---|
152 | 156 | |
---|
.. | .. |
---|
172 | 176 | }); |
---|
173 | 177 | |
---|
174 | 178 | JMenuBar menubar = new JMenuBar(); |
---|
175 | | - frame.setJMenuBar(menubar); |
---|
| 179 | + |
---|
| 180 | + // frame.setJMenuBar(menubar); |
---|
176 | 181 | |
---|
177 | 182 | JMenu fileMenu = new JMenu("File"); |
---|
178 | 183 | menubar.add(fileMenu); |
---|
179 | 184 | |
---|
180 | | - fileMenu.add(new NewDataAction(this)); |
---|
| 185 | + TimeflowAction tlAction = new NewDataAction(this); |
---|
| 186 | + fileMenu.add(tlAction); |
---|
| 187 | + tlAction.actionPerformed(null); |
---|
181 | 188 | fileMenu.add(new CopySchemaAction(this)); |
---|
182 | 189 | |
---|
183 | 190 | JMenu templateMenu = new JMenu("New From Template"); |
---|
.. | .. |
---|
199 | 206 | } |
---|
200 | 207 | |
---|
201 | 208 | fileMenu.addSeparator(); |
---|
202 | | - |
---|
203 | 209 | |
---|
204 | 210 | JMenuItem open = new JMenuItem("Open..."); |
---|
205 | 211 | fileMenu.add(open); |
---|
.. | .. |
---|
340 | 346 | } |
---|
341 | 347 | |
---|
342 | 348 | JMenu helpMenu = new JMenu("Help"); |
---|
343 | | - menubar.add(helpMenu); |
---|
| 349 | + //menubar.add(helpMenu); |
---|
344 | 350 | |
---|
345 | 351 | helpMenu.add(new WebDocAction(this)); |
---|
346 | 352 | |
---|
.. | .. |
---|
372 | 378 | } |
---|
373 | 379 | } |
---|
374 | 380 | }); |
---|
| 381 | + |
---|
| 382 | + return menubar; |
---|
375 | 383 | } |
---|
376 | 384 | |
---|
377 | 385 | void splash(boolean visible) |
---|
.. | .. |
---|
404 | 412 | |
---|
405 | 413 | Container container = getContentPane(); |
---|
406 | 414 | |
---|
407 | | - TimeFlowWindow(container, this); |
---|
| 415 | + TimeFlowWindow(container); |
---|
408 | 416 | } |
---|
409 | 417 | |
---|
410 | 418 | void makeRecentFileMenu() |
---|
.. | .. |
---|
547 | 555 | } |
---|
548 | 556 | try |
---|
549 | 557 | { |
---|
550 | | - final File f = new File(fileName); |
---|
| 558 | + final File f = new File(TimeflowApp.class.getClassLoader().getResource(fileName).toURI()); |
---|
551 | 559 | ActDB db = importer.importFile(f); |
---|
552 | 560 | model.setDB(db, fileName, readOnly, TimeflowApp.this); |
---|
553 | 561 | if (!readOnly) |
---|
.. | .. |
---|
686 | 694 | |
---|
687 | 695 | static String[] getVisibleFiles(String dir) |
---|
688 | 696 | { |
---|
689 | | - String[] s = new File(dir).list(); |
---|
690 | | - ArrayList<String> real = new ArrayList<String>(); |
---|
691 | | - for (int i = 0; i < s.length; i++) |
---|
| 697 | + System.out.println("getVisibleFiles = " + dir); |
---|
| 698 | + try |
---|
692 | 699 | { |
---|
693 | | - if (!s[i].startsWith(".")) |
---|
| 700 | + final URL resource = TimeflowApp.class.getClassLoader().getResource(dir); |
---|
| 701 | + System.out.println("resource = " + resource); |
---|
| 702 | + String[] s = new File(resource.toURI()).list(); |
---|
| 703 | + ArrayList<String> real = new ArrayList<String>(); |
---|
| 704 | + for (int i = 0; i < s.length; i++) |
---|
694 | 705 | { |
---|
695 | | - real.add(s[i]); |
---|
| 706 | + if (!s[i].startsWith(".")) |
---|
| 707 | + { |
---|
| 708 | + real.add(s[i]); |
---|
| 709 | + } |
---|
696 | 710 | } |
---|
| 711 | + return (String[]) real.toArray(new String[0]); |
---|
697 | 712 | } |
---|
698 | | - return (String[]) real.toArray(new String[0]); |
---|
| 713 | + catch (Exception e) |
---|
| 714 | + { |
---|
| 715 | + e.printStackTrace(); |
---|
| 716 | + return new String[0]; |
---|
| 717 | + } |
---|
699 | 718 | } |
---|
700 | 719 | } |
---|