KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > view > PluginsViewAdapterFactory


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 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.ui.view;
12
13 import org.eclipse.core.runtime.IAdapterFactory;
14 import org.eclipse.pde.internal.core.FileAdapter;
15 import org.eclipse.pde.internal.core.ModelEntry;
16 import org.eclipse.ui.views.properties.IPropertySource;
17
18 public class PluginsViewAdapterFactory implements IAdapterFactory {
19     private FileAdapterPropertySource adapterPropertySource;
20     private ModelEntryPropertySource entryPropertySource;
21
22 public Object JavaDoc getAdapter(Object JavaDoc adaptableObject, Class JavaDoc adapterType) {
23     if (adapterType.equals(IPropertySource.class)) return getProperties(adaptableObject);
24     return null;
25 }
26
27 public java.lang.Class JavaDoc[] getAdapterList() {
28     return new Class JavaDoc[] { IPropertySource.class };
29 }
30
31 private IPropertySource getProperties(Object JavaDoc object) {
32     if (object instanceof FileAdapter) {
33         if (adapterPropertySource==null)
34             adapterPropertySource = new FileAdapterPropertySource();
35         adapterPropertySource.setAdapter((FileAdapter)object);
36         return adapterPropertySource;
37     }
38     if (object instanceof ModelEntry) {
39         if (entryPropertySource==null)
40             entryPropertySource = new ModelEntryPropertySource();
41         entryPropertySource.setEntry((ModelEntry)object);
42         return entryPropertySource;
43     }
44     return null;
45 }
46 }
47
Popular Tags