From f1c718cce66e5651a0dae91375db6ebfaded1a92 Mon Sep 17 00:00:00 2001 From: Normand Briere <nbriere@noware.ca> Date: Sat, 27 Apr 2019 21:33:41 -0400 Subject: [PATCH] Test unfold UV --- timeflow/app/TimeflowApp.java | 32 ++++++++++++++++++++++---------- 1 files changed, 22 insertions(+), 10 deletions(-) diff --git a/timeflow/app/TimeflowApp.java b/timeflow/app/TimeflowApp.java index a057ddb..f70bc07 100755 --- a/timeflow/app/TimeflowApp.java +++ b/timeflow/app/TimeflowApp.java @@ -1,5 +1,6 @@ package timeflow.app; +import java.net.URL; import timeflow.app.ui.*; import timeflow.app.actions.*; import timeflow.app.ui.filter.*; @@ -72,7 +73,7 @@ public JMenuBar TimeFlowWindow(Container container) throws HeadlessException { // read example directory - String[] ex = getVisibleFiles("settings/examples"); + String[] ex = getVisibleFiles("timeflow/settings/examples"); int n = ex.length; examples = new String[n][2]; for (int i = 0; i < n; i++) @@ -82,10 +83,10 @@ if (dot >= 0 && dot < s.length() - 1); s = s.substring(0, dot); examples[i][0] = s; - examples[i][1] = "settings/examples/" + ex[i]; + examples[i][1] = "timeflow/settings/examples/" + ex[i]; } - templates = getVisibleFiles("settings/templates"); + templates = getVisibleFiles("timeflow/settings/templates"); fileChooser = new JFileChooser(state.getCurrentFile()); container.setLayout(new BorderLayout()); @@ -554,7 +555,7 @@ } try { - final File f = new File(fileName); + final File f = new File(TimeflowApp.class.getClassLoader().getResource(fileName).toURI()); ActDB db = importer.importFile(f); model.setDB(db, fileName, readOnly, TimeflowApp.this); if (!readOnly) @@ -693,15 +694,26 @@ static String[] getVisibleFiles(String dir) { - String[] s = new File(dir).list(); - ArrayList<String> real = new ArrayList<String>(); - for (int i = 0; i < s.length; i++) + System.out.println("getVisibleFiles = " + dir); + try { - if (!s[i].startsWith(".")) + final URL resource = TimeflowApp.class.getClassLoader().getResource(dir); + System.out.println("resource = " + resource); + String[] s = new File(resource.toURI()).list(); + ArrayList<String> real = new ArrayList<String>(); + for (int i = 0; i < s.length; i++) { - real.add(s[i]); + if (!s[i].startsWith(".")) + { + real.add(s[i]); + } } + return (String[]) real.toArray(new String[0]); } - return (String[]) real.toArray(new String[0]); + catch (Exception e) + { + e.printStackTrace(); + return new String[0]; + } } } -- Gitblit v1.6.2