KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2000, 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.actions;
12
13
14 import org.eclipse.debug.ui.IDebugModelPresentation;
15 import org.eclipse.debug.ui.IDebugView;
16 import org.eclipse.jdt.debug.core.JDIDebugModel;
17 import org.eclipse.jdt.internal.debug.ui.IJDIPreferencesConstants;
18 import org.eclipse.jdt.internal.debug.ui.JDIModelPresentation;
19 import org.eclipse.jface.action.IAction;
20 import org.eclipse.jface.preference.IPreferenceStore;
21 import org.eclipse.jface.viewers.StructuredViewer;
22 import org.eclipse.jface.viewers.Viewer;
23 import org.eclipse.swt.custom.BusyIndicator;
24
25 /**
26  * An action delegate that toggles the state of its viewer to
27  * show/hide qualified names.
28  */

29 public class ShowQualifiedAction extends ViewFilterAction {
30     
31     /**
32      * @see ViewFilterAction#getPreferenceKey()
33      */

34     protected String JavaDoc getPreferenceKey() {
35         return IJDIPreferencesConstants.PREF_SHOW_QUALIFIED_NAMES;
36     }
37
38     /**
39      * This method is not actually called - this action is not a filter. Instead
40      * it sets an attribute on the viewer's model presentation.
41      *
42      * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
43      */

44     public boolean select(Viewer viewer, Object JavaDoc parentElement, Object JavaDoc element) {
45         return true;
46     }
47     
48     /* (non-Javadoc)
49      * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
50      */

51     public void run(IAction action) {
52         final StructuredViewer viewer = getStructuredViewer();
53         IDebugView view = (IDebugView)getView().getAdapter(IDebugView.class);
54         if (view != null) {
55             IDebugModelPresentation pres = view.getPresentation(JDIDebugModel.getPluginIdentifier());
56             if (pres != null) {
57                 pres.setAttribute(JDIModelPresentation.DISPLAY_QUALIFIED_NAMES, (getValue() ? Boolean.TRUE : Boolean.FALSE));
58                 BusyIndicator.showWhile(viewer.getControl().getDisplay(), new Runnable JavaDoc() {
59                     public void run() {
60                         viewer.refresh();
61                         IPreferenceStore store = getPreferenceStore();
62                         String JavaDoc key = getView().getSite().getId() + "." + getPreferenceKey(); //$NON-NLS-1$
63
store.setValue(key, getValue());
64                     }
65                 });
66             }
67         }
68     }
69 }
70
Popular Tags