diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/actions/SystemNewConnectionAction.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/actions/SystemNewConnectionAction.java
index a048cff6617..be703c84a06 100644
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/actions/SystemNewConnectionAction.java
+++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/actions/SystemNewConnectionAction.java
@@ -18,6 +18,8 @@ package org.eclipse.rse.ui.actions;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.rse.core.IRSESystemType;
+import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.subsystems.ISubSystem;
import org.eclipse.rse.filters.ISystemFilterPoolReference;
import org.eclipse.rse.filters.ISystemFilterReference;
@@ -109,8 +111,16 @@ public class SystemNewConnectionAction extends SystemBaseWizardAction
}
// newConnWizard.setCurrentlySelectedConnection(currConn);
- // if (restrictSystemTypesTo != null)
- // newConnWizard.restrictSystemTypes(restrictSystemTypesTo);
+ if (restrictSystemTypesTo != null) {
+
+ IRSESystemType[] systemTypes = new IRSESystemType[restrictSystemTypesTo.length];
+ for (int i = 0; i < restrictSystemTypesTo.length; i++) {
+ systemTypes[i] = RSECorePlugin.getDefault().getRegistry().getSystemType(restrictSystemTypesTo[i]);
+ }
+
+ newConnWizard.restrictToSystemTypes(systemTypes);
+ }
+
// if (defaultHostName != null)
// newConnWizard.setHostName(defaultHostName);
// if (defaultConnectionName != null)
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/IRSENewConnectionWizard.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/IRSENewConnectionWizard.java
index 7436cef7093..be31bc032e3 100644
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/IRSENewConnectionWizard.java
+++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/IRSENewConnectionWizard.java
@@ -22,8 +22,29 @@ import org.eclipse.ui.INewWizard;
public interface IRSENewConnectionWizard extends INewWizard {
public static final String NEW_CONNECTION_WIZARD_DELEGATE_EXTENSION_POINT_ID = "org.eclipse.rse.ui.newConnectionWizardDelegate";
+ public static final String NEW_CONNECTION_WIZARD_DELEGATE_EXTENSION_CONFIG_NAME = "newConnectionWizardDelegate";
+ public static final String NEW_CONNECTION_WIZARD_DELEGATE_EXTENSION_CONFIG_ATTRIBUTE_SYSTEMTYPE = "systemType";
+ public static final String NEW_CONNECTION_WIZARD_DELEGATE_EXTENSION_CONFIG_ATTRIBUTE_CLASS = "class";
public IRSENewConnectionWizardDelegate getDelegate();
- public void setSystemType(IRSESystemType systemType, boolean initWithSystemType);
+ /**
+ * Restrict system types. Users will only be able to choose from the given system types.
+ * @param systemTypes the system types to restrict to.
+ */
+ public void restrictToSystemTypes(IRSESystemType[] systemTypes);
+
+ /**
+ * Restrict to a single system type. Users will not be shown the system type selection page in
+ * the wizard.
+ * @param systemType the system type to restrict to.
+ */
+ public void restrictToSystemType(IRSESystemType systemType);
+
+ /**
+ * Sets the system type that was selected in the wizard. This will only be called if the wizard
+ * shows the system type selection page, i.e. if the wizard is not restricted to a single system type.
+ * @param systemType the system type.
+ */
+ public void setSelectedSystemType(IRSESystemType systemType);
}
\ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/IRSENewConnectionWizardDelegate.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/IRSENewConnectionWizardDelegate.java
index 606d06ba143..ef9f304cc4b 100644
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/IRSENewConnectionWizardDelegate.java
+++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/IRSENewConnectionWizardDelegate.java
@@ -27,6 +27,8 @@ public interface IRSENewConnectionWizardDelegate {
public void init(RSENewConnectionWizard wizard, IRSESystemType systemType);
+ public boolean isInitialized();
+
public void systemTypeChanged(IRSESystemType systemType);
public RSENewConnectionWizard getWizard();
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/RSENewConnectionWizard.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/RSENewConnectionWizard.java
index 4bf45248d7b..4389cf91b29 100644
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/RSENewConnectionWizard.java
+++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/RSENewConnectionWizard.java
@@ -18,29 +18,30 @@ package org.eclipse.rse.ui.wizards;
import java.util.HashMap;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.rse.core.IRSESystemType;
+import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.ui.ISystemIconConstants;
import org.eclipse.rse.ui.RSEUIPlugin;
import org.eclipse.rse.ui.SystemResources;
/**
- *
- */
-/**
- * @author kmunir
- *
+ * The New Connection wizard. This wizard allows users to create new RSE connections.
*/
public class RSENewConnectionWizard extends AbstractSystemWizard implements IRSENewConnectionWizard {
private HashMap map;
private IRSESystemType systemType;
- private boolean initWithSystemType;
private IRSENewConnectionWizardDelegate delegate;
private RSENewConnectionWizardMainPage mainPage;
+ private IRSESystemType[] restrictedSystemTypes;
+ private boolean onlySystemType;
+ private IRSENewConnectionWizardDelegate defaultDelegate;
+ private boolean defaultDelegateCreated;
/**
* Constructor.
@@ -51,13 +52,35 @@ public class RSENewConnectionWizard extends AbstractSystemWizard implements IRSE
setForcePreviousAndNextButtons(true);
setNeedsProgressMonitor(true);
}
-
+
/**
- * @see org.eclipse.rse.ui.wizards.IRSENewConnectionWizard#setSystemType(org.eclipse.rse.core.IRSESystemType)
+ * @see org.eclipse.rse.ui.wizards.IRSENewConnectionWizard#restrictToSystemType(org.eclipse.rse.core.IRSESystemType)
*/
- public void setSystemType(IRSESystemType systemType, boolean initWithSystemType) {
+ public void restrictToSystemType(IRSESystemType systemType) {
+ IRSESystemType[] types = new IRSESystemType[1];
+ types[0] = systemType;
+ restrictToSystemTypes(types);
+ }
+
+ /**
+ * @see org.eclipse.rse.ui.wizards.IRSENewConnectionWizard#restrictToSystemTypes(org.eclipse.rse.core.IRSESystemType[])
+ */
+ public void restrictToSystemTypes(IRSESystemType[] systemTypes) {
+ this.restrictedSystemTypes = systemTypes;
+
+ if (systemTypes.length == 1) {
+ this.onlySystemType = true;
+ }
+ else {
+ this.onlySystemType = false;
+ }
+ }
+
+ /**
+ * @see org.eclipse.rse.ui.wizards.IRSENewConnectionWizard#setSelectedSystemType(org.eclipse.rse.core.IRSESystemType)
+ */
+ public void setSelectedSystemType(IRSESystemType systemType) {
this.systemType = systemType;
- this.initWithSystemType = initWithSystemType;
setDelegate(systemType);
}
@@ -67,6 +90,37 @@ public class RSENewConnectionWizard extends AbstractSystemWizard implements IRSE
private void readWizardDelegateExtensions() {
IExtensionRegistry registry = Platform.getExtensionRegistry();
IConfigurationElement[] elements = registry.getConfigurationElementsFor(NEW_CONNECTION_WIZARD_DELEGATE_EXTENSION_POINT_ID);
+
+ for (int i = 0; i < elements.length; i++) {
+ IConfigurationElement element = elements[0];
+
+ if (element.getName().equals(NEW_CONNECTION_WIZARD_DELEGATE_EXTENSION_CONFIG_NAME)) {
+ String systemTypeID = element.getAttribute(NEW_CONNECTION_WIZARD_DELEGATE_EXTENSION_CONFIG_ATTRIBUTE_SYSTEMTYPE);
+ Object obj = null;
+
+ try {
+ obj = element.createExecutableExtension(NEW_CONNECTION_WIZARD_DELEGATE_EXTENSION_CONFIG_ATTRIBUTE_CLASS);
+
+ if (obj instanceof IRSENewConnectionWizardDelegate) {
+
+ if (map == null) {
+ map = new HashMap();
+ }
+
+ if (!map.containsKey(systemTypeID)) {
+ map.put(systemTypeID, obj);
+ }
+ }
+ else {
+ continue;
+ }
+ }
+ catch (CoreException e) {
+ RSEUIPlugin.logError("Class " + obj + " is not executable extension", e);
+ continue;
+ }
+ }
+ }
}
/**
@@ -80,11 +134,22 @@ public class RSENewConnectionWizard extends AbstractSystemWizard implements IRSE
}
if (delegate == null) {
- delegate = new RSEDefaultNewConnectionWizardDelegate();
+
+ if (!defaultDelegateCreated) {
+ defaultDelegate = new RSEDefaultNewConnectionWizardDelegate();
+ defaultDelegateCreated = true;
+ }
+
+ delegate = defaultDelegate;
}
- // set the wizard
- delegate.init(this, systemType);
+ // initialize with wizard and system type if not initialized before
+ if (!delegate.isInitialized()) {
+ delegate.init(this, systemType);
+ }
+ else {
+ delegate.systemTypeChanged(systemType);
+ }
return delegate;
}
@@ -100,8 +165,20 @@ public class RSENewConnectionWizard extends AbstractSystemWizard implements IRSE
* @see org.eclipse.jface.wizard.Wizard#addPages()
*/
public void addPages() {
- mainPage = new RSENewConnectionWizardMainPage(this, "Select System Type", "Select a system type");
- addPage(mainPage);
+
+ if (!onlySystemType) {
+ mainPage = new RSENewConnectionWizardMainPage(this, "Select System Type", "Select a system type");
+
+ if (restrictedSystemTypes != null) {
+ mainPage.restrictToSystemTypes(restrictedSystemTypes);
+ }
+
+ addPage(mainPage);
+ }
+ else {
+ setDelegate(restrictedSystemTypes[0]);
+ addPage(delegate.getMainPage());
+ }
}
/**
@@ -109,7 +186,11 @@ public class RSENewConnectionWizard extends AbstractSystemWizard implements IRSE
*/
public boolean canFinish() {
- boolean result = mainPage.isPageComplete();
+ boolean result = true;
+
+ if (mainPage != null) {
+ result = mainPage.isPageComplete();
+ }
if (result) {
@@ -130,7 +211,7 @@ public class RSENewConnectionWizard extends AbstractSystemWizard implements IRSE
*/
public IWizardPage getNextPage(IWizardPage page) {
- if (page == mainPage) {
+ if (mainPage != null && page == mainPage) {
return super.getNextPage(page);
}
else {
@@ -157,7 +238,7 @@ public class RSENewConnectionWizard extends AbstractSystemWizard implements IRSE
*/
public IWizardPage getPreviousPage(IWizardPage page) {
- if (page == mainPage) {
+ if (mainPage != null && page == mainPage) {
return super.getPreviousPage(page);
}
else {
@@ -183,7 +264,11 @@ public class RSENewConnectionWizard extends AbstractSystemWizard implements IRSE
*/
public boolean performFinish() {
- boolean result = mainPage.performFinish();
+ boolean result = true;
+
+ if (mainPage != null) {
+ result = mainPage.performFinish();
+ }
if (result) {
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/RSENewConnectionWizardDelegate.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/RSENewConnectionWizardDelegate.java
index 326089a1907..dcd3b4e3c50 100644
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/RSENewConnectionWizardDelegate.java
+++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/RSENewConnectionWizardDelegate.java
@@ -26,6 +26,7 @@ public abstract class RSENewConnectionWizardDelegate implements IRSENewConnectio
private RSENewConnectionWizard wizard;
private IRSESystemType systemType;
+ private boolean isInitialized;
/**
* @see org.eclipse.rse.ui.wizards.IRSENewConnectionWizardDelegate#init(org.eclipse.rse.ui.wizards.RSENewConnectionWizard, org.eclipse.rse.core.IRSESystemType)
@@ -33,6 +34,7 @@ public abstract class RSENewConnectionWizardDelegate implements IRSENewConnectio
public void init(RSENewConnectionWizard wizard, IRSESystemType systemType) {
setWizard(wizard);
setSystemType(systemType);
+ setInitialized(true);
}
protected void setWizard(RSENewConnectionWizard wizard) {
@@ -42,6 +44,10 @@ public abstract class RSENewConnectionWizardDelegate implements IRSENewConnectio
protected void setSystemType(IRSESystemType systemType) {
this.systemType = systemType;
}
+
+ protected void setInitialized(boolean isInitialized) {
+ this.isInitialized = true;
+ }
/**
* @see org.eclipse.rse.ui.wizards.IRSENewConnectionWizardDelegate#getWizard()
@@ -57,6 +63,13 @@ public abstract class RSENewConnectionWizardDelegate implements IRSENewConnectio
return systemType;
}
+ /**
+ * @see org.eclipse.rse.ui.wizards.IRSENewConnectionWizardDelegate#isInitialized()
+ */
+ public boolean isInitialized() {
+ return isInitialized;
+ }
+
/**
* @see org.eclipse.rse.ui.wizards.IRSENewConnectionWizardDelegate#addPages()
*/
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/RSENewConnectionWizardMainPage.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/RSENewConnectionWizardMainPage.java
index c84e8fc7160..d745dc67597 100644
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/RSENewConnectionWizardMainPage.java
+++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/RSENewConnectionWizardMainPage.java
@@ -18,6 +18,7 @@ package org.eclipse.rse.ui.wizards;
import org.eclipse.jface.wizard.IWizard;
import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.rse.core.IRSESystemType;
import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.ui.RSEUIPlugin;
import org.eclipse.rse.ui.SystemResources;
@@ -31,13 +32,14 @@ import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
/**
- *
+ * The New Connection Wizard main page that allows selection of system type.
*/
public class RSENewConnectionWizardMainPage extends AbstractSystemWizardPage implements Listener {
protected String parentHelpId;
protected Combo textSystemType;
protected IWizardPage nextPage;
+ protected IRSESystemType[] restrictedSystemTypes;
/**
* Constructor.
@@ -65,7 +67,19 @@ public class RSENewConnectionWizardMainPage extends AbstractSystemWizardPage imp
Label labelSystemType = SystemWidgetHelpers.createLabel(composite_prompts, temp);
labelSystemType.setToolTipText(SystemResources.RESID_CONNECTION_SYSTEMTYPE_TIP);
- textSystemType = SystemWidgetHelpers.createSystemTypeCombo(parent, null);
+ if (restrictedSystemTypes == null) {
+ textSystemType = SystemWidgetHelpers.createSystemTypeCombo(parent, null);
+ }
+ else {
+ String[] systemTypeNames = new String[restrictedSystemTypes.length];
+
+ for (int i = 0; i < restrictedSystemTypes.length; i++) {
+ systemTypeNames[i] = restrictedSystemTypes[i].getName();
+ }
+
+ textSystemType = SystemWidgetHelpers.createSystemTypeCombo(parent, null, systemTypeNames);
+ }
+
textSystemType.setToolTipText(SystemResources.RESID_CONNECTION_SYSTEMTYPE_TIP);
SystemWidgetHelpers.setHelp(textSystemType, RSEUIPlugin.HELPPREFIX + "ccon0003");
@@ -73,6 +87,10 @@ public class RSENewConnectionWizardMainPage extends AbstractSystemWizardPage imp
return composite_prompts;
}
+
+ public void restrictToSystemTypes(IRSESystemType[] systemTypes) {
+ this.restrictedSystemTypes = systemTypes;
+ }
/**
* @see org.eclipse.rse.ui.wizards.AbstractSystemWizardPage#getInitialFocusControl()
@@ -99,28 +117,20 @@ public class RSENewConnectionWizardMainPage extends AbstractSystemWizardPage imp
*/
public IWizardPage getNextPage() {
- if (nextPage == null) {
+ IWizard wizard = getWizard();
- IWizard wizard = getWizard();
-
- // if the wizard is a new connection wizard, which should always be the case,
- // get the new connection wizard delegate for the selected system type and
- // ask for the main page
- if (wizard instanceof IRSENewConnectionWizard) {
- String systemTypeStr = textSystemType.getText();
- IRSENewConnectionWizard newConnWizard = (IRSENewConnectionWizard)wizard;
- newConnWizard.setSystemType(RSECorePlugin.getDefault().getRegistry().getSystemType(systemTypeStr), false);
- nextPage = newConnWizard.getDelegate().getMainPage();
- }
- else {
- nextPage = super.getNextPage();
- }
+ // if the wizard is a new connection wizard, which should always be the case,
+ // get the new connection wizard delegate for the selected system type and
+ // ask for the main page
+ if (wizard instanceof IRSENewConnectionWizard) {
+ String systemTypeStr = textSystemType.getText();
+ IRSENewConnectionWizard newConnWizard = (IRSENewConnectionWizard)wizard;
+ newConnWizard.setSelectedSystemType(RSECorePlugin.getDefault().getRegistry().getSystemType(systemTypeStr));
+ return newConnWizard.getDelegate().getMainPage();
}
else {
-
+ return super.getNextPage();
}
-
- return nextPage;
}
/**
@@ -134,7 +144,7 @@ public class RSENewConnectionWizardMainPage extends AbstractSystemWizardPage imp
if (wizard instanceof IRSENewConnectionWizard) {
String systemTypeStr = textSystemType.getText();
IRSENewConnectionWizard newConnWizard = (IRSENewConnectionWizard)wizard;
- newConnWizard.getDelegate().systemTypeChanged(RSECorePlugin.getDefault().getRegistry().getSystemType(systemTypeStr));
+ newConnWizard.setSelectedSystemType(RSECorePlugin.getDefault().getRegistry().getSystemType(systemTypeStr));
}
}
}
diff --git a/rse/plugins/org.eclipse.rse.ui/schema/newConnectionWizardDelegate.exsd b/rse/plugins/org.eclipse.rse.ui/schema/newConnectionWizardDelegate.exsd
index abf51969bdf..9651a55cadb 100644
--- a/rse/plugins/org.eclipse.rse.ui/schema/newConnectionWizardDelegate.exsd
+++ b/rse/plugins/org.eclipse.rse.ui/schema/newConnectionWizardDelegate.exsd
@@ -6,7 +6,7 @@
- This extension point allows a New Connection wizard delegate to be provided for a certain system type. This is useful for those system types that need New Connection wizard pages which are different from the default pages supplied by RSE.
+ This extension point allows a New Connection wizard delegate to be provided for a certain system type. This is useful for those system types that need New Connection wizard pages which are different from the default pages supplied by RSE.
@@ -48,10 +48,10 @@
-
+
- A class that implements
+ A class that implements <samp>org.eclipse.rse.ui.wizards.IRSENewConnectionWizardDelegate</samp>