KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2000, 2003 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-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.model.IDebugElement;
16 import org.eclipse.debug.core.model.IProcess;
17 import org.eclipse.debug.ui.DebugUITools;
18 import org.eclipse.debug.ui.IDebugModelPresentation;
19 import org.eclipse.jface.resource.ImageDescriptor;
20 import org.eclipse.ui.model.IWorkbenchAdapter;
21
22 /**
23  * This factory and the IWorkbenchAdapter that it provides exist so that
24  * a properties dialog that is realized on a launches view element will have a
25  * title.
26  */

27 /*package*/ class DebugUIPropertiesAdapterFactory implements IAdapterFactory {
28
29     class DebugUIPropertiesAdapter implements IWorkbenchAdapter {
30     
31         /**
32          * @see IWorkbenchAdapter#getChildren(Object)
33          */

34         public Object JavaDoc[] getChildren(Object JavaDoc o) {
35             return new Object JavaDoc[0];
36         }
37
38         /**
39          * @see IWorkbenchAdapter#getImageDescriptor(Object)
40          */

41         public ImageDescriptor getImageDescriptor(Object JavaDoc object) {
42             return DebugUITools.getDefaultImageDescriptor(object);
43         }
44
45         /**
46          * @see IWorkbenchAdapter#getLabel(Object)
47          */

48         public String JavaDoc getLabel(Object JavaDoc o) {
49             IDebugModelPresentation presentation= DebugUIPlugin.getModelPresentation();
50             return presentation.getText(o);
51         }
52
53         /**
54          * @see IWorkbenchAdapter#getParent(Object)
55          */

56         public Object JavaDoc getParent(Object JavaDoc o) {
57             return null;
58         }
59     }
60     
61     /**
62      * @see IAdapterFactory#getAdapter(Object, Class)
63      */

64     public Object JavaDoc getAdapter(Object JavaDoc obj, Class JavaDoc adapterType) {
65         if (adapterType.isInstance(obj)) {
66             return obj;
67         }
68         if (adapterType == IWorkbenchAdapter.class) {
69             if (obj instanceof IDebugElement) {
70                 return new DebugUIPropertiesAdapter();
71             }
72             if (obj instanceof IProcess) {
73                 return new DebugUIPropertiesAdapter();
74             }
75         }
76         return null;
77     }
78
79     /**
80      * @see IAdapterFactory#getAdapterList()
81      */

82     public Class JavaDoc[] getAdapterList() {
83         return new Class JavaDoc[] {
84             IWorkbenchAdapter.class
85         };
86     }
87 }
88
89
Popular Tags