本文整理汇总了Java中org.eclipse.ui.console.IHyperlink类的典型用法代码示例。如果您正苦于以下问题:Java IHyperlink类的具体用法?Java IHyperlink怎么用?Java IHyperlink使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IHyperlink类属于org.eclipse.ui.console包,在下文中一共展示了IHyperlink类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processIOConsole
import org.eclipse.ui.console.IHyperlink; //导入依赖的package包/类
@SuppressWarnings("restriction")
private void processIOConsole(IOConsole ioConsole) {
IDocument document = ioConsole.getDocument();
try {
Position[] positions = document.getPositions(ConsoleHyperlinkPosition.HYPER_LINK_CATEGORY);
Arrays.sort(positions, new Comparator<Position>() {
@Override
public int compare(Position o1, Position o2) {
return Integer.compare(o1.getOffset(), o2.getOffset());
}
});
if (positions.length > 0) {
Position p = positions[positions.length - 1];
if (p instanceof ConsoleHyperlinkPosition) {
ConsoleHyperlinkPosition consoleHyperlinkPosition = (ConsoleHyperlinkPosition) p;
IHyperlink hyperLink = consoleHyperlinkPosition.getHyperLink();
hyperLink.linkActivated();
}
}
} catch (BadPositionCategoryException e) {
Log.log(e);
}
}
示例2: init
import org.eclipse.ui.console.IHyperlink; //导入依赖的package包/类
@Override
public void init(final IConsole console) {
IProcess process = console.getProcess();
if (process != null) {
ILaunch launch = process.getLaunch();
if (launch != null) {
initLaunchConfiguration(launch.getLaunchConfiguration());
}
}
this.linkContainer = new ILinkContainer() {
@Override
public void addLink(IHyperlink link, int offset, int length) {
console.addLink(link, offset, length);
}
@Override
public String getContents(int offset, int length) throws BadLocationException {
return console.getDocument().get(offset, length);
}
};
}
示例3: addLink
import org.eclipse.ui.console.IHyperlink; //导入依赖的package包/类
@Override
public void addLink(IHyperlink link, int offset, int length) {
if (testOutputText == null) {
return;
}
StyleRangeWithCustomData range = new StyleRangeWithCustomData();
range.underline = true;
try {
range.underlineStyle = SWT.UNDERLINE_LINK;
} catch (Throwable e) {
//Ignore (not available on earlier versions of eclipse)
}
//Set the proper color if it's available.
TextAttribute textAttribute = ColorManager.getDefault().getHyperlinkTextAttribute();
if (textAttribute != null) {
range.foreground = textAttribute.getForeground();
} else {
range.foreground = JFaceColors.getHyperlinkText(Display.getDefault());
}
range.start = offset;
range.length = length + 1;
range.customData = link;
testOutputText.setStyleRange(range);
}
示例4: mouseUp
import org.eclipse.ui.console.IHyperlink; //导入依赖的package包/类
@Override
public void mouseUp(MouseEvent e) {
Widget w = e.widget;
if (w instanceof StyledText) {
StyledText styledText = (StyledText) w;
int offset = styledText.getCaretOffset();
if (offset >= 0 && offset < styledText.getCharCount()) {
StyleRange styleRangeAtOffset = styledText.getStyleRangeAtOffset(offset);
if (styleRangeAtOffset instanceof StyleRangeWithCustomData) {
StyleRangeWithCustomData styleRangeWithCustomData = (StyleRangeWithCustomData) styleRangeAtOffset;
Object l = styleRangeWithCustomData.customData;
if (l instanceof IHyperlink) {
((IHyperlink) l).linkActivated();
}
}
}
}
}
示例5: matchFound
import org.eclipse.ui.console.IHyperlink; //导入依赖的package包/类
@Override
public void matchFound(PatternMatchEvent event) {
int offset = event.getOffset();
int length = event.getLength();
int prefix = 0;
try {
String text = fConsole.getDocument().get(offset, length);
IHyperlink link = new EclecticTraceHyperLink(fConsole);
fConsole.addHyperlink(link, offset, length);
} catch (BadLocationException e) {
e.printStackTrace();
throw new RuntimeException(e);
// IStatus status = new Status(IStatus.ERROR, "org.eclectic.debug.ui", 0, "Cannot set link for " + event, e);
// throw new CoreException(status);
}
}
示例6: matchFound
import org.eclipse.ui.console.IHyperlink; //导入依赖的package包/类
@Override
public void matchFound(PatternMatchEvent event) {
// remove the brackets
int offset = event.getOffset() + 1;
int length = event.getLength() - 2;
try {
String name = console.getDocument().get(offset, length);
EObject ref = findBestReference(name);
if (ref != null) {
IHyperlink hyperlink = new AgreeConsoleHyperLink(ref);
console.addHyperlink(hyperlink, offset, length);
}
} catch (BadLocationException e) {
e.printStackTrace();
}
}
示例7: matchFound
import org.eclipse.ui.console.IHyperlink; //导入依赖的package包/类
@Override
public void matchFound(PatternMatchEvent event) {
if (event.getSource() instanceof TextConsole) {
try {
final TextConsole console = (TextConsole) event.getSource();
final int start = event.getOffset();
final int length = event.getLength();
IHyperlink link = new BrowserSupportBasedHyperlink(console.getDocument().get(start, length));
console.addHyperlink(link, start, length);
} catch (BadLocationException e) {
logger.log(Level.SEVERE, "Cannot create hyperlink", e);
}
}
}
示例8: matchFound
import org.eclipse.ui.console.IHyperlink; //导入依赖的package包/类
@Override
public void matchFound(PatternMatchEvent event)
{
try
{
String fileReferenceText = console.getDocument().get(event.getOffset(), event.getLength());
int separatorIndex = fileReferenceText.lastIndexOf(":");
String absoluteFilePath = fileReferenceText.substring(0, separatorIndex);
//String workspacePath = ResourcesPlugin.getWorkspace().getRoot().getLocation().toString();
//if (absoluteFilePath.startsWith(workspacePath))
{
//String relativeFilePath = absoluteFilePath.substring(workspacePath.length());
//IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(relativeFilePath)); // this way can work, but only for files in the workspace :(
int lineNumber = Integer.parseInt(fileReferenceText.substring(separatorIndex + 1));
//FileLink hyperlink = new FileLink(file, null, -1, -1, lineNumber); // a link to a file in the workspace
IHyperlink hyperlink = makeHyperlink(absoluteFilePath, lineNumber); // a link to any file
console.addHyperlink(hyperlink, event.getOffset(), event.getLength());
}
}
catch (Exception exception)
{
throw new RuntimeException(exception);
}
}
示例9: makeHyperlink
import org.eclipse.ui.console.IHyperlink; //导入依赖的package包/类
private static IHyperlink makeHyperlink(String absoluteFilePath, int lineNumber)
{
return new IHyperlink()
{
@Override
public void linkExited()
{
}
@Override
public void linkEntered()
{
}
@Override
public void linkActivated()
{
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
try
{
IEditorPart editorPart = IDE.openEditorOnFileStore(page, EFS.getStore(new File(absoluteFilePath).toURI()));
goToLine(editorPart, lineNumber);
}
catch (Exception exception)
{
throw new RuntimeException(exception);
}
}
};
}
示例10: addLink
import org.eclipse.ui.console.IHyperlink; //导入依赖的package包/类
/**
* IConsole: Add a link to the console
*/
public void addLink(IHyperlink link, int offset, int length) {
try {
super.addHyperlink(link, offset, length);
} catch (BadLocationException e) {
Log.log(e);
}
}
示例11: onHandleClick
import org.eclipse.ui.console.IHyperlink; //导入依赖的package包/类
@Override
protected void onHandleClick(Object data) {
if (data instanceof IHyperlink) {
//The order is important (when activating it'll do a hide automatically,
//but we want to do a hide without focusing the previous editor).
this.hideInformationControl(false, false);
((IHyperlink) data).linkActivated();
}
}
示例12: lineAppended
import org.eclipse.ui.console.IHyperlink; //导入依赖的package包/类
public void lineAppended(IRegion line)
{
try
{
int offset = line.getOffset();
int length = line.getLength();
String text = console.getDocument().get(offset, length);
if (fErrorMatcher.match(text) || fWarningMatcher.match(text) || fBreakPointMatcher.match(text))
{
Matcher m = fLineNumberMatcher.matcher(text);
if (m.find())
{
String lineNumber = text.substring(m.start(), m.end());
String file = text.substring(0, m.start());
Matcher m2 = fLineNumber.matcher(lineNumber);
if (m2.find())
{
String lineNo = lineNumber.substring(m2.start(), m2.end());
IHyperlink link = new DLabProConsoleHyperlink(lineNo, file, console);
console.addLink(link, offset, m.end());
}
}
}
}
catch (BadLocationException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例13: getHyperlink
import org.eclipse.ui.console.IHyperlink; //导入依赖的package包/类
public IHyperlink getHyperlink() {
return viewer.getHyperlink();
}
示例14: addLink
import org.eclipse.ui.console.IHyperlink; //导入依赖的package包/类
void addLink(IHyperlink link, int offset, int length);