Exemple #1
0
  /** Creates a {@link ModuleInfo} to reopen data at the given path. */
  private ModuleInfo createInfo(final String path) {
    final PluginModuleInfo<ImageJPlugin> info =
        new PluginModuleInfo<ImageJPlugin>("imagej.io.plugins.OpenImage", ImageJPlugin.class);

    // hard code path to open as a preset
    final HashMap<String, Object> presets = new HashMap<String, Object>();
    presets.put("inputFile", path);
    info.setPresets(presets);

    // set menu path
    final MenuPath menuPath = new MenuPath();
    menuPath.add(new MenuEntry(MenuConstants.FILE_LABEL));
    menuPath.add(new MenuEntry(RECENT_MENU_NAME));
    final MenuEntry leaf = new MenuEntry(shortPath(path));
    menuPath.add(leaf);
    info.setMenuPath(menuPath);

    // set menu position
    leaf.setWeight(0); // TODO - do this properly

    // use the same icon as File > Open
    final PluginService pluginService = ImageJ.get(PluginService.class);
    final PluginModuleInfo<RunnablePlugin> fileOpen =
        pluginService.getRunnablePlugin("imagej.io.plugins.OpenImage");
    final String iconPath = fileOpen.getIconPath();
    info.setIconPath(iconPath);
    leaf.setIconPath(iconPath);

    // register the module with the module service
    moduleService.addModule(info);

    return info;
  }
Exemple #2
0
 /** Removes a path from the list of recent files. */
 public boolean remove(final String path) {
   final ModuleInfo info = recentModules.remove(path);
   if (info != null) {
     moduleService.removeModule(info);
   }
   boolean result = recentFiles.remove(path);
   // Prefs.putList(recentFiles, RECENT_FILES_KEY);
   return result;
 }
Exemple #3
0
 /** Clears the list of recent files. */
 public void clear() {
   recentFiles.clear();
   Prefs.clear(RECENT_FILES_KEY);
   moduleService.removeModules(recentModules.values());
   recentModules.clear();
 }