|
38 | 38 | import javax.swing.JFrame; |
39 | 39 | import javax.swing.JMenuBar; |
40 | 40 |
|
41 | | -import org.scijava.command.Command; |
42 | 41 | import org.scijava.command.CommandInfo; |
43 | 42 | import org.scijava.command.CommandService; |
44 | 43 | import org.scijava.display.event.window.WinActivatedEvent; |
|
48 | 47 | import org.scijava.module.ModuleInfo; |
49 | 48 | import org.scijava.module.event.ModulesUpdatedEvent; |
50 | 49 | import org.scijava.platform.AbstractPlatform; |
51 | | -import org.scijava.platform.AppEventService; |
52 | 50 | import org.scijava.platform.Platform; |
53 | 51 | import org.scijava.platform.PlatformService; |
54 | 52 | import org.scijava.plugin.Plugin; |
@@ -150,20 +148,16 @@ private void removeAppCommandsFromMenu() { |
150 | 148 | final PlatformService platformService = getPlatformService(); |
151 | 149 | final EventService eventService = platformService.getEventService(); |
152 | 150 | final CommandService commandService = platformService.getCommandService(); |
153 | | - final AppEventService appEventService = |
154 | | - platformService.getAppEventService(); |
155 | 151 |
|
156 | | - // get the list of commands being handled at the application level |
157 | | - final List<Class<? extends Command>> commands = |
158 | | - appEventService.getCommands(); |
159 | | - |
160 | | - // remove said commands from the main menu bar |
161 | | - // (the Mac application menu will trigger them instead) |
| 152 | + // NB: Search for commands being handled at the application level. |
| 153 | + // We remove such commands from the main menu bar; |
| 154 | + // the Mac application menu will trigger them instead. |
162 | 155 | final ArrayList<ModuleInfo> infos = new ArrayList<ModuleInfo>(); |
163 | | - for (final Class<? extends Command> command : commands) { |
164 | | - final CommandInfo info = commandService.getCommand(command); |
165 | | - info.setMenuPath(null); |
166 | | - infos.add(info); |
| 156 | + for (final CommandInfo info : commandService.getCommands()) { |
| 157 | + if (info.is("app-command")) { |
| 158 | + info.setMenuPath(null); |
| 159 | + infos.add(info); |
| 160 | + } |
167 | 161 | } |
168 | 162 | eventService.publish(new ModulesUpdatedEvent(infos)); |
169 | 163 | } |
|
0 commit comments