Skip to main content



      Home
Home » Modeling » EMF » Using your own ResourceSet with an EditingDomain
Using your own ResourceSet with an EditingDomain [message #525199] Mon, 05 April 2010 15:08 Go to next message
Eclipse UserFriend
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] Mon, 05 April 2010 20:31 Go to previous message
Eclipse UserFriend
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
>
Previous Topic:Do EMF (RCP) apps require "org.eclipse.ui.ide" plugin?
Next Topic:RESTful EMF
Goto Forum:
  


Current Time: Thu Jul 10 07:40:02 EDT 2025

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

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

Back to the top