use of org.eclipse.core.runtime.IAdapterManager in project ecf by eclipse.
the class AbstractContainer method getAdapter.
public Object getAdapter(Class serviceType) {
if (serviceType == null)
return null;
if (serviceType.isInstance(this)) {
return this;
}
ECFPlugin plugin = ECFPlugin.getDefault();
if (plugin == null)
return null;
IAdapterManager adapterManager = plugin.getAdapterManager();
return (adapterManager == null) ? null : adapterManager.loadAdapter(this, serviceType.getName());
}
use of org.eclipse.core.runtime.IAdapterManager in project ecf by eclipse.
the class BaseContainerInstantiator method getAdaptersForClass.
protected Set getAdaptersForClass(Class clazz) {
Set result = new HashSet();
IAdapterManager adapterManager = ECFPlugin.getDefault().getAdapterManager();
if (adapterManager != null)
result.addAll(Arrays.asList(adapterManager.computeAdapterTypes(clazz)));
return result;
}
use of org.eclipse.core.runtime.IAdapterManager in project ecf by eclipse.
the class PresencePlugin method getAdapterManager.
public IAdapterManager getAdapterManager() {
// First, try to get the adapter manager via
if (adapterManagerTracker == null) {
adapterManagerTracker = new ServiceTracker(this.context, IAdapterManager.class.getName(), null);
adapterManagerTracker.open();
}
IAdapterManager adapterManager = (IAdapterManager) adapterManagerTracker.getService();
// PlatformHelper class
if (adapterManager == null)
adapterManager = PlatformHelper.getPlatformAdapterManager();
return adapterManager;
}
use of org.eclipse.core.runtime.IAdapterManager in project eclipse.platform.runtime by eclipse.
the class Expressions method getAsIIterable.
/**
* Converts the given variable into an <code>IIterable</code>. If a corresponding adapter can't be found an
* exception is thrown. If the corresponding adapter isn't loaded yet, <code>null</code> is returned.
*
* @param var the variable to turn into an <code>IIterable</code>
* @param expression the expression referring to the variable
*
* @return the <code>IIterable</code> or <code>null<code> if a corresponding adapter isn't loaded yet
*
* @throws CoreException if the var can't be adapted to an <code>IIterable</code>
*/
public static IIterable<?> getAsIIterable(Object var, Expression expression) throws CoreException {
if (var instanceof IIterable) {
return (IIterable<?>) var;
} else {
IAdapterManager manager = Platform.getAdapterManager();
IIterable<?> result = manager.getAdapter(var, IIterable.class);
if (result != null)
return result;
if (manager.queryAdapter(var, IIterable.class.getName()) == IAdapterManager.NOT_LOADED)
return null;
throw new CoreException(new ExpressionStatus(ExpressionStatus.VARIABLE_IS_NOT_A_COLLECTION, Messages.format(ExpressionMessages.Expression_variable_not_iterable, expression.toString())));
}
}
use of org.eclipse.core.runtime.IAdapterManager in project eclipse.platform.runtime by eclipse.
the class Expressions method getAsICountable.
/**
* Converts the given variable into an <code>ICountable</code>. If a corresponding adapter can't be found an
* exception is thrown. If the corresponding adapter isn't loaded yet, <code>null</code> is returned.
*
* @param var the variable to turn into an <code>ICountable</code>
* @param expression the expression referring to the variable
*
* @return the <code>ICountable</code> or <code>null<code> if a corresponding adapter isn't loaded yet
*
* @throws CoreException if the var can't be adapted to an <code>ICountable</code>
*/
public static ICountable getAsICountable(Object var, Expression expression) throws CoreException {
if (var instanceof ICountable) {
return (ICountable) var;
} else {
IAdapterManager manager = Platform.getAdapterManager();
ICountable result = manager.getAdapter(var, ICountable.class);
if (result != null)
return result;
if (manager.queryAdapter(var, ICountable.class.getName()) == IAdapterManager.NOT_LOADED)
return null;
throw new CoreException(new ExpressionStatus(ExpressionStatus.VARIABLE_IS_NOT_A_COLLECTION, Messages.format(ExpressionMessages.Expression_variable_not_countable, expression.toString())));
}
}
Aggregations