【问题标题】:eclipse plugin development - right click preferences menu?eclipse插件开发 - 右键单击​​首选项菜单?
【发布时间】:2013-11-03 05:08:32
【问题描述】:

我正在开发 eclipse 插件。 当在我的编辑器插件中右键单击并选择“首选项”时,它会显示带有 2 个子树项目的 Eclipse 的“常规”树项目——“外观”和“编辑器”。 在“编辑器”下有另一个树项目“文本编辑器”被选中。

当我在 plugin.xml 中声明为“org.eclipse.ui.preferencePages”的扩展点的项目时,如何更改显示的行为?

谢谢,托默

【问题讨论】:

    标签: java eclipse eclipse-plugin eclipse-rcp plugin.xml


    【解决方案1】:

    这取决于您的编辑器是从哪个类派生的。如果它派生自org.eclipse.ui.texteditor.AbstractDecoratedTextEditor 或其众多子类之一,那么您可以覆盖collectContextMenuPreferencePages。默认为:

    /**
     * Returns the preference page ids of the preference pages to be shown when executing the
     * preferences action from the editor context menu. The first page will be selected.
     * <p>
     * Subclasses may extend or replace.
     * </p>
     * 
     * @return the preference page ids to show, may be empty
     */
    protected String[] collectContextMenuPreferencePages() {
        return new String[] { "org.eclipse.ui.preferencePages.GeneralTextEditor",
                "org.eclipse.ui.editors.preferencePages.Annotations", 
                "org.eclipse.ui.editors.preferencePages.QuickDiff", 
                "org.eclipse.ui.editors.preferencePages.Accessibility", 
                "org.eclipse.ui.editors.preferencePages.Spelling", 
                "org.eclipse.ui.editors.preferencePages.LinkedModePreferencePage", 
                "org.eclipse.ui.preferencePages.ColorsAndFonts", 
            };
    }
    

    【讨论】:

    • 是的。它扩展了 org.eclipse.ui.editors.text.TextEditor 扩展了 AbstractDecoratedTextEditor
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-13
    • 2013-11-01
    • 1970-01-01
    • 2011-09-13
    相关资源
    最近更新 更多