KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > internal > core > commands > CommandAdapterFactory


1 /*******************************************************************************
2  * Copyright (c) 2006, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

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 /**
33  * Adapter factory for debug commands.
34  *
35  * @since 3.3
36  *
37  */

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     /* (non-Javadoc)
52      * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
53      */

54     public Object JavaDoc getAdapter(Object JavaDoc adaptableObject, Class JavaDoc 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     /* (non-Javadoc)
107      * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList()
108      */

109     public Class JavaDoc[] getAdapterList() {
110         return new Class JavaDoc[]{
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