Context Sensitive help for AbstractGraphicalEditPart(GMF)

93 views Asked by At

the problem is simple: To add Context Sensitive Help i followed the standard steps, but once i try to link the BLOCKS to the CONTEXT IDs with SetHelp() from IWorkbenchHelpSystem. The frist argument should be either a Control(swt) or IAction.
void setHelp(Control control, String helpContextId);. How can i refer to Control from a damos.dml.Block object type ? org.eclipselabs.damos.dml.blockTypes

FYI I've tried and visited all the content of these sites

The display and search methods are working correctly but I just need to set the help and not display it so that only upon calling Help (F1 or ctrl+F1) the context help is shown.

Thanks. After trying I thought maybe this workaround would get me the same result but 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;
}

Any help is appreciated!

1

There are 1 answers

2
AudioBubble On
   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";
        }

i have the possiblity to select a block type CTRL+F1 and voila the Help Definition of said Block is shown.