首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Eclipse开发 >

Eclipse RCP中统制Editor不重复打开的方法

2012-12-27 
Eclipse RCP中控制Editor不重复打开的方法Eclipse Rcp开发中,很多时候需要实现Editor的唯一性,就像JDT中,

Eclipse RCP中控制Editor不重复打开的方法

Eclipse Rcp开发中,很多时候需要实现Editor的唯一性,就像JDT中,同一class只打开一个Editor一样。这需要在代码中两个部分配合来实现:

?

1、在打开Editor的代码中:

public class TestInput implements IEditorInput {        ............../* (non-Javadoc) * @see java.lang.Object#equals(java.lang.Object) */@Overridepublic boolean equals(Object obj) {if(null == obj) return false;if(!(obj instanceof TestInput)) return false;if(!getName().equals(((TestInput)obj).getName())) return false;return true;}}

?

这样,在调用1中代码打开TestInput对应的Editor时,如果EditorArea中已经打开了一个,会把已打开的Editor置为active,而不是再打开新的。

热点排行