0

问题很简单:要添加上下文相关帮助,我遵循标准步骤,但是一旦我尝试使用 IWorkbenchHelpSystem 中的 SetHelp() 将块链接到上下文 ID。第一个参数应该是 Control(swt) 或 IAction。
void setHelp(控制控件,字符串 helpContextId);。如何从 damos.dml.Block 对象类型中引用 Control? org.eclipselabs.damos.dml.blockTypes

仅供参考,我已经尝试并访问了这些网站的所有内容

显示和搜索方法工作正常,但我只需要设置帮助而不显示它,这样只有在调用帮助(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;
}

任何帮助表示赞赏!

4

1 回答 1

0
   public String getSelection() {
            String blockName = "SelectBlock";
            EObject element = null;
            EditPart part = getDiagramEditPart();
            EditPartViewer viewer = part.getViewer();
            List selectedList = viewer.getSelectedEditParts();
            try {
                GraphicalEditPart editPart = (GraphicalEditPart) selectedList.get(0);
                BlockEditPart blockPart = (BlockEditPart) editPart;
                viewer.getProperty("BlockFigure");
                NodeImpl node = (NodeImpl) blockPart.getModel();
                element = node.getElement();
            } catch (IndexOutOfBoundsException e) {
                // TODO: handle exception
                e.printStackTrace();
            }

            ISelection selection1 = viewer.getSelection();// EURêKA

            if (element instanceof Block) {
                Control control2 = getGraphicalViewer().getControl();
                blockName = ((Block) element).getType().getName();
                return blockName;
                // return part.getParent().getSelected();
            }
            return "SelectBlock";
        }

我可以选择一个块类型 CTRL+F1 并且瞧,显示了该块的帮助定义。

于 2020-02-25T16:15:34.753 回答