KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > editor > feature > FeatureAdapterFactory


1 /*******************************************************************************
2  * Copyright (c) 2000, 2004 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.pde.internal.ui.editor.feature;
12
13 import org.eclipse.core.runtime.*;
14 import org.eclipse.pde.internal.core.ifeature.*;
15 import org.eclipse.pde.internal.ui.*;
16 import org.eclipse.swt.graphics.*;
17 import org.eclipse.ui.views.properties.*;
18
19 public class FeatureAdapterFactory implements IAdapterFactory {
20     private Image errorImage;
21
22     public FeatureAdapterFactory() {
23         errorImage = PDEPluginImages.DESC_ERROR_ST_OBJ.createImage();
24     }
25     public void dispose() {
26         errorImage.dispose();
27     }
28     public Object JavaDoc getAdapter(Object JavaDoc adaptableObject, Class JavaDoc adapterType) {
29         if (adapterType.equals(IPropertySource.class))
30             return getProperties(adaptableObject);
31         return null;
32     }
33     public Class JavaDoc[] getAdapterList() {
34         return new Class JavaDoc[] { IPropertySource.class };
35     }
36     private IPropertySource getProperties(Object JavaDoc object) {
37         if (object instanceof IFeatureURLElement)
38             return getURLProperties((IFeatureURLElement) object);
39         if (object instanceof IFeaturePlugin)
40             return getReferenceProperties((IFeaturePlugin) object);
41         if (object instanceof IFeatureData)
42             return getDataProperties((IFeatureData) object);
43         if (object instanceof IFeatureChild)
44             return getChildProperties((IFeatureChild) object);
45         return null;
46     }
47     private IPropertySource getReferenceProperties(IFeaturePlugin ref) {
48         return new ReferencePropertySource(ref, errorImage);
49     }
50     private IPropertySource getURLProperties(IFeatureURLElement element) {
51         return new URLElementPropertySource(element);
52     }
53
54     private IPropertySource getDataProperties(IFeatureData data) {
55         return new FeatureEntryPropertySource(data);
56     }
57
58     private IPropertySource getChildProperties(IFeatureChild child) {
59         return new FeatureChildPropertySource(child);
60     }
61 }
62
Popular Tags