如何在Eclipse中使只读编辑器(Eclipse插件开发) [英] How to make read only editor in Eclipse (Eclipse Plugin Development)

查看:215
本文介绍了如何在Eclipse中使只读编辑器(Eclipse插件开发)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何制作一个真正的只读日食编辑器。我的编辑器扩展了 TextEditor ,因此当我重新实现方法 isEditable 时始终返回 false

I'm wondering how to make a really read only eclipse editor.. My editor extends TextEditor, so when I reimplement method isEditable to always return false.

这是最简单的方法,它可以防止用户在编辑器中打开的文档中键入或删除任何内容。但是您仍然可以例如通过查找/替换来更改文档的内容。

It's the easiest way, which prevents user from typing or deleting anything in the document opened in the editor. But you can still change content of the document for example by using find/replace. And this is not desired..

还有其他简便的方法可以实现这个目标吗?

Is there any other aesy way how to arhieve this goal?

推荐答案

我想使用编辑器而不是查看器,因为已经完成了编辑器,所以我只使用了第3方插件。.

I wanted to use editor instead of viewer because the editor was already made, so I just used a 3rd party plugin..

I找到了我的解决方案-也许不是很干净,但是做得很好,很容易,所以很成功

I found my solution - maybee not very clean but does the job and is pretty easy so it wins

我已经覆盖了这些方法:

I've overriden theese methods:

@Override
public boolean isEditable() {
    return false;
}

@Override
public boolean isEditorInputModifiable() {
    return false;
}

@Override
public boolean isEditorInputReadOnly() {
    return true;
}

@Override
public boolean isDirty() {
    return false;
}

这篇关于如何在Eclipse中使只读编辑器(Eclipse插件开发)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