1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-23 00:03:53 +02:00

Updates to New Connection wizard

This commit is contained in:
Kushal Munir 2006-06-29 18:02:02 +00:00
parent 1daaecc113
commit 9c7ad4084f
9 changed files with 145 additions and 43 deletions

View file

@ -115,7 +115,7 @@ public abstract class AbstractSystemNewConnectionWizardPage extends AbstractSyst
if (ourWizard != null) { if (ourWizard != null) {
String[] systemTypes = parentFactory.getSystemTypes(); String[] systemTypes = parentFactory.getSystemTypes();
IRSESystemType systemType = RSECorePlugin.getDefault().getRegistry().getSystemType(systemTypes[0]); IRSESystemType systemType = RSECorePlugin.getDefault().getRegistry().getSystemType(systemTypes[0]);
IWizardPage wizardPage = ourWizard.getDelegate(systemType).getMainPage(); IWizardPage wizardPage = ourWizard.getDelegate().getMainPage();
if (wizardPage instanceof ISystemNewConnectionWizardMainPage) { if (wizardPage instanceof ISystemNewConnectionWizardMainPage) {
return (ISystemNewConnectionWizardMainPage)wizardPage; return (ISystemNewConnectionWizardMainPage)wizardPage;
@ -139,7 +139,7 @@ public abstract class AbstractSystemNewConnectionWizardPage extends AbstractSyst
if (ourWizard != null) { if (ourWizard != null) {
String[] systemTypes = parentFactory.getSystemTypes(); String[] systemTypes = parentFactory.getSystemTypes();
IRSESystemType systemType = RSECorePlugin.getDefault().getRegistry().getSystemType(systemTypes[0]); IRSESystemType systemType = RSECorePlugin.getDefault().getRegistry().getSystemType(systemTypes[0]);
IWizardPage wizardPage = ourWizard.getDelegate(systemType).getMainPage(); IWizardPage wizardPage = ourWizard.getDelegate().getMainPage();
if (wizardPage instanceof RSENewConnectionWizardDefaultDelegateMainPage) { if (wizardPage instanceof RSENewConnectionWizardDefaultDelegateMainPage) {
return ((RSENewConnectionWizardDefaultDelegateMainPage)wizardPage).getForm(); return ((RSENewConnectionWizardDefaultDelegateMainPage)wizardPage).getForm();

View file

@ -23,7 +23,7 @@ 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 IRSENewConnectionWizardDelegate getDelegate(IRSESystemType systemType); public IRSENewConnectionWizardDelegate getDelegate();
public void setSystemType(IRSESystemType systemType); public void setSystemType(IRSESystemType systemType, boolean initWithSystemType);
} }

View file

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

View file

@ -75,6 +75,7 @@ public class RSEDefaultNewConnectionWizardDelegate extends RSENewConnectionWizar
super.init(wizard, systemType); super.init(wizard, systemType);
restrictSystemType(systemType.getName()); restrictSystemType(systemType.getName());
activeProfileNames = SystemStartHere.getSystemProfileManager().getActiveSystemProfileNames(); activeProfileNames = SystemStartHere.getSystemProfileManager().getActiveSystemProfileNames();
systemTypeSelected(systemType.getName(), true);
} }
/** /**
@ -206,26 +207,36 @@ public class RSEDefaultNewConnectionWizardDelegate extends RSENewConnectionWizar
*/ */
protected RSENewConnectionWizardDefaultDelegateMainPage createMainPage(String[] restrictSystemTypesTo) protected RSENewConnectionWizardDefaultDelegateMainPage createMainPage(String[] restrictSystemTypesTo)
{ {
String pageTitle = null; String pageTitle = getPageTitle();
if ((restrictSystemTypesTo==null) || (restrictSystemTypesTo.length != 1))
pageTitle = SystemResources.RESID_NEWCONN_PAGE1_TITLE;
else
{
String onlySystemType = restrictSystemTypesTo[0];
if (onlySystemType.equals(IRSESystemType.SYSTEMTYPE_LOCAL))
pageTitle =SystemResources.RESID_NEWCONN_PAGE1_LOCAL_TITLE;
else
{
pageTitle =SystemResources.RESID_NEWCONN_PAGE1_REMOTE_TITLE;
pageTitle = SystemMessage.sub(pageTitle, "&1", onlySystemType);
}
}
mainPage = new RSENewConnectionWizardDefaultDelegateMainPage(getWizard(), mainPage = new RSENewConnectionWizardDefaultDelegateMainPage(getWizard(),
pageTitle, pageTitle,
SystemResources.RESID_NEWCONN_PAGE1_DESCRIPTION); SystemResources.RESID_NEWCONN_PAGE1_DESCRIPTION);
getWizard().setOutputObject(null); getWizard().setOutputObject(null);
return mainPage; return mainPage;
} }
public String getPageTitle() {
String pageTitle = null;
if ((restrictSystemTypesTo == null) || (restrictSystemTypesTo.length != 1)) {
pageTitle = SystemResources.RESID_NEWCONN_PAGE1_TITLE;
}
else {
String onlySystemType = restrictSystemTypesTo[0];
if (onlySystemType.equals(IRSESystemType.SYSTEMTYPE_LOCAL)) {
pageTitle = SystemResources.RESID_NEWCONN_PAGE1_LOCAL_TITLE;
}
else {
pageTitle = SystemResources.RESID_NEWCONN_PAGE1_REMOTE_TITLE;
pageTitle = SystemMessage.sub(pageTitle, "&1", onlySystemType);
}
}
return pageTitle;
}
/** /**
* Set the currently selected connection. Used to better default entry fields. * Set the currently selected connection. Used to better default entry fields.
*/ */
@ -391,7 +402,10 @@ public class RSEDefaultNewConnectionWizardDelegate extends RSENewConnectionWizar
*/ */
public IWizardPage getMainPage() public IWizardPage getMainPage()
{ {
addPages(); if (mainPage == null) {
addPages();
}
return mainPage; return mainPage;
} }
@ -521,7 +535,8 @@ public class RSEDefaultNewConnectionWizardDelegate extends RSENewConnectionWizar
*/ */
public boolean canFinish() public boolean canFinish()
{ {
boolean ok = true; boolean ok = mainPage.isPageComplete();
if (ok && hasAdditionalPages()) if (ok && hasAdditionalPages())
{ {
for (int idx=0; ok && (idx<subsystemFactorySuppliedWizardPages.length); idx++) for (int idx=0; ok && (idx<subsystemFactorySuppliedWizardPages.length); idx++)
@ -529,4 +544,14 @@ public class RSEDefaultNewConnectionWizardDelegate extends RSENewConnectionWizar
} }
return ok; return ok;
} }
/**
* @see org.eclipse.rse.ui.wizards.RSENewConnectionWizardDelegate#systemTypeChanged(org.eclipse.rse.core.IRSESystemType)
*/
public void systemTypeChanged(IRSESystemType systemType) {
setSystemType(systemType);
restrictSystemType(systemType.getName());
mainPage.setTitle(getPageTitle());
subsystemFactorySuppliedWizardPages = getAdditionalWizardPages(systemType.getName());
}
} }

View file

@ -30,10 +30,15 @@ import org.eclipse.rse.ui.SystemResources;
/** /**
* *
*/ */
/**
* @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;
@ -50,9 +55,10 @@ 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#setSystemType(org.eclipse.rse.core.IRSESystemType)
*/ */
public void setSystemType(IRSESystemType systemType) { public void setSystemType(IRSESystemType systemType, boolean initWithSystemType) {
this.systemType = systemType; this.systemType = systemType;
getDelegate(systemType); this.initWithSystemType = initWithSystemType;
setDelegate(systemType);
} }
/** /**
@ -67,7 +73,7 @@ public class RSENewConnectionWizard extends AbstractSystemWizard implements IRSE
* Get the new connection wizard delegate for the system type. * Get the new connection wizard delegate for the system type.
* @param systemType the system type for which we need the delegate. * @param systemType the system type for which we need the delegate.
*/ */
public IRSENewConnectionWizardDelegate getDelegate(IRSESystemType systemType) { private IRSENewConnectionWizardDelegate setDelegate(IRSESystemType systemType) {
if (map != null) { if (map != null) {
delegate = (IRSENewConnectionWizardDelegate)(map.get(systemType.getId())); delegate = (IRSENewConnectionWizardDelegate)(map.get(systemType.getId()));
@ -83,6 +89,13 @@ public class RSENewConnectionWizard extends AbstractSystemWizard implements IRSE
return delegate; return delegate;
} }
/**
* @see org.eclipse.rse.ui.wizards.IRSENewConnectionWizard#getDelegate()
*/
public IRSENewConnectionWizardDelegate getDelegate() {
return delegate;
}
/** /**
* @see org.eclipse.jface.wizard.Wizard#addPages() * @see org.eclipse.jface.wizard.Wizard#addPages()
*/ */

View file

@ -88,13 +88,22 @@ public class RSENewConnectionWizardDefaultDelegateMainPage
/** /**
* Return the main wizard typed * Return the main wizard typed
*/ */
private RSEDefaultNewConnectionWizardDelegate getOurWizardDelegate() private RSEDefaultNewConnectionWizardDelegate getOurWizardDelegate() {
{
IWizard wizard = getWizard(); IWizard wizard = getWizard();
if (wizard instanceof RSEDefaultNewConnectionWizardDelegate)
return (RSEDefaultNewConnectionWizardDelegate)wizard; if (wizard instanceof RSENewConnectionWizard) {
else IRSENewConnectionWizardDelegate delegate = ((RSENewConnectionWizard)wizard).getDelegate();
return null;
if (delegate instanceof RSEDefaultNewConnectionWizardDelegate) {
return (RSEDefaultNewConnectionWizardDelegate)delegate;
}
else {
return null;
}
}
else {
return null;
}
} }
@ -219,10 +228,10 @@ public class RSENewConnectionWizardDefaultDelegateMainPage
* Return user-entered System Type. * Return user-entered System Type.
* Call this after finish ends successfully. * Call this after finish ends successfully.
*/ */
public String getSystemType() /* public String getSystemType()
{ {
return form.getSystemType(); return form.getSystemType();
} } */
/** /**
* Return user-entered Connection Name. * Return user-entered Connection Name.
* Call this after finish ends successfully. * Call this after finish ends successfully.
@ -355,4 +364,11 @@ public class RSENewConnectionWizardDefaultDelegateMainPage
} }
} }
/**
* @see org.eclipse.rse.ui.wizards.ISystemNewConnectionWizardMainPage#getSystemType()
*/
public String getSystemType() {
RSEDefaultNewConnectionWizardDelegate newConnWizardDelegate = getOurWizardDelegate();
return newConnWizardDelegate.getSystemType().getName();
}
} }

View file

@ -31,7 +31,15 @@ public abstract class RSENewConnectionWizardDelegate implements IRSENewConnectio
* @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)
*/ */
public void init(RSENewConnectionWizard wizard, IRSESystemType systemType) { public void init(RSENewConnectionWizard wizard, IRSESystemType systemType) {
setWizard(wizard);
setSystemType(systemType);
}
protected void setWizard(RSENewConnectionWizard wizard) {
this.wizard = wizard; this.wizard = wizard;
}
protected void setSystemType(IRSESystemType systemType) {
this.systemType = systemType; this.systemType = systemType;
} }
@ -75,4 +83,11 @@ public abstract class RSENewConnectionWizardDelegate implements IRSENewConnectio
public IWizardPage getPreviousPage(IWizardPage page) { public IWizardPage getPreviousPage(IWizardPage page) {
return wizard.getStartingPage(); return wizard.getStartingPage();
} }
/**
* @see org.eclipse.rse.ui.wizards.IRSENewConnectionWizardDelegate#systemTypeChanged(org.eclipse.rse.core.IRSESystemType)
*/
public void systemTypeChanged(IRSESystemType systemType) {
}
} }

