Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 120606 | Differences between
and this patch

Collapse All | Expand All

(-)ui/org/eclipse/jdt/internal/debug/ui/actions/ShowStaticVariablesAction.java (-22 / +1 lines)
Lines 11-26 Link Here
11
package org.eclipse.jdt.internal.debug.ui.actions;
11
package org.eclipse.jdt.internal.debug.ui.actions;
12
12
13
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;
14
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
15
20
/**
16
/**
21
 * Shows non-final static variables
17
 * Shows non-final static variables
22
 */
18
 */
23
public class ShowStaticVariablesAction extends ViewFilterAction {
19
public class ShowStaticVariablesAction extends ToggleViewBooleanPreferenceAction {
24
20
25
	public ShowStaticVariablesAction() {
21
	public ShowStaticVariablesAction() {
26
		super();
22
		super();
Lines 33-53 Link Here
33
		return IJDIPreferencesConstants.PREF_SHOW_STATIC_VARIALBES; 
29
		return IJDIPreferencesConstants.PREF_SHOW_STATIC_VARIALBES; 
34
	}
30
	}
35
	
31
	
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 parentElement, Object element) {
40
		if (element instanceof IJavaVariable) {
41
			IJavaVariable variable = (IJavaVariable)element;
42
			try {
43
				if (!getValue()) {
44
					// when not on, filter non-static finals
45
					return !(variable.isStatic() && !variable.isFinal());
46
				}				
47
			} catch (DebugException e) {
48
				JDIDebugUIPlugin.log(e);
49
			} 
50
		}
51
		return true;
52
	}	
53
}
32
}
(-)ui/org/eclipse/jdt/internal/debug/ui/actions/ShowNullArrayEntriesAction.java (-24 / +1 lines)
Lines 11-27 Link Here
11
package org.eclipse.jdt.internal.debug.ui.actions;
11
package org.eclipse.jdt.internal.debug.ui.actions;
12
12
13
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;
14
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
15
21
/**
16
/**
22
 * Shows non-final static variables
17
 * Shows non-final static variables
23
 */
18
 */
24
public class ShowNullArrayEntriesAction extends ViewFilterAction {
19
public class ShowNullArrayEntriesAction extends ToggleViewBooleanPreferenceAction {
25
20
26
	public ShowNullArrayEntriesAction() {
21
	public ShowNullArrayEntriesAction() {
27
		super();
22
		super();
Lines 34-55 Link Here
34
		return IJDIPreferencesConstants.PREF_SHOW_NULL_ARRAY_ENTRIES; 
29
		return IJDIPreferencesConstants.PREF_SHOW_NULL_ARRAY_ENTRIES; 
35
	}
30
	}
36
	
31
	
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 parentElement, Object 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
}
32
}
(-)ui/org/eclipse/jdt/internal/debug/ui/actions/ShowConstantsAction.java (-22 / +1 lines)
Lines 11-26 Link Here
11
package org.eclipse.jdt.internal.debug.ui.actions;
11
package org.eclipse.jdt.internal.debug.ui.actions;
12
12
13
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;
14
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
15
20
/**
16
/**
21
 * Shows static final variables (constants)
17
 * Shows static final variables (constants)
22
 */
18
 */
23
public class ShowConstantsAction extends ViewFilterAction {
19
public class ShowConstantsAction extends ToggleViewBooleanPreferenceAction {
24
20
25
	public ShowConstantsAction() {
21
	public ShowConstantsAction() {
26
		super();
22
		super();
Lines 33-53 Link Here
33
		return IJDIPreferencesConstants.PREF_SHOW_CONSTANTS; 
29
		return IJDIPreferencesConstants.PREF_SHOW_CONSTANTS; 
34
	}
30
	}
35
	
31
	
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 parentElement, Object 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
}
32
}
(-)ui/org/eclipse/jdt/internal/debug/ui/JDIDebugUIPlugin.java (+4 lines)
Lines 61-66 Link Here
61
import org.eclipse.jdt.internal.debug.ui.sourcelookup.JavaDebugShowInAdapterFactory;
61
import org.eclipse.jdt.internal.debug.ui.sourcelookup.JavaDebugShowInAdapterFactory;
62
import org.eclipse.jdt.internal.debug.ui.threadgroups.JavaDebugElementLabelAdapterFactory;
62
import org.eclipse.jdt.internal.debug.ui.threadgroups.JavaDebugElementLabelAdapterFactory;
63
import org.eclipse.jdt.internal.debug.ui.variables.ColumnPresentationAdapterFactory;
63
import org.eclipse.jdt.internal.debug.ui.variables.ColumnPresentationAdapterFactory;
64
import org.eclipse.jdt.internal.debug.ui.variables.JavaVariableContentAdapterFactory;
64
import org.eclipse.jdt.internal.launching.DefaultProjectClasspathEntry;
65
import org.eclipse.jdt.internal.launching.DefaultProjectClasspathEntry;
65
import org.eclipse.jdt.launching.sourcelookup.IJavaSourceLocation;
66
import org.eclipse.jdt.launching.sourcelookup.IJavaSourceLocation;
66
import org.eclipse.jdt.ui.JavaElementLabelProvider;
67
import org.eclipse.jdt.ui.JavaElementLabelProvider;
Lines 331-336 Link Here
331
        
