|
4 | 4 | //@CommandService commandservice |
5 | 5 | //@DisplayService displayservice |
6 | 6 | //@TextService textservice |
7 | | - |
| 7 | +//@UIService uiservice |
8 | 8 |
|
9 | 9 | import bar.Runner |
10 | 10 | import bar.Utils |
| 11 | +import groovy.io.FileType |
11 | 12 | import org.scijava.util.FileUtils; |
12 | 13 |
|
13 | 14 | def cleanIdentifier(identifier, prefix) { |
@@ -49,7 +50,7 @@ def appendCommandList(string) { |
49 | 50 |
|
50 | 51 | def appendResources(string, directories) { |
51 | 52 | string += "\n## Resources\n" |
52 | | - for (dir in directories) { |
| 53 | + for (dir in directories) { |
53 | 54 | url = Utils.getBARresource("$dir/") |
54 | 55 | list = FileUtils.listContents(url) |
55 | 56 | string += "\n 1. **$dir**\n" |
@@ -82,22 +83,38 @@ def appendIJ1plugins(string) { |
82 | 83 | return string |
83 | 84 | } |
84 | 85 |
|
85 | | -// Append all lists |
86 | | -text = appendScriptList("# List of BAR Files") |
| 86 | +def appendLocalFiles(string) { |
| 87 | + def header = FileUtils.shortenPath(Utils.getBARDir()) |
| 88 | + string += "\n## Local Files ($header)\n" |
| 89 | + def dir = new File(Utils.getBARDir()) |
| 90 | + dir.eachFileRecurse(FileType.FILES) { |
| 91 | + string += " 1. ${it.path - dir.path}\n" |
| 92 | + } |
| 93 | + return string |
| 94 | +} |
| 95 | + |
| 96 | +// List resources in BAR jar file |
| 97 | +text = appendScriptList("# BAR Files") |
87 | 98 | text = appendCommandList(text) |
88 | 99 | text = appendIJ1plugins(text) |
89 | 100 | text = appendResources(text, ["boilerplate", "lib", "script_templates", |
90 | 101 | "tools", "tutorials"]) |
91 | 102 |
|
92 | | -// Include remaining sources |
93 | | -text += "\n## This List Does Not Include:\n" |
94 | | -text += " * Unregistered scripts in your local directories, including:\n" |
95 | | -for (item in [Utils.getBARDir(), Utils.getLibDir(), Utils.getMyRoutinesDir()]) |
96 | | - text += " * ${item}\n" |
97 | | - |
| 103 | +// List user files on local installation |
| 104 | +text = appendLocalFiles(text) |
98 | 105 |
|
99 | 106 | // Render markdown list |
100 | 107 | temp = File.createTempFile('barlist', '.md') |
101 | 108 | temp.write(text) |
102 | | -displayservice.createDisplay("List of BAR Files", textservice.asHTML(temp)) |
| 109 | +displayservice.createDisplay("BAR Files", textservice.asHTML(temp)) |
103 | 110 | temp.delete() |
| 111 | + |
| 112 | +// Check for legacy installation files |
| 113 | +if (new File(Utils.getPluginsBasedBARDir()).list()) { |
| 114 | + uiservice.showDialog("<html><div WIDTH=450>With BAR v1.5 and newer, local files are no " |
| 115 | + + "longer rooted in the plugins directory. The new, much more convenient directory " |
| 116 | + + "for your local files is <b>${Utils.getBARDir()}</b>. You should move any files " |
| 117 | + + "in the old location to the new one (and safely delete the old directory).<br><br>" |
| 118 | + + "Old location: <i>${Utils.getPluginsBasedBARDir()}</i><br>" |
| 119 | + + "New location: <i>${Utils.getBARDir()}</i>", "Legacy Warning") |
| 120 | +} |
0 commit comments