From e2b41135e19d9da35afec760a1a83fa2aeffbe47 Mon Sep 17 00:00:00 2001 From: Uwe Stieber Date: Wed, 13 Jun 2007 11:59:34 +0000 Subject: [PATCH] [192202] Default RSE new connection wizard does not allow to query created host instance anymore --- .../ui/actions/SystemNewConnectionAction.java | 30 +++++++++++++++++++ .../RSEDefaultNewConnectionWizard.java | 25 ++++++++++++---- 2 files changed, 50 insertions(+), 5 deletions(-) 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 dc47878ea0e..4f100948bd0 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 @@ -13,9 +13,11 @@ * Contributors: * Uwe Stieber (Wind River) - Set action id for identification from plugin.xml menu extensions. * Martin Oberhuber (Wind River) - [184095] Replace systemTypeName by IRSESystemType + * Uwe Stieber (Wind River) - [192202] Default RSE new connection wizard does not allow to query created host instance anymore ********************************************************************************/ package org.eclipse.rse.ui.actions; +import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.ISelectionProvider; @@ -33,6 +35,7 @@ import org.eclipse.rse.internal.ui.SystemResources; import org.eclipse.rse.ui.ISystemContextMenuConstants; import org.eclipse.rse.ui.ISystemIconConstants; import org.eclipse.rse.ui.RSEUIPlugin; +import org.eclipse.rse.ui.wizards.newconnection.RSEDefaultNewConnectionWizard; import org.eclipse.rse.ui.wizards.newconnection.RSEMainNewConnectionWizard; import org.eclipse.swt.widgets.Shell; @@ -107,6 +110,9 @@ public class SystemNewConnectionAction extends SystemBaseWizardAction { * Our default implementation is to return RSEMainNewConnectionWizard. */ protected IWizard createWizard() { + // reset the output value + setValue(null); + // create the new connection wizard instance. RSEMainNewConnectionWizard newConnWizard = new RSEMainNewConnectionWizard(); @@ -159,6 +165,30 @@ public class SystemNewConnectionAction extends SystemBaseWizardAction { this.restrictSystemTypesTo = systemTypes; } + /* (non-Javadoc) + * @see org.eclipse.rse.ui.actions.SystemBaseWizardAction#postProcessWizard(org.eclipse.jface.wizard.IWizard) + */ + protected void postProcessWizard(IWizard wizard) { + if (wizard instanceof RSEDefaultNewConnectionWizard) { + setValue(((RSEDefaultNewConnectionWizard)wizard).getCreatedHost()); + } + } + + /* (non-Javadoc) + * @see org.eclipse.rse.ui.actions.SystemBaseWizardAction#getDialogValue(org.eclipse.jface.dialogs.Dialog) + */ + protected Object getDialogValue(Dialog dlg) { + // We have to trick the super implementation a little bit because otherwise + // we do not get access to the current wizard instance. The postProcessWizard + // implementation will use setValue() for pushing the created host instance, + // which in turn we query here again in case the super implementation does + // return null to us (which is the case if the wizard does not implement ISystemWizard, + // what is what we do not want to do in case of RSEDefaultNewConnectionWizard anymore). + Object value = super.getDialogValue(dlg); + if (value == null && getValue() != null) value = getValue(); + return value; + } + /* (non-Javadoc) * @see org.eclipse.rse.ui.actions.SystemBaseAction#updateSelection(org.eclipse.jface.viewers.IStructuredSelection) */ diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/RSEDefaultNewConnectionWizard.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/RSEDefaultNewConnectionWizard.java index de1c8375f7d..76167c00691 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/RSEDefaultNewConnectionWizard.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/RSEDefaultNewConnectionWizard.java @@ -18,6 +18,7 @@ * Martin Oberhuber (Wind River) - [186748] Move ISubSystemConfigurationAdapter from UI/rse.core.subsystems.util * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry * Martin Oberhuber (Wind River) - [175680] Deprecate obsolete ISystemRegistry methods + * Uwe Stieber (Wind River) - [192202] Default RSE new connection wizard does not allow to query created host instance anymore ********************************************************************************/ package org.eclipse.rse.ui.wizards.newconnection; @@ -69,6 +70,7 @@ public class RSEDefaultNewConnectionWizard extends RSEAbstractNewConnectionWizar private ISystemProfile privateProfile = null; private IHost selectedContext = null; private static String lastProfile = null; + private IHost createdHost = null; /** * Constructor. @@ -119,6 +121,9 @@ public class RSEDefaultNewConnectionWizard extends RSEAbstractNewConnectionWizar */ public void addPages() { try { + // reset the remembered created host instance + createdHost = null; + mainPage = createMainPage(getSystemType()); SystemConnectionForm form = mainPage.getSystemConnectionForm(); @@ -329,7 +334,7 @@ public class RSEDefaultNewConnectionWizard extends RSEAbstractNewConnectionWizar try { IRSESystemType systemType = getSystemType(); SystemConnectionForm form = mainPage.getSystemConnectionForm(); - IHost conn = sr.createHost(form.getProfileName(), systemType, form.getConnectionName(), form.getHostName(), + createdHost = sr.createHost(form.getProfileName(), systemType, form.getConnectionName(), form.getHostName(), form.getConnectionDescription(), form.getDefaultUserId(), form.getUserIdLocation(), subsystemConfigurationSuppliedWizardPages); @@ -337,15 +342,15 @@ public class RSEDefaultNewConnectionWizard extends RSEAbstractNewConnectionWizar cursorSet = false; // a tweak that is the result of UCD feedback. Phil - if ((conn != null) && SystemPerspectiveHelpers.isRSEPerspectiveActive()) { + if ((createdHost != null) && SystemPerspectiveHelpers.isRSEPerspectiveActive()) { if (systemType.getId().equals(IRSESystemType.SYSTEMTYPE_ISERIES_ID)) { - ISubSystem[] objSubSystems = sr.getSubSystemsBySubSystemConfigurationCategory("nativefiles", conn); //$NON-NLS-1$ + ISubSystem[] objSubSystems = sr.getSubSystemsBySubSystemConfigurationCategory("nativefiles", createdHost); //$NON-NLS-1$ if ((objSubSystems != null) && (objSubSystems.length > 0))// might be in product that doesn't have iSeries plugins RSEUIPlugin.getTheSystemRegistryUI().expandSubSystem(objSubSystems[0]); else - RSEUIPlugin.getTheSystemRegistryUI().expandHost(conn); + RSEUIPlugin.getTheSystemRegistryUI().expandHost(createdHost); } else - RSEUIPlugin.getTheSystemRegistryUI().expandHost(conn); + RSEUIPlugin.getTheSystemRegistryUI().expandHost(createdHost); } lastProfile = form.getProfileName(); @@ -368,6 +373,16 @@ public class RSEDefaultNewConnectionWizard extends RSEAbstractNewConnectionWizar return ok; } + /** + * Returns the create host instance once the user pressed finished. The created + * host instance will be reset to null once the wizard got disposed. + * + * @return The created host instance or null. + */ + public IHost getCreatedHost() { + return createdHost; + } + /** * Private method to get all the wizard pages from all the subsystem factories, given a * system type.