KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > debug > ui > actions > ToggleBooleanPreferenceAction


1 /*******************************************************************************
2  * Copyright (c) 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.actions;
12
13 import org.eclipse.jface.action.IAction;
14 import org.eclipse.jface.preference.IPreferenceStore;
15 import org.eclipse.jface.viewers.StructuredViewer;
16 import org.eclipse.jface.viewers.Viewer;
17 import org.eclipse.swt.custom.BusyIndicator;
18
19 /**
20  * Toggle to display the thread and monitor information in the debug view.
21  */

22 public abstract class ToggleBooleanPreferenceAction extends ViewFilterAction {
23
24     /* (non-Javadoc)
25      * This method is not actually called - this action is not a filter. Instead
26      * it sets an preference.
27      *
28      * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
29      */

30     public boolean select(Viewer viewer, Object JavaDoc parentElement, Object JavaDoc element) {
31         return false;
32     }
33     
34     /* (non-Javadoc)
35      * @see org.eclipse.jdt.internal.debug.ui.actions.ViewFilterAction#run(org.eclipse.jface.action.IAction)
36      */

37     public void run(IAction action) {
38         final StructuredViewer viewer = getStructuredViewer();
39         BusyIndicator.showWhile(viewer.getControl().getDisplay(), new Runnable JavaDoc() {
40             public void run() {
41                 // note, this uses the pref key, not the composite key - the prefs are global, not view specific.
42
IPreferenceStore store = getPreferenceStore();
43                 store.setValue(getPreferenceKey(), getValue());
44                 viewer.refresh();
45             }
46         });
47     }
48
49     protected String JavaDoc getCompositeKey() {
50         return getPreferenceKey();
51     }
52
53     
54 }
55
Popular Tags