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.model;
11:
12: import org.eclipse.jface.resource.ImageDescriptor;
13: import org.eclipse.swt.graphics.FontData;
14: import org.eclipse.swt.graphics.RGB;
15:
16: /**
17: * Abstract base class with basic implementations of the IWorkbenchAdapter
18: * interface. Intended to be subclassed.
19: *
20: * @since 3.0
21: */
22: public abstract class WorkbenchAdapter implements IWorkbenchAdapter,
23: IWorkbenchAdapter2 {
24: /**
25: * The empty list of children.
26: */
27: protected static final Object[] NO_CHILDREN = new Object[0];
28:
29: /**
30: * The default implementation of this <code>IWorkbenchAdapter</code> method
31: * returns the empty list. Subclasses may override.
32: */
33: public Object[] getChildren(Object object) {
34: return NO_CHILDREN;
35: }
36:
37: /**
38: * The default implementation of this <code>IWorkbenchAdapter</code> method
39: * returns <code>null</code>. Subclasses may override.
40: */
41: public ImageDescriptor getImageDescriptor(Object object) {
42: return null;
43: }
44:
45: /**
46: * The default implementation of this <code>IWorkbenchAdapter</code> method
47: * returns the empty string if the object is <code>null</code>, and
48: * the object's <code>toString</code> otherwise. Subclasses may override.
49: */
50: public String getLabel(Object object) {
51: return object == null ? "" : object.toString(); //$NON-NLS-1$
52: }
53:
54: /**
55: * The default implementation of this <code>IWorkbenchAdapter</code> method
56: * returns <code>null</code>. Subclasses may override.
57: */
58: public Object getParent(Object object) {
59: return null;
60: }
61:
62: /**
63: * The default implementation of this <code>IWorkbenchAdapter2</code> method
64: * returns <code>null</code>. Subclasses may override.
65: */
66: public RGB getBackground(Object element) {
67: return null;
68: }
69:
70: /**
71: * The default implementation of this <code>IWorkbenchAdapter2</code> method
72: * returns <code>null</code>. Subclasses may override.
73: */
74: public RGB getForeground(Object element) {
75: return null;
76: }
77:
78: /**
79: * The default implementation of this <code>IWorkbenchAdapter2</code> method
80: * returns <code>null</code>. Subclasses may override.
81: */
82: public FontData getFont(Object element) {
83: return null;
84: }
85: }
|