0

我正在开发一个由视图和编辑器组成的 RCP 应用程序。我可以在编辑器中更改值并编辑某些参数的值。更改值后,我需要使编辑器变脏,并且还想启用保存按钮。到目前为止,我还没有实现我的保存按钮。谁能指导我如何启用保存按钮,以及当编辑器中发生一些修改时如何使编辑器变脏。

提前致谢。任何帮助将不胜感激。

问候, 吉里什

4

1 回答 1

1

这是表单编辑器逻辑的概述,希望对您有所帮助。

public class TestEditor extends FormEditor {

    @Override
    protected void addPages() {
        // this method is called when the editor is being created
        // to add the necessary pages
        // page classes should be like following
        // class TestEditorPage extends FormPage
        try {
            TestEditorPage pageTest = new TestEditorPage(this);
            addPage(pageTest);
        } catch (PartInitException e) {
        }
    }

    @Override
    public void doSave(IProgressMonitor monitor) {
        // this method will be called on save action
        // (or Ctrl + s shortcut)
    }

    @Override
    public void doSaveAs() {
        // this method will be called on save-as 
        //call (or Ctrl + Shift + s shortcut)
    }


    @Override
    public boolean isSaveAsAllowed() {
       // put here the call to the logic that 
       // check if the save is allowed
       return true;
    }


    @Override
    public boolean isDirty() {
        // Here the call for the logic that 
        // defines if the editor is dirty or not
        return true;
    }
}
于 2012-07-18T13:19:01.697 回答