Note that there are some explanatory texts on larger screens.

plurals
  1. POWriting to the Eclipse console
    primarykey
    data
    text
    <p>My plugin has to write to the eclipse console - for testing purpose I simplified my code, so that I only have the following:</p> <pre><code>public void start(BundleContext context) throws Exception { super.start(context); plugin = this; System.out.println("Tecomp Plugin is running"); MessageConsole myConsole = new MessageConsole("My Console", null); //myConsole.activate(); ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[]{ myConsole }); ConsolePlugin.getDefault().getConsoleManager().showConsoleView(myConsole); final MessageConsoleStream stream = myConsole.newMessageStream(); stream.setActivateOnWrite(true); stream.println("Hi there!"); stream.close(); } </code></pre> <p>It's a simple plugin, the method start belogs to the class extending AbstractUIPlugin - it't no rcp application. Code works fine inside the runtime workbench - once the plugin is installed, the output gets lost somewhere. The rest of the plugin is working properly.</p> <p>Is there perhaps a problem with the ConsolePlugin? Or are streams handled differently in the runtime workbench and the development workbench?</p> <p>I tried both - a feature project and directly copying the plugin jar to the eclipse directory - for installing the plugin - same result for both...</p> <p>Any help is welcome, because I'm struggeling with that problem for a while now...</p> <p>Regards, Kathi</p> <h3>Edit:</h3> <p>it doesn't seem to be a problem of the Console... I provided my own view for printing the output, but although declard in the plugin.xml there is no view after installing the plugin... here is what I did: -export the plugin with the ExportWizard into a jar-archive -copied this archive to /usr/share/eclipse/plugins -restarted eclipse</p> <p>or with a feature project: -exported the feature-project containing my plugin with the ExportWizard -removed the above jar archive from the eclipse dir -installed the feature -restarted eclipse</p> <p>both didn't word - did I get something wrong with installing the plugin? The jar-archive is ok, I checked it - it's the latest version. But somehow it seems that eclipse is still working with some older plugin without the changes I made</p> <p>regards, Kathi</p> <h3>Edit:</h3> <p>I implemented the IStartup Interface end extended the org.eclipse.ui.startup point, but nothing changed... I really thinks it's an installation problem somehow. I commented out some output but it's still printed to the debug console. Is there some sort of plugin cache in eclipse? So that the new code doesn't get read?</p> <h3>Edit:</h3> <p>Thanks for the suggestions, but starting eclipse with the -clean option didn't help - I'll try to install the plugin in some other environment next week - perhaps there is something wrong with mine...</p> <h3>Edit:</h3> <p>the code in the class calling the compilier looks as follows:</p> <pre><code>private MessageConsole findConsole(String name){ ConsolePlugin plugin = ConsolePlugin.getDefault(); IConsoleManager conMan = plugin.getConsoleManager(); IConsole[] existing = conMan.getConsoles(); for (int i = 0; i&lt;existing.length; i++){ if (name.equals(existing[i].getName())){ return (MessageConsole)existing[i]; } } //no console found -&gt; create new one MessageConsole newConsole = new MessageConsole(name, null); conMan.addConsoles(new IConsole[]{newConsole}); return newConsole; } public void run() { MessageConsole console = findConsole("tecompConsole"); //display the tecomp Console IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); String id = IConsoleConstants.ID_CONSOLE_VIEW; try { IConsoleView view = (IConsoleView) page.showView(id); view.display(console); } catch (PartInitException e) { e.printStackTrace(); } MessageConsoleStream output = console.newMessageStream(); String tecompPath = TecompPlugin.getDefault().getPreferenceStore().getString(IEiffelConstants.TECOMP_PATH); if (checkTecompPath(tecompPath)){ String line; String[] cmd = {tecompPath, pathToAceFile}; try{ output.println("calling tecomp"); Process tecomp = Runtime.getRuntime().exec(cmd); //capture stdout und stderr from tecomp BufferedReader input = new BufferedReader( new InputStreamReader(tecomp.getInputStream())); BufferedReader err = new BufferedReader( new InputStreamReader(tecomp.getErrorStream())); while ((line = input.readLine()) != null ){ output.println(line); } input.close(); while ((line = err.readLine()) != null){ output.println(line); } err.close(); output.close(); tecomp.waitFor(); //System.out.println(tecomp.exitValue()); }catch (Exception err){ err.printStackTrace(); } } else { try{ output.println("please specify a tecomp path"); output.close(); }catch (Exception err){} } } </code></pre> <p>but the first test example should work, shouldn't it? I create a new MessageConsoleStream and write to it manually. Thats exactly like the examples I found.</p> <h3>Edit:</h3> <p>The code doesn't belog to an rcp application - it's just a plugin, extending the eclipse ide with support for the eiffel programming language. So I think your suggestion doesn't work for my plugin - VonC, at least I don't know where to put your code... My first sample code in the initial question gets called inside the Plugin class extending AbstractUIPlugin within the start(BundleContext context) method. My plugin in running, so somewhere this method gets called. And as I mentioned - plugin works fine inside the runtime workbench...</p> <p>I'm sorry if this is not the right place for an additional explanation of my question - but it seemed to be the only place the system allows me to post some further lines. Comments to your answers are not allowed for me, because I just signed in and for that I don't have enough reputation points... so, please correct me, if I'm using the system wrong :) thx</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload