简体   繁体   中英

How to show context help when view is showed in eclipse RCP

I have created my own tool in my eclipse RCP application. When tool is activated the specific view is opened and when I pressed F1 button I want to show an dynamic help.

I set my context.xml and in my View's createPartControl function I have this line:

    PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, "lineer.udig.tools.yoltool.bufferView.myId"); 

"lineer.udig.tools.yoltool.bufferView" is my view ID and "myId" is my context-id <context id="myId"> in context.xml.

When I selected my tool, view is opening and when I click any textBox on this view and press F1 , dynamic help works.

However, I want to show this help anywhere on this view without click textBox or comboBox.

function createPartControl is taking parameter of "Composite parent"

public void createPartControl(Composite parent) {
     ..
     ..
}

So if we make the composite a private variable private Composite parent; then in function

public void createPartControl(Composite parent) {
     ..
     this.parent = parent;
}

And at the end of the class we need to add these two lines to setFocus() function.

    public void setFocus() {
        // TODO Auto-generated method stub
           if(parent != null) // NEW
               parent.setFocus(); // NEW

    }

So after these modifications, our dynamic help works automatically when the view is activated.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM