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.dialogs;
11:
12: import org.eclipse.core.runtime.IAdaptable;
13: import org.eclipse.ui.internal.util.Util;
14:
15: /**
16: * Class that wraps an object and forwards adapter calls if possible, otherwise
17: * returns the object. This is used to maintain API compatibility with methods that
18: * need an IAdaptable but when the operation supports a broader type.
19: *
20: * @since 3.2
21: */
22: public class AdaptableForwarder implements IAdaptable {
23:
24: private Object element;
25:
26: /**
27: * Create a new instance of the receiver.
28: * @param element
29: */
30: public AdaptableForwarder(Object element) {
31: this .element = element;
32: }
33:
34: /* (non-Javadoc)
35: * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
36: */
37: public Object getAdapter(Class adapter) {
38: return Util.getAdapter(element, adapter);
39: }
40: }
|