ISelectionService selectionService = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService();
final IHandler handler = this;
selectionService.addSelectionListener(new ISelectionListener() {
@Override
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
fireHandlerChanged(new HandlerEvent(handler, true, false));
}
});
// set the already installed flag after the listener is successfully
// added