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.jdt.internal.ui.callhierarchy;
11:
12: import org.eclipse.core.runtime.Assert;
13:
14: import org.eclipse.jface.resource.ImageDescriptor;
15:
16: import org.eclipse.ui.model.IWorkbenchAdapter;
17:
18: import org.eclipse.jdt.internal.corext.callhierarchy.MethodWrapper;
19:
20: public class MethodWrapperWorkbenchAdapter implements IWorkbenchAdapter {
21:
22: private final MethodWrapper fMethodWrapper;
23:
24: public MethodWrapperWorkbenchAdapter(MethodWrapper methodWrapper) {
25: Assert.isNotNull(methodWrapper);
26: fMethodWrapper = methodWrapper;
27: }
28:
29: public MethodWrapper getMethodWrapper() {
30: return fMethodWrapper;
31: }
32:
33: public Object[] getChildren(Object o) { //should not be called
34: return new Object[0];
35: }
36:
37: /* (non-Javadoc)
38: * @see org.eclipse.ui.model.IWorkbenchAdapter#getImageDescriptor(java.lang.Object)
39: */
40: public ImageDescriptor getImageDescriptor(Object object) {
41: return null;
42: }
43:
44: /* (non-Javadoc)
45: * @see org.eclipse.ui.model.IWorkbenchAdapter#getLabel(java.lang.Object)
46: */
47: public String getLabel(Object o) {
48: return fMethodWrapper.getMember().getElementName();
49: }
50:
51: /* (non-Javadoc)
52: * @see org.eclipse.ui.model.IWorkbenchAdapter#getParent(java.lang.Object)
53: */
54: public Object getParent(Object o) {
55: return fMethodWrapper.getParent();
56: }
57:
58: /*
59: * (non-Javadoc)
60: * @see java.lang.Object#equals(java.lang.Object)
61: */
62: public boolean equals(Object obj) {
63: //Note: A MethodWrapperWorkbenchAdapter is equal to its MethodWrapper and vice versa (bug 101677).
64: return fMethodWrapper.equals(obj);
65: }
66:
67: /*
68: * (non-Javadoc)
69: * @see java.lang.Object#hashCode()
70: */
71: public int hashCode() {
72: //Note: A MethodWrapperWorkbenchAdapter is equal to its MethodWrapper and vice versa (bug 101677).
73: return fMethodWrapper.hashCode();
74: }
75:
76: }
|