Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Plugin Development Environment (PDE) » MessageConsole Background Color Does Not Change
MessageConsole Background Color Does Not Change [message #606349] Wed, 28 July 2010 22:14 Go to next message
No real name is currently offline No real nameFriend
Messages: 2
Registered: July 2010
Junior Member
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 #606384 is a reply to message #606349] Fri, 30 July 2010 13:14 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 4
Registered: July 2010
Junior Member
I'm just in the same situation than you, so I will also appreciate any help...thanks in advance.
Re: MessageConsole Background Color Does Not Change [message #606417 is a reply to message #606384] Wed, 04 August 2010 09:00 Go to previous message
No real name is currently offline No real nameFriend
Messages: 4
Registered: July 2010
Junior Member
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.
Previous Topic:Question about the popupMenus extension-point
Next Topic:Project is importing wrong version of spring
Goto Forum:
  


Current Time: Sat Dec 20 07:25:25 GMT 2014

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

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