KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2005, 2007 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.IJavaDebugHelpContextIds;
15 import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin;
16 import org.eclipse.jdt.internal.debug.ui.JavaDebugImages;
17 import org.eclipse.jface.action.Action;
18 import org.eclipse.jface.preference.IPreferenceStore;
19 import org.eclipse.swt.SWT;
20 import org.eclipse.ui.PlatformUI;
21
22 public class AutoFormatSettingAction extends Action {
23     private JavaStackTraceConsolePage fPage;
24     private IPreferenceStore fPreferenceStore;
25
26     public AutoFormatSettingAction(JavaStackTraceConsolePage page) {
27         super(ConsoleMessages.AutoFormatSettingAction_0, SWT.TOGGLE);
28         fPage = page;
29         
30         setToolTipText(ConsoleMessages.AutoFormatSettingAction_1);
31         setImageDescriptor(JavaDebugImages.getImageDescriptor(JavaDebugImages.IMG_ELCL_AUTO_FORMAT));
32         setHoverImageDescriptor(JavaDebugImages.getImageDescriptor(JavaDebugImages.IMG_ELCL_AUTO_FORMAT));
33         PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaDebugHelpContextIds.CONSOLE_AUTOFORMAT_STACKTRACES_ACTION);
34         
35         fPreferenceStore = JDIDebugUIPlugin.getDefault().getPreferenceStore();
36         boolean checked = fPreferenceStore.getBoolean(IJDIPreferencesConstants.PREF_AUTO_FORMAT_JSTCONSOLE);
37         setChecked(checked);
38     }
39
40     public void run() {
41         boolean checked = isChecked();
42         JavaStackTraceConsoleViewer viewer = (JavaStackTraceConsoleViewer) fPage.getViewer();
43         viewer.setAutoFormat(checked);
44         fPreferenceStore.setValue(IJDIPreferencesConstants.PREF_AUTO_FORMAT_JSTCONSOLE, checked);
45     }
46 }
47
Popular Tags