Created
December 27, 2010 19:53
-
-
Save ryanjbaxter/756479 to your computer and use it in GitHub Desktop.
DemoBrowserFunctionViewPart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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