Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 421485

Summary: [Wizards] Wrong help context for the New Wizards when focus is on the Next/Prev buttons (based on the NewWizardAction)
Product: [Eclipse Project] Platform Reporter: ALOK MANJREKAR <alokmanjrekar>
Component: UIAssignee: Platform UI Triaged <platform-ui-triaged>
Status: CLOSED WONTFIX QA Contact:
Severity: major    
Priority: P3 CC: daniel_megert
Version: 4.2   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard: stalebug

Description ALOK MANJREKAR CLA 2013-11-11 16:08:25 EST
The WizardDialog class adds a HelpListener implementation on the Shell. This listener implementation relies on the current wizard Page to perform Help.

However, the NewWizardAction's run implementation adds another HelpListener on the shell of the WizardDialog instance that it creates.
The following line adds the Help Listener
 PlatformUI.getWorkbench().getHelpSystem().setHelp(dialog.getShell(),
				IWorkbenchHelpContextIds.NEW_WIZARD);

The value of IWorkbenchHelpContextIds.NEW_WIZARD is "org.eclipse.ui.new_wizard_context"

When the end user is working with a NewWizard, and he launches Help on any of the wizard pages within the NewWizard, with the focus being on the Next or Back, then both the HelpListeners added on the Shell of the wizard dialog get trigerred in the following order
1) Help Listener added within the configure Shell implementation of Wizard Dialog (This is the correct one that allows the wizard page to perform help)
2) Help Listener added by the NewWizardAction. This launches help with the context id "org.eclipse.ui.new_wizard_context".

Therefore, the end result is that the HelpSystem tries to invoke Help with the context id "org.eclipse.ui.new_wizard_context". 
This is wrong, since the help is not context sensitive based on the currently active wizard page, which would have been the expected behaviour.
Also, our RCP product does not ship documentation for the context id "org.eclipse.ui.new_wizard_context", since this is an internal eclipse help content which we do not want to expose in our product.

This issue needs to be fixed for NewWizards in the RCP products to have wizard page specific context help, when the focus in on the next/prev buttons of the wizard page.
Comment 1 Paul Webster CLA 2013-11-12 20:02:16 EST
They can get help from Help>Help Contents, so there is a workaround and no data loss.

PW
Comment 2 ALOK MANJREKAR CLA 2013-11-13 00:49:30 EST
Hello Paul,
Yes - Help from Help-> Help Contents would work. But that would need the user to search for it.
Launching the appropriate help from the new-wizard would save a lot of time. 

Our documentation team was kind of keen that we somehow address this issue. Since we would be releasing our product next month with eclipse 4.2, which would not have this fix, what do you think is the best way to address this issue?

I was wondering if we add the following piece of code within our wizardPage implementations for the time being until this issue is addressed within the eclipse platform


	public void setVisible(boolean visible) {
		super.setVisible(visible);
		// This is to address INFA368369 - which is an eclipse issue
		if(visible) {
		PlatformUI.getWorkbench().getHelpSystem().setHelp(getShell(), HELP_CONTEXT_ID);
		}
	}

What do you think of this workaround? If not, do you suggest any other approach?

Also - do you know which eclipse release can we expect this to be addressed?
Comment 3 Dani Megert CLA 2013-11-13 08:15:18 EST
Same problem in 3.x and 'NewWizardShortcutAction' has the same issue.


