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 | 60 ++++++++++++++++++++++++++++++++++++++----------------------
1 files changed, 38 insertions(+), 22 deletions(-)
diff --git a/timeflow/app/TimeflowApp.java b/timeflow/app/TimeflowApp.java
index 4826184..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;
@@ -35,7 +36,8 @@
public JMenu filterMenu;
JMenuItem save = new JMenuItem("Save");
FilterControlPanel filterControlPanel;
- LinkTabPane leftPanel;
+ //LinkTabPane
+ JTabbedPane leftPanel;
TFListener filterMenuMaker = new TFListener()
{
@Override
@@ -71,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++)
@@ -81,23 +83,25 @@
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());
// left tab area, with vertical gray divider.
JPanel leftHolder = new JPanel();
- container.add(leftHolder, BorderLayout.WEST);
+ container.add(leftHolder, BorderLayout.EAST); // WEST);
leftHolder.setLayout(new BorderLayout());
JPanel pad = new Pad(3, 3);
pad.setBackground(Color.gray);
leftHolder.add(pad, BorderLayout.EAST);
- leftPanel = new LinkTabPane();//JTabbedPane();
+ leftPanel = new //LinkTabPane();
+ JTabbedPane();
leftHolder.add(leftPanel, BorderLayout.CENTER);
JPanel configPanel = new JPanel();
@@ -112,9 +116,9 @@
configPanel.add(legend, BorderLayout.CENTER);
legend.add(new SizeLegendPanel(model), BorderLayout.NORTH);
legend.add(new ColorLegendPanel(model), BorderLayout.CENTER);
- leftPanel.addTab(configPanel, "Display", true);
+ leftPanel.add(configPanel, "Display"); //, true);
- leftPanel.addTab(filterControlPanel, "Filter", true);
+ leftPanel.add(filterControlPanel, "Filter"); //, true);
// center tab area
@@ -135,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());
}
@@ -178,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");
@@ -200,7 +206,6 @@
}
fileMenu.addSeparator();
-
JMenuItem open = new JMenuItem("Open...");
fileMenu.add(open);
@@ -550,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)
@@ -689,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