Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Writing to console
Writing to console [message #257421] Mon, 17 November 2008 15:43 Go to next message
Eclipse UserFriend
Originally posted by: gdind2003.gmail.com

I am able to write to console as shown in this article :
http://wiki.eclipse.org/FAQ_How_do_I_write_to_the_console_fr om_a_plug-in_%3F.

How do I now put colors and different fonts, and hyper links?
Thanks in advance,

--Gautam
Re: Writing to console [message #257505 is a reply to message #257421] Wed, 19 November 2008 18:45 Go to previous messageGo to next message
Eclipse UserFriend
Hello G Dev,

You could create MessageConsoleStreams as the inherited IOConsole class
provides. This lets you set color and font for each message stream.
Hyperlinks are supported by the MessageConsole itself. Please see the code
example below for further details.

MessageConsole myConsole = findConsole("Foo");
MessageConsoleStream purpleStream = myConsole.newMessageStream();
MessageConsoleStream blueStream = myConsole.newMessageStream();

Color purple = new Color(Display.getCurrent(), 160, 32, 140);
Color blue = new Color(Display.getCurrent(), 0, 0, 255);

purpleStream.setColor(purple);
blueStream.setColor(blue);

try {
myConsole.getDocument().set("Save the eels.\r\n");
purpleStream.write("The Purple Fox \r\n");
blueStream.write("Jumped over the blue bear");
myConsole.addHyperlink(new MyHyperLink(), 9, 4);
} catch (IOException e) {
e.printStackTrace();
} catch (BadLocationException e) {
e.printStackTrace();
} finally {
purpleStream.close();
blueStream.close();
}

BR David.

Purple Scout / www.purplescout.com





"G Dev" <gdind2003@gmail.com> wrote in message
news:gfsl1q$edi$1@build.eclipse.org...
>I am able to write to console as shown in this article :
> http://wiki.eclipse.org/FAQ_How_do_I_write_to_the_console_fr om_a_plug-in_%3F.
> How do I now put colors and different fonts, and hyper links?
> Thanks in advance,
>
> --Gautam
Re: Writing to console [message #257588 is a reply to message #257505] Mon, 24 November 2008 00:41 Go to previous message
Eclipse UserFriend
Originally posted by: fastcodejava.gmail.com

Hi David,

The color portion of your code worked fine. But the link is not working.
I did something like :

messageConsole.addHyperlink(new FileLink(file,
"org.eclipse.jdt.ui.CompilationUnitEditor", 0, 1, 0), 0, 10).

Code compiles, but no hyper link effect is showing. I am not how to put
the offset and length for the addHyperlink method.

Thanks,

--Gautam
http://fast-code.sourceforge.net/


David Virdefors wrote:
> Hello G Dev,
>
> You could create MessageConsoleStreams as the inherited IOConsole class
> provides. This lets you set color and font for each message stream.
> Hyperlinks are supported by the MessageConsole itself. Please see the code
> example below for further details.
>
> MessageConsole myConsole = findConsole("Foo");
> MessageConsoleStream purpleStream = myConsole.newMessageStream();
> MessageConsoleStream blueStream = myConsole.newMessageStream();
>
> Color purple = new Color(Display.getCurrent(), 160, 32, 140);
> Color blue = new Color(Display.getCurrent(), 0, 0, 255);
>
> purpleStream.setColor(purple);
> blueStream.setColor(blue);
>
> try {
> myConsole.getDocument().set("Save the eels.\r\n");
> purpleStream.write("The Purple Fox \r\n");
> blueStream.write("Jumped over the blue bear");
> myConsole.addHyperlink(new MyHyperLink(), 9, 4);
> } catch (IOException e) {
> e.printStackTrace();
> } catch (BadLocationException e) {
> e.printStackTrace();
> } finally {
> purpleStream.close();
> blueStream.close();
> }
>
> BR David.
>
> Purple Scout / www.purplescout.com
>
>
>
>
>
> "G Dev" <gdind2003@gmail.com> wrote in message
> news:gfsl1q$edi$1@build.eclipse.org...
>> I am able to write to console as shown in this article :
>> http://wiki.eclipse.org/FAQ_How_do_I_write_to_the_console_fr om_a_plug-in_%3F.
>> How do I now put colors and different fonts, and hyper links?
>> Thanks in advance,
>>
>> --Gautam
>
>
Previous Topic:Build error of jar file : Resource is out of sync with the file system
Next Topic:Custom Developed Editor only contains "ERROR" if used to open external file
Goto Forum:
  


Current Time: Tue Apr 29 07:11:47 EDT 2025

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

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

Back to the top