intial source from ttp://www.sf.net/projects/wdte
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.css.ui / src / net / sourceforge / phpeclipse / css / ui / internal / properties / CssPropertiesAdapterFactory.java
1 /*
2  * Copyright (c) 2004 Christopher Lenz and others.
3  * All rights reserved. This program and the accompanying materials 
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  * 
8  * Contributors:
9  *     Christopher Lenz - initial API and implementation
10  * 
11  * $Id: CssPropertiesAdapterFactory.java,v 1.1 2004-09-02 18:11:49 jsurfer Exp $
12  */
13
14 package net.sourceforge.phpeclipse.css.ui.internal.properties;
15
16 import net.sourceforge.phpeclipse.css.core.model.IRule;
17
18 import org.eclipse.core.runtime.IAdapterFactory;
19 import org.eclipse.core.runtime.IAdapterManager;
20 import org.eclipse.ui.views.properties.IPropertySource;
21
22 /**
23  * Factory for adapting model elements to property sources.
24  */
25 public class CssPropertiesAdapterFactory implements IAdapterFactory {
26
27         // Static Methods ----------------------------------------------------------
28
29         /**
30          * Creates and registers this adapter factory with the given manager.
31          * 
32          * @param manager the adapter manager to register with
33          */
34         public static void register(IAdapterManager manager) {
35                 CssPropertiesAdapterFactory factory = new CssPropertiesAdapterFactory();
36                 manager.registerAdapters(factory, IRule.class);
37         }
38
39         // IAdapterFactory Implementation ------------------------------------------
40
41         /*
42          * @see IAdapterFactory#getAdapter(Object, Class)
43          */
44         public Object getAdapter(Object adaptableObject, Class adapterType) {
45                 if (adapterType == IPropertySource.class) {
46                         if (adaptableObject instanceof IRule) {
47                                 return new CssRulePropertySource((IRule) adaptableObject);
48                         }
49                 }
50                 return null;
51         }
52
53         /*
54          * @see IAdapterFactory#getAdapterList()
55          */
56         public Class[] getAdapterList() {
57                 return new Class[] { IPropertySource.class };
58         }
59
60 }