diff options
Diffstat (limited to 'plugins/org.yocto.cmake.managedbuilder/src/org/yocto/cmake/managedbuilder/util/ConsoleUtility.java')
-rw-r--r-- | plugins/org.yocto.cmake.managedbuilder/src/org/yocto/cmake/managedbuilder/util/ConsoleUtility.java | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/plugins/org.yocto.cmake.managedbuilder/src/org/yocto/cmake/managedbuilder/util/ConsoleUtility.java b/plugins/org.yocto.cmake.managedbuilder/src/org/yocto/cmake/managedbuilder/util/ConsoleUtility.java new file mode 100644 index 0000000..9fb31e5 --- /dev/null +++ b/plugins/org.yocto.cmake.managedbuilder/src/org/yocto/cmake/managedbuilder/util/ConsoleUtility.java | |||
@@ -0,0 +1,49 @@ | |||
1 | /******************************************************************************* | ||
2 | * Copyright (c) 2013 BMW Car IT GmbH. | ||
3 | * All rights reserved. This program and the accompanying materials | ||
4 | * are made available under the terms of the Eclipse Public License v1.0 | ||
5 | * which accompanies this distribution, and is available at | ||
6 | * http://www.eclipse.org/legal/epl-v10.html | ||
7 | * | ||
8 | * Contributors: | ||
9 | * BMW Car IT - initial API and implementation | ||
10 | *******************************************************************************/ | ||
11 | package org.yocto.cmake.managedbuilder.util; | ||
12 | |||
13 | import org.eclipse.ui.console.ConsolePlugin; | ||
14 | import org.eclipse.ui.console.IConsole; | ||
15 | import org.eclipse.ui.console.IOConsoleOutputStream; | ||
16 | import org.eclipse.ui.console.MessageConsole; | ||
17 | |||
18 | |||
19 | public class ConsoleUtility { | ||
20 | |||
21 | public static IOConsoleOutputStream getConsoleOutput(String consoleName) { | ||
22 | return getConsole(consoleName).newOutputStream(); | ||
23 | } | ||
24 | |||
25 | public static MessageConsole getConsole(String consoleName) { | ||
26 | MessageConsole foundConsole = findConsole(consoleName); | ||
27 | if (foundConsole != null) { | ||
28 | foundConsole.clearConsole(); | ||
29 | } else { | ||
30 | foundConsole = new MessageConsole(consoleName, null); | ||
31 | ConsolePlugin.getDefault(). | ||
32 | getConsoleManager().addConsoles(new IConsole[] { foundConsole }); | ||
33 | } | ||
34 | |||
35 | return foundConsole; | ||
36 | } | ||
37 | |||
38 | public static MessageConsole findConsole(String consoleName) { | ||
39 | IConsole[] consoles = | ||
40 | ConsolePlugin.getDefault().getConsoleManager().getConsoles(); | ||
41 | for (IConsole console : consoles) { | ||
42 | if (console.getName().equals(consoleName)) { | ||
43 | return (MessageConsole) console; | ||
44 | } | ||
45 | } | ||
46 | |||
47 | return null; | ||
48 | } | ||
49 | } | ||