Java GEF编辑器和选项卡式属性视图

Java GEF编辑器和选项卡式属性视图,java,eclipse-gef,Java,Eclipse Gef,我正在开发一个基于GEF(图形编辑框架)并使用Eclipse属性视图的编辑器。我的问题是,当我更改此视图中的属性时,编辑器不知道此更改,也不建议我保存。 如何修复此问题?在编辑器命令堆栈之外执行编辑时,通常会发生这种情况。实际上,脏标志(您提到的保存建议)由绑定到自己的gef图形编辑器的org.eclipse.gef.commands.CommandStack控制 假设通过扩展AdvancedPropertySection来实现属性表编辑器,则必须从IWorkbenchPart获取Command

我正在开发一个基于GEF(图形编辑框架)并使用Eclipse属性视图的编辑器。我的问题是,当我更改此视图中的属性时,编辑器不知道此更改,也不建议我保存。
如何修复此问题?

在编辑器命令堆栈之外执行编辑时,通常会发生这种情况。实际上,脏标志(您提到的保存建议)由绑定到自己的gef图形编辑器的
org.eclipse.gef.commands.CommandStack
控制

假设通过扩展
AdvancedPropertySection
来实现属性表编辑器,则必须从
IWorkbenchPart
获取
CommandStack
适配器,并将其保存以供以后使用:

public class GEFAdvancedPropertySection extends AdvancedPropertySection {
    public void setInput(IWorkbenchPart part, ISelection selection) {
        CommandStack commandStack = (CommandStack) part.getAdapter(CommandStack.class);
        if (cs != null)
            page.setRootEntry(new GEFPropertySheetEntry(commandStack));
        super.setInput(part, selection);
    }
}
propertysheeetentry
实现中(实际上是上例中的
gefpropertysheeetentry
),您必须通过在保存的
CommandStack
上执行的
org.eclipse.gef.commands.Command
来执行模型更改:

public class GEFPropertySheetEntry extends PropertySheetEntry {

    protected CommandStack commandStack;

    public GEFPropertySheetEntry(CommandStack commandStack) {
        this.commandStack = commandStack;
    }

    protected void valueChanged(PropertySheetEntry entry) {
        GEFCommand command = new GEFCommand();

        // here you have to configure the command
        // such that it can perform
        // the expected model modifications

        commandStack.execute(command);
    }
}

该技巧是使用特定的
GEFCommand
完成的,该命令通过
CommandStack
执行模型修改,该命令绑定到原始编辑器并将其标记为污垢。

是否可以使用其他编辑器手动编辑该文件?检查权限以查看是否可以编辑文件并使用其他编辑器保存。这可能是一个权限问题。实际上,当我在properties视图中编辑属性时,我的模型会意识到更改。例如,组件的名称可以编辑,但编辑器不建议我保存。您是否真的对编辑器进行了编码?当更改不是来自属性视图时,编辑器允许您保存吗?不客气!如果你觉得这个答案有用,你能把它标为正确吗?