(In reply to ALOK MANJREKAR from comment #2)
> I was wondering if we add the following piece of code within our wizardPage
> implementations for the time being until this issue is addressed within the
> eclipse platform
> 
> 
> 	public void setVisible(boolean visible) {
> 		super.setVisible(visible);
> 		// This is to address INFA368369 - which is an eclipse issue
> 		if(visible) {
> 		PlatformUI.getWorkbench().getHelpSystem().setHelp(getShell(),
> HELP_CONTEXT_ID);
> 		}
> 	}
> 
> What do you think of this workaround? 

This will be too early i.e. it will be overwritten by the action.


> If not, do you suggest any other approach?

Note the nicest code, but it should do the trick: add the following code to WizardPage.setControl(Control):

final Shell shell= getShell();
shell.getDisplay().asyncExec(new Runnable() {
    public void run() {
        if (!shell.isDisposed())
            PlatformUI.getWorkbench().getHelpSystem().setHelp(shell, helpId);
    }
});
Comment 4 ALOK MANJREKAR CLA 2013-11-13 12:16:13 EST
Hi Dani,

Thanks for looking at this.
I tried the approach to override setVisible() of the wizardPage in a couple of places, and it seems to be working fine.

You have mentioned that 
"This will be too early i.e. it will be overwritten by the action."

It is actually not too early. SetVisible() of the WizardPage is called only when the wizardpage is about to show.
The NewWizardAction sets the hardcode helpID on the shell of the WizardDialog before calling open() on it. So, it would definitely be called before the setVisible() of the WizardPage.
I believe doing the workaround in the setVisible() of the WizardPage will not be too early, and should work.

Could you please have a look again and confirm my understanding?
Comment 5 Dani Megert CLA 2013-11-14 04:22:23 EST
(In reply to ALOK MANJREKAR from comment #4)
> Hi Dani,
> 
> Thanks for looking at this.
> I tried the approach to override setVisible() of the wizardPage in a couple
> of places, and it seems to be working fine.
> 
> You have mentioned that 
> "This will be too early i.e. it will be overwritten by the action."
> 
> It is actually not too early. SetVisible() of the WizardPage is called only
> when the wizardpage is about to show.
> The NewWizardAction sets the hardcode helpID on the shell of the
> WizardDialog before calling open() on it. So, it would definitely be called
> before the setVisible() of the WizardPage.
> I believe doing the workaround in the setVisible() of the WizardPage will
> not be too early, and should work.
> 
> Could you please have a look again and confirm my understanding?

Your understanding is wrong, at least when it comes to the first wizard page. The first page is created (and made visible) when the wizard dialog is created. This happens before the helpId is set in the action.
Comment 6 ALOK MANJREKAR CLA 2013-11-15 14:58:38 EST
I see what you mean.

But the suggestion that you gave
**************************************
Note the nicest code, but it should do the trick: add the following code to WizardPage.setControl(Control):

final Shell shell= getShell();
shell.getDisplay().asyncExec(new Runnable() {
    public void run() {
        if (!shell.isDisposed())
            PlatformUI.getWorkbench().getHelpSystem().setHelp(shell, helpId);
    }
});
***************************************

I assume you meant over-riding the setControl() in the wizardPage implementation to add the above logic.

The setControl() of the wizardPage gets called even before setVisible(). 
So if setVisible() is too early, then setControl() would be even earlier and will not work.

Any other suggestions?
Comment 7 ALOK MANJREKAR CLA 2013-11-15 15:18:34 EST
Btw .. Just to add to my previous comment .. Would this original bug which appears when NewWizardAction is used be fixed in the next eclipse release?

I noticed that we use NewWizardAction, only when there are multiple items involved in a category.
So the first page that gets shown is a generic page that lists the items in the category. 
The actual wizard pages are created only when the "Next" is activated on the initial generic wizard page. 
So the workaround that we have to add the extra logic inside "setVisible" should still work fine. 

Since setControl() of wizardPage gets called even before setVisible(), adding the logic in setControl() doesnt seem like a better solution at the moment.

What do you think?
Comment 8 Dani Megert CLA 2013-11-18 10:43:55 EST
(In reply to ALOK MANJREKAR from comment #7)
> Btw .. Just to add to my previous comment .. Would this original bug which
> appears when NewWizardAction is used be fixed in the next eclipse release?

No one is working on that.
Comment 9 Eclipse Genie CLA 2020-01-15 19:55:03 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.