diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/SystemConnectionForm.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/SystemConnectionForm.java index eaff05229ea..89eba60dc28 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/SystemConnectionForm.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/SystemConnectionForm.java @@ -43,7 +43,7 @@ import org.eclipse.rse.ui.validators.ValidatorConnectionName; import org.eclipse.rse.ui.validators.ValidatorUserId; import org.eclipse.rse.ui.widgets.InheritableEntryField; import org.eclipse.rse.ui.wizards.AbstractSystemWizardPage; -import org.eclipse.rse.ui.wizards.SystemNewConnectionWizard; +import org.eclipse.rse.ui.wizards.RSENewConnectionWizard; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.SelectionEvent; @@ -892,9 +892,9 @@ public class SystemConnectionForm IWizardPage[] pages = null; - if (wizard instanceof SystemNewConnectionWizard) { - SystemNewConnectionWizard connWizard = (SystemNewConnectionWizard)wizard; - AbstractSystemWizardPage mainPage = (AbstractSystemWizardPage)(connWizard.getMainPage()); + if (wizard instanceof RSENewConnectionWizard) { + RSENewConnectionWizard connWizard = (RSENewConnectionWizard)wizard; + AbstractSystemWizardPage mainPage = (AbstractSystemWizardPage)(connWizard.getStartingPage()); Vector pageList = new Vector(); 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 f1eab399ac4..a048cff6617 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 @@ -27,7 +27,7 @@ import org.eclipse.rse.ui.ISystemContextMenuConstants; import org.eclipse.rse.ui.ISystemIconConstants; import org.eclipse.rse.ui.RSEUIPlugin; import org.eclipse.rse.ui.SystemResources; -import org.eclipse.rse.ui.wizards.SystemNewConnectionWizard; +import org.eclipse.rse.ui.wizards.RSENewConnectionWizard; import org.eclipse.swt.widgets.Shell; @@ -102,19 +102,19 @@ public class SystemNewConnectionAction extends SystemBaseWizardAction */ protected IWizard createWizard() { - SystemNewConnectionWizard newConnWizard = new SystemNewConnectionWizard(); + RSENewConnectionWizard newConnWizard = new RSENewConnectionWizard(); if (!fromPopupMenu && (sp!=null)) { setSelection(sp.getSelection()); } - newConnWizard.setCurrentlySelectedConnection(currConn); - if (restrictSystemTypesTo != null) - newConnWizard.restrictSystemTypes(restrictSystemTypesTo); - if (defaultHostName != null) - newConnWizard.setHostName(defaultHostName); - if (defaultConnectionName != null) - newConnWizard.setConnectionName(defaultConnectionName); + // newConnWizard.setCurrentlySelectedConnection(currConn); + // if (restrictSystemTypesTo != null) + // newConnWizard.restrictSystemTypes(restrictSystemTypesTo); + // if (defaultHostName != null) + // newConnWizard.setHostName(defaultHostName); + // if (defaultConnectionName != null) + // newConnWizard.setConnectionName(defaultConnectionName); return newConnWizard; } diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/AbstractSystemNewConnectionWizardPage.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/AbstractSystemNewConnectionWizardPage.java index d307b853dc4..764373266d1 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/AbstractSystemNewConnectionWizardPage.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/AbstractSystemNewConnectionWizardPage.java @@ -16,6 +16,9 @@ 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.core.subsystems.ISubSystemConfiguration; import org.eclipse.rse.ui.SystemConnectionForm; import org.eclipse.rse.ui.SystemResources; @@ -98,9 +101,9 @@ public abstract class AbstractSystemNewConnectionWizardPage extends AbstractSyst /** * Get the parent wizard typed as the SystemNewConnectionWizard */ - public SystemNewConnectionWizard getNewConnectionWizard() + public RSENewConnectionWizard getNewConnectionWizard() { - return (SystemNewConnectionWizard)getWizard(); + return (RSENewConnectionWizard)getWizard(); } /** @@ -108,11 +111,22 @@ public abstract class AbstractSystemNewConnectionWizardPage extends AbstractSyst */ public ISystemNewConnectionWizardMainPage getMainPage() { - SystemNewConnectionWizard ourWizard = getNewConnectionWizard(); - if (ourWizard != null) - return ourWizard.getMainPage(); - else + RSENewConnectionWizard ourWizard = getNewConnectionWizard(); + if (ourWizard != null) { + String[] systemTypes = parentFactory.getSystemTypes(); + IRSESystemType systemType = RSECorePlugin.getDefault().getRegistry().getSystemType(systemTypes[0]); + IWizardPage wizardPage = ourWizard.getDelegate(systemType).getMainPage(); + + if (wizardPage instanceof ISystemNewConnectionWizardMainPage) { + return (ISystemNewConnectionWizardMainPage)wizardPage; + } + else { + return null; + } + } + else { return null; + } } /** @@ -121,11 +135,21 @@ public abstract class AbstractSystemNewConnectionWizardPage extends AbstractSyst */ public SystemConnectionForm getMainPageForm() { - SystemNewConnectionWizard ourWizard = getNewConnectionWizard(); - if (ourWizard != null) - return ourWizard.getMainPageForm(); - else - return null; + RSENewConnectionWizard ourWizard = getNewConnectionWizard(); + if (ourWizard != null) { + String[] systemTypes = parentFactory.getSystemTypes(); + IRSESystemType systemType = RSECorePlugin.getDefault().getRegistry().getSystemType(systemTypes[0]); + IWizardPage wizardPage = ourWizard.getDelegate(systemType).getMainPage(); + + if (wizardPage instanceof RSENewConnectionWizardDefaultDelegateMainPage) { + return ((RSENewConnectionWizardDefaultDelegateMainPage)wizardPage).getForm(); + } + else { + return null; + } + } + else { + return null; + } } - } \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/AbstractSystemWizard.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/AbstractSystemWizard.java index ca0d8e6abad..7fdfbeebf81 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/AbstractSystemWizard.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/AbstractSystemWizard.java @@ -289,7 +289,7 @@ public abstract class AbstractSystemWizard * For explicitly setting output object after wizard is dismissed. Called in the * wizard's processFinish method, typically. */ - protected void setOutputObject(Object outputObject) + public void setOutputObject(Object outputObject) { output = outputObject; } @@ -370,7 +370,7 @@ public abstract class AbstractSystemWizard * page's performFinish returned false. Pass the failing page. If it is not the current * page, this code will issue msg RSEG1240 "Error on another page" to the user. */ - protected void setPageError(IWizardPage pageInError) + public void setPageError(IWizardPage pageInError) { IWizardPage currentPage = getContainer().getCurrentPage(); if (currentPage != pageInError) 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 new file mode 100644 index 00000000000..fc383f570f3 --- /dev/null +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/IRSENewConnectionWizard.java @@ -0,0 +1,29 @@ +/******************************************************************************** + * Copyright (c) 2000, 2006 IBM Corporation. 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 + * + * Initial Contributors: + * The following IBM employees contributed to the Remote System Explorer + * component that contains this file: David McKnight, Kushal Munir, + * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, + * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. + * + * Contributors: + * {Name} (company) - description of contribution. + ********************************************************************************/ + +package org.eclipse.rse.ui.wizards; + +import org.eclipse.rse.core.IRSESystemType; +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 IRSENewConnectionWizardDelegate getDelegate(IRSESystemType systemType); + + public void setSystemType(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 new file mode 100644 index 00000000000..60835888924 --- /dev/null +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/IRSENewConnectionWizardDelegate.java @@ -0,0 +1,47 @@ +/******************************************************************************** + * Copyright (c) 2000, 2006 IBM Corporation. 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 + * + * Initial Contributors: + * The following IBM employees contributed to the Remote System Explorer + * component that contains this file: David McKnight, Kushal Munir, + * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, + * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. + * + * Contributors: + * {Name} (company) - description of contribution. + ********************************************************************************/ + +package org.eclipse.rse.ui.wizards; + +import org.eclipse.jface.wizard.IWizardPage; +import org.eclipse.rse.core.IRSESystemType; +import org.eclipse.rse.model.IHost; + +/** + * Interface for RSE new connection wizard delegate. + */ +public interface IRSENewConnectionWizardDelegate { + + public void init(RSENewConnectionWizard wizard, IRSESystemType systemType); + + public RSENewConnectionWizard getWizard(); + + public IRSESystemType getSystemType(); + + public void addPages(); + + public boolean performFinish(); + + public boolean canFinish(); + + public IWizardPage getMainPage(); + + public IWizardPage getNextPage(IWizardPage page); + + public IWizardPage getPreviousPage(IWizardPage page); + + public IHost getDummyHost(); +} \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/RSEDefaultNewConnectionWizardDelegate.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/RSEDefaultNewConnectionWizardDelegate.java new file mode 100644 index 00000000000..3b6ad7f1554 --- /dev/null +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/RSEDefaultNewConnectionWizardDelegate.java @@ -0,0 +1,532 @@ +/******************************************************************************** + * Copyright (c) 2000, 2006 IBM Corporation. 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 + * + * Initial Contributors: + * The following IBM employees contributed to the Remote System Explorer + * component that contains this file: David McKnight, Kushal Munir, + * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, + * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. + * + * Contributors: + * {Name} (company) - description of contribution. + ********************************************************************************/ + +package org.eclipse.rse.ui.wizards; + +import java.util.Hashtable; +import java.util.Vector; + +import org.eclipse.jface.wizard.IWizardPage; +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.rse.core.IRSESystemType; +import org.eclipse.rse.core.SystemBasePlugin; +import org.eclipse.rse.core.SystemPerspectiveHelpers; +import org.eclipse.rse.core.subsystems.ISubSystem; +import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; +import org.eclipse.rse.core.subsystems.util.ISubsystemConfigurationAdapter; +import org.eclipse.rse.model.DummyHost; +import org.eclipse.rse.model.IHost; +import org.eclipse.rse.model.ISystemProfile; +import org.eclipse.rse.model.ISystemRegistry; +import org.eclipse.rse.model.SystemStartHere; +import org.eclipse.rse.services.clientserver.messages.SystemMessage; +import org.eclipse.rse.services.clientserver.messages.SystemMessageException; +import org.eclipse.rse.ui.ISystemPreferencesConstants; +import org.eclipse.rse.ui.RSEUIPlugin; +import org.eclipse.rse.ui.SystemConnectionForm; +import org.eclipse.rse.ui.SystemResources; +import org.eclipse.rse.ui.messages.SystemMessageDialog; + + +/** + * + */ +public class RSEDefaultNewConnectionWizardDelegate extends RSENewConnectionWizardDelegate { + + private RSENewConnectionWizardDefaultDelegateMainPage mainPage; + private SystemNewConnectionWizardRenameProfilePage rnmProfilePage; + private ISystemNewConnectionWizardPage[] subsystemFactorySuppliedWizardPages; + private Hashtable ssfWizardPagesPerSystemType = new Hashtable(); + private String defaultUserId; + private String defaultConnectionName; + private String defaultHostName; + private String[] activeProfileNames = null; + private int privateProfileIndex = -1; + private ISystemProfile privateProfile = null; + private IHost currentlySelectedConnection = null; + private String[] restrictSystemTypesTo; + private static String lastProfile = null; + private boolean showProfilePageInitially = true; + private IHost _dummyHost; + + /** + * Constructor. + */ + public RSEDefaultNewConnectionWizardDelegate() { + } + + /** + * @see org.eclipse.rse.ui.wizards.RSENewConnectionWizardDelegate#init(org.eclipse.rse.ui.wizards.RSENewConnectionWizard, org.eclipse.rse.core.IRSESystemType) + */ + public void init(RSENewConnectionWizard wizard, IRSESystemType systemType) { + super.init(wizard, systemType); + restrictSystemType(systemType.getName()); + activeProfileNames = SystemStartHere.getSystemProfileManager().getActiveSystemProfileNames(); + } + + /** + * Call this to restrict the system type that the user is allowed to choose + */ + public void restrictSystemType(String systemType) + { + restrictSystemTypesTo = new String[1]; + restrictSystemTypesTo[0] = systemType; + if (mainPage != null) + mainPage.restrictSystemTypes(restrictSystemTypesTo); + } + /** + * Call this to restrict the system types that the user is allowed to choose + */ + public void restrictSystemTypes(String[] systemTypes) + { + this.restrictSystemTypesTo = systemTypes; + if (mainPage != null) + mainPage.restrictSystemTypes(systemTypes); + } + + public IHost getDummyHost() + { + if (_dummyHost == null) + { + _dummyHost = new DummyHost(mainPage.getHostName(), mainPage.getSystemType()); + } + return _dummyHost; + } + + + + /** + * Creates the wizard pages. + * This method is an override from the parent Wizard class. + */ + public void addPages() + { + try { + mainPage = createMainPage(restrictSystemTypesTo); + mainPage.setConnectionNameValidators(SystemConnectionForm.getConnectionNameValidators()); + mainPage.setCurrentlySelectedConnection(currentlySelectedConnection); + if (defaultUserId != null) + mainPage.setUserId(defaultUserId); + if (defaultConnectionName != null) + mainPage.setConnectionName(defaultConnectionName); + if (defaultHostName != null) + mainPage.setHostName(defaultHostName); + + if (restrictSystemTypesTo != null) + mainPage.restrictSystemTypes(restrictSystemTypesTo); + + ISystemProfile defaultProfile = SystemStartHere.getSystemProfileManager().getDefaultPrivateSystemProfile(); + + showProfilePageInitially = RSEUIPlugin.getDefault().getShowProfilePageInitially(); + /* DKM - I don't think we should force profiles into the faces of users + * we no longer default to "private" so hopefully this would never be + * desirable + * + // if there is a default private profile, we might want to show the rename profile page + if (defaultProfile != null) + { + // make private profile equal to default profile + privateProfile = defaultProfile; + + // get the private profile index in the list of active profiles + for (int idx=0; (privateProfileIndex<0) && (idx0)) + lastProfile = activeProfileNames[0]; + } + if (lastProfile != null) + mainPage.setProfileNamePreSelection(lastProfile); + } + } + + // getWizard().addPage((WizardPage)mainPage); + + } catch (Exception exc) + { + SystemBasePlugin.logError("New connection: Error in createPages: ",exc); + } + } + + /** + * Creates the wizard's main page. + * This method is an override from the parent class. + */ + protected RSENewConnectionWizardDefaultDelegateMainPage createMainPage(String[] restrictSystemTypesTo) + { + 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); + } + } + mainPage = new RSENewConnectionWizardDefaultDelegateMainPage(getWizard(), + pageTitle, + SystemResources.RESID_NEWCONN_PAGE1_DESCRIPTION); + getWizard().setOutputObject(null); + return mainPage; + } + /** + * Set the currently selected connection. Used to better default entry fields. + */ + public void setCurrentlySelectedConnection(IHost conn) + { + this.currentlySelectedConnection = conn; + } + + /** + * For "new" mode, allows setting of the initial user Id. Sometimes subsystems + * like to have their own default userId preference page option. If so, query + * it and set it here by calling this. + */ + public void setUserId(String userId) + { + defaultUserId = userId; + if (mainPage != null) + mainPage.setUserId(userId); + } + + /** + * Preset the connection name + */ + public void setConnectionName(String name) + { + defaultConnectionName = name; + if (mainPage != null) + mainPage.setConnectionName(name); + } + /** + * Preset the host name + */ + public void setHostName(String name) + { + defaultHostName = name; + if (mainPage != null) + mainPage.setHostName(name); + } + + /** + * Completes processing of the wizard. If this + * method returns true, the wizard will close; + * otherwise, it will stay active. + * This method is an override from the parent Wizard class. + * + * @return whether the wizard finished successfully + */ + public boolean performFinish() + { + boolean ok = mainPage.performFinish(); + if (!ok) + getWizard().setPageError((IWizardPage)mainPage); + else if (ok && hasAdditionalPages()) + { + for (int idx=0; ok && (idx0))// might be in product that doesn't have iSeries plugins + sr.expandSubSystem(objSubSystems[0]); + else + sr.expandHost(conn); + } + else + sr.expandHost(conn); + } + + lastProfile = mainPage.getProfileName(); + getWizard().setOutputObject(conn); + } catch (Exception exc) + { + if (cursorSet) + getWizard().setBusyCursor(false); + cursorSet = false; + String msg = "Exception creating connection "; + SystemBasePlugin.logError(msg, exc); + SystemMessageDialog.displayExceptionMessage(getWizard().getShell(),exc); + ok = false; + } + } + //getShell().setCursor(null); + //busyCursor.dispose(); + if (cursorSet) + getWizard().setBusyCursor(false); + return ok; + } + return ok; + } + + // callbacks from rename page + + /** + * Set the new profile name specified on the rename profile page... + */ + protected void setNewPrivateProfileName(String newName) + { + activeProfileNames[privateProfileIndex] = newName; + if (mainPage != null) + { + mainPage.setProfileNames(activeProfileNames); + mainPage.setProfileNamePreSelection(newName); + } + } + + /** + * Return the main page of this wizard + */ + public IWizardPage getMainPage() + { + addPages(); + return mainPage; + } + + /** + * Return the form of the main page of this wizard + */ + public SystemConnectionForm getMainPageForm() + { + return ((RSENewConnectionWizardDefaultDelegateMainPage)mainPage).getForm(); + } + + // ---------------------------------------- + // CALLBACKS FROM SYSTEM CONNECTION PAGE... + // ---------------------------------------- + /** + * Event: the user has selected a system type. + */ + public void systemTypeSelected(String systemType, boolean duringInitialization) + { + subsystemFactorySuppliedWizardPages = getAdditionalWizardPages(systemType); + if (!duringInitialization) + getWizard().getContainer().updateButtons(); + } + + /* + * Private method to get all the wizard pages from all the subsystem factories, given a + * system type. + */ + protected ISystemNewConnectionWizardPage[] getAdditionalWizardPages(String systemType) + { + // this query is expensive, so only do it once... + subsystemFactorySuppliedWizardPages = (ISystemNewConnectionWizardPage[])ssfWizardPagesPerSystemType.get(systemType); + if (subsystemFactorySuppliedWizardPages == null) + { + // query all affected subsystems for their list of additional wizard pages... + Vector additionalPages = new Vector(); + ISystemRegistry sr = RSEUIPlugin.getTheSystemRegistry(); + ISubSystemConfiguration[] factories = sr.getSubSystemConfigurationsBySystemType(systemType, true); + for (int idx=0; idx0); + } + + /** + * Return the first additional page to show when user presses Next on the main page + */ + protected IWizardPage getFirstAdditionalPage() + { + if ((subsystemFactorySuppliedWizardPages != null) && (subsystemFactorySuppliedWizardPages.length>0)) + { + IWizardPage previousPage = (IWizardPage)mainPage; + for (int idx=0; idx + *
  • Connection Name + *
  • Hostname/IP-address + *
  • UserId + *
  • Description + * + */ + +public class RSENewConnectionWizardDefaultDelegateMainPage + //extends WizardPage + extends AbstractSystemWizardPage + implements ISystemMessages, ISystemNewConnectionWizardMainPage, + ISystemMessageLine, ISystemConnectionFormCaller +{ + protected String[] restrictSystemTypesTo; + protected SystemConnectionForm form; + protected String parentHelpId; + protected RSEDefaultNewConnectionWizardDelegate delegate; + + /** + * Constructor. Use this when you want to supply your own title and + * description strings. + */ + public RSENewConnectionWizardDefaultDelegateMainPage(Wizard wizard, + String title, + String description) + { + super(wizard, "NewConnection", title, description); + parentHelpId = RSEUIPlugin.HELPPREFIX + "wncc0000"; + setHelp(parentHelpId); + this.delegate = delegate; + form = getForm(); + } + + /** + * Call this to restrict the system type that the user is allowed to choose + */ + public void restrictSystemType(String systemType) + { + restrictSystemTypesTo = new String[1]; + restrictSystemTypesTo[0] = systemType; + form.restrictSystemTypes(restrictSystemTypesTo); + } + /** + * Call this to restrict the system types that the user is allowed to choose + */ + public void restrictSystemTypes(String[] systemTypes) + { + restrictSystemTypesTo = systemTypes; + form.restrictSystemTypes(restrictSystemTypesTo); + } + + /** + * Return the main wizard typed + */ + private RSEDefaultNewConnectionWizardDelegate getOurWizardDelegate() + { + IWizard wizard = getWizard(); + if (wizard instanceof RSEDefaultNewConnectionWizardDelegate) + return (RSEDefaultNewConnectionWizardDelegate)wizard; + else + return null; + } + + + /** + * Overrride this if you want to supply your own form. This may be called + * multiple times so please only instantatiate if the form instance variable + * is null, and then return the form instance variable. + * @see org.eclipse.rse.ui.SystemConnectionForm + */ + protected SystemConnectionForm getForm() + { + if (form == null) + form = new SystemConnectionForm(this,this); + return form; + } + /** + * Call this to specify a validator for the connection name. It will be called per keystroke. + */ + public void setConnectionNameValidators(ISystemValidator[] v) + { + form.setConnectionNameValidators(v); + } + /** + * Call this to specify a validator for the hostname. It will be called per keystroke. + */ + public void setHostNameValidator(ISystemValidator v) + { + form.setHostNameValidator(v); + } + /** + * Call this to specify a validator for the userId. It will be called per keystroke. + */ + public void setUserIdValidator(ISystemValidator v) + { + form.setUserIdValidator(v); + } + + /** + * This method allows setting of the initial user Id. Sometimes subsystems + * like to have their own default userId preference page option. If so, query + * it and set it here by calling this. + */ + public void setUserId(String userId) + { + form.setUserId(userId); + } + + /** + * Set the profile names to show in the combo + */ + public void setProfileNames(String[] names) + { + form.setProfileNames(names); + } + /** + * Set the profile name to preselect + */ + public void setProfileNamePreSelection(String name) + { + form.setProfileNamePreSelection(name); + } + + /** + * Set the currently selected connection so as to better initialize input fields + */ + public void setCurrentlySelectedConnection(IHost connection) + { + form.setCurrentlySelectedConnection(connection); + } + + /** + * Preset the connection name + */ + public void setConnectionName(String name) + { + form.setConnectionName(name); + } + /** + * Preset the host name + */ + public void setHostName(String name) + { + form.setHostName(name); + } + + + /** + * CreateContents is the one method that must be overridden from the parent class. + * In this method, we populate an SWT container with widgets and return the container + * to the caller (JFace). This is used as the contents of this page. + */ + public Control createContents(Composite parent) + { + return form.createContents(parent, SystemConnectionForm.CREATE_MODE, parentHelpId); + } + /** + * Return the Control to be given initial focus. + * Override from parent. Return control to be given initial focus. + */ + protected Control getInitialFocusControl() + { + return form.getInitialFocusControl(); + } + + /** + * Completes processing of the wizard. If this + * method returns true, the wizard will close; + * otherwise, it will stay active. + * This method is an override from the parent Wizard class. + * + * @return whether the wizard finished successfully + */ + public boolean performFinish() + { + return form.verify(true); + } + + // --------------------------------- // + // METHODS FOR EXTRACTING USER DATA ... + // --------------------------------- // + /** + * Return user-entered System Type. + * Call this after finish ends successfully. + */ + public String getSystemType() + { + return form.getSystemType(); + } + /** + * Return user-entered Connection Name. + * Call this after finish ends successfully. + */ + public String getConnectionName() + { + return form.getConnectionName(); + } + /** + * Return user-entered Host Name. + * Call this after finish ends successfully. + */ + public String getHostName() + { + return form.getHostName(); + } + /** + * Return user-entered Default User Id. + * Call this after finish ends successfully. + */ + public String getDefaultUserId() + { + return form.getDefaultUserId(); + } + /** + * Return location where default user id is to be set. + * @see org.eclipse.rse.core.ISystemUserIdConstants + */ + public int getDefaultUserIdLocation() + { + return form.getUserIdLocation(); + } + /** + * Return user-entered Description. + * Call this after finish ends successfully. + */ + public String getConnectionDescription() + { + return form.getConnectionDescription(); + } + /** + * Return name of profile to contain new connection. + * Call this after finish ends successfully. + */ + public String getProfileName() + { + return form.getProfileName(); + } + + // ISystemMessageLine methods +// public void clearMessage() +// { +// setMessage(null); +// } + //public void clearErrorMessage() + //{ + //setErrorMessage(null); + //} + + public Object getLayoutData() + { + return null; + } + + public void setLayoutData(Object gridData) + { + } + + + + /** + * Return true if the page is complete, so to enable Finish. + * Called by wizard framework. + */ + public boolean isPageComplete() + { + //System.out.println("Inside isPageComplete. " + form.isPageComplete()); + if (form!=null) + return form.isPageComplete() && form.isConnectionUnique(); + else + return false; + } + + /** + * Intercept of WizardPage so we know when Next is pressed + */ + public IWizardPage getNextPage() + { + //if (wizard == null) + //return null; + //return wizard.getNextPage(this); + + RSEDefaultNewConnectionWizardDelegate newConnWizardDelegate = getOurWizardDelegate(); + if (newConnWizardDelegate != null) + { + return newConnWizardDelegate.getFirstAdditionalPage(); + } + else + return super.getNextPage(); + } + /** + * Intercept of WizardPge so we know when the wizard framework is deciding whether + * to enable next or not. + */ + public boolean canFlipToNextPage() + { + //return isPageComplete() && getNextPage() != null; + + RSEDefaultNewConnectionWizardDelegate newConnWizardDelegate = getOurWizardDelegate(); + if (newConnWizardDelegate != null) + { + return (isPageComplete() && newConnWizardDelegate.hasAdditionalPages() && form.isConnectionUnique()); + } + else + return super.canFlipToNextPage(); + } + + // ---------------------------------------- + // CALLBACKS FROM SYSTEM CONNECTION FORM... + // ---------------------------------------- + /** + * Event: the user has selected a system type. + */ + public void systemTypeSelected(String systemType, boolean duringInitialization) + { + RSEDefaultNewConnectionWizardDelegate newConnWizardDelegate = getOurWizardDelegate(); + if (newConnWizardDelegate != null) + { + newConnWizardDelegate.systemTypeSelected(systemType, duringInitialization); + } + } + +} \ No newline at end of file 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 new file mode 100644 index 00000000000..c4e84fb1020 --- /dev/null +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/RSENewConnectionWizardDelegate.java @@ -0,0 +1,78 @@ +/******************************************************************************** + * Copyright (c) 2000, 2006 IBM Corporation. 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 + * + * Initial Contributors: + * The following IBM employees contributed to the Remote System Explorer + * component that contains this file: David McKnight, Kushal Munir, + * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, + * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. + * + * Contributors: + * {Name} (company) - description of contribution. + ********************************************************************************/ + +package org.eclipse.rse.ui.wizards; + +import org.eclipse.jface.wizard.IWizardPage; +import org.eclipse.rse.core.IRSESystemType; + +/** + * + */ +public abstract class RSENewConnectionWizardDelegate implements IRSENewConnectionWizardDelegate { + + private RSENewConnectionWizard wizard; + private IRSESystemType systemType; + + /** + * @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) { + this.wizard = wizard; + this.systemType = systemType; + } + + /** + * @see org.eclipse.rse.ui.wizards.IRSENewConnectionWizardDelegate#getWizard() + */ + public RSENewConnectionWizard getWizard() { + return wizard; + } + + /** + * @see org.eclipse.rse.ui.wizards.IRSENewConnectionWizardDelegate#getSystemType() + */ + public IRSESystemType getSystemType() { + return systemType; + } + + /** + * @see org.eclipse.rse.ui.wizards.IRSENewConnectionWizardDelegate#addPages() + */ + public void addPages() { + } + + /** + * @see org.eclipse.rse.ui.wizards.IRSENewConnectionWizardDelegate#canFinish() + */ + public boolean canFinish() { + return false; + } + + /** + * @see org.eclipse.rse.ui.wizards.IRSENewConnectionWizardDelegate#getNextPage(org.eclipse.jface.wizard.IWizardPage) + */ + public IWizardPage getNextPage(IWizardPage page) { + return null; + } + + /** + * @see org.eclipse.rse.ui.wizards.IRSENewConnectionWizardDelegate#getPreviousPage(org.eclipse.jface.wizard.IWizardPage) + */ + public IWizardPage getPreviousPage(IWizardPage page) { + return wizard.getStartingPage(); + } +} \ No newline at end of file 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 new file mode 100644 index 00000000000..b94c2c86e33 --- /dev/null +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/RSENewConnectionWizardMainPage.java @@ -0,0 +1,110 @@ +/******************************************************************************** + * Copyright (c) 2000, 2006 IBM Corporation. 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 + * + * Initial Contributors: + * The following IBM employees contributed to the Remote System Explorer + * component that contains this file: David McKnight, Kushal Munir, + * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, + * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. + * + * Contributors: + * {Name} (company) - description of contribution. + ********************************************************************************/ + +package org.eclipse.rse.ui.wizards; + +import org.eclipse.jface.wizard.IWizard; +import org.eclipse.jface.wizard.IWizardPage; +import org.eclipse.rse.core.RSECorePlugin; +import org.eclipse.rse.ui.RSEUIPlugin; +import org.eclipse.rse.ui.SystemResources; +import org.eclipse.rse.ui.SystemWidgetHelpers; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Label; + +/** + * + */ +public class RSENewConnectionWizardMainPage extends AbstractSystemWizardPage { + + protected String parentHelpId; + protected Combo textSystemType; + + /** + * Constructor. + * @param wizard the wizard. + * @param title the title of the wizard page. + * @param description the description of the wizard page. + */ + public RSENewConnectionWizardMainPage(IRSENewConnectionWizard wizard, String title, String description) { + super(wizard, "NewConnectionSystemType", title, description); + parentHelpId = RSEUIPlugin.HELPPREFIX + "wncc0000"; + setHelp(parentHelpId); + } + + /** + * @see org.eclipse.rse.ui.wizards.AbstractSystemWizardPage#createContents(org.eclipse.swt.widgets.Composite) + */ + public Control createContents(Composite parent) { + + int nbrColumns = 2; + Composite composite_prompts = SystemWidgetHelpers.createComposite(parent, nbrColumns); + SystemWidgetHelpers.setCompositeHelp(composite_prompts, parentHelpId); + + String temp = SystemWidgetHelpers.appendColon(SystemResources.RESID_CONNECTION_SYSTEMTYPE_LABEL); + + Label labelSystemType = SystemWidgetHelpers.createLabel(composite_prompts, temp); + labelSystemType.setToolTipText(SystemResources.RESID_CONNECTION_SYSTEMTYPE_TIP); + + textSystemType = SystemWidgetHelpers.createSystemTypeCombo(parent, null); + textSystemType.setToolTipText(SystemResources.RESID_CONNECTION_SYSTEMTYPE_TIP); + SystemWidgetHelpers.setHelp(textSystemType, RSEUIPlugin.HELPPREFIX + "ccon0003"); + + return composite_prompts; + } + + /** + * @see org.eclipse.rse.ui.wizards.AbstractSystemWizardPage#getInitialFocusControl() + */ + protected Control getInitialFocusControl() { + + if (textSystemType != null) { + return textSystemType; + } + else { + return null; + } + } + + /** + * @see org.eclipse.rse.ui.wizards.AbstractSystemWizardPage#performFinish() + */ + public boolean performFinish() { + return true; + } + + /** + * @see org.eclipse.jface.wizard.WizardPage#getNextPage() + */ + public IWizardPage getNextPage() { + + 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(); + IRSENewConnectionWizardDelegate delegate = ((IRSENewConnectionWizard)wizard).getDelegate(RSECorePlugin.getDefault().getRegistry().getSystemType(systemTypeStr)); + return delegate.getMainPage(); + } + else { + return super.getNextPage(); + } + } +} \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/SubSystemServiceWizardPage.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/SubSystemServiceWizardPage.java index 3265004dc96..e994a051871 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/SubSystemServiceWizardPage.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/SubSystemServiceWizardPage.java @@ -20,6 +20,8 @@ import java.util.ArrayList; import java.util.List; import org.eclipse.jface.wizard.IWizard; +import org.eclipse.rse.core.IRSESystemType; +import org.eclipse.rse.core.RSECorePlugin; import org.eclipse.rse.core.servicesubsystem.IServiceSubSystem; import org.eclipse.rse.core.servicesubsystem.IServiceSubSystemConfiguration; import org.eclipse.rse.core.subsystems.IConnectorService; @@ -78,12 +80,16 @@ public class SubSystemServiceWizardPage extends AbstractSystemNewConnectionWizar IServiceSubSystemConfiguration currentFactory = (IServiceSubSystemConfiguration)getSubSystemFactory(); - IServiceSubSystemConfiguration[] factories = getServiceSubSystemFactories(getMainPage().getSystemType(), currentFactory.getServiceType()); + + String systemTypeStr = getMainPage().getSystemType(); + IRSESystemType systemType = RSECorePlugin.getDefault().getRegistry().getSystemType(systemTypeStr); + + IServiceSubSystemConfiguration[] factories = getServiceSubSystemFactories(systemTypeStr, currentFactory.getServiceType()); IHost dummyHost = null; - if (getWizard() instanceof SystemNewConnectionWizard) + if (getWizard() instanceof RSENewConnectionWizard) { - dummyHost = ((SystemNewConnectionWizard)getWizard()).getDummyHost(); + dummyHost = ((RSENewConnectionWizard)getWizard()).getDelegate(systemType).getDummyHost(); } // create elements for each diff --git a/rse/plugins/org.eclipse.rse.ui/plugin.xml b/rse/plugins/org.eclipse.rse.ui/plugin.xml index caed08588d1..eebf5408f6c 100644 --- a/rse/plugins/org.eclipse.rse.ui/plugin.xml +++ b/rse/plugins/org.eclipse.rse.ui/plugin.xml @@ -840,6 +840,7 @@ Contributors: + @@ -1051,7 +1052,7 @@ Contributors: name="%Creation.connection.name" icon="icons/full/etool16/newconnection_wiz.gif" category="org.eclipse.rse.ui.newWizards.rseCategory" - class="org.eclipse.rse.ui.wizards.SystemNewConnectionWizard" + class="org.eclipse.rse.ui.wizards.RSENewConnectionWizard" preferredPerspectives="org.eclipse.rse.ui.view.SystemPerspective" canFinishEarly="false" hasPages="true"> @@ -1060,4 +1061,4 @@ Contributors: - \ No newline at end of file + diff --git a/rse/plugins/org.eclipse.rse.ui/schema/newConnectionWizardDelegate.exsd b/rse/plugins/org.eclipse.rse.ui/schema/newConnectionWizardDelegate.exsd new file mode 100644 index 00000000000..abf51969bdf --- /dev/null +++ b/rse/plugins/org.eclipse.rse.ui/schema/newConnectionWizardDelegate.exsd @@ -0,0 +1,112 @@ + + + + + + + + + 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. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The system type ID. + + + + + + + A class that implements + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The provider of a new connection delegate for a certain system type must implement <samp>org.eclipse.rse.ui.wizards.IRSENewConnectionWizardDelegate</samp>. Instead of extending the interface, it is recommended that the abstract class <samp>org.eclipse.rse.ui.wizards.RSENewConnectionWizardDelegate</samp> be extended. + + + + + + + + + + + + + + + + + + Copyright (c) 2006 IBM Corporation. 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: +IBM Corporation - initial API and implementation + + + +