Search in sources :

Example 1 with IAdapterManager

use of org.eclipse.core.runtime.IAdapterManager in project jbosstools-hibernate by jbosstools.

the class HibernateConsolePlugin method start.

/**
 * This method is called upon plug-in activation
 */
public void start(BundleContext context) throws Exception {
    super.start(context);
    logger = new EclipseLogger(context.getBundle());
    // HibernateConsoleSaveParticipant participant = new HibernateConsoleSaveParticipant();
    // participant.doStart(this);
    IAdapterManager adapterManager = Platform.getAdapterManager();
    ConfigurationAdapterFactory fact = new ConfigurationAdapterFactory();
    fact.registerAdapters(adapterManager);
    loadExistingConfigurations();
    listenForConfigurations();
}
Also used : ConfigurationAdapterFactory(org.hibernate.eclipse.console.workbench.ConfigurationAdapterFactory) IAdapterManager(org.eclipse.core.runtime.IAdapterManager) EclipseLogger(org.hibernate.eclipse.logging.xpl.EclipseLogger)

Example 2 with IAdapterManager

use of org.eclipse.core.runtime.IAdapterManager in project eclipse.platform.runtime by eclipse.

the class IAdapterManagerServiceTest method getAdapterManager.

/*
	 * Return the framework log service, if available.
	 */
public IAdapterManager getAdapterManager() {
    if (adapterManagerTracker == null) {
        BundleContext context = RuntimeTestsPlugin.getContext();
        adapterManagerTracker = new ServiceTracker<>(context, IAdapterManager.class, null);
        adapterManagerTracker.open();
    }
    return adapterManagerTracker.getService();
}
Also used : IAdapterManager(org.eclipse.core.runtime.IAdapterManager) BundleContext(org.osgi.framework.BundleContext)

Example 3 with IAdapterManager

use of org.eclipse.core.runtime.IAdapterManager in project eclipse.platform.runtime by eclipse.

the class IAdapterManagerServiceTest method testHasAdapter.

/**
 * Tests API method IAdapterManager.hasAdapter.
 */
public void testHasAdapter() {
    IAdapterManager manager = getAdapterManager();
    TestAdaptable adaptable = new TestAdaptable();
    // request non-existing adaptable
    assertTrue("1.0", !manager.hasAdapter("", NON_EXISTING));
    // request adapter that is in XML but has no registered factory
    assertTrue("1.1", manager.hasAdapter(adaptable, TEST_ADAPTER));
    // request adapter that is not in XML
    assertTrue("1.2", !manager.hasAdapter(adaptable, "java.lang.String"));
    // register an adapter factory that maps adaptables to strings
    IAdapterFactory fac = new IAdapterFactory() {

        @Override
        public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) {
            if (adapterType == String.class) {
                return adapterType.cast(adaptableObject.toString());
            }
            return null;
        }

        @Override
        public Class<?>[] getAdapterList() {
            return new Class[] { String.class };
        }
    };
    manager.registerAdapters(fac, TestAdaptable.class);
    try {
        // request adapter for factory that we've just added
        assertTrue("1.3", manager.hasAdapter(adaptable, "java.lang.String"));
    } finally {
        manager.unregisterAdapters(fac, TestAdaptable.class);
    }
    // request adapter that was unloaded
    assertTrue("1.4", !manager.hasAdapter(adaptable, "java.lang.String"));
}
Also used : IAdapterFactory(org.eclipse.core.runtime.IAdapterFactory) IAdapterManager(org.eclipse.core.runtime.IAdapterManager)

Example 4 with IAdapterManager

use of org.eclipse.core.runtime.IAdapterManager in project ecf by eclipse.

the class Activator 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 5 with IAdapterManager

use of org.eclipse.core.runtime.IAdapterManager in project ecf by eclipse.

the class Activator method getAdapterManager.

private static IAdapterManager getAdapterManager(BundleContext ctx) {
    AdapterManagerTracker t = new AdapterManagerTracker(ctx);
    t.open();
    IAdapterManager am = t.getAdapterManager();
    t.close();
    return am;
}
Also used : AdapterManagerTracker(org.eclipse.ecf.core.util.AdapterManagerTracker) 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