Search in sources :

Example 1 with IOConsole

use of org.eclipse.ui.console.IOConsole in project tesb-studio-se by Talend.

the class RuntimeConsoleUtil method findConsole.

public static IOConsole findConsole() {
    ConsolePlugin plugin = ConsolePlugin.getDefault();
    IConsoleManager conMan = plugin.getConsoleManager();
    IConsole[] existing = conMan.getConsoles();
    for (int i = 0; i < existing.length; i++) {
        if (KARAF_CONSOLE.equals(existing[i].getName()))
            return (IOConsole) existing[i];
    }
    // no console found, so create a new one
    IOConsole myConsole = new IOConsole(KARAF_CONSOLE, null);
    conMan.addConsoles(new IConsole[] { myConsole });
    return myConsole;
}
Also used : IConsoleManager(org.eclipse.ui.console.IConsoleManager) ConsolePlugin(org.eclipse.ui.console.ConsolePlugin) IConsole(org.eclipse.ui.console.IConsole) IOConsole(org.eclipse.ui.console.IOConsole)

Example 2 with IOConsole

use of org.eclipse.ui.console.IOConsole in project tesb-studio-se by Talend.

the class RuntimeConsoleUtil method clearConsole.

public static void clearConsole() {
    ConsolePlugin plugin = ConsolePlugin.getDefault();
    IConsoleManager conMan = plugin.getConsoleManager();
    IConsole[] existing = conMan.getConsoles();
    for (int i = 0; i < existing.length; i++) {
        if (KARAF_CONSOLE.equals(existing[i].getName())) {
            ((IOConsole) existing[i]).destroy();
            conMan.removeConsoles(new IConsole[] { existing[i] });
        }
    }
}
Also used : IConsoleManager(org.eclipse.ui.console.IConsoleManager) ConsolePlugin(org.eclipse.ui.console.ConsolePlugin) IConsole(org.eclipse.ui.console.IConsole) IOConsole(org.eclipse.ui.console.IOConsole)

Example 3 with IOConsole

use of org.eclipse.ui.console.IOConsole in project core by jcryptool.

the class CommandsUiStartup method earlyStartup.

public void earlyStartup() {
    final IOConsole ioConsole = new IOConsole(Messages.CommandsUiStartup_consolename, null);
    ioConsole.setConsoleWidth(0);
    ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[] { ioConsole });
    CommandsUIPlugin.getDefault().setIoConsole(ioConsole);
    final CommandEvaluator evaluator = new CommandEvaluator();
    final IOConsolePromptShell monitor = new IOConsolePromptShell(ioConsole) {

        @Override
        protected void sendPrompt(final IOConsoleOutputStream o) throws IOException {
            Display.getDefault().syncExec(new Runnable() {

                public void run() {
                    Color prevColor = o.getColor();
                    int prevStyle = o.getFontStyle();
                    o.setColor(Display.getDefault().getSystemColor(SWT.COLOR_RED));
                    try {
                        o.write(PROMPT);
                    } catch (IOException e) {
                        LogUtil.logError(CommandsUIPlugin.PLUGIN_ID, e);
                    }
                    o.setColor(prevColor);
                    o.setFontStyle(prevStyle);
                }
            });
        }

        @Override
        protected void initializeConsole(IOConsoleOutputStream o) {
            super.initializeConsole(o);
            try {
                o.write(Messages.CommandsUiStartup_welcome + Messages.CommandsUiStartup_welcome_tip);
            } catch (IOException e) {
                LogUtil.logError(CommandsUIPlugin.PLUGIN_ID, e);
            }
        }
    };
    Observer monitorObserver = new Observer() {

        public void update(Observable o, Object arg) {
            String line = monitor.getLine();
            String result = Messages.CommandsUiStartup_eval_error;
            try {
                result = evaluator.evaluate(line).getResult();
            } catch (ParseException e) {
                LogUtil.logError(CommandsUIPlugin.PLUGIN_ID, e);
            }
            IOConsoleOutputStream outStream = ioConsole.newOutputStream();
            try {
                // $NON-NLS-1$
                outStream.write(result + "\n\n");
            } catch (IOException e) {
                LogUtil.logError(CommandsUIPlugin.PLUGIN_ID, e);
            }
            try {
                outStream.close();
            } catch (IOException e) {
                LogUtil.logError(CommandsUIPlugin.PLUGIN_ID, e);
            }
        }
    };
    monitor.addObserver(monitorObserver);
    monitor.startMonitoring();
}
Also used : CommandEvaluator(org.jcryptool.commands.core.evaluator.CommandEvaluator) IOConsoleOutputStream(org.eclipse.ui.console.IOConsoleOutputStream) IOConsolePromptShell(org.jcryptool.commands.ui.eclipseconsole.console.IOConsolePromptShell) Color(org.eclipse.swt.graphics.Color) Observer(java.util.Observer) IOException(java.io.IOException) ParseException(org.apache.commons.cli.ParseException) IOConsole(org.eclipse.ui.console.IOConsole) Observable(java.util.Observable)

