diff options
Diffstat (limited to 'plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/AbstractPropertyAdapterFactory.java')
-rw-r--r-- | plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/AbstractPropertyAdapterFactory.java | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/AbstractPropertyAdapterFactory.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/AbstractPropertyAdapterFactory.java new file mode 100644 index 0000000000..675ae0c99a --- /dev/null +++ b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/AbstractPropertyAdapterFactory.java @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.net4j.util.ui; + +import org.eclipse.core.runtime.IAdapterFactory; +import org.eclipse.ui.views.properties.IPropertySource; +import org.eclipse.ui.views.properties.IPropertySourceProvider; + +/** + * @author Eike Stepper + * @since 3.2 + */ +@SuppressWarnings("rawtypes") +public abstract class AbstractPropertyAdapterFactory implements IAdapterFactory +{ + private static final Class[] CLASSES = { IPropertySourceProvider.class }; + + public AbstractPropertyAdapterFactory() + { + } + + public Class[] getAdapterList() + { + return CLASSES; + } + + public Object getAdapter(Object adaptableObject, Class adapterType) + { + if (adapterType == CLASSES[0]) + { + final IPropertySource propertySource = createPropertySource(adaptableObject); + if (propertySource != null) + { + return new IPropertySourceProvider() + { + public IPropertySource getPropertySource(Object object) + { + return propertySource; + } + }; + } + } + + return null; + } + + protected abstract IPropertySource createPropertySource(Object object); +} |