Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » MessageConsole + Hyperlinks
MessageConsole + Hyperlinks [message #304254] Mon, 05 June 2006 05:37 Go to next message
Eclipse UserFriend
Hi,

I am trying to add hyperlinks to my console (a la Java exception
reporting) so that I can navigate from errors to the source line/column
of my programs. I use messageConsole.newMessageStream() to get my debug
and error message streams and print messages to the console using their
..print() and .println() methods. However, when I try to add a hyperlink
using the addHyperlink method, I get a BadLocationException. I have
inspected the messageConsole.getDocument().getLength() and it is
constantly 0 (and that is the reason of the exception) although I have
printed messages using the print-println methods before... Any ideas or
examples?

In case it helps I am using Eclipse 3.1.0 under WinXP.

Cheers,
Dimitrios
Re: MessageConsole + Hyperlinks [message #304309 is a reply to message #304254] Mon, 05 June 2006 11:11 Go to previous messageGo to next message
Eclipse UserFriend
Dimitrios Kolovos wrote:
> Hi,
>
> I am trying to add hyperlinks to my console (a la Java exception
> reporting) so that I can navigate from errors to the source line/column
> of my programs. I use messageConsole.newMessageStream() to get my debug
> and error message streams and print messages to the console using their
> .print() and .println() methods. However, when I try to add a hyperlink
> using the addHyperlink method, I get a BadLocationException. I have
> inspected the messageConsole.getDocument().getLength() and it is
> constantly 0 (and that is the reason of the exception) although I have
> printed messages using the print-println methods before... Any ideas or
> examples?
>
> In case it helps I am using Eclipse 3.1.0 under WinXP.
>
> Cheers,
> Dimitrios


The asynchronous nature of the console make this more difficult that it
seems it should be because writing to the console doesn't mean that the
text is actually in the document yet. You can get around this by using a
pattern matcher.

From ProcessConsole.java:

private class ConsoleLogFilePatternMatcher implements
IPatternMatchListener {
String fFilePath;

public ConsoleLogFilePatternMatcher(String filePath) {
fFilePath = escape(filePath);
}

private String escape(String path) {
StringBuffer buffer = new StringBuffer(path);
int index = buffer.indexOf("\\"); //$NON-NLS-1$
while (index >= 0) {
buffer.insert(index, '\\');
index = buffer.indexOf("\\", index+2); //$NON-NLS-1$
}
return buffer.toString();
}

public String getPattern() {
return fFilePath;
}

public void matchFound(PatternMatchEvent event) {
try {
addHyperlink(new ConsoleLogFileHyperlink(fFilePath),
event.getOffset(), event.getLength());
removePatternMatchListener(this);
} catch (BadLocationException e) {
}
}

public int getCompilerFlags() {
return 0;
}

public String getLineQualifier() {
return null;
}

public void connect(TextConsole console) {
}

public void disconnect() {
}
}
Re: MessageConsole + Hyperlinks [message #304346 is a reply to message #304309] Mon, 05 June 2006 18:51 Go to previous message
Eclipse UserFriend
Hi Kevin,

I tried that and it worked :)

Thanks,
Dimitrios

Kevin Barnes wrote:

> The asynchronous nature of the console make this more difficult that it
> seems it should be because writing to the console doesn't mean that the
> text is actually in the document yet. You can get around this by using a
> pattern matcher.
Previous Topic:remote debug, connection refused
Next Topic:why eclipse often occupy more than 95% cpu?
Goto Forum:
  


Current Time: Tue Jul 22 15:44:11 EDT 2025

Powered by FUDForum. Page generated in 0.04360 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top