1 11 package org.eclipse.debug.internal.ui.views.launch; 12 13 import org.eclipse.core.runtime.IAdaptable; 14 import org.eclipse.debug.core.DebugException; 15 import org.eclipse.debug.core.ILaunch; 16 import org.eclipse.debug.core.ILaunchManager; 17 import org.eclipse.debug.core.model.IDebugTarget; 18 import org.eclipse.debug.core.model.IProcess; 19 import org.eclipse.debug.core.model.IStackFrame; 20 import org.eclipse.debug.core.model.IThread; 21 import org.eclipse.debug.internal.ui.views.RemoteTreeContentManager; 22 import org.eclipse.ui.IWorkbenchPartSite; 23 import org.eclipse.ui.model.BaseWorkbenchContentProvider; 24 import org.eclipse.ui.progress.IDeferredWorkbenchAdapter; 25 26 30 public class DebugViewContentProvider extends BaseWorkbenchContentProvider { 31 32 private RemoteTreeContentManager fManager; 33 34 public DebugViewContentProvider(LaunchViewer tree, IWorkbenchPartSite site) { 35 fManager = new RemoteTreeContentManager(this, tree, site); 36 } 37 38 41 public Object [] getChildren(Object parentElement) { 42 if (parentElement instanceof IStackFrame) { 43 return null; 44 } 45 Object [] children = fManager.getChildren(parentElement); 46 if (children == null) { 47 children = super.getChildren(parentElement); 48 } 49 return children; 50 } 51 52 55 public boolean hasChildren(Object element) { 56 if (element instanceof IStackFrame) { 57 return false; 58 } 59 if (element instanceof IDebugTarget) { 60 try { 61 return ((IDebugTarget)element).hasThreads(); 62 } catch (DebugException e) { 63 return false; 64 } 65 } 66 if (element instanceof IThread) { 67 try { 68 return ((IThread)element).hasStackFrames(); 69 } catch (DebugException e) { 70 return false; 71 } 72 } 73 if (element instanceof IProcess) { 74 return false; 75 } 76 if (element instanceof ILaunch) { 77 return ((ILaunch)element).hasChildren(); 78 } 79 if (element instanceof ILaunchManager) { 80 return ((ILaunchManager) element).getLaunches().length > 0; 81 } 82 if (element instanceof IAdaptable) { 83 IAdaptable adaptable = (IAdaptable) element; 84 IDeferredWorkbenchAdapter adapter = (IDeferredWorkbenchAdapter) adaptable.getAdapter(IDeferredWorkbenchAdapter.class); 85 if (adapter != null) { 86 return adapter.isContainer(); 87 } 88 } 89 return super.hasChildren(element); 90 } 91 92 95 public void dispose() { 96 fManager.cancel(); 97 super.dispose(); 98 } 99 100 } 101 | Popular Tags |