From 7ac1b01c591ed65743676b1181d60eb17c5cb69d Mon Sep 17 00:00:00 2001
From: Normand Briere <nbriere@noware.ca>
Date: Wed, 21 Aug 2019 18:58:52 -0400
Subject: [PATCH] U dir and average.
---
timeflow/app/TimeflowApp.java | 40 +++++++++++++++++++++++++++-------------
1 files changed, 27 insertions(+), 13 deletions(-)
diff --git a/timeflow/app/TimeflowApp.java b/timeflow/app/TimeflowApp.java
index c579393..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.*;
@@ -25,7 +26,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 +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,9 +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());
@@ -180,7 +182,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 +206,6 @@
}
fileMenu.addSeparator();
-
JMenuItem open = new JMenuItem("Open...");
fileMenu.add(open);
@@ -552,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)
@@ -691,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