KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > runtime > registry > RegistryPropertySourceFactory


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 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.pde.internal.runtime.registry;
12
13 import org.eclipse.core.runtime.*;
14 import org.eclipse.ui.views.properties.IPropertySource;
15
16 public class RegistryPropertySourceFactory implements IAdapterFactory {
17
18 public Object JavaDoc getAdapter(Object JavaDoc adaptableObject, Class JavaDoc adapterType) {
19     if (adapterType.equals(IPropertySource.class)) return getPropertySource(adaptableObject);
20     return null;
21 }
22 public java.lang.Class JavaDoc[] getAdapterList() {
23     return new Class JavaDoc[] { IPropertySource.class };
24 }
25 protected IPropertySource getPropertySource(Object JavaDoc sourceObject) {
26     if (sourceObject instanceof PluginObjectAdapter)
27         sourceObject = ((PluginObjectAdapter) sourceObject).getObject();
28     if (sourceObject instanceof IPluginDescriptor) {
29         return new PluginPropertySource((IPluginDescriptor) sourceObject);
30     }
31     if (sourceObject instanceof IExtension) {
32         return new ExtensionPropertySource((IExtension) sourceObject);
33     }
34     if (sourceObject instanceof IExtensionPoint) {
35         return new ExtensionPointPropertySource((IExtensionPoint) sourceObject);
36     }
37     if (sourceObject instanceof ILibrary) {
38         return new LibraryPropertySource((ILibrary) sourceObject);
39     }
40     if (sourceObject instanceof IConfigurationElement) {
41         return new ConfigurationElementPropertySource((IConfigurationElement) sourceObject);
42     }
43     if (sourceObject instanceof IPluginPrerequisite) {
44         return new PrerequisitePropertySource((IPluginPrerequisite) sourceObject);
45     }
46     return null;
47 }
48 }
49
Popular Tags