1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-09 01:05:38 +02:00

RSE New Connection Wizard update

This commit is contained in:
Kushal Munir 2006-06-30 13:47:50 +00:00
parent 1069e41afc
commit de3af0763d
7 changed files with 187 additions and 46 deletions

View file

@ -18,6 +18,8 @@ package org.eclipse.rse.ui.actions;
import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.IWizard; 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.core.subsystems.ISubSystem;
import org.eclipse.rse.filters.ISystemFilterPoolReference; import org.eclipse.rse.filters.ISystemFilterPoolReference;
import org.eclipse.rse.filters.ISystemFilterReference; import org.eclipse.rse.filters.ISystemFilterReference;
@ -109,8 +111,16 @@ public class SystemNewConnectionAction extends SystemBaseWizardAction
} }
// newConnWizard.setCurrentlySelectedConnection(currConn); // newConnWizard.setCurrentlySelectedConnection(currConn);
// if (restrictSystemTypesTo != null) if (restrictSystemTypesTo != null) {
// newConnWizard.restrictSystemTypes(restrictSystemTypesTo);
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) // if (defaultHostName != null)
// newConnWizard.setHostName(defaultHostName); // newConnWizard.setHostName(defaultHostName);
// if (defaultConnectionName != null) // if (defaultConnectionName != null)

View file

@ -22,8 +22,29 @@ import org.eclipse.ui.INewWizard;
public interface IRSENewConnectionWizard extends 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_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 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);
} }

View file