332
        
332
        IAdapterFactory entryFactory = new ClasspathEntryAdapterFactory();
333
        IAdapterFactory entryFactory = new ClasspathEntryAdapterFactory();
333
        manager.registerAdapters(entryFactory, DefaultProjectClasspathEntry.class);
334
        manager.registerAdapters(entryFactory, DefaultProjectClasspathEntry.class);
335
        
336
        IAdapterFactory contentFactory = new JavaVariableContentAdapterFactory();
337
        manager.registerAdapters(contentFactory, IJavaVariable.class);
334
		
338
		
335
		fHCRListener= new JavaHotCodeReplaceListener();
339
		fHCRListener= new JavaHotCodeReplaceListener();
336
		JDIDebugModel.addHotCodeReplaceListener(fHCRListener);
340
		JDIDebugModel.addHotCodeReplaceListener(fHCRListener);
(-)ui/org/eclipse/jdt/internal/debug/ui/variables/ElementFilter.java (+29 lines)
Added Link Here
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.variables;
12
13
/**
14
 * A filter for elements in a viewer.
15
 * 
16
 * @since 3.2.1
17
 */
18
public abstract class ElementFilter {
19
	
20
	/**
21
	 * Returns whether the given element should be filtered.
22
	 * 
23
	 * @param parent parent element
24
	 * @param element element
25
	 * @return whether the given element should be filtered
26
	 */
27
	public abstract boolean isFiltered(Object parent, Object element);
28
29
}
(-)ui/org/eclipse/jdt/internal/debug/ui/variables/StaticVariablesFilter.java (+37 lines)
Added Link Here
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.variables;
12
13
import org.eclipse.debug.core.DebugException;
14
import org.eclipse.jdt.debug.core.IJavaVariable;
15
16
/**
17
 * Filter for 'show static variables' toggle.
18
 * 
19
 * @since 3.2.1
20
 */
21
public class StaticVariablesFilter extends ElementFilter {
22
23
	/* (non-Javadoc)
24
	 * @see org.eclipse.jdt.internal.debug.ui.variables.ElementFilter#isFiltered(java.lang.Object, java.lang.Object)
25
	 */
26
	public boolean isFiltered(Object parent, Object element) {
27
		if (element instanceof IJavaVariable) {
28
			IJavaVariable variable = (IJavaVariable)element;
29
			try {
30
				return variable.isStatic() && !variable.isFinal();			
31
			} catch (DebugException e) {
32
			} 
33
		}
34
		return false;
35
	}
36
37
}
(-)ui/org/eclipse/jdt/internal/debug/ui/variables/JavaDebugElementFilters.java (+188 lines)
Added Link Here
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.variables;
12
13
import java.util.ArrayList;
14
import java.util.HashMap;
15
import java.util.Iterator;
16
import java.util.List;
17
import java.util.ListIterator;
18
import java.util.Map;
19
import java.util.Map.Entry;
20
21
import org.eclipse.debug.internal.ui.viewers.provisional.IPresentationContext;
22
import org.eclipse.debug.ui.IDebugUIConstants;
23
import org.eclipse.jdt.debug.ui.IJavaDebugUIConstants;
24
import org.eclipse.jdt.internal.debug.ui.IJDIPreferencesConstants;
25
import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin;
26
import org.eclipse.jface.preference.IPreferenceStore;
27
import org.eclipse.jface.util.IPropertyChangeListener;
28
import org.eclipse.jface.util.PropertyChangeEvent;
29
import org.eclipse.ui.IWorkbenchPart;
30
31
/**
32
 * Filters debug elements based on presentation context. Used with content adapters.
33
 * 
34
 * @since 3.2.1
35
 */
