I havn't done it before but ... with the help of
EclipseEnvironmentInfo.getDefault().getCommandLineArgs()
you can get at the command line arguments eclipse is started with ("org.eclipse.core.runtime.internal.adaptor.EclipseEnvironmentInfo" is an internal class but you can access it anyhow ... at your own risk ;) ). A quick test shows that if you start a file with eclipse, the last argument is the path to that file.
Normal startup:
-os, win32, -ws, win32, -arch, x86, -product, org.eclipse.epp.package.rcp.product
With file:
*-os, win32, -ws, win32, -arch, x86, -product, org.eclipse.epp.package.rcp.product, D:\Programme\Eclipse3.5-RCP\readme\readme_eclipse.html*
You can extend the extension point "org.eclipse.ui.startup" and implement "org.eclipse.ui.IStartup" to check the command line Arguments and invoke your own command.
Heres my test class:
import java.util.Arrays;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.internal.adaptor.EclipseEnvironmentInfo;
import org.eclipse.ui.IStartup;
import test.Activator;
public class Test implements IStartup {
@Override
public void earlyStartup() {
String message = "Arguments: " + Arrays.toString(EclipseEnvironmentInfo.getDefault().getCommandLineArgs());
Activator.getDefault().getLog().log(new Status(IStatus.INFO, "Test", message));
}
}