1 11 package org.eclipse.jdt.internal.debug.ui.threadgroups; 12 13 import org.eclipse.core.runtime.CoreException; 14 import org.eclipse.debug.internal.ui.viewers.provisional.AsynchronousContentAdapter; 15 import org.eclipse.debug.internal.ui.viewers.provisional.IPresentationContext; 16 import org.eclipse.debug.ui.IDebugUIConstants; 17 import org.eclipse.jdt.debug.core.IJavaThread; 18 import org.eclipse.jdt.debug.core.IJavaThreadGroup; 19 20 25 public class JavaThreadGroupContentAdapter extends AsynchronousContentAdapter { 26 27 protected Object [] getChildren(Object parent, IPresentationContext context) throws CoreException { 28 if (parent instanceof IJavaThreadGroup) { 29 IJavaThreadGroup group = (IJavaThreadGroup) parent; 30 IJavaThreadGroup[] threadGroups = group.getThreadGroups(); 31 IJavaThread[] threads = group.getThreads(); 32 Object [] kids = new Object [threadGroups.length + threads.length]; 33 int index = 0; 34 for (int i = 0; i < threads.length; i++) { 35 kids[index]= threads[i]; 36 index++; 37 } 38 for (int i = 0; i < threadGroups.length; i++) { 39 kids[index] = threadGroups[i]; 40 index++; 41 } 42 return kids; 43 } 44 return EMPTY; 45 } 46 47 protected boolean hasChildren(Object element, IPresentationContext context) throws CoreException { 48 if (element instanceof IJavaThreadGroup) { 49 IJavaThreadGroup group = (IJavaThreadGroup) element; 50 return group.hasThreads() || group.hasThreadGroups(); 51 } 52 return false; 53 } 54 55 protected boolean supportsPartId(String id) { 56 return IDebugUIConstants.ID_DEBUG_VIEW.equals(id); 57 } 58 59 } 60 | Popular Tags |