Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running External Apps on save in Eclipse

Since we cannot setup Eclipse's RSE to use at the tool for remote editing, I have installed Unison. But how can I get Eclipse to automatically run unison on every file save? Is there an eclipse plugin available for this?

TIA

like image 267
Gregory Avatar asked Dec 23 '22 14:12

Gregory


2 Answers

You can setup it to be run on every build. Any external tool can be run on every build, just open project's preferences, go to Builders page, click “New…”.

like image 123
Andrey Tarantsov Avatar answered Jan 04 '23 17:01

Andrey Tarantsov


Depending on the importance, I would write a simple plugin to handle this.

EDIT: All you really need to do is this:

1) Create the plugin from the templates with the RCP\PDE Eclipse install
2) Add the following code to your activator...

@Override
public void start( final BundleContext context ) throws Exception {
    super.start( context );
    plugin = this;

    ICommandService commandService = (ICommandService)plugin.getWorkbench().getService( ICommandService.class );
    commandService.addExecutionListener( new IExecutionListener() {

        public void notHandled( final String commandId, final NotHandledException exception ) {}

        public void postExecuteFailure( final String commandId, final ExecutionException exception ) {}

        public void postExecuteSuccess( final String commandId, final Object returnValue ) {
            if ( commandId.equals( "org.eclipse.ui.file.save" ) ) {
                // add in your action here...
                // personally, I would use a custom preference page, 
                // but hard coding would work ok too
            }
        }

        public void preExecute( final String commandId, final ExecutionEvent event ) {}

    } );
}
like image 27
javamonkey79 Avatar answered Jan 04 '23 17:01

javamonkey79