5

现在我可以在 Eclipse WizardDialog/Editor 中注册上下文帮助。

1)我创建了一个 help_contexts.xml 文件。

<?xml version="1.0" encoding="UTF-8"?>
<?NLS TYPE="org.eclipse.help.contexts"?>
<contexts>
   <context  id="my.plugin.help.general" >
        <description>test</description>
        <topic label="test" href="http://domain.com/help.html"/>
   </context>
</contexts>

2) 我在我的 plugin.xml 中引用了这个文件

  <extension
         point="org.eclipse.help.contexts">
         <contexts file="help_contexts.xml" plugin="my.plugin.MainEditor">
         </contexts>
   </extension>

3) 我在 build.properties 中添加了一行以将此文件包含在 bin 目录中 (bin.includes = help_contexts.xml, ... )

4) 运行基于 GEF 的插件时,我在动态帮助下看到“未找到“my.plugin.MainEditor”的匹配项”。

我知道我需要在某处创建类似的东西,但我不知道在哪里为我的 WizardDialog 或至少为我的整个编辑器设置它:

  public void createPartControl(Composite parent) {
      ...
      PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, 
         "my.plugin.help.general");
   }

注意:这个问题最初包含两个问题。我已经删除了要在其他地方发布的第一个(未答复的部分)。

4

2 回答 2

10

以下是您的操作方法: 1) 我创建了一个 help_contexts.xml 文件。上下文 ID 中没有句点。不要在其中包含您的插件名称。

<?xml version="1.0" encoding="UTF-8"?>
<?NLS TYPE="org.eclipse.help.contexts"?>
<contexts>
   <context  id="help_general" >
        <description>test</description>
        <topic label="test" href="http://domain.com/help.html"/>
   </context>
</contexts>

2) 我在我的 plugin.xml 中引用了这个文件 如果您引用自己的插件,请不要包含插件 ID。

 <extension
         point="org.eclipse.help.contexts">
         <contexts file="help_contexts.xml">
         </contexts>
   </extension>

3) 我在 build.properties 中添加了一行以将此文件包含在 bin 目录中 (bin.includes = help_contexts.xml, ... )。请注意 Manifest.MF 中的 Bundle-SymbolicName(在您的 plugin.xml 编辑器中也可见)。示例:my.plugin

4) 在 WizardPage 中设置上下文 id(归功于 @VonC)

public class MyWizardPage extends WizardPage
    public void createControl(Composite parent) {
        PlatformUI.getWorkbench.getHelpSystem.setHelp(parent, "my.plugin.help_general");
    }
}
于 2009-06-20T14:25:22.580 回答
3

对于主要问题,我不确定您的 setHelp 第二个参数。看到这个线程

在方法调用中

PlatformUI.getWorkbench().getHelpSystem().setHelp()

第二个参数是contextID.
它应该以pluginID类似的前缀:“ pluginID.contextID”。
现在我不确定在哪里可以找到我的插件的插件 ID。
所以我使用了这个属性的值: Bundle-Name Bundle-Symbolic-NamefromMANIFEST.MF作为插件 ID。
现在它起作用了。


对于旁注(帮助WizardDialog),这个线程可能会有所帮助(来自 David Kyle 和他的博客“ Eclipse RCP ”):

我们在向导页面中设置上下文 ID。

public class MyWizardPage extends WizardPage
    public void createControl(Composite parent) {
        PlatformUI.getWorkbench.getHelpSystem.setHelp(parent, 
MyPluginActivator.ID + ".mycontexthelpid");
    }
}

我们为向导对话框设置了帮助。

WizardDialog dialog = new WizardDialog(.....);
PlatformUI.getWorkbench().getHelpSystem().setHelp(dialog.getShell(), 
"mycontexthelp.id");

我们不覆盖performHelp().

至于帮助上下文 id。在插件中定义一个上下文 xml 文件。

<?xml version="1.0" encoding="UTF-8"?>
<?NLS TYPE="org.eclipse.help.contexts"?>
<contexts>
    <context id="mycontexthelpid" >
        <description>My wizard help.</description>
        <topic label="Wizard help" href="reference/wizard/help.xhtml"/>
    </context>
</contexts>

在你的插件中

<plugin>
    <extension point="org.eclipse.help.contexts">
        <contexts file="mywizard.xml" plugin="com.mypluginid"/>
    </extension>
</plugin>

一个常见的问题是弄乱了插件和上下文帮助 ID。您可以设置几个断点来查看正在请求哪个上下文 ID。

于 2009-06-18T16:15:47.830 回答