From 92e4487d01f910c705211ffb5762a5c96bdd6d8c Mon Sep 17 00:00:00 2001 From: Normand Briere <nbriere@noware.ca> Date: Tue, 23 Apr 2019 22:59:09 -0400 Subject: [PATCH] Fix timeflow examples. --- timeflow/app/TimeflowApp.java | 36 +++++++++++++++++++++++------------- 1 files changed, 23 insertions(+), 13 deletions(-) diff --git a/timeflow/app/TimeflowApp.java b/timeflow/app/TimeflowApp.java index c579393..d2c47c4 100755 --- a/timeflow/app/TimeflowApp.java +++ b/timeflow/app/TimeflowApp.java @@ -25,7 +25,7 @@ public class TimeflowApp extends JFrame { - public TFModel model = new TFModel(); + public TimeflowModel model = new TimeflowModel(); public JFileChooser fileChooser; AboutWindow splash; String[][] examples; @@ -72,7 +72,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,9 +82,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()); @@ -180,7 +181,9 @@ JMenu fileMenu = new JMenu("File"); menubar.add(fileMenu); - fileMenu.add(new NewDataAction(this)); + TimeflowAction tlAction = new NewDataAction(this); + fileMenu.add(tlAction); + tlAction.actionPerformed(null); fileMenu.add(new CopySchemaAction(this)); JMenu templateMenu = new JMenu("New From Template"); @@ -202,7 +205,6 @@ } fileMenu.addSeparator(); - JMenuItem open = new JMenuItem("Open..."); fileMenu.add(open); @@ -552,7 +554,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) @@ -691,15 +693,23 @@ 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(".")) + String[] s = new File(TimeflowApp.class.getClassLoader().getResource(dir).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) + { + return new String[0]; + } } } -- Gitblit v1.6.2