use of org.eclipse.swt.browser.Browser in project eclipse-integration-commons by spring-projects.
the class HtmlTooltip method createToolTipContentArea.
@Override
protected Composite createToolTipContentArea(Event event, Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
composite.setLayout(GridLayoutFactory.fillDefaults().create());
Browser browser = new Browser(composite, SWT.NONE);
browser.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND));
browser.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
browser.setJavascriptEnabled(false);
browser.addOpenWindowListener(new OpenWindowListener() {
@Override
public void open(WindowEvent event) {
// Cancel opening of new windows
event.required = true;
}
});
// Replace browser's built-in context menu with none
browser.setMenu(new Menu(browser.getShell(), SWT.NONE));
String htmlContent = html.get();
browser.setText(htmlContent);
Point size = computeSizeHint(browser, htmlContent);
browser.setLayoutData(GridDataFactory.swtDefaults().hint(size.x, size.y).create());
// Add after HTML content is set to avoid event fired after the content is set
browser.addLocationListener(new LocationAdapter() {
@Override
public void changing(LocationEvent event) {
super.changing(event);
event.doit = false;
try {
PlatformUI.getWorkbench().getBrowserSupport().createBrowser(null).openURL(new URL(event.location));
hide();
} catch (PartInitException | MalformedURLException e) {
UiPlugin.log(e);
}
}
});
return composite;
}
use of org.eclipse.swt.browser.Browser in project eclipse-integration-commons by spring-projects.
the class StsBrowserView method createPartControl.
@Override
public void createPartControl(Composite parent) {
parent.setLayout(new FillLayout());
browserViewer = new StsBrowserViewer(parent, hasToolbar() ? StsBrowserViewer.BUTTON_BAR | StsBrowserViewer.LOCATION_BAR : SWT.NONE);
if (initialUrl != null) {
setUrl(initialUrl);
}
Browser browser = getBrowserViewer().getBrowser();
if (browser != null) {
browser.addProgressListener(new ProgressAdapter() {
@Override
public void completed(ProgressEvent event) {
if (browserManager == null) {
browserManager = new StsBrowserManager();
}
browserManager.setClient(getBrowserViewer().getBrowser());
}
});
}
}
use of org.eclipse.swt.browser.Browser in project azure-tools-for-java by Microsoft.
the class EclipseMessageDialog method createMessageArea.
protected Control createMessageArea(Composite composite) {
final Image image = this.getImage();
if (image != null) {
this.imageLabel = new Label(composite, 0);
image.setBackground(this.imageLabel.getBackground());
this.imageLabel.setImage(image);
GridDataFactory.fillDefaults().align(16777216, 1).applyTo(this.imageLabel);
}
final Browser browser = new Browser(composite, SWT.NONE);
browser.setText(this.getMessage().getContent());
browser.setSize(360, 160);
browser.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
GridDataFactory.fillDefaults().align(4, 1).grab(true, false).hint(this.convertHorizontalDLUsToPixels(300), -1).applyTo(browser);
return composite;
}
use of org.eclipse.swt.browser.Browser in project bndtools by bndtools.
the class JPMBrowserView method createPartControl.
@Override
public void createPartControl(Composite parent) {
StackLayout stack = new StackLayout();
parent.setLayout(stack);
JpmPreferences prefs = new JpmPreferences();
if (prefs.getBrowserSelection() == JpmPreferences.PREF_BROWSER_EXTERNAL) {
external = true;
Composite composite = new Composite(parent, SWT.NONE);
composite.setLayout(new GridLayout(2, false));
new Label(composite, SWT.NONE).setText("Searchable Repository is configured to open in an external browser.");
Hyperlink linkToPrefs = new Hyperlink(composite, SWT.NONE);
linkToPrefs.setText("Open Preference Page");
linkToPrefs.setUnderlined(true);
linkToPrefs.addHyperlinkListener(new HyperlinkAdapter() {
@Override
public void linkActivated(HyperlinkEvent e) {
PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(getViewSite().getShell(), "bndtools.prefPages.jpm", new String[] { "bndtools.prefPages.jpm" }, null);
dialog.open();
}
});
// linkToPrefs.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, true, false));
stack.topControl = composite;
} else {
if (prefs.getBrowserSelection() == JpmPreferences.PREF_BROWSER_PLATFORM_DEFAULT) {
browser = new Browser(parent, SWT.NONE);
stack.topControl = browser;
} else if (prefs.getBrowserSelection() == JpmPreferences.PREF_BROWSER_WEBKIT) {
browser = new Browser(parent, SWT.WEBKIT);
stack.topControl = browser;
} else if (prefs.getBrowserSelection() == JpmPreferences.PREF_BROWSER_MOZILLA) {
browser = new Browser(parent, SWT.MOZILLA);
stack.topControl = browser;
}
createActions();
// Prevent navigation away from JPM4J.org, and redirect from HTTP back to HTTPS
browser.addLocationListener(new LocationAdapter() {
@Override
public void changing(LocationEvent event) {
setContentDescription(event.location);
/*
* if (event.location.startsWith(HTTPS_URL)) return; if (event.location.startsWith(HTTP_URL))
* event.location = event.location.replaceFirst(HTTP_URL, HTTP_URL); else event.doit = false;
*/
}
});
}
selectionService = getViewSite().getWorkbenchWindow().getSelectionService();
selectionService.addSelectionListener(this);
handleWorkbenchSelection(selectionService.getSelection());
}
use of org.eclipse.swt.browser.Browser in project tesb-studio-se by Talend.
the class EsbStartingBrowser method createPartControl.
@Override
public void createPartControl(Composite parent) {
try {
browser = new Browser(parent, SWT.NONE);
browser.setText(EsbStartingHelper.getHelper().getHtmlContent());
browser.addLocationListener(new BrowserDynamicPartLocationListener());
} catch (IOException e) {
ExceptionHandler.process(e);
} catch (Throwable t) {
Exception ex = new Exception("The internal web browser can not be access,the starting page won't be displayed");
ExceptionHandler.process(ex);
}
}
Aggregations