KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > debug > ui > variables > JavaDebugElementAdapterFactory


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.jdt.internal.debug.ui.variables;
12
13 import org.eclipse.core.runtime.IAdapterFactory;
14 import org.eclipse.debug.internal.ui.model.elements.ExpressionLabelProvider;
15 import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementContentProvider;
16 import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementLabelProvider;
17 import org.eclipse.debug.ui.actions.IWatchExpressionFactoryAdapter;
18 import org.eclipse.jdt.debug.core.IJavaVariable;
19 import org.eclipse.jdt.internal.debug.ui.display.JavaInspectExpression;
20 import org.eclipse.jdt.internal.debug.ui.heapwalking.JavaWatchExpressionFilter;
21
22 /**
23  * Provides provider adapters for IJavaVariables.
24  *
25  * @see IJavaVariable
26  * @see JavaVariableLabelProvider
27  * @see JavaVariableContentProvider
28  * @see ExpressionLabelProvider
29  * @see JavaExpressionContentProvider
30  * @see JavaWatchExpressionFilter
31  * @since 3.3
32  */

33 public class JavaDebugElementAdapterFactory implements IAdapterFactory {
34     
35     private static final IElementLabelProvider fgLPVariable = new JavaVariableLabelProvider();
36     private static final IElementContentProvider fgCPVariable = new JavaVariableContentProvider();
37     private static final IElementLabelProvider fgLPExpression = new ExpressionLabelProvider();
38     private static final IElementContentProvider fgCPExpression = new JavaExpressionContentProvider();
39     private static final IWatchExpressionFactoryAdapter fgWEVariable = new JavaWatchExpressionFilter();
40
41     /* (non-Javadoc)
42      * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
43      */

44     public Object JavaDoc getAdapter(Object JavaDoc adaptableObject, Class JavaDoc adapterType) {
45         if (IElementLabelProvider.class.equals(adapterType)) {
46             if (adaptableObject instanceof IJavaVariable) {
47                 return fgLPVariable;
48             }
49             if (adaptableObject instanceof JavaInspectExpression) {
50                 return fgLPExpression;
51             }
52         }
53         if (IElementContentProvider.class.equals(adapterType)) {
54             if (adaptableObject instanceof IJavaVariable) {
55                 return fgCPVariable;
56             }
57             if (adaptableObject instanceof JavaInspectExpression) {
58                 return fgCPExpression;
59             }
60         }
61         if (IWatchExpressionFactoryAdapter.class.equals(adapterType)) {
62             if (adaptableObject instanceof IJavaVariable) {
63                 return fgWEVariable;
64             }
65             if (adaptableObject instanceof JavaInspectExpression) {
66                 return fgCPExpression;
67             }
68         }
69         return null;
70     }
71
72     /* (non-Javadoc)
73      * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList()
74      */

75     public Class JavaDoc[] getAdapterList() {
76         return new Class JavaDoc[]{IElementLabelProvider.class,IElementContentProvider.class,IWatchExpressionFactoryAdapter.class};
77     }
78
79 }
80
Popular Tags