Eclipse RCP应用程序中的项目特定首选项页面 [英] Project specific preference page in Eclipse RCP application

查看:175
本文介绍了Eclipse RCP应用程序中的项目特定首选项页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为我们的产品启用基于项目的首选项对话框。我绊倒了两个不同的问题:

I want to enable project-based Preference-dialogs for our product. I stumble upon 2 different problems:

如何存储这些项目相关的信息。作为一个受过教育的猜测,我会尝试这个:

How do I store those project related informations. As an educated guess I would try this one:


  • IPreferenceStore store = new ScopedPreferenceStore(new ProjectScope(project.getIProject ()),Activator.PLUGIN_ID);

  • 之后根据需要设置项目商店(例如,在首选项页面中作为商店)

如何仅为项目启用首选项页?我知道我可以使用 PreferenceUtils.createPreferenceDialogOn(...)将某些预选页面称为偏好对话框。不幸的是,偏好页的ID必须在 org.eclipse.ui.preferencePages 扩展点中定义。但是如果它们在这个扩展点内,这些页面也在产品的全局首选项中。如果EP中没有指定页面,则不会显示页面。

How do I enable a Preference Page only for a project? I know I can call a preference dialog with some preselected pages using the PreferenceUtils.createPreferenceDialogOn(…). Unfortunately the IDs of the preference pages have to defined in the org.eclipse.ui.preferencePagesextension point. But if they are inside this extension point, these pages are also in the global "Preferences" of the product. If they are not specified inside the EP the pages are not shown.

有什么提示?感谢提前:)

Any hints on that? Thanks in advance :)

编辑:我实际想要的是属性对话框,而不是首选项对话框。如果您正在使用属性页,则PreferenceUtils根本不起作用。如果您通过 org.eclipse.ui.propertyPages 为标准eclipse导航器提供了一个属性页面,但是如何在自定义导航器(Common Navigator Framework )?

What I actually wanted was a properties dialog, not a preference dialog. If you are working with property pages, the PreferenceUtils does not work at all. If you contribute a properties page via org.eclipse.ui.propertyPages it works well for the standard eclipse navigator - but how do I handle this inside a custom navigator (Common Navigator Framework)?

推荐答案

您需要将 PropertiesPage 在你的plugin.xml中引用它,例如。这使用两个不同的属性页面,一个在项目选择时显示,另一个用于文件。而且它们只存在于具有指定项目性质的项目中。

You will need to subclass PropertiesPage and then put a reference to it in your plugin.xml like this for example. This uses two different properties pages, one that is shown when a project is select, the other for a file. And they are both only present in the projects with the specified project nature.

<extension point="org.eclipse.ui.propertyPages">
    <page
        class="com.oaklandsw.transform.editor.TransformProjectPropertiesPage"
    id="com.oaklandsw.transform.filePropPage"
    name="%appHandle">
    <enabledWhen>
    <and>
            <instanceof
             value="org.eclipse.core.resources.IProject">
        </instanceof>
            <adapt type="org.eclipse.core.resources.IResource" >
                <test
                 property="org.eclipse.core.resources.projectNature"
                value="com.oaklandsw.transform.runtime.nature">
                </test>
            </adapt>   
    </and>
    </enabledWhen>
    </page> 
    <page class="com.oaklandsw.transform.editor.TransformFilePropertiesPage"
        id="com.oaklandsw.transform.projectPropPage" name="%appHandle">
        <enabledWhen>
            <and>
        <instanceof
            value="org.eclipse.core.resources.IFile">
        </instanceof>
            <adapt type="org.eclipse.core.resources.IResource" >
                <test property="org.eclipse.core.resources.projectNature"
                    value="com.oaklandsw.transform.runtime.nature" />
            </adapt>        
            </and>
        </enabledWhen>
    </page>
</extension>

这篇关于Eclipse RCP应用程序中的项目特定首选项页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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