|
Lines 11-16
Link Here
|
| 11 |
package org.eclipse.ui.model; |
11 |
package org.eclipse.ui.model; |
| 12 |
|
12 |
|
| 13 |
import org.eclipse.core.runtime.IAdaptable; |
13 |
import org.eclipse.core.runtime.IAdaptable; |
|
|
14 |
import org.eclipse.core.runtime.Platform; |
| 14 |
import org.eclipse.jface.resource.ImageDescriptor; |
15 |
import org.eclipse.jface.resource.ImageDescriptor; |
| 15 |
import org.eclipse.jface.viewers.DecoratingLabelProvider; |
16 |
import org.eclipse.jface.viewers.DecoratingLabelProvider; |
| 16 |
import org.eclipse.jface.viewers.IColorProvider; |
17 |
import org.eclipse.jface.viewers.IColorProvider; |
|
Lines 115-131
Link Here
|
| 115 |
|
116 |
|
| 116 |
/** |
117 |
/** |
| 117 |
* Returns the implementation of IWorkbenchAdapter for the given |
118 |
* Returns the implementation of IWorkbenchAdapter for the given |
|
|
119 |
* object. Returns null if the adapter is not defined for this |
| 120 |
* type. |
| 121 |
* |
| 122 |
* @param element the element |
| 123 |
* @return the corresponding workbench adapter object |
| 124 |
*/ |
| 125 |
protected Object getAdapter(Object element, Class clazz) { |
| 126 |
Object adapter = null; |
| 127 |
if (element instanceof IAdaptable) |
| 128 |
adapter = (IWorkbenchAdapter) ((IAdaptable) element) |
| 129 |
.getAdapter(clazz); |
| 130 |
if(adapter == null) { |
| 131 |
adapter = Platform.getAdapterManager().loadAdapter(element, clazz.getName()); |
| 132 |
} |
| 133 |
return adapter; |
| 134 |
} |
| 135 |
|
| 136 |
/** |
| 137 |
* Returns the implementation of IWorkbenchAdapter for the given |
| 118 |
* object. |
138 |
* object. |
| 119 |
* @param o the object to look up. |
139 |
* @param o the object to look up. |
| 120 |
* @return IWorkbenchAdapter or<code>null</code> if the adapter is not defined or the |
140 |
* @return IWorkbenchAdapter or<code>null</code> if the adapter is not defined or the |
| 121 |
* object is not adaptable. |
141 |
* object is not adaptable. |
| 122 |
*/ |
142 |
*/ |
| 123 |
protected final IWorkbenchAdapter getAdapter(Object o) { |
143 |
protected final IWorkbenchAdapter getAdapter(Object o) { |
| 124 |
if (!(o instanceof IAdaptable)) { |
144 |
return (IWorkbenchAdapter)getAdapter(o, IWorkbenchAdapter.class); |
| 125 |
return null; |
|
|
| 126 |
} |
| 127 |
return (IWorkbenchAdapter) ((IAdaptable) o) |
| 128 |
.getAdapter(IWorkbenchAdapter.class); |
| 129 |
} |
145 |
} |
| 130 |
|
146 |
|
| 131 |
/** |
147 |
/** |
|
Lines 136-146
Link Here
|
| 136 |
* object is not adaptable. |
152 |
* object is not adaptable. |
| 137 |
*/ |
153 |
*/ |
| 138 |
protected final IWorkbenchAdapter2 getAdapter2(Object o) { |
154 |
protected final IWorkbenchAdapter2 getAdapter2(Object o) { |
| 139 |
if (!(o instanceof IAdaptable)) { |
155 |
return (IWorkbenchAdapter2)getAdapter(o, IWorkbenchAdapter2.class); |
| 140 |
return null; |
|
|
| 141 |
} |
| 142 |
return (IWorkbenchAdapter2) ((IAdaptable) o) |
| 143 |
.getAdapter(IWorkbenchAdapter2.class); |
| 144 |
} |
156 |
} |
| 145 |
|
157 |
|
| 146 |
/* (non-Javadoc) |
158 |
/* (non-Javadoc) |