(MouseEvent e)
| 1335 | } |
| 1336 | |
| 1337 | void showSwitchPopupMenu(MouseEvent e) { |
| 1338 | String path = IJ.getDir("macros")+"toolsets/"; |
| 1339 | if (path==null) |
| 1340 | return; |
| 1341 | boolean applet = IJ.getApplet()!=null; |
| 1342 | File f = new File(path); |
| 1343 | String[] list; |
| 1344 | if (!applet && f.exists() && f.isDirectory()) { |
| 1345 | list = f.list(); |
| 1346 | if (list==null) return; |
| 1347 | Arrays.sort(list); |
| 1348 | } else |
| 1349 | list = new String[0]; |
| 1350 | switchPopup.removeAll(); |
| 1351 | path = IJ.getDir("macros") + "StartupMacros.txt"; |
| 1352 | f = new File(path); |
| 1353 | if (!f.exists()) { |
| 1354 | path = IJ.getDir("macros") + "StartupMacros.ijm"; |
| 1355 | f = new File(path); |
| 1356 | } |
| 1357 | if (!applet && f.exists()) |
| 1358 | addItem("Startup Macros"); |
| 1359 | else |
| 1360 | addItem("StartupMacros*"); |
| 1361 | for (int i=0; i<list.length; i++) { |
| 1362 | String name = list[i]; |
| 1363 | if (name.startsWith(".") || name.endsWith(" Tool")) |
| 1364 | continue; |
| 1365 | if (name.endsWith(".txt")) { |
| 1366 | name = name.substring(0, name.length()-4); |
| 1367 | addItem(name); |
| 1368 | } else if (name.endsWith(".ijm")) { |
| 1369 | name = name.substring(0, name.length()-4) + " "; |
| 1370 | addItem(name); |
| 1371 | } |
| 1372 | } |
| 1373 | addItem("Overlay Editing Tools*"); |
| 1374 | addPluginTools(); |
| 1375 | addItem("Restore Startup Tools"); |
| 1376 | addItem("Remove Custom Tools"); |
| 1377 | addItem("Help..."); |
| 1378 | add(ovalPopup); |
| 1379 | if (IJ.isMacOSX()) IJ.wait(10); |
| 1380 | switchPopup.show(e.getComponent(), e.getX(), e.getY()); |
| 1381 | } |
| 1382 | |
| 1383 | private void addPluginTools() { |
| 1384 | switchPopup.addSeparator(); |
no test coverage detected