问题很简单:要添加上下文相关帮助,我遵循标准步骤,但是一旦我尝试使用 IWorkbenchHelpSystem 中的 SetHelp() 将块链接到上下文 ID。第一个参数应该是 Control(swt) 或 IAction。
void setHelp(控制控件,字符串 helpContextId);。如何从 damos.dml.Block 对象类型中引用 Control?
org.eclipselabs.damos.dml.blockTypes
仅供参考,我已经尝试并访问了这些网站的所有内容
- http://rajakannappan.blogspot.com/2009/05/context-sensitive-help-in-eclipse.html
- https://help.eclipse.org/2019-03/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Fguide%2Fua_help_context.htm&cp=2_0_19_1_2
- https://help.eclipse.org/luna/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fextension-points%2Forg_eclipse_ui_commands.html
显示和搜索方法工作正常,但我只需要设置帮助而不显示它,这样只有在调用帮助(F1 或 ctrl+F1)时才会显示上下文帮助。
谢谢。在尝试之后,我认为这种解决方法可能会得到相同的结果,但 NADA。
private Block getBlock() {
EObject semanticElement = resolveSemanticElement();
if (semanticElement instanceof Block) {
Block block = (Block) semanticElement;
PlatformUI.getWorkbench().getHelpSystem().search(block.getType().getName());
//PlatformUI.getWorkbench().getHelpSystem().setHelp(?, Activator.HELP_VIEW); Cannot cast block directly to Control
PlatformUI.getWorkbench().getHelpSystem().displayHelp(Activator.HELP_VIEW);
return block;
} else {
return null;
}
}
@Override
protected NodeFigure createMainFigure() {
blockFigure = new BlockFigure();
// OB: java.awt.event.KeyEvent.VK_F1 is wrong, use SWT.F1
blockFigure.setFocusTraversable(true);
blockFigure.setRequestFocusEnabled(true);
blockFigure.addMouseListener(new MouseListener.Stub() {
@Override
public void mousePressed(final MouseEvent me) {
blockFigure.requestFocus();
}
});
blockFigure.addKeyListener(new KeyListener.Stub() {
@Override
public void keyReleased(KeyEvent ke) {
}
@Override
public void keyPressed(KeyEvent ke) {
if (ke.keycode == SWT.F1) {
PlatformUI.getWorkbench().getHelpSystem().search(getBlock().getType().getName());
PlatformUI.getWorkbench().getHelpSystem().displayHelp(Activator.HELP_VIEW);
}
}
});
return blockFigure;
}
任何帮助表示赞赏!