MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / open

Method open

ij/src/main/java/ij/plugin/Compiler.java:223–263  ·  view source on GitHub ↗
(String path, String msg)

Source from the content-addressed store, hash-verified

221
222 // open the .java source file
223 boolean open(String path, String msg) {
224 boolean okay;
225 String fileName, directory;
226 if (path.equals("")) {
227 if (dir==null) dir = IJ.getDirectory("plugins");
228 OpenDialog od = new OpenDialog(msg, dir, name);
229 directory = od.getDirectory();
230 fileName = od.getFileName();
231 okay = fileName!=null;
232 String lcName = okay?fileName.toLowerCase(Locale.US):null;
233 if (okay) {
234 if (msg.startsWith("Compile")) {
235 if (!(lcName.endsWith(".java")||lcName.endsWith(".class"))) {
236 IJ.error("File name must end with \".java\" or \".class\".");
237 okay = false;
238 }
239 } else if (!(lcName.endsWith(".java")||lcName.endsWith(".txt")||lcName.endsWith(".ijm")||lcName.endsWith(".js")||lcName.endsWith(".py")||lcName.endsWith(".bsh"))) {
240 IJ.error("File name must end with \".java\", \".txt\", \".ijm\", \".js\" or \".py\"");
241 okay = false;
242 }
243 }
244 } else {
245 int i = path.lastIndexOf('/');
246 if (i==-1)
247 i = path.lastIndexOf('\\');
248 if (i>0) {
249 directory = path.substring(0, i+1);
250 fileName = path.substring(i+1);
251 } else {
252 directory = "";
253 fileName = path;
254 }
255 okay = true;
256 }
257 if (okay) {
258 name = fileName;
259 dir = directory;
260 Editor.setDefaultDirectory(dir);
261 }
262 return okay;
263 }
264
265 // only show files with names ending in ".java"
266 // doesn't work with Windows

Callers 2

editMethod · 0.95
compileAndRunMethod · 0.95

Calls 8

getDirectoryMethod · 0.95
getDirectoryMethod · 0.95
getFileNameMethod · 0.95
errorMethod · 0.95
setDefaultDirectoryMethod · 0.95
startsWithMethod · 0.80
substringMethod · 0.80
equalsMethod · 0.45

Tested by

no test coverage detected