Notification of ImportWizard in Eclipse RCP
I am developing开发者_JAVA技巧 an Eclipse RCP application. In this application I am importing the project using an Import Wizard. I want to get notified after the Import wizard is over.
Please help me!
I would add an org.eclipse.core.resources.IWorkspace.addResourceChangeListener(IResourceChangeListener)
to the workspace when you launch the import wizard. Monitor the events and see if org.eclipse.core.resources.IResourceChangeEvent.POST_CHANGE
is issued when the import it done.
You can use ICommandService to monitor execution of commands in Eclipse Platform.
So you can notified when importing is executed with command id " org.eclipse.ui.file.import":
ICommandService service = (ICommandService)
PlatformUI.getWorkbench().getService(ICommandService.class);
service.addExecutionListener(...)
You can describe logic which will executed after importing with extending WorkspaceJob.
public AfterImportingJob extends WorkspaceJob{
...
public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException{
... do something
return Status.OK_STATUS;
}
...
}
WorkspaceJob automatically synchronized with Workspace. So After all change is done in Workspace, your Job will run. And it makes sure No other workspace modification is not running during your job is executing.
All you have to do to use this magic is just scheduling:
AfterImportingJob myJob = new AfterImporingJob();
myJob.schdule();
精彩评论