Skip to content

Commit df040f6

Browse files
committed
Report local files
1 parent 00aaffd commit df040f6

2 files changed

Lines changed: 39 additions & 11 deletions

File tree

BAR/src/main/java/bar/Utils.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,17 @@ public static String getBARDir() {
749749
return BAR_DIR;
750750
}
751751

752+
/**
753+
* The absolute path to the legacy /BAR directory on the "plugins" folder.
754+
* It is no longer used but it was used prior to BAR v1.5. Included here for
755+
* convenience.
756+
*
757+
* @return the absolute path to the root directory of BAR prior to v1.5
758+
*/
759+
public static String getPluginsBasedBARDir() {
760+
return IJ.getDirectory("plugins") + "Scripts" + File.separator + "BAR" + File.separator;
761+
}
762+
752763
/**
753764
* Returns the path to {@code BAR/My_Routines/}, creating it .
754765
*

BAR/src/main/resources/scripts/BAR/Utilities/List_BAR_Scripts.groovy

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
//@CommandService commandservice
55
//@DisplayService displayservice
66
//@TextService textservice
7-
7+
//@UIService uiservice
88

99
import bar.Runner
1010
import bar.Utils
11+
import groovy.io.FileType
1112
import org.scijava.util.FileUtils;
1213

1314
def cleanIdentifier(identifier, prefix) {
@@ -49,7 +50,7 @@ def appendCommandList(string) {
4950

5051
def appendResources(string, directories) {
5152
string += "\n## Resources\n"
52-
for (dir in directories) {
53+
for (dir in directories) {
5354
url = Utils.getBARresource("$dir/")
5455
list = FileUtils.listContents(url)
5556
string += "\n 1. **$dir**\n"
@@ -82,22 +83,38 @@ def appendIJ1plugins(string) {
8283
return string
8384
}
8485

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")
8798
text = appendCommandList(text)
8899
text = appendIJ1plugins(text)
89100
text = appendResources(text, ["boilerplate", "lib", "script_templates",
90101
"tools", "tutorials"])
91102

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)
98105

99106
// Render markdown list
100107
temp = File.createTempFile('barlist', '.md')
101108
temp.write(text)
102-
displayservice.createDisplay("List of BAR Files", textservice.asHTML(temp))
109+
displayservice.createDisplay("BAR Files", textservice.asHTML(temp))
103110
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

Comments
 (0)