【发布时间】:2020-06-11 07:03:50
【问题描述】:
我在 Eclipse 插件中创建了一个 EMF 模型。我想在 Nebula Grid 中显示模型内容(使用 GridTreeViewer 进行显示,使用选项卡式属性表进行编辑)。
网格查看器
我编写了一个自定义标签和内容提供程序,因为我没有让 EMF 生成的提供程序来使用所有 Nebula 网格功能(复选框、工具提示)。
public class OverviewViewLabelProvider extends ColumnLabelProvider {
[...]
public void update(ViewerCell cell) {
AbstractEntry entry = (AbstractEntry) cell.getElement();
GridItem item = (GridItem) cell.getItem();
switch (cell.getColumnIndex()) {...}
}
}
在主视图类中设置选择提供者
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;
}
选项卡式属性表
这与 EMF 数据绑定一起工作得很好,下面只是一个字段的示例:
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)
);
更新适配器和模型
public class OverviewViewUpdateAdapter extends EContentAdapter{
public void notifyChanged(Notification notification) {
super.notifyChanged(notification);
this.viewer.refresh();
}
}
现在我想使用编辑域和命令堆栈,但是我失败了。
在我做的模型工厂里:
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);
我也试过了:
this.domain = new AdapterFactoryEditingDomain(new AdapterFactoryImpl(), this.stack);
两者都不起作用。 任何人都可以帮助我获得一个没有整个 model.edit 东西的工作编辑域,这似乎不支持 nebula 小部件。
【问题讨论】:
标签: eclipse-plugin editing emf