eclipse-plugineditingemf

Aquiring EMF Editing Domain


I have created an EMF model inside an Eclipse plugin. I want to display the models contents in a Nebula Grid (using a GridTreeViewer for display and a tabbed properties sheet for editing).

Gridviewer

I have written a custom label and content provider, as I did not get the EMF generated ones to use all the Nebula grid features (checkboxes, Toolips).

public class OverviewViewLabelProvider extends ColumnLabelProvider {
    [...]
    public void update(ViewerCell cell) {
        AbstractEntry entry = (AbstractEntry) cell.getElement();
        GridItem item = (GridItem) cell.getItem();
        switch (cell.getColumnIndex()) {...}
    }
}

set the selection provider in the main view class

public class OverviewViewPart extends ViewPart implements ITabbedPropertySheetPageContributor {
[...]
this.getSite().setSelectionProvider(this.viewer);
[...]
public Object getAdapter(Class adapter) {
    if (adapter == IPropertySheetPage.class) {
        return new TabbedPropertySheetPage(this);
    }
    return super.getAdapter(adapter);
}
public String getContributorId() {
    return TaxEditorPlugin.PLUGIN_ID;
}

Tabbed Property Sheet

This works fine togehter with EMF Databinding, below just the example of one field:

this.descriptionText.setText(this.entry.getDescription());
this.descriptionText.setData(this.entry);
emfDataBindingContext.bindValue(
    WidgetProperties.text(SWT.Modify).observe(this.descriptionText),
    EMFProperties.value(ModelPackage.Literals.ABSTRACT_ENTRY__DESCRIPTION).observe(this.entry)
);

Update Adapter and Model

public class OverviewViewUpdateAdapter extends EContentAdapter{
    public void notifyChanged(Notification notification) {
        super.notifyChanged(notification);
        this.viewer.refresh();
    }
}

Now I want to use the editing domain and the command stack, but I fail miserably.

In the model factory I do:

Editing domain = TransactionalEditingDomain.Registry.INSTANCE.getEditingDomain("at.liebhart.tax.editor.domain");
Resource resource = domain.getResourceSet().createResource(URI.createURI(taxModel.toString() + ".taxgui"));
resource.getContents().add(taxModel);       

I also tried:

this.domain = new AdapterFactoryEditingDomain(new AdapterFactoryImpl(), this.stack);

Both did not work. Can anybody help me to get a working editing domain without the whole model.edit stuff, which seems not to support nebula widgets.


Solution

  • TransactionalEditingDomain.Registry.INSTANCE.getEditingDomain(String)
    

    is for retrieving the EditingDomain associated to a particular ID (usually because you want to re-use the EditingDomain of an existing editor, etc.).

    My guess is you want to use:

    org.eclipse.emf.transaction.TransactionalEditingDomain.Factory.createEditingDomain(ResourceSet)