KickJava   Java API By Example, From Geeks To Geeks.

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


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.jdt.internal.debug.ui.console;
12
13 import org.eclipse.jface.action.IAction;
14 import org.eclipse.jface.viewers.ISelection;
15 import org.eclipse.ui.IViewActionDelegate;
16 import org.eclipse.ui.IViewPart;
17 import org.eclipse.ui.console.IConsole;
18 import org.eclipse.ui.console.IConsoleView;
19
20 public class FormatStackTraceActionDelegate implements IViewActionDelegate {
21     
22     private JavaStackTraceConsole fConsole;
23     private IConsoleView fView;
24     
25     public FormatStackTraceActionDelegate() {}
26     
27     public FormatStackTraceActionDelegate(JavaStackTraceConsole console) {
28         fConsole = console;
29     }
30
31     /* (non-Javadoc)
32      * @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart)
33      */

34     public void init(IViewPart view) {
35         if (view instanceof IConsoleView) {
36             fView = (IConsoleView) view;
37         }
38     }
39
40     /* (non-Javadoc)
41      * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
42      */

43     public void run(IAction action) {
44         if (fConsole != null) {
45             fConsole.format();
46         }
47         else if (fView != null) {
48             IConsole console = fView.getConsole();
49             if (console instanceof JavaStackTraceConsole) {
50                 fConsole = (JavaStackTraceConsole) console;
51                 fConsole.format();
52             }
53         }
54     }
55     
56     /* (non-Javadoc)
57      * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
58      */

59     public void selectionChanged(IAction action, ISelection selection) {}
60 }
61
Popular Tags