MessageConsole Background Color Does Not Change [message #550053] |
Wed, 28 July 2010 18:14  |
Eclipse User |
|
|
|
I'm new to writing plugins so I'm playing around a bit trying to get a feel for how everything interacts. My goal for now is to write text of different colors to a MessageConsole and to make the colors stand out more I want to change the background color of the console to black. The problem is that even though I change the color in my code, when I launch the plugin the color remains the same (white).
Any help would be appreciated. Thanks.
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
Display display = Display.getCurrent();
MessageConsole myConsole = findConsole("myConsoleTest");
myConsole.setBackground(new Color(display,0,0,0));
MessageConsoleStream out = myConsole.newMessageStream();
out.setColor(new Color(display,0,0,200));
out.println("Hello from console plugin");
}
|
|
|
|
Re: MessageConsole Background Color Does Not Change [message #550745 is a reply to message #550464] |
Wed, 04 August 2010 05:00   |
Eclipse User |
|
|
|
Hi, I have found the solution, I don't know if still useful for you, but I will let it here for someone searching for the same problem.
The color isn't changed because the setBackground or setColor raise an "Invalid thread access" exception because trying to access the UI thread and then the color isn't changed. The calls should be done synchronized with the UI thread in the following way:
TextMessageConsole myConsole = findConsole("My Console");
// Set colors of console background, output and error
// but in a synchronized way with the UI-thread
Display.getDefault().syncExec(new Runnable() {
public void run() {
MessageConsoleStream out = myConsole.newMessageStream();
myConsole.setBackground(new Color(null, 0, 0, 0);
out.setColor(new Color(null, 255, 0, 0);
}
And color is changed. Hope it helps.
|
|
|
|
Powered by
FUDForum. Page generated in 0.03835 seconds