Source:
private void focusLogCatView(final IDevice device, final String appName) { Display.getDefault().asyncExec(new Runnable() { @Override public void run() { IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); if (window == null) { return; } IWorkbenchPage page = window.getActivePage(); if (page == null) { return; } if (!isLogCatViewVisible(page)) { boolean showLogCatView = promptUserOnce(page.getWorkbenchWindow().getShell()); if (!showLogCatView) { return; } } final LogCatView v = displayLogCatView(page); if (v == null) { return; } v.selectionChanged(device); v.selectTransientAppFilter(appName); } private boolean isLogCatViewVisible(IWorkbenchPage page) { IViewPart view = page.findView(LogCatView.ID); return view != null && page.isPartVisible(view); } private LogCatView displayLogCatView(IWorkbenchPage page) { IViewPart view = page.findView(LogCatView.ID); if (view != null) { page.bringToTop(view); if (view instanceof LogCatView) { return (LogCatView)view; } } try { return (LogCatView) page.showView(LogCatView.ID); } catch (PartInitException e) { return null; } } private boolean promptUserOnce(Shell shell) { boolean promptShown = mPrefStore.getBoolean(AUTO_MONITOR_PROMPT); if (promptShown) { System.out.println("prompt alreayd shown"); return mPrefStore.getBoolean(AUTO_MONITOR_PREFKEY); } LogCatMonitorDialog dlg = new LogCatMonitorDialog(shell); int r = dlg.open(); mPrefStore.setValue(AUTO_MONITOR_PROMPT, true); mPrefStore.setValue(AUTO_MONITOR_PREFKEY, dlg.shouldMonitor()); mPrefStore.setValue(AUTO_MONITOR_LOGLEVEL, dlg.getMinimumPriority()); return r == Window.OK && dlg.shouldMonitor(); } }); }

Target:
private void focusLogCatView(final IDevice device, final String appName) { Display.getDefault().asyncExec(new Runnable() { @Override public void run() { IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); if (window == null) { return; } IWorkbenchPage page = window.getActivePage(); if (page == null) { return; } if (!isLogCatViewVisible(page)) { boolean showLogCatView = promptUserOnce(page.getWorkbenchWindow().getShell()); if (!showLogCatView) { return; } } final LogCatView v = displayLogCatView(page); if (v == null) { return; } v.selectionChanged(device); v.selectTransientAppFilter(appName); } private boolean isLogCatViewVisible(IWorkbenchPage page) { IViewPart view = page.findView(LogCatView.ID); return view != null && page.isPartVisible(view); } private LogCatView displayLogCatView(IWorkbenchPage page) { IViewPart view = page.findView(LogCatView.ID); if (view != null) { page.bringToTop(view); if (view instanceof LogCatView) { return (LogCatView)view; } } try { return (LogCatView) page.showView(LogCatView.ID); } catch (PartInitException e) { return null; } } private boolean promptUserOnce(Shell shell) { boolean promptShown = mPrefStore.getBoolean(AUTO_MONITOR_PROMPT_SHOWN); if (promptShown) { return mPrefStore.getBoolean(AUTO_MONITOR_PREFKEY); } LogCatMonitorDialog dlg = new LogCatMonitorDialog(shell); int r = dlg.open(); mPrefStore.setValue(AUTO_MONITOR_PROMPT_SHOWN, true); mPrefStore.setValue(AUTO_MONITOR_PREFKEY, dlg.shouldMonitor()); mPrefStore.setValue(AUTO_MONITOR_LOGLEVEL, dlg.getMinimumPriority()); return r == Window.OK && dlg.shouldMonitor(); } }); }