KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > ccvs > ui > console > CVSConsoleFactory


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
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  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.team.internal.ccvs.ui.console;
12
13 import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
14 //commented out because of Bug 75387
15
//import org.eclipse.team.internal.ccvs.ui.console.CVSOutputConsole.MyLifecycle;
16
import org.eclipse.ui.console.*;
17
18 /**
19  * Console factory is used to show the console from the Console view "Open Console"
20  * drop-down action. This factory is registered via the org.eclipse.ui.console.consoleFactory
21  * extension point.
22  *
23  * @since 3.1
24  */

25 public class CVSConsoleFactory implements IConsoleFactory {
26
27     public CVSConsoleFactory() {
28     }
29     
30     public void openConsole() {
31         showConsole();
32     }
33     
34     public static void showConsole() {
35         CVSOutputConsole console = CVSUIPlugin.getPlugin().getConsole();
36         if (console != null) {
37             IConsoleManager manager = ConsolePlugin.getDefault().getConsoleManager();
38             IConsole[] existing = manager.getConsoles();
39             boolean exists = false;
40             for (int i = 0; i < existing.length; i++) {
41                 if(console == existing[i])
42                     exists = true;
43             }
44             if(! exists)
45                 manager.addConsoles(new IConsole[] {console});
46             manager.showConsoleView(console);
47         }
48     }
49     
50     public static void closeConsole() {
51         IConsoleManager manager = ConsolePlugin.getDefault().getConsoleManager();
52         CVSOutputConsole console = CVSUIPlugin.getPlugin().getConsole();
53         if (console != null) {
54             manager.removeConsoles(new IConsole[] {console});
55             ConsolePlugin.getDefault().getConsoleManager().addConsoleListener(console.new MyLifecycle());
56         }
57     }
58 }
59
Popular Tags