KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > internal > ui > DebugUIAdapterFactory


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 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;
12
13  
14 import org.eclipse.core.runtime.IAdapterFactory;
15 import org.eclipse.debug.core.ILaunchConfiguration;
16 import org.eclipse.debug.core.ILaunchConfigurationType;
17 import org.eclipse.debug.core.model.IBreakpoint;
18 import org.eclipse.debug.internal.ui.launchConfigurations.PersistableLaunchConfigurationFactory;
19 import org.eclipse.debug.internal.ui.launchConfigurations.PersistableLaunchConfigurationTypeFactory;
20 import org.eclipse.debug.internal.ui.views.breakpoints.BreakpointContainer;
21 import org.eclipse.debug.internal.ui.views.breakpoints.BreakpointContainerWorkbenchAdapter;
22 import org.eclipse.debug.internal.ui.views.breakpoints.BreakpointPersistableElementAdapter;
23 import org.eclipse.ui.IPersistableElement;
24 import org.eclipse.ui.model.IWorkbenchAdapter;
25 import org.eclipse.ui.model.IWorkbenchAdapter2;
26
27 public class DebugUIAdapterFactory implements IAdapterFactory {
28
29     /**
30      * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(Object, Class)
31      */

32     public Object JavaDoc getAdapter(Object JavaDoc obj, Class JavaDoc adapterType) {
33         if (adapterType.isInstance(obj)) {
34             return obj;
35         }
36         
37         if (adapterType == IPersistableElement.class) {
38             if (obj instanceof ILaunchConfiguration) {
39                 return new PersistableLaunchConfigurationFactory((ILaunchConfiguration)obj);
40             } else if (obj instanceof ILaunchConfigurationType) {
41                 return new PersistableLaunchConfigurationTypeFactory((ILaunchConfigurationType)obj);
42             } else if (obj instanceof IBreakpoint) {
43                 return new BreakpointPersistableElementAdapter((IBreakpoint)obj);
44             }
45         }
46         
47         if (adapterType == IWorkbenchAdapter.class) {
48             if (obj instanceof IWorkbenchAdapter) {
49                 return obj;
50             }
51             if (obj instanceof BreakpointContainer) {
52                 return new BreakpointContainerWorkbenchAdapter();
53             }
54         }
55         
56         if (adapterType == IWorkbenchAdapter2.class) {
57             if (obj instanceof IWorkbenchAdapter2) {
58                 return obj;
59             }
60             if (obj instanceof BreakpointContainer) {
61                 return new BreakpointContainerWorkbenchAdapter();
62             }
63         }
64         
65         return null;
66     }
67
68     /**
69      * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList()
70      */

71     public Class JavaDoc[] getAdapterList() {
72         return new Class JavaDoc[] {IPersistableElement.class, IWorkbenchAdapter.class, IWorkbenchAdapter2.class};
73     }
74
75 }
76
Popular Tags