Search in sources :

Example 6 with IAdapterManager

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());
}
Also used : ECFPlugin(org.eclipse.ecf.internal.core.ECFPlugin) IAdapterManager(org.eclipse.core.runtime.IAdapterManager)

Example 7 with IAdapterManager

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;
}
Also used : IAdapterManager(org.eclipse.core.runtime.IAdapterManager)

Example 8 with IAdapterManager

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;
}
Also used : ServiceTracker(org.osgi.util.tracker.ServiceTracker) IAdapterManager(org.eclipse.core.runtime.IAdapterManager)

Example 9 with IAdapterManager

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())));
    }
}
Also used : IIterable(org.eclipse.core.expressions.IIterable) CoreException(org.eclipse.core.runtime.CoreException) IAdapterManager(org.eclipse.core.runtime.IAdapterManager)

Example 10 with IAdapterManager

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())));
    }
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) ICountable(org.eclipse.core.expressions.ICountable) IAdapterManager(org.eclipse.core.runtime.IAdapterManager)

Aggregations

IAdapterManager (org.eclipse.core.runtime.IAdapterManager)16 ServiceTracker (org.osgi.util.tracker.ServiceTracker)4 IAdapterFactory (org.eclipse.core.runtime.IAdapterFactory)3 CoreException (org.eclipse.core.runtime.CoreException)2 IStatus (org.eclipse.core.runtime.IStatus)2 Status (org.eclipse.core.runtime.Status)2 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ICountable (org.eclipse.core.expressions.ICountable)1 IIterable (org.eclipse.core.expressions.IIterable)1 IAdaptable (org.eclipse.core.runtime.IAdaptable)1 ID (org.eclipse.ecf.core.identity.ID)1 AdapterManagerTracker (org.eclipse.ecf.core.util.AdapterManagerTracker)1 IFileTransferInfo (org.eclipse.ecf.filetransfer.IFileTransferInfo)1 IFileTransferListener (org.eclipse.ecf.filetransfer.IFileTransferListener)1