本文整理汇总了Java中org.eclipse.core.runtime.IAdapterFactory类的典型用法代码示例。如果您正苦于以下问题:Java IAdapterFactory类的具体用法?Java IAdapterFactory怎么用?Java IAdapterFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IAdapterFactory类属于org.eclipse.core.runtime包,在下文中一共展示了IAdapterFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: start
import org.eclipse.core.runtime.IAdapterFactory; //导入依赖的package包/类
@Override
public void start ( final BundleContext context ) throws Exception
{
super.start ( context );
plugin = this;
this.treeRoot = new WritableSet ( DisplayRealm.getRealm ( getWorkbench ().getDisplay () ) );
this.treeRootManager = new ConnectionTreeManager ( this.treeRoot );
this.connectionManager = new ConnectionManager ( context );
for ( final Map.Entry<Class<?>, IAdapterFactory> entry : this.adaperFactories.entrySet () )
{
Platform.getAdapterManager ().registerAdapters ( entry.getValue (), entry.getKey () );
}
}
示例2: stop
import org.eclipse.core.runtime.IAdapterFactory; //导入依赖的package包/类
@Override
public void stop ( final BundleContext context ) throws Exception
{
for ( final Map.Entry<Class<?>, IAdapterFactory> entry : this.adaperFactories.entrySet () )
{
Platform.getAdapterManager ().unregisterAdapters ( entry.getValue (), entry.getKey () );
}
if ( this.connectionManager != null )
{
this.connectionManager.dispose ();
this.connectionManager = null;
}
this.treeRootManager.dispose ();
this.treeRoot.dispose ();
this.discoverers.dispose ();
plugin = null;
super.stop ( context );
}
示例3: getAdapter
import org.eclipse.core.runtime.IAdapterFactory; //导入依赖的package包/类
/**
* Returns an adapter of the given type for the provided adapter.
*
* @param adaptable
* the object to adapt
* @param adapterType
* the type to adapt the object to
* @param force
* <code>true</code> if the plug-in providing the factory should
* be activated if necessary. <code>false</code> if no plugin
* activations are desired.
*/
private Object getAdapter(Object adaptable, String adapterType,
boolean force) {
IAdapterFactory factory = (IAdapterFactory) getFactories(
adaptable.getClass()).get(adapterType);
if (force && factory instanceof IAdapterFactoryExt)
factory = ((IAdapterFactoryExt) factory).loadFactory(true);
Object result = null;
if (factory != null) {
Class clazz = classForName(factory, adapterType);
if (clazz != null)
result = factory.getAdapter(adaptable, clazz);
}
if (result == null
&& adaptable.getClass().getName().equals(adapterType))
return adaptable;
return result;
}
示例4: start
import org.eclipse.core.runtime.IAdapterFactory; //导入依赖的package包/类
public void start ( final BundleContext context ) throws Exception
{
super.start ( context );
for ( final Map.Entry<Class<?>, IAdapterFactory> entry : this.adaperFactories.entrySet () )
{
Platform.getAdapterManager ().registerAdapters ( entry.getValue (), entry.getKey () );
}
plugin = this;
}
示例5: stop
import org.eclipse.core.runtime.IAdapterFactory; //导入依赖的package包/类
public void stop ( final BundleContext context ) throws Exception
{
plugin = null;
for ( final Map.Entry<Class<?>, IAdapterFactory> entry : this.adaperFactories.entrySet () )
{
Platform.getAdapterManager ().registerAdapters ( entry.getValue (), entry.getKey () );
}
super.stop ( context );
}
示例6: addAdapterFactory
import org.eclipse.core.runtime.IAdapterFactory; //导入依赖的package包/类
/**
* @param limpetAdapters
*/
public void addAdapterFactory(IAdapterFactory newFactory)
{
if (_adapters == null)
{
_adapters = new ArrayList<IAdapterFactory>();
}
_adapters.add(newFactory);
}
示例7: cacheClassLookup
import org.eclipse.core.runtime.IAdapterFactory; //导入依赖的package包/类
private void cacheClassLookup(IAdapterFactory factory, Class clazz) {
synchronized (classLookupLock) {
// cache reference to lookup to protect against concurrent flush
Map lookup = classLookup;
if (lookup == null)
classLookup = lookup = new HashMap(4);
HashMap classes = (HashMap) lookup.get(factory);
if (classes == null) {
classes = new HashMap(4);
lookup.put(factory, classes);
}
classes.put(clazz.getName(), clazz);
}
}
示例8: cachedClassForName
import org.eclipse.core.runtime.IAdapterFactory; //导入依赖的package包/类
private Class cachedClassForName(IAdapterFactory factory, String typeName) {
synchronized (classLookupLock) {
Class clazz = null;
// cache reference to lookup to protect against concurrent flush
Map lookup = classLookup;
if (lookup != null) {
HashMap classes = (HashMap) lookup.get(factory);
if (classes != null) {
clazz = (Class) classes.get(typeName);
}
}
return clazz;
}
}
示例9: classForName
import org.eclipse.core.runtime.IAdapterFactory; //导入依赖的package包/类
/**
* Returns the class with the given fully qualified name, or null if that
* class does not exist or belongs to a plug-in that has not yet been
* loaded.
*/
private Class classForName(IAdapterFactory factory, String typeName) {
Class clazz = cachedClassForName(factory, typeName);
if (clazz == null) {
if (factory instanceof IAdapterFactoryExt)
factory = ((IAdapterFactoryExt) factory).loadFactory(false);
if (factory != null) {
// try {
// clazz = factory.getClass().getClassLoader()
// .loadClass(typeName);
// } catch (ClassNotFoundException e) {
// // it is possible that the default bundle classloader is
// // unaware of this class
// // but the adaptor factory can load it in some other way.
// // See bug 200068.
// if (typeName == null)
// return null;
// Class[] adapterList = factory.getAdapterList();
// clazz = null;
// for (int i = 0; i < adapterList.length; i++) {
// if (typeName.equals(adapterList[i].getName())) {
// clazz = adapterList[i];
// break;
// }
// }
// if (clazz == null)
// return null; // class not yet loaded
// }
// cacheClassLookup(factory, clazz);
}
}
return clazz;
}
示例10: queryAdapter
import org.eclipse.core.runtime.IAdapterFactory; //导入依赖的package包/类
public int queryAdapter(Object adaptable, String adapterTypeName) {
IAdapterFactory factory = (IAdapterFactory) getFactories(
adaptable.getClass()).get(adapterTypeName);
if (factory == null)
return NONE;
if (factory instanceof IAdapterFactoryExt) {
factory = ((IAdapterFactoryExt) factory).loadFactory(false); // don't
// force
// loading
if (factory == null)
return NOT_LOADED;
}
return LOADED;
}
示例11: registerFactory
import org.eclipse.core.runtime.IAdapterFactory; //导入依赖的package包/类
public void registerFactory(IAdapterFactory factory, String adaptableType) {
List list = (List) factories.get(adaptableType);
if (list == null) {
list = new ArrayList(5);
factories.put(adaptableType, list);
}
list.add(factory);
}
示例12: unregisterAdapters
import org.eclipse.core.runtime.IAdapterFactory; //导入依赖的package包/类
public synchronized void unregisterAdapters(IAdapterFactory factory,
Class adaptable) {
List factoryList = (List) factories.get(adaptable.getName());
if (factoryList == null)
return;
factoryList.remove(factory);
flushLookup();
}
示例13: stubAdapterFactory
import org.eclipse.core.runtime.IAdapterFactory; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private static IAdapterFactory stubAdapterFactory( Collection<Object> expected ) {
IAdapterFactory result = mock( IAdapterFactory.class );
when( result.getAdapter( anyObject(), any( Class.class ) ) ).thenReturn( expected );
when( result.getAdapterList() ).thenReturn( new Class[] { ADAPTER_TYPE_1, ADAPTER_TYPE_2 } );
return result;
}
示例14: getAdapters
import org.eclipse.core.runtime.IAdapterFactory; //导入依赖的package包/类
/**
* @return
*/
public ArrayList<IAdapterFactory> getAdapters()
{
return _adapters;
}
示例15: newSelection
import org.eclipse.core.runtime.IAdapterFactory; //导入依赖的package包/类
protected void newSelection(final ISelection selection)
{
if (selection == _curSelection)
{
return;
}
else
{
_curSelection = selection;
}
final List<IStoreItem> res = new ArrayList<IStoreItem>();
if (selection instanceof StructuredSelection)
{
final StructuredSelection str = (StructuredSelection) selection;
// check if it/they are suitable
final Iterator<?> iter = str.iterator();
while (iter.hasNext())
{
final Object object = iter.next();
if (object instanceof IAdaptable)
{
final IAdaptable ad = (IAdaptable) object;
final IStoreItem coll = (IStoreItem) ad.getAdapter(IStoreItem.class);
if (coll != null)
{
res.add(coll);
}
}
else
{
// can we adapt it?
final ArrayList<IAdapterFactory> adapters =
Activator.getDefault().getAdapters();
if (adapters != null)
{
final Iterator<IAdapterFactory> aIter = adapters.iterator();
while (aIter.hasNext())
{
final IAdapterFactory iAdapterFactory = aIter.next();
final Object match =
iAdapterFactory.getAdapter(object, IStoreItem.class);
if (match != null)
{
res.add((IStoreItem) match);
break;
}
}
}
}
}
}
// have we found any, and are they suitable for us?
if ((res.size()) > 0 && appliesToMe(res, getATests()))
{
// ok, stop listening to the old list
clearChangeListeners();
// and start listening to the new ones
createChangeListeners(res);
// ok, display them
display(res);
}
else
{
// ok, nothing to display - clear the graph
// display(new ArrayList<IStoreItem>());
}
}