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
9 * Christopher Lenz - initial implementation
11 * $Id: JSModelAdapterFactory.java,v 1.1 2004-09-02 18:23:57 jsurfer Exp $
14 package net.sourceforge.phpeclipse.js.ui.model;
16 import net.sourceforge.phpeclipse.js.core.model.JSElement;
17 import net.sourceforge.phpeclipse.js.core.model.JSElementList;
19 import org.eclipse.core.runtime.IAdapterFactory;
20 import org.eclipse.core.runtime.IAdapterManager;
21 import org.eclipse.ui.model.IWorkbenchAdapter;
24 * Factory that creates adapters for JavaScript model objects.
26 public class JSModelAdapterFactory implements IAdapterFactory {
28 // Static Methods ----------------------------------------------------------
31 * Creates and registers this adapter factory with the given manager.
33 * @param manager the adapter manager to register with
35 public static void register(IAdapterManager manager) {
36 JSModelAdapterFactory factory = new JSModelAdapterFactory();
37 manager.registerAdapters(factory, JSElement.class);
38 manager.registerAdapters(factory, JSElementList.class);
41 // IAdapterFactory Implementation ------------------------------------------
44 * @see IAdapterFactory#getAdapter(Object, Class)
46 public Object getAdapter(Object adaptableObject, Class adapterType) {
47 if (adapterType == IWorkbenchAdapter.class) {
48 if ((adaptableObject instanceof JSElement)
49 || (adaptableObject instanceof JSElementList)) {
50 return new JSWorkbenchAdapter();
57 * @see IAdapterFactory#getAdapterList()
59 public Class[] getAdapterList() {
60 return new Class[] { IWorkbenchAdapter.class };