KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2005, 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.jdt.internal.debug.ui.IJDIPreferencesConstants;
14 import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin;
15 import org.eclipse.jface.preference.IPreferenceStore;
16 import org.eclipse.jface.text.ITextOperationTarget;
17 import org.eclipse.swt.widgets.Composite;
18 import org.eclipse.ui.console.TextConsoleViewer;
19
20 /**
21  * provides the viewer for Java stack trace consoles
22  */

23 public class JavaStackTraceConsoleViewer extends TextConsoleViewer {
24
25     private JavaStackTraceConsole fConsole;
26     private boolean fAutoFormat = false;
27
28     /**
29      * Constructor
30      * @param parent the parent to add this viewer to
31      * @param console the console associated with this viewer
32      */

33     public JavaStackTraceConsoleViewer(Composite parent, JavaStackTraceConsole console) {
34         super(parent, console);
35         fConsole = console;
36         
37         IPreferenceStore fPreferenceStore = JDIDebugUIPlugin.getDefault().getPreferenceStore();
38         fAutoFormat = fPreferenceStore.getBoolean(IJDIPreferencesConstants.PREF_AUTO_FORMAT_JSTCONSOLE);
39     }
40
41     /**
42      * @see org.eclipse.jface.text.source.SourceViewer#doOperation(int)
43      */

44     public void doOperation(int operation) {
45         super.doOperation(operation);
46
47         if (fAutoFormat && operation == ITextOperationTarget.PASTE)
48             fConsole.format();
49     }
50
51     /**
52      * Sets the state of the autoformat action
53      * @param checked the desired state of the autoformat action
54      */

55     public void setAutoFormat(boolean checked) {
56         fAutoFormat = checked;
57     }
58 }
59
Popular Tags