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();
}
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();
}
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"));
}
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;
}
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;
}
Aggregations