[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.modeling.mdt] Re: [UML2] how to load UML_PRIMITIVE_TYPES_LIBRARY

Jinhui,

Its sounds like a resource factory has not been registered to hande the URI 
you are trying load. The FAQ entry that I pointed you to shows how to do 
this:
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION, 
UMLResource.Factory.INSTANCE);Kenn

"Jinhui" <zhuj@xxxxxxxxx> wrote in message 
news:902de8df46b383e348d19ed88a7e0b73$1@xxxxxxxxxxxxxxxxxx
> Hi Kenn,
>
> first, sorry for misplacing the message in the MDT group. Newbie!
>
>
> I tried both the two approaches mentioned in the article, neither worked.
> the one as in the Profile-tutorial looks like this:
>
> PrimitiveType primitiveType = importPrimitiveType( "Boolean");
>
> protected static PrimitiveType importPrimitiveType(String name) {
>  Model umlLibrary = 
> (Model)load(URI.createURI(UMLResource.UML_PRIMITIVE_TYPES_LIBRARY_URI));
>  PrimitiveType primitiveType = (PrimitiveType) 
> umlLibrary.getOwnedType(name);
>  return primitiveType;
> }
>
> protected static org.eclipse.uml2.uml.Package load(URI uri) {
>  org.eclipse.uml2.uml.Package package_ = null;
>  try {
>    Resource resource = RESOURCE_SET.getResource(uri, true); (****) 
> package_ =(org.eclipse.uml2.uml.Package)EcoreUtil.getObjectByType(
>      resource.getContents(), UMLPackage.Literals.PACKAGE);        } catch 
> (WrappedException we) {
>  }
>  return package_;
> }
>
>
>
> I got Exception at (****):
> "Cannot create a resource for 
> 'pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml'; a registered 
> resource factory is needed"
>
>>> I suspect the problem you are having relates to not registering the
> pathmaps for the UML library resources
>
> Can you give me more hints on this?
>
> best Regards! Jinhui
>