KickJava   Java API By Example, From Geeks To Geeks.

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


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.IJavaDebugTarget;
16 import org.eclipse.jdt.internal.debug.core.model.JDIArrayEntryVariable;
17 import org.eclipse.jdt.internal.debug.ui.IJDIPreferencesConstants;
18 import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin;
19 import org.eclipse.jface.viewers.Viewer;
20
21 /**
22  * Shows non-final static variables
23  */

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

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

40     public boolean select(Viewer viewer, Object JavaDoc parentElement, Object JavaDoc element) {
41         if (getValue()) {
42             // when on, filter nothing
43
return true;
44         }
45         if (element instanceof JDIArrayEntryVariable) {
46             JDIArrayEntryVariable variable = (JDIArrayEntryVariable)element;
47             try {
48                 return !variable.getValue().equals(((IJavaDebugTarget)variable.getDebugTarget()).nullValue());
49             } catch (DebugException e) {
50                 JDIDebugUIPlugin.log(e);
51             }
52         }
53         return true;
54     }
55 }
56
Popular Tags