1 11 package org.eclipse.debug.internal.ui.views.launch; 12 13 14 import org.eclipse.debug.core.DebugException; 15 import org.eclipse.debug.core.DebugPlugin; 16 import org.eclipse.debug.core.ILaunch; 17 import org.eclipse.debug.core.ILaunchManager; 18 import org.eclipse.debug.core.model.IDebugElement; 19 import org.eclipse.debug.core.model.IDebugTarget; 20 import org.eclipse.debug.core.model.IProcess; 21 import org.eclipse.debug.core.model.IStackFrame; 22 import org.eclipse.debug.core.model.IThread; 23 import org.eclipse.debug.internal.ui.DebugUIPlugin; 24 import org.eclipse.jface.viewers.ITreeContentProvider; 25 import org.eclipse.jface.viewers.Viewer; 26 27 30 public class LaunchViewContentProvider implements ITreeContentProvider { 31 32 35 public Object [] getChildren(Object parent) { 36 try { 37 if (parent instanceof IDebugTarget) { 38 return ((IDebugTarget)parent).getThreads(); 39 } 40 if (parent instanceof IThread) { 41 return ((IThread)parent).getStackFrames(); 42 } 43 } catch (DebugException e) { 44 DebugUIPlugin.log(e); 45 } 46 if (parent instanceof ILaunch) { 47 return ((ILaunch)parent).getChildren(); 48 } 49 if (parent instanceof ILaunchManager) { 50 return ((ILaunchManager) parent).getLaunches(); 51 } 52 return new Object [0]; 53 } 54 55 58 public Object getParent(Object element) { 59 if (element instanceof IStackFrame) { 60 return ((IStackFrame)element).getThread(); 61 } 62 if (element instanceof IThread) { 63 return ((IThread)element).getDebugTarget(); 64 } 65 if (element instanceof IDebugTarget) { 66 return ((IDebugElement)element).getLaunch(); 67 } 68 if (element instanceof IProcess) { 69 return ((IProcess)element).getLaunch(); 70 } 71 if (element instanceof ILaunch) { 72 return DebugPlugin.getDefault().getLaunchManager(); 73 } 74 return null; 75 } 76 77 80 public boolean hasChildren(Object element) { 81 if (element instanceof IStackFrame) { 82 return false; 83 } 84 if (element instanceof IDebugTarget) { 85 try { 86 return ((IDebugTarget)element).hasThreads(); 87 } catch (DebugException e) { 88 return false; 89 } 90 } 91 if (element instanceof IThread) { 92 try { 93 return ((IThread)element).hasStackFrames(); 94 } catch (DebugException e) { 95 return false; 96 } 97 } 98 if (element instanceof IProcess) { 99 return false; 100 } 101 if (element instanceof ILaunch) { 102 return ((ILaunch)element).hasChildren(); 103 } 104 if (element instanceof ILaunchManager) { 105 return ((ILaunchManager) element).getLaunches().length > 0; 106 } 107 return false; 108 } 109 110 113 public Object [] getElements(Object inputElement) { 114 return getChildren(inputElement); 115 } 116 117 122 public void dispose() { 123 } 124 125 128 public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { 129 } 130 131 } 132 | Popular Tags |