KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > internal > ui > views > launch > DebugElementAdapterFactory


1 /*******************************************************************************
2  * Copyright (c) 2000, 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.ui.views.launch;
12
13 import org.eclipse.core.runtime.IAdapterFactory;
14 import org.eclipse.debug.core.IExpressionManager;
15 import org.eclipse.debug.core.ILaunch;
16 import org.eclipse.debug.core.ILaunchManager;
17 import org.eclipse.debug.core.model.IDebugElement;
18 import org.eclipse.debug.core.model.IDebugTarget;
19 import org.eclipse.debug.core.model.IExpression;
20 import org.eclipse.debug.core.model.IMemoryBlock;
21 import org.eclipse.debug.core.model.IMemoryBlockRetrieval;
22 import org.eclipse.debug.core.model.IProcess;
23 import org.eclipse.debug.core.model.IRegisterGroup;
24 import org.eclipse.debug.core.model.IStackFrame;
25 import org.eclipse.debug.core.model.IThread;
26 import org.eclipse.debug.core.model.IVariable;
27 import org.eclipse.debug.internal.ui.elements.adapters.AsynchronousDebugLabelAdapter;
28 import org.eclipse.debug.internal.ui.elements.adapters.MemoryBlockContentAdapter;
29 import org.eclipse.debug.internal.ui.elements.adapters.MemoryBlockLabelAdapter;
30 import org.eclipse.debug.internal.ui.elements.adapters.MemoryRetrievalContentAdapter;
31 import org.eclipse.debug.internal.ui.elements.adapters.MemorySegmentLabelAdapter;
32 import org.eclipse.debug.internal.ui.elements.adapters.StackFrameSourceDisplayAdapter;
33 import org.eclipse.debug.internal.ui.elements.adapters.VariableColumnFactoryAdapter;
34 import org.eclipse.debug.internal.ui.model.elements.DebugElementLabelProvider;
35 import org.eclipse.debug.internal.ui.model.elements.DebugTargetContentProvider;
36 import org.eclipse.debug.internal.ui.model.elements.ExpressionContentProvider;
37 import org.eclipse.debug.internal.ui.model.elements.ExpressionLabelProvider;
38 import org.eclipse.debug.internal.ui.model.elements.ExpressionManagerContentProvider;
39 import org.eclipse.debug.internal.ui.model.elements.ExpressionsViewMementoProvider;
40 import org.eclipse.debug.internal.ui.model.elements.LaunchContentProvider;
41 import org.eclipse.debug.internal.ui.model.elements.LaunchManagerContentProvider;
42 import org.eclipse.debug.internal.ui.model.elements.MemoryBlockContentProvider;
43 import org.eclipse.debug.internal.ui.model.elements.MemoryBlockLabelProvider;
44 import org.eclipse.debug.internal.ui.model.elements.MemoryRetrievalContentProvider;
45 import org.eclipse.debug.internal.ui.model.elements.MemoryViewElementMementoProvider;
46 import org.eclipse.debug.internal.ui.model.elements.RegisterGroupContentProvider;
47 import org.eclipse.debug.internal.ui.model.elements.RegisterGroupLabelProvider;
48 import org.eclipse.debug.internal.ui.model.elements.StackFrameContentProvider;
49 import org.eclipse.debug.internal.ui.model.elements.ThreadContentProvider;
50 import org.eclipse.debug.internal.ui.model.elements.VariableContentProvider;
51 import org.eclipse.debug.internal.ui.model.elements.VariableEditor;
52 import org.eclipse.debug.internal.ui.model.elements.VariableLabelProvider;
53 import org.eclipse.debug.internal.ui.model.elements.VariablesViewElementMementoProvider;
54 import org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentationFactory;
55 import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementContentProvider;
56 import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementEditor;
57 import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementLabelProvider;
58 import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementMementoProvider;
59 import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelProxyFactory;
60 import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelSelectionPolicyFactory;
61 import org.eclipse.debug.internal.ui.viewers.provisional.IAsynchronousContentAdapter;
62 import org.eclipse.debug.internal.ui.viewers.provisional.IAsynchronousLabelAdapter;
63 import org.eclipse.debug.internal.ui.viewers.update.DefaultModelProxyFactory;
64 import org.eclipse.debug.internal.ui.viewers.update.DefaultModelSelectionPolicyFactory;
65 import org.eclipse.debug.internal.ui.views.memory.renderings.MemorySegment;
66 import org.eclipse.debug.ui.sourcelookup.ISourceDisplay;
67
68 /**
69  * DebugElementAdapterFactory
70  */

