本文整理汇总了Java中org.eclipse.jface.text.hyperlink.IHyperlink.open方法的典型用法代码示例。如果您正苦于以下问题:Java IHyperlink.open方法的具体用法?Java IHyperlink.open怎么用?Java IHyperlink.open使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jface.text.hyperlink.IHyperlink
的用法示例。
在下文中一共展示了IHyperlink.open方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import org.eclipse.jface.text.hyperlink.IHyperlink; //导入方法依赖的package包/类
public Object execute(ExecutionEvent event) throws ExecutionException {
XtextEditor xtextEditor = EditorUtils.getActiveXtextEditor(event);
if (xtextEditor != null) {
ITextSelection selection = (ITextSelection) xtextEditor.getSelectionProvider().getSelection();
IRegion region = new Region(selection.getOffset(), selection.getLength());
ISourceViewer internalSourceViewer = xtextEditor.getInternalSourceViewer();
IHyperlink[] hyperlinks = getDetector().detectHyperlinks(internalSourceViewer, region, false);
if (hyperlinks != null && hyperlinks.length > 0) {
IHyperlink hyperlink = hyperlinks[0];
hyperlink.open();
}
}
return null;
}
示例2: execute
import org.eclipse.jface.text.hyperlink.IHyperlink; //导入方法依赖的package包/类
public Object execute(ExecutionEvent event) throws ExecutionException
{
TLAEditorAndPDFViewer editor = (TLAEditorAndPDFViewer) HandlerUtil.getActiveEditor(event);
ISourceViewer internalSourceViewer = editor.getTLAEditor().getSourceViewer();
ITextSelection selection = (ITextSelection) editor.getTLAEditor().getSelectionProvider().getSelection();
IRegion region = new Region(selection.getOffset(), selection.getLength());
// get the detectors
IHyperlinkDetector[] hyperlinkDetectors = editor.getTLAEditor().getSourceViewerConfiguration()
.getHyperlinkDetectors(internalSourceViewer);
if (hyperlinkDetectors != null)
{
for (int i = 0; i < hyperlinkDetectors.length; i++)
{
// detect
IHyperlink[] hyperlinks = hyperlinkDetectors[i].detectHyperlinks(internalSourceViewer, region,
false);
if (hyperlinks != null && hyperlinks.length > 0)
{
// open
IHyperlink hyperlink = hyperlinks[0];
hyperlink.open();
break;
}
}
}
return null;
}