如何设置编辑器页面的标题(Eclipse)

时间:2018-12-14 18:48:40

标签: eclipse eclipse-plugin eclipse-rcp

我正在使用以下方式在Eclipse中以编程方式打开编辑器页面

package org.eclipse.ui.ide;
/**
 * Opens an editor on the given object.
 * <p>
 * If the page already has an editor open on the target object then that
 * editor is brought to front; otherwise, a new editor is opened. If
 * <code>activate == true</code> the editor will be activated.
 * <p>
 *
 * @param page
 *            the page in which the editor will be opened
 * @param input
 *            the editor input
 * @param editorId
 *            the id of the editor extension to use
 * @param activate
 *            if <code>true</code> the editor will be activated
 * @return an open editor or <code>null</code> if an external editor was
 *         opened
 * @exception PartInitException
 *                if the editor could not be initialized
 * @see org.eclipse.ui.IWorkbenchPage#openEditor(IEditorInput, String,
 *      boolean)
 */
public static IEditorPart openEditor(IWorkbenchPage page,
        IEditorInput input, String editorId, boolean activate)
        throws PartInitException {
    // sanity checks
    if (page == null) {
        throw new IllegalArgumentException();
    }

    // open the editor on the file
    return page.openEditor(input, editorId, activate);
}

到目前为止,还算不错,我可以看到我的编辑器实例和数据,但是刚刚创建的编辑器页面没有任何标题,因此很难看清:enter image description here

所以,我的问题是,'如何设置/修改刚创建的编辑器的标题?

感谢您的回答。 胡安

1 个答案:

答案 0 :(得分:0)

找到我的答案,实际上它是打开编辑器所需的IStorageEditorInput的一部分,它具有一个名为public String getName()的成员,该成员正是用于该提议的,将名称带到选项卡。在可能的情况下,我只是返回了null。