36
public class JavaDebugElementFilters implements IPropertyChangeListener {
37
	
38
	/**
39
	 * Map of part identifiers to active <ElementFilters> for that part.
40
	 */
41
	private Map fFilters = new HashMap();
42
	
43
	/**
44
	 * Map of parts and arrays of associated preferences
45
	 */
46
	private Map fPartsAndPreferences = new HashMap();
47
	
48
	// filters
49
	private ElementFilter fStaticVariablesFilter = new StaticVariablesFilter();
50
	private ElementFilter fConstantsFilter = new ConstantsFilter();
51
	private ElementFilter fNullEntriesFilter = new NullArrayEntriesFilter();
52
	
53
	/**
54
	 * Singleton filter manager.
55
	 */
56
	private static JavaDebugElementFilters fgDefault = null;
57
58
	public synchronized static JavaDebugElementFilters getDefault() {
59
		if (fgDefault == null) {
60
			fgDefault = new JavaDebugElementFilters();
61
		}
62
		return fgDefault;
63
	}
64
	
65
	private JavaDebugElementFilters() {
66
		init();
67
	}
68
	
69
	private void init() {
70
		IPreferenceStore preferenceStore = JDIDebugUIPlugin.getDefault().getPreferenceStore();
71
		preferenceStore.addPropertyChangeListener(this);
72
		// initialize preferences associated with each part
73
		fPartsAndPreferences.put(IDebugUIConstants.ID_VARIABLE_VIEW,
74
				new String[]{
75
					IJDIPreferencesConstants.PREF_SHOW_CONSTANTS,
76
					IJDIPreferencesConstants.PREF_SHOW_STATIC_VARIALBES,
77
					IJDIPreferencesConstants.PREF_SHOW_NULL_ARRAY_ENTRIES});
78
		fPartsAndPreferences.put(IDebugUIConstants.ID_EXPRESSION_VIEW,
79
				new String[]{
80
					IJDIPreferencesConstants.PREF_SHOW_CONSTANTS,
81
					IJDIPreferencesConstants.PREF_SHOW_STATIC_VARIALBES,
82
					IJDIPreferencesConstants.PREF_SHOW_NULL_ARRAY_ENTRIES});
83
		// initialize filters based on preference settings
84
		Iterator entries = fPartsAndPreferences.entrySet().iterator();
85
		while (entries.hasNext()) {
86
			Entry entry = (Entry) entries.next();
87
			String partId = (String) entry.getKey();
88
			String[] prefs = (String[]) entry.getValue();
89
			for (int i = 0; i < prefs.length; i++) {
90
				String pref = partId + "." + prefs[i]; //$NON-NLS-1$
91
				PropertyChangeEvent event = new PropertyChangeEvent(preferenceStore, pref,
92
						null, new Boolean(preferenceStore.getBoolean(pref)));
93
				propertyChange(event);
94
			}
95
		}
96
	}
97
98
	/* (non-Javadoc)
99
	 * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
100
	 */
101
	public void propertyChange(PropertyChangeEvent event) {
102
		String property = event.getProperty();
103
		if (property.endsWith(IJDIPreferencesConstants.PREF_SHOW_CONSTANTS)) {
104
			updateFilter(getPartId(property, IJDIPreferencesConstants.PREF_SHOW_CONSTANTS),
105
					fConstantsFilter, !getBooleanValue(event.getNewValue()));
106
		} else if (property.endsWith(IJDIPreferencesConstants.PREF_SHOW_STATIC_VARIALBES)) {
107
			updateFilter(getPartId(property, IJDIPreferencesConstants.PREF_SHOW_STATIC_VARIALBES),
108
					fStaticVariablesFilter, !getBooleanValue(event.getNewValue()));
109
		} else if (property.endsWith(IJDIPreferencesConstants.PREF_SHOW_NULL_ARRAY_ENTRIES)) {
110
			updateFilter(getPartId(property, IJDIPreferencesConstants.PREF_SHOW_NULL_ARRAY_ENTRIES),
111
					fNullEntriesFilter, !getBooleanValue(event.getNewValue()));
112
		}
113
	}
114
	
115
	/**
116
	 * Updates the specified filter for the specified part.
117
	 * 
118
	 * @param partId part to update
119
	 * @param filter the filter to add or remove
120
	 * @param add whether to add the filter
121
	 */
122
	private void updateFilter(String partId, ElementFilter filter, boolean add) {
123
		List filters = (List) fFilters.get(partId);
124
		if (add) {
125
			if (filters == null) {
126
				filters = new ArrayList();
127
				fFilters.put(partId, filters);
128
			}
129
			filters.add(filter);
130
		} else {
131
			if (filters != null) {
132
				filters.remove(filter);
133
			}
134
		}
135
	}
136
	
137
	private boolean getBooleanValue(Object object) {
138
		if (object instanceof Boolean) {
139
			return ((Boolean)object).booleanValue();
140
		}
141
		return false;
142
	}
143
	
144
	/**
145
	 * Returns the part effected by the preference change.
146
	 * 
147
	 * @param key
148
	 * @param pref
149
	 * @return part id
150
	 */
151
	private String getPartId(String key, String pref) {
152
		return key.substring(0, key.length() - pref.length() - 1);
153
	}
154
	
155
	/**
156
	 * Filters the given element based on presentation context.
157
	 * 
158
	 * @param parent parent element
159
	 * @param elements elements to filter
160
	 * @param context context in which the elements are displayed
161
	 * @return filtered elements
162
	 */
163
	public Object[] filter(Object parent, Object[] elements, IPresentationContext context) {
164
		IWorkbenchPart part = context.getPart();
165
		if (part != null) {
166
			String id = part.getSite().getId();
167
			List list = (List) fFilters.get(id);
168
			if (list != null && !list.isEmpty()) {
169
				Iterator filters = list.iterator();
170
				List filteredElements = new ArrayList(elements.length);
171
				for (int i = 0; i < elements.length; i++) {
172
					filteredElements.add(elements[i]);
173
				}
174
				while (filters.hasNext()) {
175
					ElementFilter filter = (ElementFilter) filters.next();
176
					ListIterator iterator = filteredElements.listIterator();
177
					while (iterator.hasNext()) {
178
						if (filter.isFiltered(parent, iterator.next())) {
179
							iterator.remove();
180
						}
181
					}
182
				}
183
				return filteredElements.toArray();
184
			}
185
		}
186
		return elements;
187
	}
188
}
(-)ui/org/eclipse/jdt/internal/debug/ui/actions/ToggleViewBooleanPreferenceAction.java (+50 lines)
Added Link Here
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
 * Toggles a view specific boolean preference. 
