KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 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.core.DebugException;
15 import org.eclipse.jdt.debug.core.IJavaVariable;
16 import org.eclipse.jdt.internal.debug.ui.IJDIPreferencesConstants;
17 import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin;
18 import org.eclipse.jface.viewers.Viewer;
19
20 /**
21  * Shows static final variables (constants)
22  */

23 public class ShowConstantsAction extends ViewFilterAction {
24
25     public ShowConstantsAction() {
26         super();
27     }
28
29     /**
30      * @see ViewFilterAction#getPreferenceKey()
31      */

32     protected String JavaDoc getPreferenceKey() {
33         return IJDIPreferencesConstants.PREF_SHOW_CONSTANTS;
34     }
35     
36     /**
37      * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
38      */

39     public boolean select(Viewer viewer, Object JavaDoc parentElement, Object JavaDoc element) {
40         if (element instanceof IJavaVariable) {
41             IJavaVariable variable = (IJavaVariable)element;
42             try {
43                 if (!getValue()) {
44                     // when not on, filter static finals
45
return !(variable.isStatic() && variable.isFinal());
46                 }
47             } catch (DebugException e) {
48                 JDIDebugUIPlugin.log(e);
49             }
50         }
51         return true;
52     }
53 }
54
Popular Tags