1 11 package org.eclipse.jdt.internal.debug.ui.monitors; 12 13 import org.eclipse.core.runtime.IAdapterFactory; 14 import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementContentProvider; 15 import org.eclipse.jdt.debug.core.IJavaStackFrame; 16 import org.eclipse.jdt.debug.core.IJavaThread; 17 import org.eclipse.jdt.internal.debug.ui.variables.JavaStackFrameContentProvider; 18 19 23 public class MonitorsAdapterFactory implements IAdapterFactory { 24 25 private static IElementContentProvider fgCPThread; 26 private static IElementContentProvider fgCPFrame = new JavaStackFrameContentProvider(); 27 private static IElementContentProvider fgCPOwnedMonitor; 28 private static IElementContentProvider fgCPWaitingThread; 29 private static IElementContentProvider fgCPContendedMonitor; 30 private static IElementContentProvider fgCPOwningThread; 31 32 35 public Object getAdapter(Object adaptableObject, Class adapterType) { 36 37 if (IElementContentProvider.class.equals(adapterType)) { 38 if (adaptableObject instanceof IJavaThread) { 39 return getThreadPresentation(); 40 } 41 if (adaptableObject instanceof IJavaStackFrame) { 42 return fgCPFrame; 43 } 44 if (adaptableObject instanceof JavaOwnedMonitor) { 45 return getOwnedMonitorContentProvider(); 46 } 47 if (adaptableObject instanceof JavaWaitingThread) { 48 return getWaitingThreadContentProvider(); 49 } 50 if (adaptableObject instanceof JavaContendedMonitor) { 51 return getContendedMonitorContentProvider(); 52 } 53 if (adaptableObject instanceof JavaOwningThread) { 54 return getOwningThreadContentProvider(); 55 } 56 } 57 return null; 58 } 59 60 63 public Class [] getAdapterList() { 64 return new Class [] {IElementContentProvider.class}; 65 } 66 67 private IElementContentProvider getThreadPresentation() { 68 if (fgCPThread == null) { 69 fgCPThread = new JavaThreadContentProvider(); 70 } 71 return fgCPThread; 72 } 73 74 private IElementContentProvider getOwnedMonitorContentProvider() { 75 if (fgCPOwnedMonitor == null) { 76 fgCPOwnedMonitor = new OwnedMonitorContentProvider(); 77 } 78 return fgCPOwnedMonitor; 79 } 80 81 private IElementContentProvider getWaitingThreadContentProvider() { 82 if (fgCPWaitingThread == null) { 83 fgCPWaitingThread = new WaitingThreadContentProvider(); 84 } 85 return fgCPWaitingThread; 86 } 87 88 private IElementContentProvider getContendedMonitorContentProvider() { 89 if (fgCPContendedMonitor == null) { 90 fgCPContendedMonitor = new ContendedMonitorContentProvider(); 91 } 92 return fgCPContendedMonitor; 93 } 94 95 private IElementContentProvider getOwningThreadContentProvider() { 96 if (fgCPOwningThread == null) { 97 fgCPOwningThread = new OwningThreadContentProvider(); 98 } 99 return fgCPOwningThread; 100 } 101 } 102 | Popular Tags |