KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > debug > ui > console > JavaStackTraceConsoleFactory


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 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.jdt.internal.debug.ui.console;
12
13 import org.eclipse.ui.console.ConsolePlugin;
14 import org.eclipse.ui.console.IConsole;
15 import org.eclipse.ui.console.IConsoleFactory;
16 import org.eclipse.ui.console.IConsoleListener;
17 import org.eclipse.ui.console.IConsoleManager;
18
19 /**
20  * Creates a new console into which users can paste stack traces and follow
21  * the hyperlinks.
22  *
23  * @since 3.1
24  */

25 public class JavaStackTraceConsoleFactory implements IConsoleFactory {
26     private IConsoleManager fConsoleManager = null;
27     private JavaStackTraceConsole fConsole = null;
28
29     public JavaStackTraceConsoleFactory() {
30         fConsoleManager = ConsolePlugin.getDefault().getConsoleManager();
31         fConsoleManager.addConsoleListener(new IConsoleListener() {
32             public void consolesAdded(IConsole[] consoles) {
33             }
34
35             public void consolesRemoved(IConsole[] consoles) {
36                 for (int i = 0; i < consoles.length; i++) {
37                     if(consoles[i] == fConsole) {
38                         fConsole.saveDocument();
39                         fConsole = null;
40                     }
41                 }
42             }
43         
44         });
45     }
46     /* (non-Javadoc)
47      * @see org.eclipse.ui.console.IConsoleFactory#openConsole()
48      */

49     public void openConsole() {
50         if (fConsole == null) {
51             fConsole = new JavaStackTraceConsole();
52             fConsole.initializeDocument();
53             fConsoleManager.addConsoles(new IConsole[]{fConsole});
54         }
55         fConsoleManager.showConsoleView(fConsole);
56     }
57 }
58
Popular Tags