本文整理汇总了Java中org.scijava.command.CommandService类的典型用法代码示例。如果您正苦于以下问题:Java CommandService类的具体用法?Java CommandService怎么用?Java CommandService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CommandService类属于org.scijava.command包,在下文中一共展示了CommandService类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removeAppCommandsFromMenu
import org.scijava.command.CommandService; //导入依赖的package包/类
private void removeAppCommandsFromMenu() {
final PlatformService platformService = getPlatformService();
final EventService eventService = platformService.eventService();
final CommandService commandService = platformService.commandService();
// NB: Search for commands being handled at the application level.
// We remove such commands from the main menu bar;
// the Mac application menu will trigger them instead.
final ArrayList<ModuleInfo> infos = new ArrayList<>();
for (final CommandInfo info : commandService.getCommands()) {
if (info.is("app-command")) {
info.setMenuPath(null);
infos.add(info);
}
}
eventService.publish(new ModulesUpdatedEvent(infos));
}
示例2: run
import org.scijava.command.CommandService; //导入依赖的package包/类
/**
* This method is called when the plugin is loaded. See
* {@link ij.plugin.PlugIn#run(java.lang.String)} Prompts user for a new
* snippet that will be saved in {@code BAR/My_Routines/}
*
* @param arg
* ignored (Otherwise specified in plugins.config).
*/
@Override
public void run(final String arg) {
Utils.shiftClickWarning();
if (new GuiUtils().getFileCount(Utils.getLibDir()) == 0) {
final YesNoCancelDialog query = new YesNoCancelDialog(null, "Install lib Files?",
"Some of the code generated by this plugin assumes the adoption\n"
+ "of centralized lib files, but none seem to exist in your local directory\n" + "("
+ Utils.getLibDir() + ")\nWould you like to install them now?");
if (query.cancelPressed()) {
return;
} else if (query.yesPressed()) {
final Context context = (Context) IJ.runPlugIn("org.scijava.Context", "");
final CommandService commandService = context.getService(CommandService.class);
commandService.run(Installer.class, true);
return;
}
}
if (showDialog()) {
if (sContents.length()>0)
saveAndOpenSnippet();
else
IJ.showStatus(sFilename +" was empty. No file was saved...");
}
}
示例3: openROIManager
import org.scijava.command.CommandService; //导入依赖的package包/类
/** Open the ImageJ overlay manager window */
private void openROIManager() {
CommandService cs = os.getContext().getService(CommandService.class);
try {
cs.run(OverlayManager.class, true, new Object[0]);
} catch(Exception e) {
log.println("\nUnable to open ROI Manager window.");
handleError(e);
}
}
示例4: SlideSetPluginLoader
import org.scijava.command.CommandService; //导入依赖的package包/类
public SlideSetPluginLoader(ImageJ context,
DataTypeIDService dtid, SlideSetLog log, HelpLoader hl) {
if(context == null || dtid == null || log == null)
throw new IllegalStateException("Cannot initialize "
+ "plugin loader without other SlideSet components");
this.ij = context;
this.cs = ij.get(CommandService.class);
this.dtid = dtid;
this.log = log;
this.hl = hl;
this.plugins = loadPlugins();
}
示例5: testRunCommand
import org.scijava.command.CommandService; //导入依赖的package包/类
@Test
public void testRunCommand() throws InterruptedException, ExecutionException {
final CommandService cs = context.service(CommandService.class);
final CommandModule module = cs.run(Fibonacci.class, true, "n", 7).get();
final int result = (Integer) module.getOutput("result");
assertEquals(13, result);
}
示例6: CommandPicker
import org.scijava.command.CommandService; //导入依赖的package包/类
public CommandPicker(Context c) {
context = c;
commandService = c.getService(CommandService.class);
}
示例7: main
import org.scijava.command.CommandService; //导入依赖的package包/类
public static void main(final String... args) {
final Context c = new Context();
c.service(UIService.class).showUI();
c.service(CommandService.class).run(OpenImageFromOMERO.class, true);
}
示例8: testGenerateAll
import org.scijava.command.CommandService; //导入依赖的package包/类
@Test
public void testGenerateAll() throws IOException {
// create a context with a minimal command set
final PluginIndex pluginIndex = new PluginIndex() {
@Override
public void discover() {
super.discover();
removeAll(getPlugins(Command.class));
add(pluginInfo(FileNew.class));
add(pluginInfo(FileOpen.class));
add(pluginInfo(FileSave.class));
add(pluginInfo(FileExit.class));
add(pluginInfo(Lion.class));
add(pluginInfo(Tiger.class));
add(pluginInfo(Bear.class));
}
};
final ArrayList<Class<? extends Service>> classes =
new ArrayList<Class<? extends Service>>();
classes.add(AppService.class);
classes.add(CommandService.class);
classes.add(MenuService.class);
final Context context = new Context(classes, pluginIndex);
final ScriptGenerator scriptGen = new ScriptGenerator(context);
final File tempDir =
TestUtils.createTemporaryDirectory("script-generator-");
final File libDir = new File(tempDir, "lib");
final File scriptsDir = new File(libDir, "scripts");
assertTrue(scriptsDir.mkdirs());
final int returnCode = scriptGen.generateAll(tempDir);
context.dispose();
assertEquals(0, returnCode);
final File imagejDir = new File(scriptsDir, "imagej");
assertTrue(imagejDir.isDirectory());
final File fileDir = new File(imagejDir, "File");
assertTrue(fileDir.isDirectory());
final File animalsDir = new File(imagejDir, "\ufeffAnimals");
assertTrue(animalsDir.isDirectory());
assertTrue(new File(fileDir, "New.py").exists());
assertTrue(new File(fileDir, "\ufeffOpen.py").exists());
assertTrue(new File(fileDir, "\ufeff\ufeffSave.py").exists());
assertTrue(new File(fileDir, "\ufeff\ufeff\ufeffExit.py").exists());
assertTrue(new File(animalsDir, "Lion.py").exists());
assertTrue(new File(animalsDir, "\ufeffTiger.py").exists());
assertTrue(new File(animalsDir, "\ufeff\ufeffBear.py").exists());
FileUtils.deleteRecursively(tempDir);
}