|
Re: Loading Resources through Browse Registered Packages [message #669531 is a reply to message #669505] |
Tue, 10 May 2011 15:31 |
Ed Merks Messages: 33216 Registered: July 2009 |
Senior Member |
|
|
Jevon,
Comments below.
Jevon Wright wrote:
> Hi,
>
> In an EMF-generated editor, it is already possible to load an existing
> resource through Load Resource > Browse Registered Packages.
Well, that's not true of all generated EMF editors. It's specifically
added for the Ecore editor itself.
> In my generated GMF editors, I can also load an existing resource, but
> there is no option to Browse Registered Packages -- only the
> filesystem and workspace.
>
> Is this a problem with my configuration, or expected behaviour? How
> can I modify my editors to provide this option? I'd like to be able to
> reference platform:/plugin/* resources in my model instances.
Are these really references to Ecore models, i.e., references to
EPackage or EClass, or do you have instances of your specific type of model?
> If I provide the platform:/plugin/* URI manually, the resource is
> successfully loaded into the underlying model instance.
>
> Any ideas would be appreciated!
There isn't a general way to browse all resources you might have bundled
up in your jars. In the case of Ecore, we're using an extension point
to register the packages and we can use the associated registry to find
them all. I doubt you have such a thing, yet...
>
> Thanks
> Jevon
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: Loading Resources through Browse Registered Packages [message #669621 is a reply to message #669531] |
Wed, 11 May 2011 00:08 |
Jevon Messages: 164 Registered: July 2009 |
Senior Member |
|
|
Hi Ed,
Thanks for your reply. That makes a lot of sense!
However yes, in this case I am trying to refer to Ecore models, in
particular the XSD.ecore model as provided by org.eclipse.xsd.
After a bit of hunting I found the Ecore editor implementation of
LoadResourceAction --
org.eclipse.emf.ecore.presentation.EcoreActionBarContributor .ExtendedLoadResourceAction
-- and with a bit of modification to the diagram editor, this action
worked perfectly:
public class LoadResourceAction extends AbstractHandler {
public Object execute(ExecutionEvent event) throws ExecutionException {
ExtendedLoadResourceAction act = new ExtendedLoadResourceAction();
IEditorPart diagramEditor =
HandlerUtil.getActiveEditorChecked(event);
TransactionalEditingDomain editingDomain = ((DiagramEditor)
diagramEditor)
.getEditingDomain();
act.setEditingDomain(editingDomain);
act.run();
return null;
}
}
It's necessary to call setEditingDomain() directly, as
ExtendedLoadResourceAction only provides a single default constructor.
Thanks for your help!
Jevon
Ed Merks wrote:
> Jevon,
>
> Comments below.
>
> Jevon Wright wrote:
>> Hi,
>>
>> In an EMF-generated editor, it is already possible to load an existing
>> resource through Load Resource > Browse Registered Packages.
> Well, that's not true of all generated EMF editors. It's specifically
> added for the Ecore editor itself.
>> In my generated GMF editors, I can also load an existing resource, but
>> there is no option to Browse Registered Packages -- only the
>> filesystem and workspace.
>>
>> Is this a problem with my configuration, or expected behaviour? How
>> can I modify my editors to provide this option? I'd like to be able to
>> reference platform:/plugin/* resources in my model instances.
> Are these really references to Ecore models, i.e., references to
> EPackage or EClass, or do you have instances of your specific type of
> model?
>> If I provide the platform:/plugin/* URI manually, the resource is
>> successfully loaded into the underlying model instance.
>>
>> Any ideas would be appreciated!
> There isn't a general way to browse all resources you might have bundled
> up in your jars. In the case of Ecore, we're using an extension point
> to register the packages and we can use the associated registry to find
> them all. I doubt you have such a thing, yet...
>>
>> Thanks
>> Jevon
|
|
|
Powered by
FUDForum. Page generated in 0.05607 seconds