Bug 237816 - [api] restrictToSystemType does not work for RSEMainNewConnectionWizard
Summary: [api] restrictToSystemType does not work for RSEMainNewConnectionWizard
Status: RESOLVED FIXED
Alias: None
Product: Target Management
Classification: Tools
Component: RSE (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P4 minor (vote)
Target Milestone: 3.1 M3   Edit
Assignee: Uwe Stieber CLA
QA Contact: Martin Oberhuber CLA
URL:
Whiteboard:
Keywords: api
Depends on:
Blocks:
 
Reported: 2008-06-19 13:03 EDT by Jacob Garcowski CLA
Modified: 2008-11-12 13:20 EST (History)
2 users (show)

See Also:


Attachments
New Connection Wizard with restricted system types (12.88 KB, image/gif)
2008-06-20 04:55 EDT, Uwe Stieber CLA
no flags Details
Adds an interactive test case for reproducing the issue (13.99 KB, text/plain)
2008-07-06 10:56 EDT, Uwe Stieber CLA
no flags Details
mylyn/context/zip (1.81 KB, application/octet-stream)
2008-07-06 10:57 EDT, Uwe Stieber CLA
no flags Details
Patch to allow usage of new connection wizard embedded within another wizard (4.91 KB, patch)
2008-07-07 05:53 EDT, Uwe Stieber CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jacob Garcowski CLA 2008-06-19 13:03:43 EDT
If you call restrictToSystemType on a org.eclipse.rse.ui.wizards.newconnection.RSEMainNewConnectionWizard, the wizard will not be able to get past the first page.  The next button remains grayed out.
Comment 1 Uwe Stieber CLA 2008-06-20 04:54:24 EDT
Works perfect for me. See attached screenshot. However, you should not use RSEMainNewConnectionWizard directly. Much better is to open the new connection wizard, with or without restrictions, via the SystemNewConnectionAction. This action asures that the RSEMainNewConnectionWizard is handled correctly
Comment 2 Uwe Stieber CLA 2008-06-20 04:55:32 EDT
Created attachment 105476 [details]
New Connection Wizard with restricted system types
Comment 3 Martin Oberhuber CLA 2008-06-24 13:59:05 EDT
I agree with Uwe and think this request is invalid. Reopen if you disagree.
Comment 4 Jacob Garcowski CLA 2008-06-25 15:05:34 EDT
The problem seems to occur when you have an RseMainNewConnectionWizard that you want to restrict to a single system type.
Comment 5 Jacob Garcowski CLA 2008-06-25 15:28:17 EDT
To help define my situation better, I have an IWizardNode, and I want one of the wizards to create a connection, but be limited to a single connection type, which makes using the SystemNewConnectionAction problematic.
Comment 6 Martin Oberhuber CLA 2008-06-26 06:10:05 EDT
(In reply to comment #5)

As Uwe has shown, restricting to system type works fine in the wizard. Considering your IWizardNode situation, could it be that your problem really is that you're trying to triple-nest wizards here? RSEMainNewConnectionWizard is a wizard delegating to other wizards. Embedding that one as a delegate might be problematic.

Jacob, given that we can prove that restricting to System types works fine in "naked" standard RSE, I'm afraid we'll be only able to help you if you come up with some sample code that we can execute to reproduce your problem, or you debug it and attach a patch that fixes your problem.

For the sample code, you can do the simplest thing you can think of and attach a patch (e.g. create an additional toolbar button in rse.ui/plugin.xml that runs your code) - or, write a unit test.
Comment 7 Uwe Stieber CLA 2008-06-26 06:38:28 EDT
I'm still not fully understanding the use-case here.

Asuming you have your own wizard creating or doing whatever. This wizard should create an RSE connection as one of it's steps? If yes, why are you trying to embed the whole wizard UI including the system type selection page into your wizard?

You can either provide a button to create a new connection and the button is doing nothing else than opening a subwizard dialog via the SystemNewConnectionAction 

or

as you know the specific system type you should do what the SystemNewConnectionAction does

...
RSEMainNewConnectionWizard newConnWizard = new RSEMainNewConnectionWizard();
...
newConnWizard.restrictToSystemTypes(...);
...
if (newConnWizard.isRestrictedToSingleSystemType()) {
    IWizard wizard = newConnWizard.getSelectedWizard();
    if (wizard instanceof ISelectionChangedListener) {
        ((ISelectionChangedListener)wizard).selectionChanged(new SelectionChangedEvent(newConnWizard, newConnWizard.getSelection()));
    }
    return wizard;
}

and use the system type specific wizard directly. It doesn't make sense to use the system type selection page if there is only one system type to select.
Comment 8 Jacob Garcowski CLA 2008-06-26 10:00:29 EDT
Uwe, I agree with your second suggestion, since I do not need the selection page.  

However, there can still be a situation where someone does not know they will only have one connection type at compile time, and will want to use a wizard instead of an action, so I believe the bug is still valid.  I sadly do not have time at the moment to create a simple case in base RSE, but I will do so at a future time if needed.
Comment 9 Martin Oberhuber CLA 2008-06-26 10:14:59 EDT
Uwe has shown that "restrict to system type" works properly, at least when the Sample Code is used that we use in the SystemNewConnectionAction, and that Uwe also posted.

It might be necessary to manually update the selection or something like that.

Uwe, can you think of anything that we still have to do or is this request in fact INVALID?
Comment 10 Uwe Stieber CLA 2008-06-26 14:10:08 EDT
Martin, let's give Jacob a chance to make his case. He decreased the severity to minor already and I've set priority to P4 now. Leave it assigned to me and I'll try to solve it with him. I haven't much time either, but I can give it a try to construct a case based on Jacobs information. I remember that handling a single wizard within the selection page had been difficult, mainly because the user do no require to click on the system type as, if I'm not mistaken, the system type is preselected. I try to reserve some time for it as soon as I can. Deal?
Comment 11 Martin Oberhuber CLA 2008-06-26 14:19:16 EDT
Thanks Uwe. Though I still think that Jacob is the next actor, so I don't see any urgency for this before we get more information. Deal!
Comment 12 Uwe Stieber CLA 2008-07-06 10:56:59 EDT
Created attachment 106663 [details]
Adds an interactive test case for reproducing the issue

The patch adds a new interactive test suite which is opening a wizard having a page allowing for very simple system type selection. Once a system type is selected, the user can advance to the next page, which is the standard RSE new connection system type selection page backed up by a standard RSEMainNewConnectionWizard instance. If the user switches to the second page, the next and the finish buttons will not be activated.

Jacob: Can you please confirm that this is exactly what you see and the test case is matching your approach?
Comment 13 Uwe Stieber CLA 2008-07-06 10:57:03 EDT
Created attachment 106664 [details]
mylyn/context/zip
Comment 14 Uwe Stieber CLA 2008-07-06 11:15:36 EDT
Hi Jacob,
you can very easely workaround the issue on your end. After the line where you restrict the system type to the main wizard add the initialization of the wizard pages.

...
				fMainWizard.restrictToSystemType(<the single system type instance>);
				// Initialize the pages of the selected wizard
				if (fMainWizard.getSelectedWizard() != null && fMainWizard.getSelectedWizard().getStartingPage() == null) {
					fMainWizard.getSelectedWizard().addPages();
				}
...

I even tend to believe that this is the correct usage anyway. Having the standard RSE new connection selection wizard page and the RSE main new connection wizard embedded within another wizard is a kind of special case. The requirement which causes the issue is that if the RSE new connection wizard is restricted to a single type, the main selection page shall _not_ be shown as this page will add nothing useful to the user. If restricted to a single system type, we open the new connection wizard directly with the first page of the system type specific new connection wizard.

For fixing the issue to make it work without above workaround, we will have to detect that the main RSE new connection system type selection page isn't the first page shown by the enclosing wizard dialog. Not yet checked on this if we can get this information.
Comment 15 Uwe Stieber CLA 2008-07-07 05:53:14 EDT
Created attachment 106702 [details]
Patch to allow usage of new connection wizard embedded within another wizard

- Fixed the issue within RSEMainNewConnectionWizard and call selectedWizard.addPages() if the system type selection page isn't the first page.
- Fixed an issue within the system type selection page which failed to refresh the tree content if the restricted system type changed
- Fixed an issue within the system type selection page which failed to update the initial selection if the restricted system type changed. This fix introduce a new API method, therefor the patch can be applied to the 3.1 branch only.
Comment 16 Uwe Stieber CLA 2008-10-11 11:43:18 EDT
Applied and retested applied patches.
Comment 17 Martin Oberhuber CLA 2008-11-12 13:20:52 EST
Fix involved an API addition:
RSENewConnectionWizardSelectionPage#initializeSelection(TreeViewer)