【问题标题】:Eclipse rename EditorPartEclipse 重命名 EditorPart
【发布时间】:2017-03-02 02:49:03
【问题描述】:

我有一个具有编辑器视图的 Eclipse 插件项目。所以我扩展了EditorPart 类。最初,init 方法被调用,我也可以在那里调用setPartName 方法来更新选项卡的标签,如:

@Override
public void init(IEditorSite site, IEditorInput input) throws PartInitException {
    super.init(site, input);
    //...
    setPartName(filename);
}

setPartName 方法是受保护的方法。我现在有另一个类(比如说DataModel),它是我的编辑器的数据模型。是否可以从此类更新编辑器部分?因为DataModel 类中的文件重命名了,现在我想显示新文件名/替换旧文件名。

编辑:这是一个基于 gef4 的项目,View(扩展 AbstractFXEditor,扩展 EditorPart)在 init 方法中创建 DataModel 的实例:

IFile file = ((IFileEditorInput) input).getFile();
URI inputUri = URI.createURI(file.getFullPath().toString(), true);
getContentViewer().getContents().setAll(createContents(inputUri));

createContents(URI) 方法创建DataModel 的实例。

谢谢

【问题讨论】:

  • 因此,在您的编辑器中声明一个公共方法,该方法调用 setPartName 并从您的 DataModel 调用该方法。

标签: java eclipse


【解决方案1】:

哎呀,这是漫长的一天。可以自己回答...

只需将View 添加到DataModel 构造函数,声明一个调用setPartName 的公共方法,从DataModel 内部的任何位置调用它即可。

【讨论】:

    猜你喜欢
    • 2011-12-01
    • 2015-07-22
    • 2011-05-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多