private static Control getActiveControl(final Shell shell) { Object adapter = shell.getAdapter(IShellAdapter.class); IShellAdapter shellAdapter = (IShellAdapter) adapter; Control activeControl = shellAdapter.getActiveControl(); return activeControl; }