Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » message console and terminate button
message console and terminate button [message #1047092] Mon, 22 April 2013 19:34 Go to next message
Juliana Franco is currently offline Juliana FrancoFriend
Messages: 1
Registered: April 2013
Junior Member
Hi,

I have developed a language in xtext and I need to write some messages in console.
To do that, I have seen this site http://wiki.eclipse.org/FAQ_How_do_I_write_to_the_console_from_a_plug-in%3F and then I have implemented this code:

private static MessageConsole findConsole(String name) {

		if (ConsolePlugin.getDefault() == null)
			return null;
		ConsolePlugin plugin = ConsolePlugin.getDefault();
		IConsoleManager conMan = plugin.getConsoleManager();
		IConsole[] existing = conMan.getConsoles();
		for (int i = 0; i < existing.length; i++)
			if (name.equals(existing[i].getName())) {
				conMan.showConsoleView(existing[i]);
				return (MessageConsole) existing[i];
			}
		// no console found, so create a new one
		MessageConsole myConsole = new MessageConsole(name, null);
		conMan.addConsoles(new IConsole[] { myConsole });
		return myConsole;
	}

public MessageConsoleStream getMessageStream() {
		MessageConsole myConsole = findConsole("console");
		if (myConsole != null) {

			IWorkbench wb = PlatformUI.getWorkbench();
			IWorkbenchWindow win = wb.getActiveWorkbenchWindow();
			IWorkbenchPage page = win.getActivePage();
			String id = IConsoleConstants.ID_CONSOLE_VIEW;
			IConsoleView view;
			try {

				view = (IConsoleView) page.showView(id);
				view.display(myConsole);

				return myConsole.newMessageStream();
			} catch (PartInitException e) {
				e.printStackTrace();
			}
		}
		return null;
	}


I have added org.eclipse.ui.console to plugin.xml > dependencies > required plugins.

When I want to print some message:
MessageConsoleStream out = getMessageStream();
out.println(...);

And it is working. But I need a "terminate button" in my console and it seems that this code isn't enough.
How can I do that?
Thanks.
Re: message console and terminate button [message #1047104 is a reply to message #1047092] Mon, 22 April 2013 19:54 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

i dont see how this is related to Xtext.

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: message console and terminate button [message #1051563 is a reply to message #1047104] Mon, 29 April 2013 00:49 Go to previous messageGo to next message
Yoandri Saavedra is currently offline Yoandri SaavedraFriend
Messages: 24
Registered: February 2013
Junior Member

Is my problem too, we need input/output to the console, so I thought automatically run my generator .java, because I no find this cuestion in the Xtext documentation, in google, ... ...so the xbase is alright.. but someone could write an example for this???..thanks for reading this...
Re: message console and terminate button [message #1051576 is a reply to message #1051563] Mon, 29 April 2013 01:16 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
On 2013-29-04 2:49, Yoandri Saavedra wrote:
> Is my problem too, we need input/output to the console, so I thought
> automatically run my generator .java, because I no find this cuestion in
> the Xtext documentation, in google, ... ...so the xbase is alright.. but
> someone could write an example for this???..thanks for reading this...

Here is a link to a console I used in the eclipse b3 project.
https://github.com/eclipse/b3/blob/master/org.eclipse.b3.beelang.ui/src/org/eclipse/b3/beelang/ui/BeeLangConsoleUtils.java?source=c

You have to figure out where and how it is used, and if you want input
as well - how to do that.

Here is an example where the main function in a DSL is found and
executed with output to the console.

https://github.com/eclipse/b3/blob/ec4b447e6c7954806589956e5419851f6c6ba9c9/org.eclipse.b3.build.ui/src/org/eclipse/b3/build/ui/commands/RunMainFunctionInModelHandler.java

Doing the same for Xbase etc. is naturally different.

Hope this helps as examples.

Regards
- henrik
Re: message console and terminate button [message #1051587 is a reply to message #1051576] Mon, 29 April 2013 01:43 Go to previous message
Yoandri Saavedra is currently offline Yoandri SaavedraFriend
Messages: 24
Registered: February 2013
Junior Member

Thank you very much ... very understandable example .. if not too much to ask .. I might know how to route the output minimally interpreter Xbase .. please .. a simple idea would help me a lot .. some small example using the Xbase interpreter that takes computer .. b3 eclipse is very dense for a beginner reading .. again thanks .. god accompany
Previous Topic: how to automatically compile my . java from src-gen??
Next Topic:Using the XText Formatter
Goto Forum:
  


Current Time: Thu Apr 18 20:26:46 GMT 2024

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

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

Back to the top