@ -27,6 +27,8 @@ public interface IRSENewConnectionWizardDelegate {
public void init(RSENewConnectionWizard wizard, IRSESystemType systemType); public void init(RSENewConnectionWizard wizard, IRSESystemType systemType);
public boolean isInitialized();
public void systemTypeChanged(IRSESystemType systemType); public void systemTypeChanged(IRSESystemType systemType);
public RSENewConnectionWizard getWizard(); public RSENewConnectionWizard getWizard();

View file

@ -18,29 +18,30 @@ package org.eclipse.rse.ui.wizards;
import java.util.HashMap; import java.util.HashMap;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtensionRegistry; import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.wizard.IWizardPage; import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.rse.core.IRSESystemType; import org.eclipse.rse.core.IRSESystemType;
import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.ui.ISystemIconConstants; import org.eclipse.rse.ui.ISystemIconConstants;
import org.eclipse.rse.ui.RSEUIPlugin; import org.eclipse.rse.ui.RSEUIPlugin;
import org.eclipse.rse.ui.SystemResources; import org.eclipse.rse.ui.SystemResources;
/** /**
* * The New Connection wizard. This wizard allows users to create new RSE connections.
*/
/**
* @author kmunir
*
*/ */
public class RSENewConnectionWizard extends AbstractSystemWizard implements IRSENewConnectionWizard { public class RSENewConnectionWizard extends AbstractSystemWizard implements IRSENewConnectionWizard {
private HashMap map; private HashMap map;
private IRSESystemType systemType; private IRSESystemType systemType;
private boolean initWithSystemType;
private IRSENewConnectionWizardDelegate delegate; private IRSENewConnectionWizardDelegate delegate;
private RSENewConnectionWizardMainPage mainPage; private RSENewConnectionWizardMainPage mainPage;
private IRSESystemType[] restrictedSystemTypes;
private boolean onlySystemType;
private IRSENewConnectionWizardDelegate defaultDelegate;
private boolean defaultDelegateCreated;
/** /**
* Constructor. * Constructor.
@ -53,11 +54,33 @@ public class RSENewConnectionWizard extends AbstractSystemWizard implements IRSE
} }
/** /**
* @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.systemType = systemType;
this.initWithSystemType = initWithSystemType;
setDelegate(systemType); setDelegate(systemType);
} }
@ -67,6 +90,37 @@ public class RSENewConnectionWizard extends AbstractSystemWizard implements IRSE
private void readWizardDelegateExtensions() { private void readWizardDelegateExtensions() {
IExtensionRegistry registry = Platform.getExtensionRegistry(); IExtensionRegistry registry = Platform.getExtensionRegistry();
IConfigurationElement[] elements = registry.getConfigurationElementsFor(NEW_CONNECTION_WIZARD_DELEGATE_EXTENSION_POINT_ID); 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) { if (delegate == null) {
delegate = new RSEDefaultNewConnectionWizardDelegate();
if (!defaultDelegateCreated) {
defaultDelegate = new RSEDefaultNewConnectionWizardDelegate();
defaultDelegateCreated = true;
}
delegate = defaultDelegate;
} }
// set the wizard // initialize with wizard and system type if not initialized before
delegate.init(this, systemType); if (!delegate.isInitialized()) {
delegate.init(this, systemType);
}
else {
delegate.systemTypeChanged(systemType);
}
return delegate; return delegate;
} }
@ -100,8 +165,20 @@ public class RSENewConnectionWizard extends AbstractSystemWizard implements IRSE
* @see org.eclipse.jface.wizard.Wizard#addPages() * @see org.eclipse.jface.wizard.Wizard#addPages()
*/ */
public void 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() { public boolean canFinish() {
boolean result = mainPage.isPageComplete(); boolean result = true;
if (mainPage != null) {
result = mainPage.isPageComplete();
}
if (result) { if (result) {
@ -130,7 +211,7 @@ public class RSENewConnectionWizard extends AbstractSystemWizard implements IRSE
*/ */
public IWizardPage getNextPage(IWizardPage page) { public IWizardPage getNextPage(IWizardPage page) {
if (page == mainPage) { if (mainPage != null && page == mainPage) {
return super.getNextPage(page); return super.getNextPage(page);
} }
else { else {
@ -157,7 +238,7 @@ public class RSENewConnectionWizard extends AbstractSystemWizard implements IRSE
*/ */
public IWizardPage getPreviousPage(IWizardPage page) { public IWizardPage getPreviousPage(IWizardPage page) {
if (page == mainPage) { if (mainPage != null && page == mainPage) {
return super.getPreviousPage(page); return super.getPreviousPage(page);
} }
else { else {
@ -183,7 +264,11 @@ public class RSENewConnectionWizard extends AbstractSystemWizard implements IRSE
*/ */
public boolean performFinish() { public boolean performFinish() {
boolean result = mainPage.performFinish(); boolean result = true;
if (mainPage != null) {
result = mainPage.performFinish();
}
if (result) { if (result) {

View file

@ -26,6 +26,7 @@ public abstract class RSENewConnectionWizardDelegate implements IRSENewConnectio
private RSENewConnectionWizard wizard; private RSENewConnectionWizard wizard;
private IRSESystemType systemType; 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) * @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) { public void init(RSENewConnectionWizard wizard, IRSESystemType systemType) {
setWizard(wizard); setWizard(wizard);
setSystemType(systemType); setSystemType(systemType);
setInitialized(true);
} }
protected void setWizard(RSENewConnectionWizard wizard) { protected void setWizard(RSENewConnectionWizard wizard) {
@ -43,6 +45,10 @@ public abstract class RSENewConnectionWizardDelegate implements IRSENewConnectio
this.systemType = systemType; this.systemType = systemType;
} }
protected void setInitialized(boolean isInitialized) {
this.isInitialized = true;
}
/** /**
* @see org.eclipse.rse.ui.wizards.IRSENewConnectionWizardDelegate#getWizard() * @see org.eclipse.rse.ui.wizards.IRSENewConnectionWizardDelegate#getWizard()
*/ */
@ -57,6 +63,13 @@ public abstract class RSENewConnectionWizardDelegate implements IRSENewConnectio
return systemType; return systemType;
} }
/**
* @see org.eclipse.rse.ui.wizards.IRSENewConnectionWizardDelegate#isInitialized()
*/
public boolean isInitialized() {
return isInitialized;
}
/** /**
* @see org.eclipse.rse.ui.wizards.IRSENewConnectionWizardDelegate#addPages() * @see org.eclipse.rse.ui.wizards.IRSENewConnectionWizardDelegate#addPages()
*/ */

View file

@ -18,6 +18,7 @@ package org.eclipse.rse.ui.wizards;
import org.eclipse.jface.wizard.IWizard; import org.eclipse.jface.wizard.IWizard;
import org.eclipse.jface.wizard.IWizardPage; import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.rse.core.IRSESystemType;
import org.eclipse.rse.core.RSECorePlugin; import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.ui.RSEUIPlugin; import org.eclipse.rse.ui.RSEUIPlugin;
import org.eclipse.rse.ui.SystemResources; import org.eclipse.rse.ui.SystemResources;
@ -31,13 +32,14 @@ import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener; 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 { public class RSENewConnectionWizardMainPage extends AbstractSystemWizardPage implements Listener {
protected String parentHelpId; protected String parentHelpId;
protected Combo textSystemType; protected Combo textSystemType;
protected IWizardPage nextPage; protected IWizardPage nextPage;
protected IRSESystemType[] restrictedSystemTypes;
/** /**
* Constructor. * Constructor.
@ -65,7 +67,19 @@ public class RSENewConnectionWizardMainPage extends AbstractSystemWizardPage imp
Label labelSystemType = SystemWidgetHelpers.createLabel(composite_prompts, temp); Label labelSystemType = SystemWidgetHelpers.createLabel(composite_prompts, temp);
labelSystemType.setToolTipText(SystemResources.RESID_CONNECTION_SYSTEMTYPE_TIP); 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); textSystemType.setToolTipText(SystemResources.RESID_CONNECTION_SYSTEMTYPE_TIP);
SystemWidgetHelpers.setHelp(textSystemType, RSEUIPlugin.HELPPREFIX + "ccon0003"); SystemWidgetHelpers.setHelp(textSystemType, RSEUIPlugin.HELPPREFIX + "ccon0003");
@ -74,6 +88,10 @@ public class RSENewConnectionWizardMainPage extends AbstractSystemWizardPage imp
return composite_prompts; return composite_prompts;
} }
public void restrictToSystemTypes(IRSESystemType[] systemTypes) {
this.restrictedSystemTypes = systemTypes;
}
/** /**
* @see org.eclipse.rse.ui.wizards.AbstractSystemWizardPage#getInitialFocusControl() * @see org.eclipse.rse.ui.wizards.AbstractSystemWizardPage#getInitialFocusControl()
*/ */
@ -99,28 +117,20 @@ public class RSENewConnectionWizardMainPage extends AbstractSystemWizardPage imp
*/ */
public IWizardPage getNextPage() { 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
// if the wizard is a new connection wizard, which should always be the case, // ask for the main page
// get the new connection wizard delegate for the selected system type and if (wizard instanceof IRSENewConnectionWizard) {
// ask for the main page String systemTypeStr = textSystemType.getText();
if (wizard instanceof IRSENewConnectionWizard) { IRSENewConnectionWizard newConnWizard = (IRSENewConnectionWizard)wizard;
String systemTypeStr = textSystemType.getText(); newConnWizard.setSelectedSystemType(RSECorePlugin.getDefault().getRegistry().getSystemType(systemTypeStr));
IRSENewConnectionWizard newConnWizard = (IRSENewConnectionWizard)wizard; return newConnWizard.getDelegate().getMainPage();
newConnWizard.setSystemType(RSECorePlugin.getDefault().getRegistry().getSystemType(systemTypeStr), false);
nextPage = newConnWizard.getDelegate().getMainPage();
}
else {
nextPage = super.getNextPage();
}
} }
else { else {
return super.getNextPage();
} }
return nextPage;
} }
/** /**
@ -134,7 +144,7 @@ public class RSENewConnectionWizardMainPage extends AbstractSystemWizardPage imp
if (wizard instanceof IRSENewConnectionWizard) { if (wizard instanceof IRSENewConnectionWizard) {
String systemTypeStr = textSystemType.getText(); String systemTypeStr = textSystemType.getText();
IRSENewConnectionWizard newConnWizard = (IRSENewConnectionWizard)wizard; IRSENewConnectionWizard newConnWizard = (IRSENewConnectionWizard)wizard;
newConnWizard.getDelegate().systemTypeChanged(RSECorePlugin.getDefault().getRegistry().getSystemType(systemTypeStr)); newConnWizard.setSelectedSystemType(RSECorePlugin.getDefault().getRegistry().getSystemType(systemTypeStr));
} }
} }
} }

View file

@ -48,10 +48,10 @@
</documentation> </documentation>
</annotation> </annotation>
</attribute> </attribute>
<attribute name="class" type="string" use="default" value="org.eclipse.rse.ui.wizards.RSENewConnectionWizardDelegate"> <attribute name="class" type="string" use="default" value="org.eclipse.rse.ui.wizards.RSEDefaultNewConnectionWizardDelegate">
<annotation> <annotation>
<documentation> <documentation>
A class that implements A class that implements &lt;samp&gt;org.eclipse.rse.ui.wizards.IRSENewConnectionWizardDelegate&lt;/samp&gt;
</documentation> </documentation>
</annotation> </annotation>
</attribute> </attribute>