use of org.eclipse.ui.internal.browser.BrowserViewer in project yamcs-studio by yamcs.
the class WebBrowserFigure method createSWTWidget.
@Override
protected BrowserViewer createSWTWidget(Composite parent, int style) {
try {
browserViewer = new BrowserViewer(parent, style);
browserViewer.setLayoutData(null);
browser = browserViewer.getBrowser();
} catch (Exception e) {
errorMassage = "Failed to create web browser widget.\n" + "It may not available on your platform.\n" + e;
ErrorHandlerUtil.handleError(errorMassage, e);
}
return browserViewer;
}
use of org.eclipse.ui.internal.browser.BrowserViewer in project knime-core by knime.
the class AbstractInjector method findIntroPageBrowser.
/**
* Looks for the open intro page editor (and HTML editor) and returns the Browser instance. This (unfortunately)
* involves some heavy reflection stuff as there is no other way to attach a listener otherwise. If the intro page
* editor cannot be found then <code>null</code> is returned.
*
* @param introPageFile the temporary intro page file
* @return the browser instance showing the intro page or <code>null</code>
*/
@SuppressWarnings("restriction")
static Browser findIntroPageBrowser(final File introPageFile) {
for (IWorkbenchWindow window : PlatformUI.getWorkbench().getWorkbenchWindows()) {
for (IWorkbenchPage page : window.getPages()) {
for (IEditorReference ref : page.getEditorReferences()) {
try {
if (isIntroPageEditor(ref, introPageFile)) {
IEditorPart part = ref.getEditor(false);
if (part instanceof WebBrowserEditor) {
WebBrowserEditor editor = (WebBrowserEditor) part;
Field webBrowser = editor.getClass().getDeclaredField("webBrowser");
webBrowser.setAccessible(true);
BrowserViewer viewer = (BrowserViewer) webBrowser.get(editor);
Field browserField = viewer.getClass().getDeclaredField("browser");
browserField.setAccessible(true);
return (Browser) browserField.get(viewer);
}
}
} catch (PartInitException ex) {
NodeLogger.getLogger(AbstractInjector.class).error("Could not open web browser with intro page: " + ex.getMessage(), ex);
} catch (SecurityException | NoSuchFieldException | IllegalArgumentException | IllegalAccessException ex) {
NodeLogger.getLogger(AbstractInjector.class).error("Could not attach location listener to web browser: " + ex.getMessage(), ex);
}
}
}
}
return null;
}
Aggregations