blob: 12f8d371734f23a7c7b930f4b6cce6f7081383d1 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.ui.views.properties;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IAdapterFactory;
/**
* Dispenses an <code>IPropertySource</code> adapter for the core resource objects.
*/
/* package */ class StandardPropertiesAdapterFactory implements IAdapterFactory {
/* (non-Javadoc)
* Method declared on IAdapterFactory.
*/
public Object getAdapter(Object o, Class adapterType) {
if (adapterType.isInstance(o)) {
return o;
}
if (adapterType == IPropertySource.class) {
if (o instanceof IResource) {
IResource resource = (IResource) o;
if (resource.getType() == IResource.FILE)
return new FilePropertySource((IFile) o);
else
return new ResourcePropertySource((IResource) o);
}
}
return null;
}
/* (non-Javadoc)
* Method declared on IAdapterFactory.
*/
public Class[] getAdapterList() {
return new Class[] {
IPropertySource.class
};
}
}