1 11 package org.eclipse.debug.internal.core.commands; 12 13 import org.eclipse.core.runtime.IAdapterFactory; 14 import org.eclipse.debug.core.ILaunch; 15 import org.eclipse.debug.core.commands.IDisconnectHandler; 16 import org.eclipse.debug.core.commands.IDropToFrameHandler; 17 import org.eclipse.debug.core.commands.IResumeHandler; 18 import org.eclipse.debug.core.commands.IStepFiltersHandler; 19 import org.eclipse.debug.core.commands.IStepIntoHandler; 20 import org.eclipse.debug.core.commands.IStepOverHandler; 21 import org.eclipse.debug.core.commands.IStepReturnHandler; 22 import org.eclipse.debug.core.commands.ISuspendHandler; 23 import org.eclipse.debug.core.commands.ITerminateHandler; 24 import org.eclipse.debug.core.model.IDebugElement; 25 import org.eclipse.debug.core.model.IDisconnect; 26 import org.eclipse.debug.core.model.IDropToFrame; 27 import org.eclipse.debug.core.model.IProcess; 28 import org.eclipse.debug.core.model.IStep; 29 import org.eclipse.debug.core.model.ISuspendResume; 30 import org.eclipse.debug.core.model.ITerminate; 31 32 38 public class CommandAdapterFactory implements IAdapterFactory { 39 40 41 private static ITerminateHandler fgTerminateCommand = new TerminateCommand(); 42 private static IStepOverHandler fgStepOverCommand = new StepOverCommand(); 43 private static IStepIntoHandler fgStepIntoCommand = new StepIntoCommand(); 44 private static IStepReturnHandler fgStepReturnCommand = new StepReturnCommand(); 45 private static IDropToFrameHandler fgDropToFrameCommand = new DropToFrameCommand(); 46 private static IDisconnectHandler fgDisconnectCommand = new DisconnectCommand(); 47 private static ISuspendHandler fgSuspendCommand = new SuspendCommand(); 48 private static IResumeHandler fgResumeCommand = new ResumeCommand(); 49 private static IStepFiltersHandler fgStepFiltersCommand = new StepFiltersCommand(); 50 51 54 public Object getAdapter(Object adaptableObject, Class adapterType) { 55 if (IStepFiltersHandler.class.equals(adapterType)) { 56 if (adaptableObject instanceof IDebugElement || 57 adaptableObject instanceof ILaunch || 58 adaptableObject instanceof IProcess) { 59 return fgStepFiltersCommand; 60 } 61 } 62 63 if (ITerminateHandler.class.equals(adapterType)) { 64 if (adaptableObject instanceof ITerminate) { 65 return fgTerminateCommand; 66 } 67 } 68 if (IStepOverHandler.class.equals(adapterType)) { 69 if (adaptableObject instanceof IStep) { 70 return fgStepOverCommand; 71 } 72 } 73 if (IStepIntoHandler.class.equals(adapterType)) { 74 if (adaptableObject instanceof IStep) { 75 return fgStepIntoCommand; 76 } 77 } 78 if (IStepReturnHandler.class.equals(adapterType)) { 79 if (adaptableObject instanceof IStep) { 80 return fgStepReturnCommand; 81 } 82 } 83 if (ISuspendHandler.class.equals(adapterType)) { 84 if (adaptableObject instanceof ISuspendResume) { 85 return fgSuspendCommand; 86 } 87 } 88 if (IResumeHandler.class.equals(adapterType)) { 89 if (adaptableObject instanceof ISuspendResume) { 90 return fgResumeCommand; 91 } 92 } 93 if (IDisconnectHandler.class.equals(adapterType)) { 94 if (adaptableObject instanceof IDisconnect) { 95 return fgDisconnectCommand; 96 } 97 } 98 if (IDropToFrameHandler.class.equals(adapterType)) { 99 if (adaptableObject instanceof IDropToFrame) { 100 return fgDropToFrameCommand; 101 } 102 } 103 return null; 104 } 105 106 109 public Class [] getAdapterList() { 110 return new Class []{ 111 ITerminateHandler.class, 112 IStepOverHandler.class, 113 IStepIntoHandler.class, 114 IStepReturnHandler.class, 115 ISuspendHandler.class, 116 IResumeHandler.class, 117 IDropToFrameHandler.class, 118 IDisconnectHandler.class, 119 IStepFiltersHandler.class}; 120 } 121 122 } 123 | Popular Tags |