AdapterManager not loading classes
----------------------------------
Key: UDIG-1427
URL: http://jira.codehaus.org/browse/UDIG-1427
Project: uDIG
Issue Type: Bug
Components: API libs
Affects Versions: UDIG 1.2
Reporter: Amr A. Alam
We've been playing around with Adapters and found this neat problem. This is
from section 4 of the udig tutorial, using IAdaptable:
IAdapterManager manager = Platform.getAdapterManager();
if( manager.hasAdapter(object,"java.net.URL")){
URL url = (URL) manager.getAdapter( object, URL.class );
if( url != null ){
buffer.append("AdapterManager has a factory making us into a URL:"+url);
buffer.append(separator);
}
}
So in this code snippet, if an IGeoResource object comes in, nothing happens.
It doesn't realize that it CAN be adapted to a URL.
However, if I've performed the 'display url' operation from the example first
(by right clicking on a georesource in the catalog, and going to
Operations->Display URL) then this code works fine.
Alternatively, this code works regardless of whether i've been right clicking
or not:
if( AdapterUtil.instance.canAdaptTo(object, URL.class) ) {
URL url;
try {
url = AdapterUtil.instance.adapt("java.net.URL", object, null);
} catch (IOException e) {
throw (RuntimeException) new RuntimeException( ).initCause( e );
}
if( url != null ){
buffer.append("AdapterManager has a factory making us into a URL:"+url);
buffer.append(separator);
}
}
It seems that the AdapterManager code does not look/load new adapters, whereas
the AdapterUtil does.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel