Normand Briere
2019-04-24 92e4487d01f910c705211ffb5762a5c96bdd6d8c
timeflow/app/TimeflowApp.java
....@@ -25,7 +25,7 @@
2525
2626 public class TimeflowApp extends JFrame
2727 {
28
- public TFModel model = new TFModel();
28
+ public TimeflowModel model = new TimeflowModel();
2929 public JFileChooser fileChooser;
3030 AboutWindow splash;
3131 String[][] examples;
....@@ -72,7 +72,7 @@
7272 public JMenuBar TimeFlowWindow(Container container) throws HeadlessException
7373 {
7474 // read example directory
75
- String[] ex = getVisibleFiles("settings/examples");
75
+ String[] ex = getVisibleFiles("timeflow/settings/examples");
7676 int n = ex.length;
7777 examples = new String[n][2];
7878 for (int i = 0; i < n; i++)
....@@ -82,9 +82,10 @@
8282 if (dot >= 0 && dot < s.length() - 1);
8383 s = s.substring(0, dot);
8484 examples[i][0] = s;
85
- examples[i][1] = "settings/examples/" + ex[i];
85
+ examples[i][1] = "timeflow/settings/examples/" + ex[i];
8686 }
87
- templates = getVisibleFiles("settings/templates");
87
+
88
+ templates = getVisibleFiles("timeflow/settings/templates");
8889 fileChooser = new JFileChooser(state.getCurrentFile());
8990
9091 container.setLayout(new BorderLayout());
....@@ -180,7 +181,9 @@
180181 JMenu fileMenu = new JMenu("File");
181182 menubar.add(fileMenu);
182183
183
- fileMenu.add(new NewDataAction(this));
184
+ TimeflowAction tlAction = new NewDataAction(this);
185
+ fileMenu.add(tlAction);
186
+ tlAction.actionPerformed(null);
184187 fileMenu.add(new CopySchemaAction(this));
185188
186189 JMenu templateMenu = new JMenu("New From Template");
....@@ -202,7 +205,6 @@
202205 }
203206
204207 fileMenu.addSeparator();
205
-
206208
207209 JMenuItem open = new JMenuItem("Open...");
208210 fileMenu.add(open);
....@@ -552,7 +554,7 @@
552554 }
553555 try
554556 {
555
- final File f = new File(fileName);
557
+ final File f = new File(TimeflowApp.class.getClassLoader().getResource(fileName).toURI());
556558 ActDB db = importer.importFile(f);
557559 model.setDB(db, fileName, readOnly, TimeflowApp.this);
558560 if (!readOnly)
....@@ -691,15 +693,23 @@
691693
692694 static String[] getVisibleFiles(String dir)
693695 {
694
- String[] s = new File(dir).list();
695
- ArrayList<String> real = new ArrayList<String>();
696
- for (int i = 0; i < s.length; i++)
696
+ System.out.println("getVisibleFiles = " + dir);
697
+ try
697698 {
698
- if (!s[i].startsWith("."))
699
+ String[] s = new File(TimeflowApp.class.getClassLoader().getResource(dir).toURI()).list();
700
+ ArrayList<String> real = new ArrayList<String>();
701
+ for (int i = 0; i < s.length; i++)
699702 {
700
- real.add(s[i]);
703
+ if (!s[i].startsWith("."))
704
+ {
705
+ real.add(s[i]);
706
+ }
701707 }
708
+ return (String[]) real.toArray(new String[0]);
702709 }
703
- return (String[]) real.toArray(new String[0]);
710
+ catch (Exception e)
711
+ {
712
+ return new String[0];
713
+ }
704714 }
705715 }