Normand Briere
2019-04-24 92e4487d01f910c705211ffb5762a5c96bdd6d8c
timeflow/app/TimeflowApp.java
....@@ -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,10 +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 }
8787
88
- templates = getVisibleFiles("settings/templates");
88
+ templates = getVisibleFiles("timeflow/settings/templates");
8989 fileChooser = new JFileChooser(state.getCurrentFile());
9090
9191 container.setLayout(new BorderLayout());
....@@ -554,7 +554,7 @@
554554 }
555555 try
556556 {
557
- final File f = new File(fileName);
557
+ final File f = new File(TimeflowApp.class.getClassLoader().getResource(fileName).toURI());
558558 ActDB db = importer.importFile(f);
559559 model.setDB(db, fileName, readOnly, TimeflowApp.this);
560560 if (!readOnly)
....@@ -693,15 +693,23 @@
693693
694694 static String[] getVisibleFiles(String dir)
695695 {
696
- String[] s = new File(dir).list();
697
- ArrayList<String> real = new ArrayList<String>();
698
- for (int i = 0; i < s.length; i++)
696
+ System.out.println("getVisibleFiles = " + dir);
697
+ try
699698 {
700
- 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++)
701702 {
702
- real.add(s[i]);
703
+ if (!s[i].startsWith("."))
704
+ {
705
+ real.add(s[i]);
706
+ }
703707 }
708
+ return (String[]) real.toArray(new String[0]);
704709 }
705
- return (String[]) real.toArray(new String[0]);
710
+ catch (Exception e)
711
+ {
712
+ return new String[0];
713
+ }
706714 }
707715 }