Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Loading Resources through Browse Registered Packages
Loading Resources through Browse Registered Packages [message #669505] Tue, 10 May 2011 07:02 Go to next message
Jevon  is currently offline Jevon Friend
Messages: 164
Registered: July 2009
Senior Member
Hi,

In an EMF-generated editor, it is already possible to load an existing
resource through Load Resource > Browse Registered Packages. 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. If I
provide the platform:/plugin/* URI manually, the resource is
successfully loaded into the underlying model instance.

Any ideas would be appreciated!

Thanks
Jevon
Re: Loading Resources through Browse Registered Packages [message #669531 is a reply to message #669505] Tue, 10 May 2011 15:31 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
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 Go to previous message
Jevon  is currently offline Jevon Friend
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
Previous Topic:The "+" popup: how to remove it?
Next Topic:strange inheritance error
Goto Forum:
  


Current Time: Wed Apr 24 22:39:28 GMT 2024

Powered by FUDForum. Page generated in 0.03143 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top