21
 * 
22
 * @since 3.2.1
23
 */
24
public abstract class ToggleViewBooleanPreferenceAction extends ViewFilterAction {
25
26
	/* (non-Javadoc)
27
	 * This method is not actually called - this action is not a filter. Instead
28
	 * it sets an preference.
29
	 * 
30
	 * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
31
	 */
32
	public boolean select(Viewer viewer, Object parentElement, Object element) {
33
		return false;
34
	}
35
	
36
	/* (non-Javadoc)
37
	 * @see org.eclipse.jdt.internal.debug.ui.actions.ViewFilterAction#run(org.eclipse.jface.action.IAction)
38
	 */
39
	public void run(IAction action) {
40
		final StructuredViewer viewer = getStructuredViewer();
41
		BusyIndicator.showWhile(viewer.getControl().getDisplay(), new Runnable() {
42
			public void run() {
43
				IPreferenceStore store = getPreferenceStore();
44
				store.setValue(getCompositeKey(), getValue());			
45
				viewer.refresh();
46
			}
47
		});
48
	}
49
	
50
}
(-)ui/org/eclipse/jdt/internal/debug/ui/variables/NullArrayEntriesFilter.java (+38 lines)
Added Link Here
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.variables;
12
13
import org.eclipse.debug.core.DebugException;
14
import org.eclipse.jdt.debug.core.IJavaDebugTarget;
15
import org.eclipse.jdt.internal.debug.core.model.JDIArrayEntryVariable;
16
17
/**
18
 * Filter for 'show null array entries' toggle.
19
 * 
20
 * @since 3.2.1
21
 */
