Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Using your own ResourceSet with an EditingDomain
Using your own ResourceSet with an EditingDomain [message #525199] Mon, 05 April 2010 19:08 Go to next message
Bryan Hunt is currently offline Bryan HuntFriend
Messages: 366
Registered: July 2009
Senior Member
I have a case where I need to use my own ResourceSet with the generated
editor. The EditingDomain API supports this just fine, but you quickly
find out that when you modify a property, the editor never goes dirty.
It turns out that the item providers get access to the EditingDomain
through the AdapterFactoryEditingDomainResourceSet which does not exist
when you use your own ResourceSet. I've hacked around this problem as
follows:

editingDomain.getResourceSet().eAdapters().add(new EditingDomainAdapter());

private class EditingDomainAdapter implements Adapter, IEditingDomainProvider
{
@Override
public EditingDomain getEditingDomain()
{
return RuntimeEditor.this.getEditingDomain();
}

@Override
public void notifyChanged(Notification notification)
{
}

@Override
public Notifier getTarget()
{
return null;
}

@Override
public void setTarget(Notifier newTarget)
{
}

@Override
public boolean isAdapterForType(Object type)
{
if(type == IEditingDomainProvider.class)
return true;

return false;
}
}


Is there any better way to deal with this problem?

Bryan
Re: Using your own ResourceSet with an EditingDomain [message #525273 is a reply to message #525199] Tue, 06 April 2010 00:31 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33218
Registered: July 2009
Senior Member
Bryan,

That's the right way. Extend your ResourceSetImpl to implement that
interface directly. Or extend AdapterImpl to write less methods.


Bryan Hunt wrote:
> I have a case where I need to use my own ResourceSet with the
> generated editor. The EditingDomain API supports this just fine, but
> you quickly find out that when you modify a property, the editor
> never goes dirty. It turns out that the item providers get access to
> the EditingDomain through the AdapterFactoryEditingDomainResourceSet
> which does not exist when you use your own ResourceSet. I've hacked
> around this problem as follows:
>
> editingDomain.getResourceSet().eAdapters().add(new
> EditingDomainAdapter());
>
> private class EditingDomainAdapter implements Adapter,
> IEditingDomainProvider
> {
> @Override
> public EditingDomain getEditingDomain()
> {
> return RuntimeEditor.this.getEditingDomain();
> }
>
> @Override
> public void notifyChanged(Notification notification)
> {
> }
>
> @Override
> public Notifier getTarget()
> {
> return null;
> }
>
> @Override
> public void setTarget(Notifier newTarget)
> {
> }
>
> @Override
> public boolean isAdapterForType(Object type)
> {
> if(type == IEditingDomainProvider.class)
> return true;
>
> return false;
> }
> }
>
>
> Is there any better way to deal with this problem?
>
> Bryan
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Do EMF (RCP) apps require "org.eclipse.ui.ide" plugin?
Next Topic:RESTful EMF
Goto Forum:
  


Current Time: Tue Sep 24 23:18:35 GMT 2024

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

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

Back to the top