KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > debug > ui > threadgroups > JavaDebugTargetContentAdapter


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.threadgroups;
12
13 import org.eclipse.core.runtime.CoreException;
14 import org.eclipse.core.runtime.Preferences;
15 import org.eclipse.debug.internal.ui.elements.adapters.DebugTargetContentAdapter;
16 import org.eclipse.debug.internal.ui.viewers.provisional.IPresentationContext;
17 import org.eclipse.debug.ui.IDebugUIConstants;
18 import org.eclipse.jdt.debug.core.IJavaDebugTarget;
19 import org.eclipse.jdt.debug.ui.IJavaDebugUIConstants;
20 import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin;
21
22 /**
23  * Content adapter for debug target to show thread groups.
24  *
25  * @since 3.2
26  */

27 public class JavaDebugTargetContentAdapter extends DebugTargetContentAdapter {
28
29     protected Object JavaDoc[] getChildren(Object JavaDoc parent, IPresentationContext context) throws CoreException {
30         String JavaDoc id = context.getPart().getSite().getId();
31         if (IDebugUIConstants.ID_DEBUG_VIEW.equals(id)) {
32             if (isShowThreadGroups()) {
33                 if (parent instanceof IJavaDebugTarget) {
34                     IJavaDebugTarget target = (IJavaDebugTarget) parent;
35                     return target.getRootThreadGroups();
36                 }
37             }
38         }
39         return super.getChildren(parent, context);
40     }
41     
42     /**
43      * Returns whether thread groups are being displayed (in the debug view)
44      *
45      * @return whether thread groups are being displayed
46      */

47     protected static boolean isShowThreadGroups() {
48         Preferences pluginPreferences = JDIDebugUIPlugin.getDefault().getPluginPreferences();
49         return pluginPreferences.getBoolean(IJavaDebugUIConstants.PREF_SHOW_THREAD_GROUPS);
50     }
51
52 }
53
Popular Tags