22
public class NullArrayEntriesFilter extends ElementFilter {
23
24
	/* (non-Javadoc)
25
	 * @see org.eclipse.jdt.internal.debug.ui.variables.ElementFilter#isFiltered(java.lang.Object, java.lang.Object)
26
	 */
27
	public boolean isFiltered(Object parent, Object element) {
28
		if (element instanceof JDIArrayEntryVariable) {
29
			JDIArrayEntryVariable variable = (JDIArrayEntryVariable)element;
30
			try {
31
				return variable.getValue().equals(((IJavaDebugTarget)variable.getDebugTarget()).nullValue());				
32
			} catch (DebugException e) {
33
			} 
34
		}
35
		return false;
36
	}
37
38
}
(-)ui/org/eclipse/jdt/internal/debug/ui/variables/JavaVariableContentAdapterFactory.java (+49 lines)
Added Link Here
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.variables;
12
13
import org.eclipse.core.runtime.IAdapterFactory;
14
import org.eclipse.debug.internal.ui.viewers.provisional.IAsynchronousContentAdapter;
15
import org.eclipse.debug.internal.ui.viewers.provisional.IAsynchronousLabelAdapter;
16
import org.eclipse.debug.internal.ui.viewers.provisional.IColumnEditorFactoryAdapter;
17
import org.eclipse.debug.internal.ui.viewers.provisional.IColumnPresentationFactoryAdapter;
18
import org.eclipse.jdt.debug.core.IJavaStackFrame;
19
import org.eclipse.jdt.debug.core.IJavaVariable;
20
21
/**
22
 * Adapter factory.
23
 * 
24
 * @since 3.2.1
25
 */
26
public class JavaVariableContentAdapterFactory implements IAdapterFactory {
27
	
28
	private static final IAsynchronousContentAdapter fgVariableContentAdapter = new JavaVariableContentAdapter();
29
30
	/* (non-Javadoc)
31
	 * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
32
	 */
33
	public Object getAdapter(Object adaptableObject, Class adapterType) {
34
		if (adaptableObject instanceof IJavaVariable) {
35
			if (IAsynchronousContentAdapter.class.equals(adapterType)) {
36
				return fgVariableContentAdapter;
37
			}
38
		}
39
		return null;
40
	}
41
42
	/* (non-Javadoc)
43
	 * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList()
44
	 */
45
	public Class[] getAdapterList() {
46
		return new Class[]{IAsynchronousContentAdapter.class};
47
	}
48
49
}
(-)ui/org/eclipse/jdt/internal/debug/ui/variables/JavaVariableContentAdapter.java (+34 lines)
Added Link Here
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.variables;
12
13
import org.eclipse.core.runtime.CoreException;
14
import org.eclipse.debug.core.model.IDebugElement;
15
import org.eclipse.debug.core.model.IValue;
16
import org.eclipse.debug.internal.ui.elements.adapters.VariableContentAdapter;
17
import org.eclipse.debug.internal.ui.viewers.provisional.IPresentationContext;
18
19
/**
20
 * Content adapter for Java variables to incorporate filters.
21
 * 
22
 * @since 3.2.1
23
 */
24
public class JavaVariableContentAdapter extends VariableContentAdapter {
25
26
	/* (non-Javadoc)
27
	 * @see org.eclipse.debug.internal.ui.elements.adapters.VariableContentAdapter#getValueChildren(org.eclipse.debug.core.model.IDebugElement, org.eclipse.debug.core.model.IValue, org.eclipse.debug.internal.ui.viewers.provisional.IPresentationContext)
28
	 */
29
	protected Object[] getValueChildren(IDebugElement parent, IValue value, IPresentationContext context) throws CoreException {
30
		Object[] children = super.getValueChildren(parent, value, context);
31
		return JavaDebugElementFilters.getDefault().filter(parent, children, context);
32
	}
33
34
}
(-)ui/org/eclipse/jdt/internal/debug/ui/variables/ConstantsFilter.java (+37 lines)
Added Link Here
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.variables;
12
13
import org.eclipse.debug.core.DebugException;
14
import org.eclipse.jdt.debug.core.IJavaVariable;
15
16
/**
17
 * Filter for 'show constants' toggle.
18
 * 
19
 * @since 3.2.1
20
 */
21
public class ConstantsFilter extends ElementFilter {
22
23
	/* (non-Javadoc)
24
	 * @see org.eclipse.jdt.internal.debug.ui.variables.ElementFilter#isFiltered(java.lang.Object, java.lang.Object)
25
	 */
26
	public boolean isFiltered(Object parent, Object element) {
27
		if (element instanceof IJavaVariable) {
28
			IJavaVariable variable = (IJavaVariable)element;
29
			try {
30
				return variable.isStatic() && variable.isFinal();			
31
			} catch (DebugException e) {
32
			} 
33
		}
34
		return false;
35
	}
36
37
}

Return to bug 120606