71 public class DebugElementAdapterFactory implements IAdapterFactory {
72     
73     private static IModelProxyFactory fgModelProxyFactoryAdapter = new DefaultModelProxyFactory();
74     private static ISourceDisplay fgStackFrameSourceDisplayAdapter = new StackFrameSourceDisplayAdapter();
75     private static IModelSelectionPolicyFactory fgModelSelectionPolicyFactoryAdapter = new DefaultModelSelectionPolicyFactory();
76     
77     private static IAsynchronousLabelAdapter fgDebugLabelAdapter = new AsynchronousDebugLabelAdapter();
78     private static IAsynchronousLabelAdapter fgMemoryBlockLabelAdapter = new MemoryBlockLabelAdapter();
79     private static IAsynchronousLabelAdapter fgTableRenderingLineLabelAdapter = new MemorySegmentLabelAdapter();
80     
81     private static IElementLabelProvider fgLPDebugElement = new DebugElementLabelProvider();
82     private static IElementLabelProvider fgLPVariable = new VariableLabelProvider();
83     private static IElementLabelProvider fgLPExpression = new ExpressionLabelProvider();
84     private static IElementLabelProvider fgLPRegisterGroup = new RegisterGroupLabelProvider();
85     private static IElementLabelProvider fgLPMemoryBlock = new MemoryBlockLabelProvider();
86     
87     private static IElementEditor fgEEVariable = new VariableEditor();
88     
89     private static IAsynchronousContentAdapter fgAsyncMemoryRetrieval = new MemoryRetrievalContentAdapter();
90     private static IAsynchronousContentAdapter fgAsyncMemoryBlock = new MemoryBlockContentAdapter();
91     
92     private static IElementContentProvider fgCPLaunchManger = new LaunchManagerContentProvider();
93     private static IElementContentProvider fgCPLaunch = new LaunchContentProvider();
94     private static IElementContentProvider fgCPTarget = new DebugTargetContentProvider();
95     private static IElementContentProvider fgCPThread = new ThreadContentProvider();
96     private static IElementContentProvider fgCPFrame = new StackFrameContentProvider();
97     private static IElementContentProvider fgCPVariable = new VariableContentProvider();
98     private static IElementContentProvider fgCPExpressionManager = new ExpressionManagerContentProvider();
99     private static IElementContentProvider fgCPExpression = new ExpressionContentProvider();
100     private static IElementContentProvider fgCPRegisterGroup = new RegisterGroupContentProvider();
101     private static IElementContentProvider fgCPMemoryRetrieval = new MemoryRetrievalContentProvider();
102     private static IElementContentProvider fgCPMemoryBlock = new MemoryBlockContentProvider();
103     
104     private static IElementMementoProvider fgMPFrame = new VariablesViewElementMementoProvider();
105     private static IElementMementoProvider fgMPExpressions = new ExpressionsViewMementoProvider();
106     private static IElementMementoProvider fgMPMemory = new MemoryViewElementMementoProvider();
107     
108     private static IColumnPresentationFactory fgVariableColumnFactory = new VariableColumnFactoryAdapter();
109     
110
111     /* (non-Javadoc)
112      * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
113      */

114     public Object JavaDoc getAdapter(Object JavaDoc adaptableObject, Class JavaDoc adapterType) {
115         if (adapterType.isInstance(adaptableObject)) {
116             return adaptableObject;
117         }
118         
119         if (adapterType.equals(IAsynchronousContentAdapter.class)) {
120             if (adaptableObject instanceof IMemoryBlockRetrieval) {
121                 return fgAsyncMemoryRetrieval;
122             }
123             if (adaptableObject instanceof IMemoryBlock) {
124                 return fgAsyncMemoryBlock;
125             }
126         }
127         
128         if (adapterType.equals(IElementContentProvider.class)) {
129             if (adaptableObject instanceof ILaunchManager) {
130                 return fgCPLaunchManger;
131             }
132             if (adaptableObject instanceof ILaunch) {
133                 return fgCPLaunch;
134             }
135             if (adaptableObject instanceof IDebugTarget) {
136                 return fgCPTarget;
137             }
138             if (adaptableObject instanceof IMemoryBlockRetrieval)
139             {
140                 return fgCPMemoryRetrieval;
141             }
142             if (adaptableObject instanceof IThread) {
143                 return fgCPThread;
144             }
145             if (adaptableObject instanceof IStackFrame) {
146                 return fgCPFrame;
147             }
148             if (adaptableObject instanceof IVariable) {
149                 return fgCPVariable;
150             }
151             if (adaptableObject instanceof IExpressionManager) {
152                 return fgCPExpressionManager;
153             }
154             if (adaptableObject instanceof IExpression) {
155                 return fgCPExpression;
156             }
157             if (adaptableObject instanceof IRegisterGroup) {
158                 return fgCPRegisterGroup;
159             }
160             if (adaptableObject instanceof IMemoryBlock) {
161                 return fgCPMemoryBlock;
162             }
163         }
164         
165         if (adapterType.equals(IAsynchronousLabelAdapter.class)) {
166             if (adaptableObject instanceof IMemoryBlock) {
167                 return fgMemoryBlockLabelAdapter;
168             }
169             
170             if (adaptableObject instanceof MemorySegment) {
171                 return fgTableRenderingLineLabelAdapter;
172             }
173             return fgDebugLabelAdapter;
174         }
175         
176         if (adapterType.equals(IElementLabelProvider.class)) {
177             if (adaptableObject instanceof IVariable) {
178                 return fgLPVariable;
179             }
180             if (adaptableObject instanceof IExpression) {
181                 return fgLPExpression;
182             }
183             if (adaptableObject instanceof IRegisterGroup) {
184                 return fgLPRegisterGroup;
185             }
186             if (adaptableObject instanceof IMemoryBlock) {
187                 return fgLPMemoryBlock;
188             }
189             return fgLPDebugElement;
190         }
191         
192         if (adapterType.equals(IModelProxyFactory.class)) {
193             if (adaptableObject instanceof ILaunch || adaptableObject instanceof IDebugTarget ||
194                     adaptableObject instanceof IProcess || adaptableObject instanceof ILaunchManager ||
195                     adaptableObject instanceof IStackFrame || adaptableObject instanceof IExpressionManager ||
196                     adaptableObject instanceof IExpression || adaptableObject instanceof IMemoryBlockRetrieval ||
197                     adaptableObject instanceof IMemoryBlock)
198             return fgModelProxyFactoryAdapter;
199         }
200         
201         if (adapterType.equals(ISourceDisplay.class)) {
202             if (adaptableObject instanceof IStackFrame) {
203                 return fgStackFrameSourceDisplayAdapter;
204             }
205         }
206         
207         if (adapterType.equals(IModelSelectionPolicyFactory.class)) {
208             if (adaptableObject instanceof IDebugElement) {
209                 return fgModelSelectionPolicyFactoryAdapter;
210             }
211         }
212         
213         if (adapterType.equals(IColumnPresentationFactory.class)) {
214             if (adaptableObject instanceof IStackFrame) {
215                 return fgVariableColumnFactory;
216             }
217         }
218         
219         if (adapterType.equals(IElementMementoProvider.class)) {
220             if (adaptableObject instanceof IStackFrame) {
221                 return fgMPFrame;
222             }
223             if (adaptableObject instanceof IExpressionManager) {
224                 return fgMPExpressions;
225             }
226             if (adaptableObject instanceof IMemoryBlockRetrieval) {
227                 return fgMPMemory;
228             }
229         }
230         
231         if (adapterType.equals(IElementEditor.class)) {
232             if (adaptableObject instanceof IVariable) {
233                 return fgEEVariable;
234             }
235         }
236         
237         return null;
238     }
239
240     /* (non-Javadoc)
241      * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList()
242      */

243     public Class JavaDoc[] getAdapterList() {
244         return new Class JavaDoc[] {
245                 IAsynchronousLabelAdapter.class,
246                 IAsynchronousContentAdapter.class,
247                 IModelProxyFactory.class,
248                 ISourceDisplay.class,
249                 IModelSelectionPolicyFactory.class,
250                 IColumnPresentationFactory.class,
251                 IElementContentProvider.class,
252                 IElementLabelProvider.class,
253                 IElementMementoProvider.class,
254                 IElementEditor.class};
255     }
256
257 }
258
Popular Tags