在RCP产品中保存选项

时间:2012-07-17 06:03:06

标签: eclipse-plugin eclipse-rcp rcp

开发一个由视图和编辑器组成的RCP应用程序。我可以在编辑器中更改值并编辑某些参数的值。当一个值被更改时,我需要使编辑器变脏,并且还要启用保存按钮。直到现在,我还没有实现我的保存按钮。任何人都可以指导我如何启用保存按钮以及如何在编辑器中进行某些修改时使编辑器变脏。

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

此致 吉里什

1 个答案:

答案 0 :(得分: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;
    }
}