(String cmd)
| 128 | } |
| 129 | |
| 130 | void runCommand(String cmd) { |
| 131 | Hashtable table = Menus.getCommands(); |
| 132 | String className = (String)table.get(cmd); |
| 133 | if (className!=null) { |
| 134 | String arg = ""; |
| 135 | if (className.endsWith("\")")) { |
| 136 | // extract string argument (e.g. className("arg")) |
| 137 | int argStart = className.lastIndexOf("(\""); |
| 138 | if (argStart>0) { |
| 139 | arg = className.substring(argStart+2, className.length()-2); |
| 140 | className = className.substring(0, argStart); |
| 141 | } |
| 142 | } |
| 143 | if (Prefs.nonBlockingFilterDialogs) { |
| 144 | // we have the plugin class name, let us see whether it is allowed to run it |
| 145 | ImagePlus imp = WindowManager.getCurrentImage(); |
| 146 | boolean imageLocked = imp!=null && imp.isLockedByAnotherThread(); |
| 147 | if (imageLocked && !allowedWithLockedImage(className)) { |
| 148 | IJ.beep(); |
| 149 | IJ.showStatus("\""+cmd + "\" blocked because \"" + imp.getTitle() + "\" is locked"); |
| 150 | return; |
| 151 | } |
| 152 | } |
| 153 | // run the plugin |
| 154 | if (IJ.shiftKeyDown() && className.startsWith("ij.plugin.Macro_Runner") && !Menus.getShortcuts().contains("*"+cmd)) |
| 155 | IJ.open(IJ.getDirectory("plugins")+arg); |
| 156 | else |
| 157 | IJ.runPlugIn(cmd, className, arg); |
| 158 | } else { // command is not a plugin |
| 159 | // is command in the Plugins>Macros menu? |
| 160 | if (MacroInstaller.runMacroCommand(cmd)) |
| 161 | return; |
| 162 | // is it in the Image>Lookup Tables menu? |
| 163 | if (loadLut(cmd)) |
| 164 | return; |
| 165 | // is it in the File>Open Recent menu? |
| 166 | if (openRecent(cmd)) |
| 167 | return; |
| 168 | // is it an example in Help>Examples menu? |
| 169 | if (IJ.getInstance()!=null && !GraphicsEnvironment.isHeadless()) { |
| 170 | if (Editor.openExample(cmd)) |
| 171 | return; |
| 172 | } |
| 173 | if ("Auto Threshold".equals(cmd)&&(String)table.get("Auto Threshold...")!=null) |
| 174 | runCommand("Auto Threshold..."); |
| 175 | else if ("Enhance Local Contrast (CLAHE)".equals(cmd)&&(String)table.get("CLAHE ")!=null) |
| 176 | runCommand("CLAHE "); |
| 177 | else { |
| 178 | if ("Table...".equals(cmd)) |
| 179 | IJ.runPlugIn("ij.plugin.NewPlugin", "table"); |
| 180 | else { |
| 181 | if (repeatingCommand) |
| 182 | IJ.runMacro(previousCommand); |
| 183 | else { |
| 184 | if (!extraCommand(cmd)) |
| 185 | IJ.error("Unrecognized command: \"" + cmd+"\""); |
| 186 | } |
| 187 | } |
no test coverage detected