View file

@ -22,18 +22,22 @@ 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;
import org.eclipse.rse.ui.SystemWidgetHelpers; import org.eclipse.rse.ui.SystemWidgetHelpers;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
/** /**
* *
*/ */
public class RSENewConnectionWizardMainPage extends AbstractSystemWizardPage { public class RSENewConnectionWizardMainPage extends AbstractSystemWizardPage implements Listener {
protected String parentHelpId; protected String parentHelpId;
protected Combo textSystemType; protected Combo textSystemType;
protected IWizardPage nextPage;
/** /**
* Constructor. * Constructor.
@ -65,6 +69,8 @@ public class RSENewConnectionWizardMainPage extends AbstractSystemWizardPage {
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");
textSystemType.addListener(SWT.Selection, this);
return composite_prompts; return composite_prompts;
} }
@ -93,18 +99,43 @@ public class RSENewConnectionWizardMainPage extends AbstractSystemWizardPage {
*/ */
public IWizardPage getNextPage() { public IWizardPage getNextPage() {
IWizard wizard = getWizard(); if (nextPage == null) {
// if the wizard is a new connection wizard, which should always be the case, IWizard wizard = getWizard();
// get the new connection wizard delegate for the selected system type and
// ask for the main page // if the wizard is a new connection wizard, which should always be the case,
if (wizard instanceof IRSENewConnectionWizard) { // get the new connection wizard delegate for the selected system type and
String systemTypeStr = textSystemType.getText(); // ask for the main page
IRSENewConnectionWizardDelegate delegate = ((IRSENewConnectionWizard)wizard).getDelegate(RSECorePlugin.getDefault().getRegistry().getSystemType(systemTypeStr)); if (wizard instanceof IRSENewConnectionWizard) {
return delegate.getMainPage(); String systemTypeStr = textSystemType.getText();
IRSENewConnectionWizard newConnWizard = (IRSENewConnectionWizard)wizard;
newConnWizard.setSystemType(RSECorePlugin.getDefault().getRegistry().getSystemType(systemTypeStr), false);
nextPage = newConnWizard.getDelegate().getMainPage();
}
else {
nextPage = super.getNextPage();
}
} }
else { else {
return super.getNextPage();
}
return nextPage;
}
/**
* @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event)
*/
public void handleEvent(Event event) {
if (event.type == SWT.Selection && event.widget == textSystemType) {
IWizard wizard = getWizard();
if (wizard instanceof IRSENewConnectionWizard) {
String systemTypeStr = textSystemType.getText();
IRSENewConnectionWizard newConnWizard = (IRSENewConnectionWizard)wizard;
newConnWizard.getDelegate().systemTypeChanged(RSECorePlugin.getDefault().getRegistry().getSystemType(systemTypeStr));
}
} }
} }
} }

View file

@ -89,7 +89,7 @@ public class SubSystemServiceWizardPage extends AbstractSystemNewConnectionWizar
IHost dummyHost = null; IHost dummyHost = null;
if (getWizard() instanceof RSENewConnectionWizard) if (getWizard() instanceof RSENewConnectionWizard)
{ {
dummyHost = ((RSENewConnectionWizard)getWizard()).getDelegate(systemType).getDummyHost(); dummyHost = ((RSENewConnectionWizard)getWizard()).getDelegate().getDummyHost();
} }
// create elements for each // create elements for each