在SWT中使用ISaveablePart2时,无法启用“保存菜单项”

时间:2015-11-24 13:53:27

标签: java swt

下面的调用实现了我正在执行的ViewPart拖放

public class DiagramWindow extends ViewPart implements ISaveablePart2 {

    private boolean isDirty;
    private boolean saveNeeded;

    public void setDirty(boolean isDirty, boolean saveNeeded) {
        this.isDirty = isDirty;
        this.saveNeeded = saveNeeded;
        firePropertyChange(PROP_DIRTY);
    }
}

对于菜单项,我在扩展ActionBarAdvisor的类中注册它:

saveFileAction = ActionFactory.SAVE.create(window);
register(saveFileAction);

我打电话的代码部分

@Override
public void drop(DropTargetEvent event) {
    //DiagramWindow view
    view.setDirty(true, true);
}

1 个答案:

答案 0 :(得分:0)

greg-449是对的。 isDirty方法中的内容是什么?您应该在类DiagramWindow中覆盖isDirty方法。据我所知,默认情况下它是假的。我想你所要做的就是 -

public boolean isDirty() 
{ 
   return this.isDirty; 
}