Java 类org.eclipse.core.runtime.IAdapterFactory 实例源码
项目:neoscada
文件:Activator.java
@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 () );
}
}
项目:neoscada
文件:Activator.java
@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 );
}
项目:gef-gwt
文件:AdapterManager.java
/**
* 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;
}
项目:neoscada
文件:Activator.java
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;
}
项目:neoscada
文件:Activator.java
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 );
}
项目:neoscada
文件:Activator.java
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;
}
项目:neoscada
文件:Activator.java
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 );
}
项目:limpet
文件:Activator.java
/**
* @param limpetAdapters
*/
public void addAdapterFactory(IAdapterFactory newFactory)
{
if (_adapters == null)
{
_adapters = new ArrayList<IAdapterFactory>();
}
_adapters.add(newFactory);
}
项目:gef-gwt
文件:AdapterManager.java
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);
}
}
项目:gef-gwt
文件:AdapterManager.java
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;
}
}
项目:gef-gwt
文件:AdapterManager.java
/**
* 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;
}
项目:gef-gwt
文件:AdapterManager.java
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;
}
项目:gef-gwt
文件:AdapterManager.java
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);
}
项目:gef-gwt
文件:AdapterManager.java
public synchronized void unregisterAdapters(IAdapterFactory factory,
Class adaptable) {
List factoryList = (List) factories.get(adaptable.getName());
if (factoryList == null)
return;
factoryList.remove(factory);
flushLookup();
}
项目:xiliary
文件:AdaptersPDETest.java
@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;
}
项目:limpet
文件:Activator.java
/**
* @return
*/
public ArrayList<IAdapterFactory> getAdapters()
{
return _adapters;
}
项目:limpet
文件:CoreAnalysisView.java
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>());
}
}
项目:gef-gwt
文件:AdapterManager.java
public synchronized void registerAdapters(IAdapterFactory factory,
Class adaptable) {
registerFactory(factory, adaptable.getName());
flushLookup();
}
项目:gef-gwt
文件:AdapterManager.java
public synchronized void unregisterAdapters(IAdapterFactory factory) {
for (Iterator it = factories.values().iterator(); it.hasNext();)
((List) it.next()).remove(factory);
flushLookup();
}
项目:birt
文件:ElementAdapter.java
public IAdapterFactory getFactory( )
{
return factory;
}
项目:birt
文件:ElementAdapter.java
public void setFactory( IAdapterFactory factory )
{
this.factory = factory;
}
项目:xiliary
文件:AdaptersPDETest.java
private void registerAdapterFactory( IAdapterFactory adapterFactory, Class<?> type ) {
Platform.getAdapterManager().registerAdapters( adapterFactory, type );
this.adapterFactory = adapterFactory;
}
项目:gef-gwt
文件:IAdapterFactoryExt.java
/**
* Loads the real adapter factory, but only if its associated plug-in is
* already loaded. Returns the real factory if it was successfully loaded.
* @param force if <code>true</code> the plugin providing the
* factory will be loaded if necessary, otherwise no plugin activations
* will occur.
*/
public IAdapterFactory loadFactory(boolean force);