Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » message in a console
message in a console [message #856336] Wed, 25 April 2012 11:18 Go to next message
Gael Quemener is currently offline Gael Quemener
Messages: 1
Registered: April 2012
Junior Member
Hi,
I'd like to display a console view and print a message in it in a RCP project.
Anyone has an example or an idea of how to do it?

Thanks,

Gael
Re: message in a console [message #870572 is a reply to message #856336] Tue, 08 May 2012 15:13 Go to previous message
Russ Loucks is currently offline Russ Loucks
Messages: 11
Registered: December 2011
Junior Member
On 04/25/2012 10:18 AM, Gael Quemener wrote:
> Hi,
> I'd like to display a console view and print a message in it in a RCP
> project.
> Anyone has an example or an idea of how to do it?
>
> Thanks,
>
> Gael

Two things. In the plugin.xml for you workbench plugin, add:

<extension
point="org.eclipse.ui.perspectiveExtensions">
<perspectiveExtension targetID="someID">
<view
id="org.eclipse.ui.console.ConsoleView"
relationship="stack"
relative="bottom"/>
</perspectiveExtension>
</extension>


For code (not the best coding practices below. Best use singleton
pattern for the MyConsole class):

1)

public class ConsoleFactory implements IConsoleFactory {

/* (non-Javadoc)
* @see org.eclipse.ui.console.IConsoleFactory#openConsole()
*/
public void openConsole() {
MyConsole.msg("Started");
MessageConsole console = MyConsole.getMessageConsole();
ConsolePlugin.getDefault().getConsoleManager().addConsoles(
new IConsole[] { console });
}
}

2)

public class MyConsole {
private static MessageConsole console;
private static MessageConsoleStream msgStream;

public static MessageConsoleStream getMessageConsoleStream () {
return msgStream;
}
public static MessageConsole getMessageConsole () {
return console;
}

public static void msg (String msg) {
if (console == null) {
console = new MessageConsole (Application.APP_NAME + " console", null);
msgStream = console.newMessageStream();
}
if (msg != null) {
msgStream.println(msg);
}
}
}
Previous Topic:RCP plugin to use logic disigner
Next Topic:hide minimize/maximize button in views
Goto Forum:
  


Current Time: Wed Aug 20 02:52:41 EDT 2014

Powered by FUDForum. Page generated in 0.01523 seconds