diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/RSEMainNewConnectionWizard.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/RSEMainNewConnectionWizard.java
index d89f528eb9e..a23dfc64642 100644
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/RSEMainNewConnectionWizard.java
+++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/RSEMainNewConnectionWizard.java
@@ -23,6 +23,7 @@
package org.eclipse.rse.ui.wizards.newconnection;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
@@ -147,6 +148,14 @@ public class RSEMainNewConnectionWizard extends Wizard implements INewWizard, IS
restrictedSystemTypes = systemTypes;
onlySystemType = restrictedSystemTypes.length == 1;
mainPage.restrictToSystemTypes(restrictedSystemTypes);
+
+ if (onlySystemType && !restrictedSystemTypes[0].equals(selectedSystemType))
+ selectedSystemType = restrictedSystemTypes[0];
+ else if (restrictedSystemTypes.length > 0 && !Arrays.asList(restrictedSystemTypes).contains(selectedSystemType))
+ selectedSystemType = null;
+ else if (restrictedSystemTypes.length == 0)
+ selectedSystemType = null;
+
onSelectedSystemTypeChanged();
}
@@ -329,7 +338,7 @@ public class RSEMainNewConnectionWizard extends Wizard implements INewWizard, IS
// Note: Do not call IWizard.addPages() here in case the main wizard is restricted to
// a single system type. The IWizard.addPages() method will be called from the
// enclosing wizard dialog directly instead!
- if (!onlySystemType && selectedWizard != null && !initializedWizards.contains(selectedWizard)) {
+ if ((!onlySystemType || mainPage.getPreviousPage() != null) && selectedWizard != null && !initializedWizards.contains(selectedWizard)) {
selectedWizard.addPages();
initializedWizards.add(selectedWizard);
}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/RSENewConnectionWizardSelectionPage.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/RSENewConnectionWizardSelectionPage.java
index 9d6a1b60d79..3957bf76549 100644
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/RSENewConnectionWizardSelectionPage.java
+++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/RSENewConnectionWizardSelectionPage.java
@@ -263,7 +263,26 @@ public class RSENewConnectionWizardSelectionPage extends WizardPage {
// before initializing the selection.
restoreWidgetValues();
+ // Initialize the tree selection
+ initializeSelection(treeViewer);
+
// Initialize the selection in the tree
+ filteredTree.getFilterControl().setFocus();
+
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), helpId);
+
+ }
+
+ /**
+ * Set the initial tree selection for the given tree viewer instance.
+ *
+ * @param treeViewer The tree viewer instance.
+ *
+ * @since 3.1
+ */
+ protected void initializeSelection(TreeViewer treeViewer) {
+ if (treeViewer == null) return;
+
if (getWizard() instanceof ISelectionProvider) {
ISelectionProvider selectionProvider = (ISelectionProvider)getWizard();
if (selectionProvider.getSelection() instanceof IStructuredSelection) {
@@ -275,14 +294,9 @@ public class RSENewConnectionWizardSelectionPage extends WizardPage {
}
}
}
-
- // we put the initial focus into the filter field
- filteredTree.getFilterControl().setFocus();
-
- PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), helpId);
-
+
}
-
+
/**
* Called from the selection listener to propage the current
* system type selection to the underlaying wizard.
@@ -338,6 +352,12 @@ public class RSENewConnectionWizardSelectionPage extends WizardPage {
// if the page will become hidden, save the expansion state of
// the tree elements.
if (!visible) saveWidgetValues();
+ // If the page will become visible, refresh the viewer
+ // content -> The listed system types might have changed.
+ else if (filteredTree != null && filteredTree.getViewer() != null) {
+ filteredTree.getViewer().refresh();
+ initializeSelection(filteredTree.getViewer());
+ }
}
/**
diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/RSETestsResources.properties b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/RSETestsResources.properties
index e5d3667bd5d..465dfb7a4c1 100644
--- a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/RSETestsResources.properties
+++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/RSETestsResources.properties
@@ -37,6 +37,8 @@ TestSubsystemTestCase.testAddAndDeleteDeepNodes=true
TestSubsystemTestCase.testAddAndDeleteFlatNodes=true
TestSubsystemTestCase.testBugzilla170728=true
+RSENewConnectionWizardTestCase.testRestrictToSystemType=true
+
#
# The following section controls enablement of test cases by target or client platform.
# Uncomment a line to disable running unit tests on the specified target connection.
diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/ui/connectionwizard/RSENewConnectionWizardTestCase.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/ui/connectionwizard/RSENewConnectionWizardTestCase.java
new file mode 100644
index 00000000000..b0889668c6a
--- /dev/null
+++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/ui/connectionwizard/RSENewConnectionWizardTestCase.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Uwe Stieber (Wind River) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.rse.tests.ui.connectionwizard;
+
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.rse.core.IRSECoreRegistry;
+import org.eclipse.rse.core.RSECorePlugin;
+import org.eclipse.rse.tests.RSETestsPlugin;
+import org.eclipse.rse.tests.core.RSECoreTestCase;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * Tests the RSE new connection wizard functionality.
+ *
+ * @author uwe.stieber@windriver.com
+ */
+public class RSENewConnectionWizardTestCase extends RSECoreTestCase {
+
+ /* Test restrictToSystemType functionality. See bug 237816 */
+ public void testRestrictToSystemType() {
+ //-test-author-:UweStieber
+ if (!RSETestsPlugin.isTestCaseEnabled("RSENewConnectionWizardTestCase.testRestrictToSystemType")) return; //$NON-NLS-1$
+
+ IRSECoreRegistry coreRegistry = RSECorePlugin.getTheCoreRegistry();
+ assertNotNull("Failed to fetch RSE core registry instance!", coreRegistry); //$NON-NLS-1$
+
+ // Construct the wizard
+ RSENewConnectionWizardTestWizard wizard = new RSENewConnectionWizardTestWizard();
+
+ WizardDialog dialog = new WizardDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), wizard);
+ dialog.open();
+ }
+}
diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/ui/connectionwizard/RSENewConnectionWizardTestSimpleWizardPage.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/ui/connectionwizard/RSENewConnectionWizardTestSimpleWizardPage.java
new file mode 100644
index 00000000000..a67e0d8e2b0
--- /dev/null
+++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/ui/connectionwizard/RSENewConnectionWizardTestSimpleWizardPage.java
@@ -0,0 +1,144 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Uwe Stieber (Wind River) - initial API and implementation.
+ *******************************************************************************/
+package org.eclipse.rse.tests.ui.connectionwizard;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.rse.core.IRSECoreRegistry;
+import org.eclipse.rse.core.IRSESystemType;
+import org.eclipse.rse.core.RSECorePlugin;
+import org.eclipse.rse.ui.wizards.newconnection.RSEMainNewConnectionWizard;
+import org.eclipse.rse.ui.wizards.newconnection.RSENewConnectionWizardRegistry;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.List;
+
+/**
+ * Simple wizard page listing the available system types in a simple text list.
+ *
+ * @author uwe.stieber@windriver.com
+ */
+public class RSENewConnectionWizardTestSimpleWizardPage extends WizardPage {
+ private List fList;
+ private IRSESystemType[] fSystemTypes;
+ RSEMainNewConnectionWizard fMainWizard;
+ /**
+ * Constructor.
+ *
+ * @param wizardRegistry The wizard registry to use. Must not be null
+ * @param pageName the name of the page
+ */
+ public RSENewConnectionWizardTestSimpleWizardPage(RSENewConnectionWizardRegistry wizardRegistry, String pageName) {
+ super(pageName);
+ assert wizardRegistry != null;
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param wizardRegistry The wizard registry to use. Must not be null
+ * @param pageName the name of the page
+ * @param title the title for this wizard page,
+ * or null
if none
+ * @param titleImage the image descriptor for the title of this wizard page,
+ * or null
if none
+ */
+ public RSENewConnectionWizardTestSimpleWizardPage(RSENewConnectionWizardRegistry wizardRegistry, String pageName, String title, ImageDescriptor titleImage) {
+ super(pageName, title, titleImage);
+ assert wizardRegistry != null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.DialogPage#dispose()
+ */
+ public void dispose() {
+ fSystemTypes = null;
+
+ fList = null;
+
+ if (fMainWizard != null) { fMainWizard.dispose(); fMainWizard = null; }
+
+ super.dispose();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createControl(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayout(new GridLayout());
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+ setControl(composite);
+
+ fList = new List(composite, SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL | SWT.H_SCROLL);
+ fList.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ IRSECoreRegistry coreRegistry = RSECorePlugin.getTheCoreRegistry();
+ fSystemTypes = coreRegistry.getSystemTypes();
+ for (int i = 0; i < fSystemTypes.length; i++) {
+ fList.add(fSystemTypes[i].getLabel());
+ }
+
+ fList.addSelectionListener(new SelectionAdapter() {
+ /* (non-Javadoc)
+ * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ public void widgetSelected(SelectionEvent e) {
+ // Update the main wizard if already created
+ if (fMainWizard != null && getSelectedSystemType() != null) fMainWizard.restrictToSystemType(getSelectedSystemType());
+ setPageComplete(getSelectedSystemType() != null);
+ }
+ });
+
+ setPageComplete(false);
+ }
+
+ /**
+ * Returns the selected system type instance. This method will
+ * return null
if the page hasn't been visible yet or
+ * got already disposed.
+ *
+ * @return The selected RSE system type instance or null
.
+ */
+ public IRSESystemType getSelectedSystemType() {
+ if (fList != null && !fList.isDisposed() && fList.getSelectionIndex() != -1) {
+ return fSystemTypes[fList.getSelectionIndex()];
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.wizard.WizardPage#canFlipToNextPage()
+ */
+ public boolean canFlipToNextPage() {
+ return super.canFlipToNextPage() && (fList != null && !fList.isDisposed() && fList.getSelectionIndex() != -1);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.wizard.WizardPage#getNextPage()
+ */
+ public IWizardPage getNextPage() {
+ if (fMainWizard == null) {
+ // Create a new instance
+ fMainWizard = new RSEMainNewConnectionWizard();
+ // Create the pages
+ fMainWizard.addPages();
+ // Restrict the wizard to the selected system type
+ if (getSelectedSystemType() != null) fMainWizard.restrictToSystemType(getSelectedSystemType());
+ }
+ return fMainWizard.getStartingPage();
+ }
+}
diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/ui/connectionwizard/RSENewConnectionWizardTestSuite.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/ui/connectionwizard/RSENewConnectionWizardTestSuite.java
new file mode 100644
index 00000000000..2110419dde2
--- /dev/null
+++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/ui/connectionwizard/RSENewConnectionWizardTestSuite.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Uwe Stieber (Wind River) - initial API and implementation.
+ *******************************************************************************/
+package org.eclipse.rse.tests.ui.connectionwizard;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.eclipse.rse.tests.framework.DelegatingTestSuiteHolder;
+
+public class RSENewConnectionWizardTestSuite extends DelegatingTestSuiteHolder {
+ /**
+ * Standard Java application main method. Allows to launch the test
+ * suite from outside as part of nightly runs, headless runs or other.
+ *
Note: Use only junit.textui.TestRunner
here as
+ * it is explicitly supposed to output the test output to the shell the
+ * test suite has been launched from.
+ *
+ * @param args The standard Java application command line parameters passed in. + */ + public static void main(String[] args) { + junit.textui.TestRunner.run(suite()); + } + + /** + * Combine all test into a suite and returns the test suite instance. + *
+ * Note: This method must be always called suite
! Otherwise
+ * the JUnit plug-in test launcher will fail to detect this class!
+ *
+ * @return The test suite instance. + */ + public static Test suite() { + TestSuite suite = new TestSuite("RSE Registries Test Suite"); //$NON-NLS-1$ + // add the single test suites to the overall one here. + suite.addTestSuite(RSENewConnectionWizardTestCase.class); + + return suite; + } + + /* (non-Javadoc) + * @see org.eclipse.rse.tests.framework.AbstractTestSuiteHolder#getTestSuite() + */ + public TestSuite getTestSuite() { + return (TestSuite)RSENewConnectionWizardTestSuite.suite(); + } + +} diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/ui/connectionwizard/RSENewConnectionWizardTestWizard.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/ui/connectionwizard/RSENewConnectionWizardTestWizard.java new file mode 100644 index 00000000000..3c9401eba2f --- /dev/null +++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/ui/connectionwizard/RSENewConnectionWizardTestWizard.java @@ -0,0 +1,62 @@ +/******************************************************************************* + * Copyright (c) 2008 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Uwe Stieber (Wind River) - initial API and implementation + *******************************************************************************/ + +package org.eclipse.rse.tests.ui.connectionwizard; + +import org.eclipse.jface.wizard.Wizard; +import org.eclipse.rse.ui.wizards.newconnection.RSENewConnectionWizardRegistry; + +/** + * Simple test wizard implementation. + * + * @author uwe.stieber@windriver.com + */ +public class RSENewConnectionWizardTestWizard extends Wizard { + private final RSENewConnectionWizardRegistry fWizardRegisty; + + /** + * Constructor. + * + */ + public RSENewConnectionWizardTestWizard() { + super(); + + fWizardRegisty = new RSENewConnectionWizardRegistry(); + + setNeedsProgressMonitor(false); + setForcePreviousAndNextButtons(true); + } + + /** + * Returns the RSE new connection wizard registry instance. + * + * @return The new connection wizard registry. + */ + public RSENewConnectionWizardRegistry getWizardRegistry() { + return fWizardRegisty; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.wizard.Wizard#addPages() + */ + public void addPages() { + addPage(new RSENewConnectionWizardTestSimpleWizardPage(getWizardRegistry(), "Simple Selection Page")); //$NON-NLS-1$ + } + + /* (non-Javadoc) + * @see org.eclipse.jface.wizard.Wizard#performFinish() + */ + public boolean performFinish() { + return true; + } + + +}