Ticket #1024 (closed enhancement: moved)

Opened 8 years ago

Last modified 7 years ago

File>New>Plugin (Eclipse)

Reported by: dscho Owned by: dscho
Priority: major Milestone: imagej2-b11-docs
Component: Plugins Version:
Severity: minor Keywords:
Cc: Blocked By: #1351
Blocking: #1207


Eclipse seems to become more and more popular these days. So, to make things easier for developers, add a plugin that sets up an Eclipse project to develop an IJ2 plugin. This entails:

  • a wizard-like user interface
  • discovering/asking for the location of Eclipse (and remembering it via Preferences)
  • setting up the directory structure
  • activating the annotation processing (see #1023)
  • adding an appropriate Run configuration

We might be able to come up with way to "listen" for an event sent by the Run configuration that triggers

  • setting up a new class loader
  • loading the classes compiled by Eclipse
  • running the plugin
  • giving feedback via the established connection about exceptions/failures/success

Eclipse provides quite powerful debugging facilities. This most likely requires ImageJ's to be started in a special mode listening for debuggers (which we could even store in ImageJ.cfg so that any subsequent restart of ImageJ activates that mode), but we might not be able to benefit from Eclipse's in-place code-replacing.

So: even if we manage to come up with a Run configuration that will run the plugin in the current ImageJ instance, we will most probably need to come up with a standalone Run and Debug configuration (that starts up ImageJ whereever it might be installed, adding the appropriate classpath so the plugin is discovered, possibly loading certain images -- that might be chosen from the list of open images at the time File>New>Plugin (Eclipse) is run -- and then runs the plugin).

As a consequence, we need to teach imagej.Main to sprout a way to open images and call plugins from the command-line. The appropriate place is AbstractUserInterface's processArgs() method (whose javadoc should then contain the note that subclasses overriding that method need to hand off to AbstractUserInterface to handle the default command-line parameters).

Change History

comment:1 Changed 8 years ago by curtis

  • Blocking 1207 added

comment:2 Changed 8 years ago by curtis

  • Milestone changed from imagej-2.0.0 to imagej-2.0.0-beta4

comment:3 Changed 8 years ago by dscho

  • Blocked By 1351 added

comment:4 Changed 8 years ago by dscho

  • Milestone changed from imagej-2.0.0-beta4 to imagej-2.0.0-beta5

comment:5 Changed 8 years ago by curtis

Note that the UIService#processArgs(String...) method has moved to a dedicated ConsoleService now (also part of ij-app). And I agree that adding these debugging hooks as DefaultConsoleService options is definitely the right way to go! Though we probably want to have a DebugService which the ConsoleService merely configures as it is told via command line args.

comment:6 Changed 8 years ago by dscho

This minimal Beanshell script shows how to start Eclipse from within a Java application:

import java.io.File;
eclipseRoot = new File(System.getProperty("user.home") + "/eclipse/");
addClassPath(new File(eclipseRoot, "plugins/org.eclipse.osgi_3.7.2.v20120110-1415.jar").getPath());

for (File file : new File(eclipseRoot, "plugins").listFiles())
	if (file.getName().endsWith(".jar"))
	else if (file.isDirectory())
		for (File file2 : file.listFiles())
			if (file2.getName().endsWith(".jar"))

import org.eclipse.core.runtime.adaptor.EclipseStarter;
import java.util.HashMap;
import java.util.Map;

Map properties = new HashMap();
properties.put("osgi.install.area", eclipseRoot.getPath());
properties.put("osgi.syspath", eclipseRoot.getPath() + "/plugins");
properties.put("osgi.configuration.area", eclipseRoot.getPath() + "/configuration");
properties.put("osgi.parentClassloader", "fwk");
EclipseStarter.setInitialProperties(properties );

EclipseStarter.startup(new String[] {}, null);
c = EclipseStarter.run(null);
// TODO: EclipseStarter.shutdown();

To import the Maven project, something similar to

eclipse -nosplash 
    -application org.eclipse.cdt.managedbuilder.core.headlessbuild 
    -import {[uri:/]/path/to/project} 
    -build {project_name | all} 
    -cleanBuild {projec_name | all}

might work.

comment:7 Changed 8 years ago by dscho

Most likely something like this should work for importing the Maven project:

import org.eclipse.m2e.core.MavenPlugin;

List<IMavenProjectImportResult> results =
        projects, importConfiguration, monitor);

See:  https://github.com/eclipse/m2e-core/blob/master/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/IProjectConfigurationManager.java#L36

comment:8 Changed 7 years ago by bdezonia

  • Milestone changed from imagej2-b7-ndim-data to imagej2-unscheduled

comment:9 Changed 7 years ago by curtis

The Icy team has created a plugin  Icy4Eclipse that eases development of Icy and Icy plugins within Eclipse.

comment:10 Changed 7 years ago by curtis

  • Milestone changed from imagej2-unscheduled to imagej2-b11-docs

comment:10 Changed 6 years ago by curtis

  • Status changed from new to closed
  • Resolution set to moved
Note: See TracTickets for help on using tickets.