KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > internal > ui > views > console > ScrollLockAction


1 /*******************************************************************************
2  * Copyright (c) 2000, 2004 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.debug.internal.ui.views.console;
12
13
14 import org.eclipse.debug.internal.ui.DebugPluginImages;
15 import org.eclipse.debug.internal.ui.DebugUIPlugin;
16 import org.eclipse.debug.internal.ui.IDebugHelpContextIds;
17 import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
18 import org.eclipse.debug.internal.ui.actions.ActionMessages;
19 import org.eclipse.debug.ui.IDebugUIConstants;
20 import org.eclipse.jface.action.Action;
21 import org.eclipse.jface.preference.IPreferenceStore;
22 import org.eclipse.jface.util.IPropertyChangeListener;
23 import org.eclipse.jface.util.PropertyChangeEvent;
24 import org.eclipse.ui.help.WorkbenchHelp;
25
26 /**
27  * Toggles console auto-scroll
28  */

29 public class ScrollLockAction extends Action implements IPropertyChangeListener {
30
31     private IPreferenceStore fStore = DebugUIPlugin.getDefault().getPreferenceStore();
32     
33     public ScrollLockAction() {
34         super(ActionMessages.getString("ScrollLockAction.Scroll_Lock_1")); //$NON-NLS-1$
35
setToolTipText(ActionMessages.getString("ScrollLockAction.Scroll_Lock_1")); //$NON-NLS-1$
36
setHoverImageDescriptor(DebugPluginImages.getImageDescriptor(IDebugUIConstants.IMG_LCL_LOCK));
37         setDisabledImageDescriptor(DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_DLCL_LOCK));
38         setImageDescriptor(DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_LOCK));
39         WorkbenchHelp.setHelp(
40             this,
41             IDebugHelpContextIds.CONSOLE_SCROLL_LOCK_ACTION);
42         setChecked(DebugUIPlugin.getDefault().getPreferenceStore().getBoolean(IInternalDebugUIConstants.PREF_CONSOLE_SCROLL_LOCK));
43         fStore.addPropertyChangeListener(this);
44     }
45
46     /**
47      * @see org.eclipse.jface.action.IAction#run()
48      */

49     public void run() {
50         fStore.setValue(IInternalDebugUIConstants.PREF_CONSOLE_SCROLL_LOCK, isChecked());
51     }
52     
53     public void dispose() {
54         fStore.removePropertyChangeListener(this);
55     }
56
57     /* (non-Javadoc)
58      * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
59      */

60     public void propertyChange(PropertyChangeEvent event) {
61         if (event.getProperty().equals(IInternalDebugUIConstants.PREF_CONSOLE_SCROLL_LOCK)) {
62             setChecked(fStore.getBoolean(IInternalDebugUIConstants.PREF_CONSOLE_SCROLL_LOCK));
63         }
64         
65     }
66 }
67
68
Popular Tags