try {
IPreferenceScope eclipsePreferences = Owl.getPreferenceService().getEclipseScope();
IPreferenceScope owlPreferences = Owl.getPreferenceService().getGlobalScope();
WebBrowserInput input = new WebBrowserInput(href, context);
IWorkbenchPage page = OwlUI.getPage();
if (page != null) {
boolean multipleTabs = eclipsePreferences.getBoolean(DefaultPreferences.ECLIPSE_MULTIPLE_TABS);
boolean openInBackground = owlPreferences.getBoolean(DefaultPreferences.OPEN_BROWSER_IN_BACKGROUND);
boolean reuseTab = owlPreferences.getBoolean(DefaultPreferences.ALWAYS_REUSE_BROWSER);
/* Try to Reuse existing Browser first if set */
if (reuseTab) {
WebBrowserView browser = OwlUI.getFirstActiveBrowser();
if (browser != null) {
browser.setInput(input);
if (!openInBackground)
page.activate(browser);
return browser;
}
}
/* Open Browser Tab in Background */
if (multipleTabs && openInBackground) {
IEditorPart previousActiveEditor = page.getActiveEditor();
page.getWorkbenchWindow().getShell().setRedraw(false);
try {
view = (WebBrowserView) page.openEditor(input, WebBrowserView.EDITOR_ID, true);
if (previousActiveEditor != null)
page.activate(previousActiveEditor);
} finally {
page.getWorkbenchWindow().getShell().setRedraw(true);
}
}
/* Open Browser Tab in Front */
else
view = (WebBrowserView) page.openEditor(input, WebBrowserView.EDITOR_ID, true);
}
} catch (PartInitException e) {
Activator.getDefault().logError(e.getMessage(), e);
}