public class HtmlTooltip extends BrowserInformationControl{
public final static String APPEARANCE_JAVADOC_FONT= "org.eclipse.jdt.ui.javadocfont"; //$NON-NLS-1$
private static final String fgStyleSheet= "/* Font definitions */\n" + //$NON-NLS-1$
"body, h1, h2, h3, h4, h5, h6, p, table, td, caption, th, ul, ol, dl, li, dd, dt {font-family: sans-serif; font-size: 9pt }\n" + //$NON-NLS-1$
"pre { font-family: monospace; font-size: 9pt }\n" + //$NON-NLS-1$
"\n" + //$NON-NLS-1$
"/* Margins */\n" + //$NON-NLS-1$
"body { overflow: auto; margin-top: 0; margin-bottom: 4; margin-left: 3; margin-right: 0 }\n" + //$NON-NLS-1$
"h1 { margin-top: 5; margin-bottom: 1 } \n" + //$NON-NLS-1$
"h2 { margin-top: 25; margin-bottom: 3 }\n" + //$NON-NLS-1$
"h3 { margin-top: 20; margin-bottom: 3 }\n" + //$NON-NLS-1$
"h4 { margin-top: 20; margin-bottom: 3 }\n" + //$NON-NLS-1$
"h5 { margin-top: 0; margin-bottom: 0 }\n" + //$NON-NLS-1$
"p { margin-top: 10px; margin-bottom: 10px }\n" + //$NON-NLS-1$
"pre { margin-left: 6 }\n" + //$NON-NLS-1$
"ul { margin-top: 0; margin-bottom: 10 }\n" + //$NON-NLS-1$
"li { margin-top: 0; margin-bottom: 0 } \n" + //$NON-NLS-1$
"li p { margin-top: 0; margin-bottom: 0 } \n" + //$NON-NLS-1$
"ol { margin-top: 0; margin-bottom: 10 }\n" + //$NON-NLS-1$
"dl { margin-top: 0; margin-bottom: 10 }\n" + //$NON-NLS-1$
"dt { margin-top: 0; margin-bottom: 0; font-weight: bold }\n" + //$NON-NLS-1$
"dd { margin-top: 0; margin-bottom: 0 }\n" + //$NON-NLS-1$
"\n" + //$NON-NLS-1$
"/* Styles and colors */\n" + //$NON-NLS-1$
"a:link { color: #0000FF }\n" + //$NON-NLS-1$
"a:hover { color: #000080 }\n" + //$NON-NLS-1$
"a:visited { text-decoration: underline }\n" + //$NON-NLS-1$
"h4 { font-style: italic }\n" + //$NON-NLS-1$
"strong { font-weight: bold }\n" + //$NON-NLS-1$
"em { font-style: italic }\n" + //$NON-NLS-1$
"var { font-style: italic }\n" + //$NON-NLS-1$
"th { font-weight: bold }\n" + //$NON-NLS-1$
""; //$NON-NLS-1$
public HtmlTooltip(Shell parent,boolean resizable) {
super(parent, APPEARANCE_JAVADOC_FONT, resizable);
}
public HtmlTooltip(Shell parent, String symbolicFontName, boolean resizable) {
super(parent, symbolicFontName, resizable);
}
protected void createContent(Composite parent) {
super.createContent(parent);
super.addLocationListener(new LocationListener() {
public void changing(LocationEvent event) {
String url = event.location;
if (url.startsWith("about:")) {
return;
}
event.doit = false;
if( url.startsWith("http"))
launchBrowser(url);
}
public void changed(LocationEvent event) {
}
});
}
protected void launchBrowser(String url) {
// open url in external browser
Program.launch(url);
}
public void setTooltip(String content){
content= addCSSToHTMLFragment(content);
super.setInformation(content);
}
/**
* Adds a HTML header and CSS info if <code>html</code> is only an HTML fragment (has no
* <html> section).
*
* @param html the html / text produced by a revision
* @return modified html
*/
private String addCSSToHTMLFragment(String html) {
int max= Math.min(100, html.length());
if (html.substring(0, max).indexOf("<html>") != -1) //$NON-NLS-1$
// there is already a header
return html;
StringBuffer info= new StringBuffer(512 + html.length());
HTMLPrinter.insertPageProlog(info, 0, fgStyleSheet);
info.append(html);
HTMLPrinter.addPageEpilog(info);
return info.toString();
}
}
分享到:
相关推荐
org.eclipse.swt.custom.StyledTextDropTargetEffect.class org.eclipse.swt.custom.StyledTextEvent.class org.eclipse.swt.custom.StyledTextListener.class org.eclipse.swt.custom.StyledTextPrintOptions.class...
SWT配置 SWT配置 SWT配置 SWT配置 SWT配置 SWT配置 SWT配置 SWT配置
64位windows操作系统使用的SWT库
下载编译的SWT库,版本号4.911,包含多个版本: org.eclipse.swt.cocoa.macosx.x86_64 org.eclipse.swt.gtk.linux.aarch64 org.eclipse.swt.gtk.linux.arm org.eclipse.swt.gtk.linux.ppc64le org.eclipse.swt.gtk....
SWT examples,SWT官方例子:http://www.eclipse.org/swt/examples.php 该页面所要下载的例子 其中,swt的例子在\plugins\org.eclipse.swt.examples.source_3.7.0.v3740f.jar中
org.eclipse.swt 相关jar包,JAVA调用火狐内核制作浏览器教程中所需,供各位下载,可在我的博客中查看详细用法。
swt工具文档 swt工具文档 swt工具文档 swt工具文档 swt工具文档 swt工具文档
swt 基础教程 swt 基础教程 swt 基础教程swt 基础教程swt 基础教程
SWT插件中文教程SWT常用方法SWT插件中文教程SWT常用方法SWT插件中文教程SWT常用方法SWT插件中文教程SWT常用方法SWT插件中文教程SWT常用方法SWT插件中文教程SWT常用方法
swt教程 有关SWT怎么应用
SWT官方api文档 开发基于swt的GUI程序必备手册
swt.jar swt.jar swt.jar swt.jar swt.jar
swt框架 适用与window下java窗口开发~~~~
swt 画图小程序 自由画线 矩形。。import org.eclipse.swt.SWT; import org.eclipse.swt.events.MouseAdapter; import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.events.MouseMoveListener; ...
swt table 实现换行
swt-api java swt GUI java界面编程,swt的开发DOC,谁用谁知道,一般人我不告诉他
基本上关于swt_win32_extension该有的都有了,其中org.eclipse.swt.win32.jar并不是必须的,如果出现OS.class未找到异常等,就在构建路径里加上org.sf.feeling.swt.win32.extension_1.1.0.jar这个包就可以了。...
swt资源释放问题,详细介绍swt如何释放屏幕资源
完整的用SWT树例子源码,有注释,实现联动。结构清晰,适合新手使用。
SWT Table 单元格编辑实例代码