Example 4 with IOConsole

use of org.eclipse.ui.console.IOConsole in project statecharts by Yakindu.

the class StatechartLaunchShortcut method showConsole.

protected void showConsole() {
    IConsoleManager consoleManager = ConsolePlugin.getDefault().getConsoleManager();
    IConsole[] consoles = consoleManager.getConsoles();
    for (IConsole iConsole : consoles) {
        if (TYPE.equals(iConsole.getType())) {
            if (iConsole instanceof IOConsole) {
                ((IOConsole) iConsole).activate();
                consoleManager.showConsoleView(iConsole);
            }
        }
    }
}
Also used : IConsoleManager(org.eclipse.ui.console.IConsoleManager) IConsole(org.eclipse.ui.console.IConsole) IOConsole(org.eclipse.ui.console.IOConsole)

Example 5 with IOConsole

use of org.eclipse.ui.console.IOConsole in project gemoc-studio by eclipse.

the class EclipseConsoleIOFactory method getConsoleIO.

/**
 * retrieve or create a ConsoleIO with the given UId
 * the name is used only if the console is created
 * @param name
 * @return
 */
public EclipseConsoleIO getConsoleIO(String uid, String name) {
    EclipseConsoleIO consoleIo = consoleIOMap.get(uid);
    if (consoleIo == null) {
        // create the eclipse console
        IOConsole ioConsole = new IOConsole(name, null);
        ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[] { ioConsole });
        // ConsolePlugin.getDefault().getConsoleManager().showConsoleView(ioConsole);
        // ioConsole.activate(); // console will be displayed on first use
        // create the IO with this console
        consoleIo = new EclipseConsoleIO(ioConsole);
        consoleIOMap.put(uid, consoleIo);
    }
    return consoleIo;
}
Also used : IOConsole(org.eclipse.ui.console.IOConsole)

Aggregations

IOConsole (org.eclipse.ui.console.IOConsole)13 IConsole (org.eclipse.ui.console.IConsole)7 IOException (java.io.IOException)4 CoreException (org.eclipse.core.runtime.CoreException)4 IConsoleManager (org.eclipse.ui.console.IConsoleManager)4 IOConsoleOutputStream (org.eclipse.ui.console.IOConsoleOutputStream)4 ConsolePlugin (org.eclipse.ui.console.ConsolePlugin)3 OutputStream (java.io.OutputStream)2 Matcher (java.util.regex.Matcher)2 Pattern (java.util.regex.Pattern)2 IProcessTerminationListener (net.vtst.eclipse.easyxtext.ui.launching.EasyLaunchConfigurationDelegateUtils.IProcessTerminationListener)2 EasyPatternMatchListener (net.vtst.eclipse.easyxtext.ui.launching.EasyPatternMatchListener)2 IFile (org.eclipse.core.resources.IFile)2 IMarker (org.eclipse.core.resources.IMarker)2 Status (org.eclipse.core.runtime.Status)2 IProcess (org.eclipse.debug.core.model.IProcess)2 BadLocationException (org.eclipse.jface.text.BadLocationException)2 PatternMatchEvent (org.eclipse.ui.console.PatternMatchEvent)2 TextConsole (org.eclipse.ui.console.TextConsole)2 BufferedReader (java.io.BufferedReader)1