From 623dc0fa8cbd9473830a1786f6d49fa808a09439 Mon Sep 17 00:00:00 2001 From: Normand Briere <nbriere@noware.ca> Date: Sun, 05 May 2019 14:06:12 -0400 Subject: [PATCH] Rename Grafreed --- timeflow/app/TimeflowApp.java | 48 +++++++++++++++++++++++++++++++----------------- 1 files changed, 31 insertions(+), 17 deletions(-) diff --git a/timeflow/app/TimeflowApp.java b/timeflow/app/TimeflowApp.java index 1bdc790..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()); @@ -137,18 +139,18 @@ AbstractView[] views = { timeline, - new CalendarView(model), + //new CalendarView(model), new ListView(model), new TableView(model), new BarGraphView(model), - intro, - new DescriptionView(model), + //intro, new SummaryView(model), + new DescriptionView(model), }; for (int i = 0; i < views.length; i++) { - center.addTab(views[i], views[i].getName(), i < 5); + center.addTab(views[i], views[i].getName(), true); // i < 5); displayPanel.addLocalControl(views[i].getName(), views[i].getControls()); } @@ -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