求助:Eclipse中从HTML/Javascript文档启动自定义动作遇阻,同Active Help页面问题
Hey there! I’ve worked through similar Active Help wizard launch issues in Eclipse before, so let’s walk through some concrete fixes to get your custom action up and running:
Double-check your Active Help extension configuration
Open your plugin.xml and verify the<activeHelp>extension is correctly linked to your action class. Make sure the class implements eitherIActionorIActiveHelpAction, and that its package is exported in your OSGi manifest (Export-Package section). Example config:<extension point="org.eclipse.ui.activeHelp"> <topic id="com.your.plugin.help.launch_wizard_topic" label="Launch My Custom Wizard"> <action class="com.your.plugin.actions.LaunchWizardAction" label="Start Wizard"/> </topic> </extension>Validate the HTML/JS call syntax
Ensure your Active Help link uses the correct format to trigger the action. Two common valid patterns:- Direct action call via JavaScript:
<a href="javascript:org.eclipse.ui.cheatsheets.openAction('com.your.plugin.actions.LaunchWizardAction')">Launch Custom Wizard</a> - Link to the registered Active Help topic:
<a href="activehelp://com.your.plugin.help.launch_wizard_topic">Launch Custom Wizard</a>
Pro tip: Match the IDs exactly—case sensitivity matters here!
- Direct action call via JavaScript:
Confirm your custom wizard is properly registered
If your action launches a wizard via its ID, make sure the wizard is registered in theorg.eclipse.ui.newWizardsextension. Example:<extension point="org.eclipse.ui.newWizards"> <category id="com.your.plugin.wizard.category" name="My Plugins"/> <wizard id="com.your.plugin.wizard.custom_wizard" name="Custom Wizard" class="com.your.plugin.wizards.MyCustomWizard" category="com.your.plugin.wizard.category" icon="icons/wizban/custom_wiz.png"> </wizard> </extension>In your action class, ensure you’re fetching the wizard correctly:
public void run(IAction action) { IWizard wizard = PlatformUI.getWorkbench() .getNewWizardRegistry() .findWizard("com.your.plugin.wizard.custom_wizard"); if (wizard != null) { WizardDialog dialog = new WizardDialog(Display.getDefault().getActiveShell(), wizard); dialog.open(); } }Debug with logs and console output
Launch Eclipse with the-consoleLogflag to catch any runtime errors (like class not found exceptions or ID mismatches). Add debug print statements or use Eclipse’s logging framework in your action’srun()method to confirm if the action is even being triggered.Check Eclipse version compatibility
Some older Eclipse versions have known bugs with Active Help JS triggers. If you’re running an outdated release, try upgrading to the latest LTS version (e.g., 2023-09) to rule out version-specific issues.
If none of these steps resolve the problem, sharing snippets of your plugin.xml and the relevant HTML/JS code would help narrow down the root cause further.
内容的提问来源于stack exchange,提问作者Gionata

