| .. | .. |
|---|
| 1 | 1 | package timeflow.app; |
|---|
| 2 | 2 | |
|---|
| 3 | +import java.net.URL; |
|---|
| 3 | 4 | import timeflow.app.ui.*; |
|---|
| 4 | 5 | import timeflow.app.actions.*; |
|---|
| 5 | 6 | import timeflow.app.ui.filter.*; |
|---|
| .. | .. |
|---|
| 72 | 73 | public JMenuBar TimeFlowWindow(Container container) throws HeadlessException |
|---|
| 73 | 74 | { |
|---|
| 74 | 75 | // read example directory |
|---|
| 75 | | - String[] ex = getVisibleFiles("settings/examples"); |
|---|
| 76 | + String[] ex = getVisibleFiles("timeflow/settings/examples"); |
|---|
| 76 | 77 | int n = ex.length; |
|---|
| 77 | 78 | examples = new String[n][2]; |
|---|
| 78 | 79 | for (int i = 0; i < n; i++) |
|---|
| .. | .. |
|---|
| 82 | 83 | if (dot >= 0 && dot < s.length() - 1); |
|---|
| 83 | 84 | s = s.substring(0, dot); |
|---|
| 84 | 85 | examples[i][0] = s; |
|---|
| 85 | | - examples[i][1] = "settings/examples/" + ex[i]; |
|---|
| 86 | + examples[i][1] = "timeflow/settings/examples/" + ex[i]; |
|---|
| 86 | 87 | } |
|---|
| 87 | 88 | |
|---|
| 88 | | - templates = getVisibleFiles("settings/templates"); |
|---|
| 89 | + templates = getVisibleFiles("timeflow/settings/templates"); |
|---|
| 89 | 90 | fileChooser = new JFileChooser(state.getCurrentFile()); |
|---|
| 90 | 91 | |
|---|
| 91 | 92 | container.setLayout(new BorderLayout()); |
|---|
| .. | .. |
|---|
| 554 | 555 | } |
|---|
| 555 | 556 | try |
|---|
| 556 | 557 | { |
|---|
| 557 | | - final File f = new File(fileName); |
|---|
| 558 | + final File f = new File(TimeflowApp.class.getClassLoader().getResource(fileName).toURI()); |
|---|
| 558 | 559 | ActDB db = importer.importFile(f); |
|---|
| 559 | 560 | model.setDB(db, fileName, readOnly, TimeflowApp.this); |
|---|
| 560 | 561 | if (!readOnly) |
|---|
| .. | .. |
|---|
| 693 | 694 | |
|---|
| 694 | 695 | static String[] getVisibleFiles(String dir) |
|---|
| 695 | 696 | { |
|---|
| 696 | | - String[] s = new File(dir).list(); |
|---|
| 697 | | - ArrayList<String> real = new ArrayList<String>(); |
|---|
| 698 | | - for (int i = 0; i < s.length; i++) |
|---|
| 697 | + System.out.println("getVisibleFiles = " + dir); |
|---|
| 698 | + try |
|---|
| 699 | 699 | { |
|---|
| 700 | | - 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++) |
|---|
| 701 | 705 | { |
|---|
| 702 | | - real.add(s[i]); |
|---|
| 706 | + if (!s[i].startsWith(".")) |
|---|
| 707 | + { |
|---|
| 708 | + real.add(s[i]); |
|---|
| 709 | + } |
|---|
| 703 | 710 | } |
|---|
| 711 | + return (String[]) real.toArray(new String[0]); |
|---|
| 704 | 712 | } |
|---|
| 705 | | - return (String[]) real.toArray(new String[0]); |
|---|
| 713 | + catch (Exception e) |
|---|
| 714 | + { |
|---|
| 715 | + e.printStackTrace(); |
|---|
| 716 | + return new String[0]; |
|---|
| 717 | + } |
|---|
| 706 | 718 | } |
|---|
| 707 | 719 | } |
|---|