Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
DemoBrowserFunctionViewPart
package com.acme.demo.browserfunction;
import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.browser.BrowserFunction;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.part.ViewPart;
public class DemoBrowserFunctionView extends ViewPart {
private static final String HTML =
"<html>" +
"<body>" +
"<a href=\"#\" onclick=\"helloWorld(); false;\">Test</a>" +
"</body>" +
"</html>";
public DemoBrowserFunctionView() {
// TODO Auto-generated constructor stub
}
@Override
public void createPartControl(Composite parent) {
Browser browser = new Browser(parent, SWT.NONE);
new BrowserFunction(browser, "helloWorld"){
@Override
public Object function(Object[] arg0) {
System.out.println("hello world called from javascript!");
return null;
}
};
browser.setText(HTML);
}
@Override
public void setFocus() {
// TODO Auto-generated method stub
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.