When developing eclipse extensions, it is sometimes necessary to output the information directly to the console, such as Debug. At the same time, in RCP applications, the end user may want to output the current operation information and so on. Then we can use the following method to output our message to the console view:
//org.eclipse.ui.console
Messageconsolestream console = This.openlogconsole ("RCP",
"Informatiol",
"Org.eclipse.workbench.ui.ide");
Console.println (New Date (System.currenttimemillis ())
+ ": selected!");
Public Messageconsolestream openlogconsole (string domainname,
String Stationid, String applicationid) {
System.err.println ("Openlogconsole" (domain= + domainname +),
station= "
+ Stationid +", app= "+ ApplicationID +" )");
/*
* Get console name and create a new console
*/
StringBuffer consolename = new StringBuffer (domainname) ;
if (Stationid!= null) {
Consolename.append (">" + stationid);
if (ApplicationID!= null) {
Consolename . Append (">" + ApplicationID);
}
}
Messageconsole console = new
Messageconsole (consolename.tostring (),
Null);
Final Messageconsolestream Consolestream =
Console.newmessagestream ();
Consolestream.setcolor (Display.getDefault (). Getsystemcolor (
SWT.Color_blue));
/*
* Show View
*/
Iconsolemanager manager = (iconsolemanager)
Consoleplugin.getdefault ()
. Getcon Solemanager ();
Manager
. Addconsoles (New org.eclipse.ui.console.iconsole[] {
(org.eclipse.ui.console.IConsole) Console} );
Manager.showconsoleview (console);
return consolestream;
}