01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.ui.internal.ide.model;
11:
12: import org.eclipse.core.resources.IFile;
13: import org.eclipse.core.resources.IResource;
14: import org.eclipse.core.runtime.IAdapterFactory;
15: import org.eclipse.ui.views.properties.FilePropertySource;
16: import org.eclipse.ui.views.properties.IPropertySource;
17: import org.eclipse.ui.views.properties.ResourcePropertySource;
18:
19: /**
20: * Dispenses an <code>IPropertySource</code> adapter for the core resource objects.
21: */
22: /* package */class StandardPropertiesAdapterFactory implements
23: IAdapterFactory {
24: /* (non-Javadoc)
25: * Method declared on IAdapterFactory.
26: */
27: public Object getAdapter(Object o, Class adapterType) {
28: if (adapterType.isInstance(o)) {
29: return o;
30: }
31: if (adapterType == IPropertySource.class) {
32: if (o instanceof IResource) {
33: IResource resource = (IResource) o;
34: if (resource.getType() == IResource.FILE) {
35: return new FilePropertySource((IFile) o);
36: } else {
37: return new ResourcePropertySource((IResource) o);
38: }
39: }
40: }
41: return null;
42: }
43:
44: /* (non-Javadoc)
45: * Method declared on IAdapterFactory.
46: */
47: public Class[] getAdapterList() {
48: return new Class[] { IPropertySource.class };
49: }
50: }
|