Normand Briere
2019-07-27 1af7d3700724834e40ad8636bc9a56cdc3b19b15
timeflow/app/TimeflowApp.java
....@@ -1,5 +1,6 @@
11 package timeflow.app;
22
3
+import java.net.URL;
34 import timeflow.app.ui.*;
45 import timeflow.app.actions.*;
56 import timeflow.app.ui.filter.*;
....@@ -25,7 +26,7 @@
2526
2627 public class TimeflowApp extends JFrame
2728 {
28
- public TFModel model = new TFModel();
29
+ public TimeflowModel model = new TimeflowModel();
2930 public JFileChooser fileChooser;
3031 AboutWindow splash;
3132 String[][] examples;
....@@ -72,7 +73,7 @@
7273 public JMenuBar TimeFlowWindow(Container container) throws HeadlessException
7374 {
7475 // read example directory
75
- String[] ex = getVisibleFiles("settings/examples");
76
+ String[] ex = getVisibleFiles("timeflow/settings/examples");
7677 int n = ex.length;
7778 examples = new String[n][2];
7879 for (int i = 0; i < n; i++)
....@@ -82,9 +83,10 @@
8283 if (dot >= 0 && dot < s.length() - 1);
8384 s = s.substring(0, dot);
8485 examples[i][0] = s;
85
- examples[i][1] = "settings/examples/" + ex[i];
86
+ examples[i][1] = "timeflow/settings/examples/" + ex[i];
8687 }
87
- templates = getVisibleFiles("settings/templates");
88
+
89
+ templates = getVisibleFiles("timeflow/settings/templates");
8890 fileChooser = new JFileChooser(state.getCurrentFile());
8991
9092 container.setLayout(new BorderLayout());
....@@ -137,18 +139,18 @@
137139 AbstractView[] views =
138140 {
139141 timeline,
140
- new CalendarView(model),
142
+ //new CalendarView(model),
141143 new ListView(model),
142144 new TableView(model),
143145 new BarGraphView(model),
144
- intro,
145
- new DescriptionView(model),
146
+ //intro,
146147 new SummaryView(model),
148
+ new DescriptionView(model),
147149 };
148150
149151 for (int i = 0; i < views.length; i++)
150152 {
151
- center.addTab(views[i], views[i].getName(), i < 5);
153
+ center.addTab(views[i], views[i].getName(), true); // i < 5);
152154 displayPanel.addLocalControl(views[i].getName(), views[i].getControls());
153155 }
154156
....@@ -180,7 +182,9 @@
180182 JMenu fileMenu = new JMenu("File");
181183 menubar.add(fileMenu);
182184
183
- fileMenu.add(new NewDataAction(this));
185
+ TimeflowAction tlAction = new NewDataAction(this);
186
+ fileMenu.add(tlAction);
187
+ tlAction.actionPerformed(null);
184188 fileMenu.add(new CopySchemaAction(this));
185189
186190 JMenu templateMenu = new JMenu("New From Template");
....@@ -202,7 +206,6 @@
202206 }
203207
204208 fileMenu.addSeparator();
205
-
206209
207210 JMenuItem open = new JMenuItem("Open...");
208211 fileMenu.add(open);
....@@ -552,7 +555,7 @@
552555 }
553556 try
554557 {
555
- final File f = new File(fileName);
558
+ final File f = new File(TimeflowApp.class.getClassLoader().getResource(fileName).toURI());
556559 ActDB db = importer.importFile(f);
557560 model.setDB(db, fileName, readOnly, TimeflowApp.this);
558561 if (!readOnly)
....@@ -691,15 +694,26 @@
691694
692695 static String[] getVisibleFiles(String dir)
693696 {
694
- String[] s = new File(dir).list();
695
- ArrayList<String> real = new ArrayList<String>();
696
- for (int i = 0; i < s.length; i++)
697
+ System.out.println("getVisibleFiles = " + dir);
698
+ try
697699 {
698
- if (!s[i].startsWith("."))
700
+ final URL resource = TimeflowApp.class.getClassLoader().getResource(dir);
701
+ System.out.println("resource = " + resource);
702
+ String[] s = new File(resource.toURI()).list();
703
+ ArrayList<String> real = new ArrayList<String>();
704
+ for (int i = 0; i < s.length; i++)
699705 {
700
- real.add(s[i]);
706
+ if (!s[i].startsWith("."))
707
+ {
708
+ real.add(s[i]);
709
+ }
701710 }
711
+ return (String[]) real.toArray(new String[0]);
702712 }
703
- return (String[]) real.toArray(new String[0]);
713
+ catch (Exception e)
714
+ {
715
+ e.printStackTrace();
716
+ return new String[0];
717
+ }
704718 }
705719 }