.. | .. |
---|
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; |
---|
.. | .. |
---|
72 | 73 | public JMenuBar TimeFlowWindow(Container container) throws HeadlessException |
---|
73 | 74 | { |
---|
74 | 75 | // read example directory |
---|
75 | | - String[] ex = getVisibleFiles("settings/examples"); |
---|
| 76 | + String[] ex = getVisibleFiles("timeflow/settings/examples"); |
---|
76 | 77 | int n = ex.length; |
---|
77 | 78 | examples = new String[n][2]; |
---|
78 | 79 | for (int i = 0; i < n; i++) |
---|
.. | .. |
---|
82 | 83 | if (dot >= 0 && dot < s.length() - 1); |
---|
83 | 84 | s = s.substring(0, dot); |
---|
84 | 85 | examples[i][0] = s; |
---|
85 | | - examples[i][1] = "settings/examples/" + ex[i]; |
---|
| 86 | + examples[i][1] = "timeflow/settings/examples/" + ex[i]; |
---|
86 | 87 | } |
---|
87 | | - templates = getVisibleFiles("settings/templates"); |
---|
| 88 | + |
---|
| 89 | + templates = getVisibleFiles("timeflow/settings/templates"); |
---|
88 | 90 | fileChooser = new JFileChooser(state.getCurrentFile()); |
---|
89 | 91 | |
---|
90 | 92 | container.setLayout(new BorderLayout()); |
---|
.. | .. |
---|
180 | 182 | JMenu fileMenu = new JMenu("File"); |
---|
181 | 183 | menubar.add(fileMenu); |
---|
182 | 184 | |
---|
183 | | - fileMenu.add(new NewDataAction(this)); |
---|
| 185 | + TimeflowAction tlAction = new NewDataAction(this); |
---|
| 186 | + fileMenu.add(tlAction); |
---|
| 187 | + tlAction.actionPerformed(null); |
---|
184 | 188 | fileMenu.add(new CopySchemaAction(this)); |
---|
185 | 189 | |
---|
186 | 190 | JMenu templateMenu = new JMenu("New From Template"); |
---|
.. | .. |
---|
202 | 206 | } |
---|
203 | 207 | |
---|
204 | 208 | fileMenu.addSeparator(); |
---|
205 | | - |
---|
206 | 209 | |
---|
207 | 210 | JMenuItem open = new JMenuItem("Open..."); |
---|
208 | 211 | fileMenu.add(open); |
---|
.. | .. |
---|
552 | 555 | } |
---|
553 | 556 | try |
---|
554 | 557 | { |
---|
555 | | - final File f = new File(fileName); |
---|
| 558 | + final File f = new File(TimeflowApp.class.getClassLoader().getResource(fileName).toURI()); |
---|
556 | 559 | ActDB db = importer.importFile(f); |
---|
557 | 560 | model.setDB(db, fileName, readOnly, TimeflowApp.this); |
---|
558 | 561 | if (!readOnly) |
---|
.. | .. |
---|
691 | 694 | |
---|
692 | 695 | static String[] getVisibleFiles(String dir) |
---|
693 | 696 | { |
---|
694 | | - String[] s = new File(dir).list(); |
---|
695 | | - ArrayList<String> real = new ArrayList<String>(); |
---|
696 | | - for (int i = 0; i < s.length; i++) |
---|
| 697 | + System.out.println("getVisibleFiles = " + dir); |
---|
| 698 | + try |
---|
697 | 699 | { |
---|
698 | | - 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++) |
---|
699 | 705 | { |
---|
700 | | - real.add(s[i]); |
---|
| 706 | + if (!s[i].startsWith(".")) |
---|
| 707 | + { |
---|
| 708 | + real.add(s[i]); |
---|
| 709 | + } |
---|
701 | 710 | } |
---|
| 711 | + return (String[]) real.toArray(new String[0]); |
---|
702 | 712 | } |
---|
703 | | - return (String[]) real.toArray(new String[0]); |
---|
| 713 | + catch (Exception e) |
---|
| 714 | + { |
---|
| 715 | + e.printStackTrace(); |
---|
| 716 | + return new String[0]; |
---|
| 717 | + } |
---|
704 | 718 | } |
---|
705 | 719 | } |
---|