KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > internal > ui > actions > context > ActionAdapterFactory


1 /*******************************************************************************
2  * Copyright (c) 2006 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.ui.actions.context;
12
13 import org.eclipse.core.runtime.IAdapterFactory;
14 import org.eclipse.debug.core.ILaunch;
15 import org.eclipse.debug.core.model.IDebugElement;
16 import org.eclipse.debug.core.model.IDisconnect;
17 import org.eclipse.debug.core.model.IDropToFrame;
18 import org.eclipse.debug.core.model.IProcess;
19 import org.eclipse.debug.core.model.IStep;
20 import org.eclipse.debug.core.model.ISuspendResume;
21 import org.eclipse.debug.core.model.ITerminate;
22 import org.eclipse.debug.internal.ui.actions.provisional.IAsynchronousDisconnectAdapter;
23 import org.eclipse.debug.internal.ui.actions.provisional.IAsynchronousDropToFrameAdapter;
24 import org.eclipse.debug.internal.ui.actions.provisional.IAsynchronousStepAdapter;
25 import org.eclipse.debug.internal.ui.actions.provisional.IAsynchronousStepFiltersAdapter;
26 import org.eclipse.debug.internal.ui.actions.provisional.IAsynchronousSuspendResumeAdapter;
27 import org.eclipse.debug.internal.ui.actions.provisional.IAsynchronousTerminateAdapter;
28
29 /**
30  * Adapter factory for debug capabilities.
31  *
32  * @since 3.2
33  *
34  */

35 public class ActionAdapterFactory implements IAdapterFactory {
36     
37     private static IAsynchronousDisconnectAdapter fgDisconnectAdapter = new DisconnectAdapter();
38     private static IAsynchronousDropToFrameAdapter fgDropToFrameAdapter = new DropToFrameAdapter();
39     private static IAsynchronousStepAdapter fgStepAdapter = new StepAdapter();
40     private static IAsynchronousStepFiltersAdapter fgStepFiltersAdapter = new StepFiltersAdapter();
41     private static IAsynchronousSuspendResumeAdapter fgSuspendResumeAdapter = new SuspendResumeAdapter();
42     private static IAsynchronousTerminateAdapter fgTerminateAdapter = new TerminateAdapter();
43
44     /* (non-Javadoc)
45      * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
46      */

47     public Object JavaDoc getAdapter(Object JavaDoc adaptableObject, Class JavaDoc adapterType) {
48         if (IAsynchronousDisconnectAdapter.class.equals(adapterType)) {
49             if (adaptableObject instanceof IDisconnect) {
50                 return fgDisconnectAdapter;
51             }
52         }
53         if (IAsynchronousDropToFrameAdapter.class.equals(adapterType)) {
54             if (adaptableObject instanceof IDropToFrame) {
55                 return fgDropToFrameAdapter;
56             }
57         }
58         if (IAsynchronousStepAdapter.class.equals(adapterType)) {
59             if (adaptableObject instanceof IStep) {
60                 return fgStepAdapter;
61             }
62         }
63         if (IAsynchronousStepFiltersAdapter.class.equals(adapterType)) {
64             if (adaptableObject instanceof IDebugElement ||
65                 adaptableObject instanceof ILaunch ||
66                 adaptableObject instanceof IProcess) {
67                 return fgStepFiltersAdapter;
68             }
69         }
70         if (IAsynchronousSuspendResumeAdapter.class.equals(adapterType)) {
71             if (adaptableObject instanceof ISuspendResume) {
72                 return fgSuspendResumeAdapter;
73             }
74         }
75         if (IAsynchronousTerminateAdapter.class.equals(adapterType)) {
76             if (adaptableObject instanceof ITerminate) {
77                 return fgTerminateAdapter;
78             }
79         }
80         return null;
81     }
82
83     /* (non-Javadoc)
84      * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList()
85      */

86     public Class JavaDoc[] getAdapterList() {
87         return new Class JavaDoc[]{IAsynchronousDisconnectAdapter.class,
88                 IAsynchronousDropToFrameAdapter.class,
89                 IAsynchronousStepAdapter.class,
90                 IAsynchronousStepFiltersAdapter.class,
91                 IAsynchronousSuspendResumeAdapter.class,
92                 IAsynchronousTerminateAdapter.class};
93     }
94
95 }
96
Popular Tags