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 9c77d0268b6..c5b34775d26 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 @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (c) 2002, 2006 IBM Corporation. All rights reserved. + * Copyright (c) 2002, 2007 IBM Corporation and others. 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 @@ -13,12 +13,13 @@ * Contributors: * David Dykstal (IBM) - moved SystemPreferencesManager to a new package * - created and used RSEPreferencesManager + * Uwe Stieber (Wind River) - bugfixing and reworked new connection wizard ********************************************************************************/ package org.eclipse.rse.ui; + import java.lang.reflect.InvocationTargetException; import java.net.InetAddress; -import java.net.UnknownHostException; import java.util.Vector; import org.eclipse.core.runtime.IProgressMonitor; @@ -61,8 +62,6 @@ import org.eclipse.swt.widgets.Text; import org.eclipse.ui.IWorkbenchPropertyPage; import org.eclipse.ui.dialogs.PropertyPage; - - /** * A reusable form for prompting for connection information, * in new or update mode. @@ -74,93 +73,87 @@ import org.eclipse.ui.dialogs.PropertyPage; *
*/ -public class SystemConnectionForm - implements Listener, IRSEUserIdConstants, - SelectionListener, Runnable, IRunnableWithProgress -{ - +public class SystemConnectionForm implements Listener, IRSEUserIdConstants, SelectionListener, Runnable, IRunnableWithProgress { + public static final boolean CREATE_MODE = false; public static final boolean UPDATE_MODE = true; - public static String lastSystemType = null; + public static String lastSystemType = null; - // GUI widgets - protected Label labelType, labelConnectionName,labelHostName,labelUserId, labelDescription, labelProfile; + protected Label labelType, labelConnectionName, labelHostName, labelUserId, labelDescription, labelProfile; protected Label labelTypeValue, labelSystemTypeValue, labelProfileValue; - protected Combo textSystemType,textHostName, profileCombo; - protected Text textConnectionName, textDescription; + protected Combo textSystemType, textHostName, profileCombo; + protected Text textConnectionName, textDescription; protected Button verifyHostNameCB; - + // yantzi:artemis 6.0, work offline support protected Button workOfflineCB; - + protected InheritableEntryField textUserId; - protected Label textSystemTypeReadOnly; // for update mode + protected Label textSystemTypeReadOnly; // for update mode // validators protected ISystemValidator[] nameValidators; - protected ISystemValidator hostValidator; + protected ISystemValidator hostValidator; protected ISystemValidator userIdValidator; - + // other inputs - protected ISystemMessageLine msgLine; + protected ISystemMessageLine msgLine; protected ISystemConnectionFormCaller caller; - protected String[] restrictSystemTypesTo; - protected String defaultSystemType, defaultConnectionName, defaultHostName; - protected String defaultUserId, defaultDescription, defaultProfile; // update mode initial values + protected String[] restrictSystemTypesTo; + protected String defaultSystemType, defaultConnectionName, defaultHostName; + protected String defaultUserId, defaultDescription, defaultProfile; // update mode initial values protected String[] defaultProfileNames; - protected boolean defaultWorkOffline; - - protected boolean userPickedVerifyHostnameCB = false; - + protected boolean defaultWorkOffline; + + protected boolean userPickedVerifyHostnameCB = false; + // max lengths protected int hostNameLength = 100; protected int connectionNameLength = ValidatorConnectionName.MAX_CONNECTIONNAME_LENGTH; protected int userIdLength = 100; protected int descriptionLength = 100; - + // state/output - protected int userIdLocation = IRSEUserIdConstants.USERID_LOCATION_HOST; + protected int userIdLocation = IRSEUserIdConstants.USERID_LOCATION_HOST; protected boolean callerInstanceOfWizardPage, callerInstanceOfSystemPromptDialog, callerInstanceOfPropertyPage; protected boolean userIdFromSystemTypeDefault; protected boolean updateMode = false; protected boolean contentsCreated = false; protected boolean connectionNameEmpty = false; - protected boolean connectionNameListen = true; - protected boolean singleTypeMode = false; - protected String originalHostName = null; - protected String currentHostName = null; - protected SystemMessage errorMessage = null; - protected SystemMessage verifyingHostName; - + protected boolean connectionNameListen = true; + protected boolean singleTypeMode = false; + protected String originalHostName = null; + protected String currentHostName = null; + protected SystemMessage errorMessage = null; + protected SystemMessage verifyingHostName; + /** * Constructor. * @param msgLine A GUI widget capable of writing error messages to. * @param caller The wizardpage or dialog hosting this form. */ - public SystemConnectionForm(ISystemMessageLine msgLine, ISystemConnectionFormCaller caller) - { + public SystemConnectionForm(ISystemMessageLine msgLine, ISystemConnectionFormCaller caller) { this.msgLine = msgLine; this.caller = caller; this.defaultProfileNames = RSEUIPlugin.getTheSystemRegistry().getActiveSystemProfileNames(); callerInstanceOfWizardPage = caller instanceof IWizardPage; - callerInstanceOfSystemPromptDialog = caller instanceof ISystemPromptDialog; + callerInstanceOfSystemPromptDialog = caller instanceof ISystemPromptDialog; callerInstanceOfPropertyPage = caller instanceof IWorkbenchPropertyPage; - userIdValidator = new ValidatorUserId(true); // false => allow empty? Yes. - defaultUserId = ""; //$NON-NLS-1$ + userIdValidator = new ValidatorUserId(true); // false => allow empty? Yes. + defaultUserId = ""; //$NON-NLS-1$ } - // ------------------------------------------------------------- - // INPUT METHODS CALLABLE BY CALLER TO INITIALIZE INPUT OR STATE - // ------------------------------------------------------------- - + // ------------------------------------------------------------- + // INPUT METHODS CALLABLE BY CALLER TO INITIALIZE INPUT OR STATE + // ------------------------------------------------------------- + /** * Often the message line is null at the time of instantiation, so we have to call this after * it is created. */ - public void setMessageLine(ISystemMessageLine msgLine) - { + public void setMessageLine(ISystemMessageLine msgLine) { this.msgLine = msgLine; } @@ -170,96 +163,90 @@ public class SystemConnectionForm * The order must be the same as the order of profiles given by getActiveSystemProfiles() in * the system registry. */ - public void setConnectionNameValidators(ISystemValidator[] v) - { + public void setConnectionNameValidators(ISystemValidator[] v) { nameValidators = v; } + /** * Call this to specify a validator for the hostname. It will be called per keystroke. */ - public void setHostNameValidator(ISystemValidator v) - { + public void setHostNameValidator(ISystemValidator v) { hostValidator = v; - } + } + /** * Call this to specify a validator for the userId. It will be called per keystroke. */ - public void setUserIdValidator(ISystemValidator v) - { + public void setUserIdValidator(ISystemValidator v) { userIdValidator = v; } - - /** - * Set the profile names to show in the combo - */ - public void setProfileNames(String[] names) - { - this.defaultProfileNames = names; - if (profileCombo != null) - profileCombo.setItems(names); - } - /** - * Set the profile name to preselect - */ - public void setProfileNamePreSelection(String selection) - { - this.defaultProfile = selection; - if ((profileCombo != null) && (selection != null)) - { - int selIdx = profileCombo.indexOf(selection); - if (selIdx >= 0) - profileCombo.select(selIdx); - else - profileCombo.select(0); - } - } - - /** - * 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; - } - /** - * Set the currently selected connection so as to better initialize input fields - */ - public void setCurrentlySelectedConnection(IHost connection) - { - if (connection != null) - { - initializeInputFields(connection, false); - } - } - /** - * Call this to restrict the system type that the user is allowed to choose - */ - public void restrictSystemType(String systemType) - { - if (systemType.equals("*")) //$NON-NLS-1$ - return; - this.restrictSystemTypesTo = new String[1]; - this.restrictSystemTypesTo[0] = systemType; - if (defaultSystemType == null) - defaultSystemType = systemType; - } - /** - * Call this to restrict the system types that the user is allowed to choose - */ - public void restrictSystemTypes(String[] systemTypes) - { - if (systemTypes == null) - return; - else if ((systemTypes.length==1) && (systemTypes[0].equals("*"))) //$NON-NLS-1$ - return; - this.restrictSystemTypesTo = systemTypes; - if (defaultSystemType == null) - defaultSystemType = systemTypes[0]; - } - + /** + * Set the profile names to show in the combo + */ + public void setProfileNames(String[] names) { + this.defaultProfileNames = names; + if (profileCombo != null) + profileCombo.setItems(names); + } + + /** + * Set the profile name to preselect + */ + public void setProfileNamePreSelection(String selection) { + this.defaultProfile = selection; + if ((profileCombo != null) && (selection != null)) { + int selIdx = profileCombo.indexOf(selection); + if (selIdx >= 0) + profileCombo.select(selIdx); + else + profileCombo.select(0); + } + } + + /** + * 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; + } + + /** + * Set the currently selected connection so as to better initialize input fields + */ + public void setCurrentlySelectedConnection(IHost connection) { + if (connection != null) { + initializeInputFields(connection, false); + } + } + + /** + * Call this to restrict the system type that the user is allowed to choose + */ + public void restrictSystemType(String systemType) { + if (systemType.equals("*")) //$NON-NLS-1$ + return; + this.restrictSystemTypesTo = new String[1]; + this.restrictSystemTypesTo[0] = systemType; + if (defaultSystemType == null) + defaultSystemType = systemType; + } + + /** + * Call this to restrict the system types that the user is allowed to choose + */ + public void restrictSystemTypes(String[] systemTypes) { + if (systemTypes == null) + return; + else if ((systemTypes.length == 1) && (systemTypes[0].equals("*"))) //$NON-NLS-1$ + return; + this.restrictSystemTypesTo = systemTypes; + if (defaultSystemType == null) + defaultSystemType = systemTypes[0]; + } + /** * Initialize input fields to current values in update mode. * Note in update mode we do NOT allow users to change the system type. @@ -267,10 +254,10 @@ public class SystemConnectionForm * You must also be sure to pass true in createContents in order to call this method. * @param conn The SystemConnection object that is being modified. */ - public void initializeInputFields(IHost conn) - { + public void initializeInputFields(IHost conn) { initializeInputFields(conn, true); } + /** * Initialize input fields to current values in update mode. * Note in update mode we do NOT allow users to change the system type. @@ -278,8 +265,7 @@ public class SystemConnectionForm * You must also be sure to pass true in createContents in order to call this method. * @param conn The SystemConnection object that is being modified. */ - public void initializeInputFields(IHost conn, boolean updateMode) - { + public void initializeInputFields(IHost conn, boolean updateMode) { this.updateMode = updateMode; defaultSystemType = conn.getSystemType(); defaultConnectionName = conn.getAliasName(); @@ -289,86 +275,74 @@ public class SystemConnectionForm defaultProfile = conn.getSystemProfile().getName(); defaultWorkOffline = conn.isOffline(); - if (updateMode) - { - defaultProfileNames = new String[1]; - defaultProfileNames[0] = defaultProfile; + if (updateMode) { + defaultProfileNames = new String[1]; + defaultProfileNames[0] = defaultProfile; } - - if (contentsCreated) - doInitializeFields(); + + if (contentsCreated) + doInitializeFields(); } - + /** * Preset the connection name */ - public void setConnectionName(String name) - { + public void setConnectionName(String name) { defaultConnectionName = name; } + /** * Preset the host name */ - public void setHostName(String name) - { + public void setHostName(String name) { defaultHostName = name; } - /** * This method can be called by the dialog or wizard page host, to decide whether to enable * or disable the next, final or ok buttons. It returns true if the minimal information is * available and is correct. */ - public boolean isPageComplete() - { + public boolean isPageComplete() { boolean pageComplete = false; - + if (errorMessage == null) { - pageComplete = ((getConnectionName().length() > 0) - && (getHostName().length() > 0) - && (getProfileName().length() > 0)); + pageComplete = ((getConnectionName().length() > 0) && (getHostName().length() > 0) && (getProfileName().length() > 0)); } - + return pageComplete; } - + /** * @return whether the connection name is unique or not */ - public boolean isConnectionUnique() - { + public boolean isConnectionUnique() { // DKM - d53587 - used to check connection name uniqueness without displaying the error // TODO - need to display a directive for the user to specify a unique connection name // when it's invalid to be consistent with the rest of eclipse rather than // an error message int selectedProfile = 0; - if (profileCombo != null) - { + if (profileCombo != null) { selectedProfile = profileCombo.getSelectionIndex(); } if (selectedProfile < 0) - selectedProfile = 0; - + selectedProfile = 0; + ISystemValidator nameValidator = null; - if ((nameValidators!=null) && (nameValidators.length>0)) + if ((nameValidators != null) && (nameValidators.length > 0)) nameValidator = nameValidators[selectedProfile]; String connName = textConnectionName.getText().trim(); if (nameValidator != null) errorMessage = nameValidator.validate(connName); - - if (errorMessage != null) - { + + if (errorMessage != null) { return false; + } else { + return true; } - else - { - return true; - } - + } - - + // --------------------------------------------- // OUTPUT METHODS FOR EXTRACTING USER DATA ... // --------------------------------------------- @@ -378,121 +352,99 @@ public class SystemConnectionForm * cursor on error checking, else we do not. * @return true if there are no errors in the user input */ - public boolean verify(boolean okPressed) - { + public boolean verify(boolean okPressed) { boolean ok = true; - + //SystemMessage errMsg = null; Control controlInError = null; if (msgLine != null) msgLine.clearErrorMessage(); - + // validate connection name... errorMessage = validateConnectionNameInput(false); if (errorMessage != null) controlInError = textConnectionName; - + // validate host name... - if ((errorMessage == null) && (textHostName != null)) - { + if ((errorMessage == null) && (textHostName != null)) { errorMessage = validateHostNameInput(); if (errorMessage != null) - controlInError = textHostName; - } + controlInError = textHostName; + } // validate user Id... - if ((errorMessage == null) && (textUserId != null)) - { - errorMessage = validateUserIdInput(); - if (errorMessage != null) - controlInError = textUserId; + if ((errorMessage == null) && (textUserId != null)) { + errorMessage = validateUserIdInput(); + if (errorMessage != null) + controlInError = textUserId; } // verify host name... - if ((errorMessage == null) && okPressed && (textHostName != null) && verifyHostNameCB.getSelection()) - { + if ((errorMessage == null) && okPressed && (textHostName != null) && verifyHostNameCB.getSelection()) { currentHostName = textHostName.getText().trim(); - if (currentHostName.length() > 0) - { - if (verifyingHostName == null) { - verifyingHostName = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_HOSTNAME_VERIFYING); - } - - try - { - getRunnableContext().run(true, true, this); - } - catch (InterruptedException e) - { - // user canceled - ok = false; - controlInError = textHostName; - } - catch (InvocationTargetException e) - { - // error found - errorMessage = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_HOSTNAME_NOTFOUND); - errorMessage.makeSubstitution(currentHostName); - controlInError = textHostName; - } + if (currentHostName.length() > 0) { + if (verifyingHostName == null) { + verifyingHostName = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_HOSTNAME_VERIFYING); + } + + try { + getRunnableContext().run(true, true, this); + } catch (InterruptedException e) { + // user canceled + ok = false; + controlInError = textHostName; + } catch (InvocationTargetException e) { + // error found + errorMessage = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_HOSTNAME_NOTFOUND); + errorMessage.makeSubstitution(currentHostName); + controlInError = textHostName; + } } } - + // if ok pressed, test for warning situation that connection name is in use in another profile... - if (ok && (errorMessage==null) && okPressed) - { + if (ok && (errorMessage == null) && okPressed) { String connectionName = textConnectionName.getText().trim(); - if (!connectionName.equals(defaultConnectionName)) - { + if (!connectionName.equals(defaultConnectionName)) { ok = ValidatorConnectionName.validateNameNotInUse(connectionName, caller.getShell()); } controlInError = textConnectionName; } - // ...end of validation... - - if (!ok || (errorMessage != null)) - { + // ...end of validation... + + if (!ok || (errorMessage != null)) { ok = false; if (okPressed && controlInError != null) controlInError.setFocus(); - showErrorMessage(errorMessage); + showErrorMessage(errorMessage); } // DETERMINE DEFAULT USER ID AND WHERE IT IS TO BE SET... // Possibly prompt for where to set user Id... - else - { + else { boolean isLocal = false; - if (textUserId != null) - { + if (textUserId != null) { isLocal = textUserId.isLocal(); if (isLocal) userIdLocation = IRSEUserIdConstants.USERID_LOCATION_HOST; // edit this connection's local value - else + else userIdLocation = IRSEUserIdConstants.USERID_LOCATION_DEFAULT_SYSTEMTYPE; // edit the preference value - } - else + } else userIdLocation = IRSEUserIdConstants.USERID_LOCATION_NOTSET; SystemPreferencesManager.setVerifyConnection(verifyHostNameCB.getSelection()); } - + return ok; - } - + } + /** * Return the runnable context from the hosting dialog or wizard, if * applicable */ - protected IRunnableContext getRunnableContext() - { - if (callerInstanceOfWizardPage) - { + protected IRunnableContext getRunnableContext() { + if (callerInstanceOfWizardPage) { return ((WizardPage)caller).getWizard().getContainer(); - } - else if (callerInstanceOfSystemPromptDialog) - { + } else if (callerInstanceOfSystemPromptDialog) { return ((SystemPromptDialog)caller); - } - else - { + } else { return new ProgressMonitorDialog(caller.getShell()); } } @@ -500,109 +452,100 @@ public class SystemConnectionForm /** * Check if this system type is enabled for offline support */ - private boolean enableOfflineCB() - { + private boolean enableOfflineCB() { // disabled offline checkbox for new connections - if (!updateMode) - { + if (!updateMode) { return false; } - + IRSESystemType sysType = RSECorePlugin.getDefault().getRegistry().getSystemType(defaultSystemType); RSESystemTypeAdapter sysTypeAdapter = (RSESystemTypeAdapter)(sysType.getAdapter(IRSESystemType.class)); return sysTypeAdapter.isEnableOffline(sysType); } - + /** * Return user-entered System Type. * Call this after finish ends successfully. */ - public String getSystemType() - { + public String getSystemType() { if (textSystemType != null) - return textSystemType.getText().trim(); + return textSystemType.getText().trim(); else - return defaultSystemType; - } + return defaultSystemType; + } + /** * Return user-entered Connection Name. * Call this after finish ends successfully. */ - public String getConnectionName() - { + public String getConnectionName() { return textConnectionName.getText().trim(); - } + } + /** * Return user-entered Host Name. * Call this after finish ends successfully. */ - public String getHostName() - { + public String getHostName() { return textHostName.getText().trim(); } + /** * Return user-entered Default User Id. * Call this after finish ends successfully. - */ - public String getDefaultUserId() - { + */ + public String getDefaultUserId() { if (textUserId != null) - return textUserId.getText().trim(); + return textUserId.getText().trim(); else - return ""; //$NON-NLS-1$ + return ""; //$NON-NLS-1$ } - + /** * Return the user-entered value for work offline. * Call this after finish ends successfully. */ - public boolean isWorkOffline() - { - if (workOfflineCB != null) - { + public boolean isWorkOffline() { + if (workOfflineCB != null) { return workOfflineCB.getSelection(); - } - else - { + } else { return false; } } - + /** * Return user-entered Description. * Call this after finish ends successfully. - */ - public String getConnectionDescription() - { + */ + public String getConnectionDescription() { return textDescription.getText().trim(); - } + } + /** * Return user-selected profile to contain this connection * Call this after finish ends successfully, and only in update mode. - */ - public String getProfileName() - { - return (labelProfileValue!=null)?labelProfileValue.getText():profileCombo.getText(); - } + */ + public String getProfileName() { + return (labelProfileValue != null) ? labelProfileValue.getText() : profileCombo.getText(); + } - /** - * If a default userId was specified, the user may have been queried - * where to put the userId. This returns one of the constants from - * IRSEUserIdConstants. - * @return the user id location - * @see IRSEUserIdConstants - */ - public int getUserIdLocation() - { - if ((textUserId != null) && (textUserId.getText().trim().length()>0)) - return userIdLocation; - else - return IRSEUserIdConstants.USERID_LOCATION_NOTSET; - } - - // -------------------- - // INTERNAL METHODS... - // -------------------- + /** + * If a default userId was specified, the user may have been queried + * where to put the userId. This returns one of the constants from + * IRSEUserIdConstants. + * @return the user id location + * @see IRSEUserIdConstants + */ + public int getUserIdLocation() { + if ((textUserId != null) && (textUserId.getText().trim().length() > 0)) + return userIdLocation; + else + return IRSEUserIdConstants.USERID_LOCATION_NOTSET; + } + + // -------------------- + // INTERNAL METHODS... + // -------------------- /** * CreateContents is the one method that must be overridden from the parent class. @@ -612,7 +555,6 @@ public class SystemConnectionForm * @param updateMode true if we are in update mode versus create mode. */ public Control createContents(Composite parent, boolean updateMode, String parentHelpId) { - contentsCreated = true; Label labelSystemType = null; String temp = null; @@ -737,7 +679,6 @@ public class SystemConnectionForm SystemWidgetHelpers.setHelp(workOfflineCB, RSEUIPlugin.HELPPREFIX + "wofp0000"); //$NON-NLS-1$ } - connectionNameEmpty = (textConnectionName.getText().trim().length() == 0); // d43191 textConnectionName.setFocus(); @@ -784,354 +725,320 @@ public class SystemConnectionForm doInitializeFields(); + contentsCreated = true; + return composite_prompts; // composite; } - + /** * Return control to recieve initial focus */ - public Control getInitialFocusControl() - { - if (updateMode || !singleTypeMode) - return textConnectionName; - else - return textHostName; // create mode and restricted to one system type + public Control getInitialFocusControl() { + if (updateMode || !singleTypeMode) + return textConnectionName; + else + return textHostName; // create mode and restricted to one system type } - + /** * Default implementation to satisfy Listener interface. Does nothing. */ - public void handleEvent(Event evt) {} - - /** - * Combo selection listener method - */ - public void widgetDefaultSelected(SelectionEvent event) - { + public void handleEvent(Event evt) { } + /** * Combo selection listener method */ - public void widgetSelected(SelectionEvent event) - { + public void widgetDefaultSelected(SelectionEvent event) { + } + + /** + * Combo selection listener method + */ + public void widgetSelected(SelectionEvent event) { Object src = event.getSource(); - - if (src == profileCombo) - { - profileCombo.getDisplay().asyncExec(this); - } - else if (src == textSystemType) // can only happen in create mode + + if (src == profileCombo) { + profileCombo.getDisplay().asyncExec(this); + } else if (src == textSystemType) // can only happen in create mode { String currHostName = textHostName.getText().trim(); boolean hostNameChanged = !currHostName.equals(originalHostName); String currSystemType = textSystemType.getText().trim(); - textHostName.setItems(RSEUIPlugin.getTheSystemRegistry().getHostNames(currSystemType)); - if (hostNameChanged) - { - textHostName.setText(currHostName); - } - else if (textHostName.getItemCount()>0) - { - textHostName.setText(textHostName.getItem(0)); - originalHostName = textHostName.getText(); - } - else - { - String connName = textConnectionName.getText().trim(); - if (connName.indexOf(' ') == -1) - textHostName.setText(connName); - else - textHostName.setText(""); //$NON-NLS-1$ - originalHostName = textHostName.getText(); - } + textHostName.setItems(RSEUIPlugin.getTheSystemRegistry().getHostNames(currSystemType)); + if (hostNameChanged) { + textHostName.setText(currHostName); + } else if (textHostName.getItemCount() > 0) { + textHostName.setText(textHostName.getItem(0)); + originalHostName = textHostName.getText(); + } else { + String connName = textConnectionName.getText().trim(); + if (connName.indexOf(' ') == -1) + textHostName.setText(connName); + else + textHostName.setText(""); //$NON-NLS-1$ + originalHostName = textHostName.getText(); + } - initializeUserIdField(currSystemType, null); + initializeUserIdField(currSystemType, null); - verify(false); // re-check all fields in top-down order - - caller.systemTypeSelected(currSystemType, false); + verify(false); // re-check all fields in top-down order + + caller.systemTypeSelected(currSystemType, false); } // if verify host name checkbox event else if (src == verifyHostNameCB) { - + userPickedVerifyHostnameCB = true; - // if the check box was unselected - if (!verifyHostNameCB.getSelection()) { - - // clear host name not valid or not found error message so that wizard next page is enabled - if (errorMessage != null && errorMessage == RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_HOSTNAME_NOTFOUND)) { - errorMessage = null; - - if (msgLine != null) { - msgLine.clearErrorMessage(); - } - - // set this page to complete so we can go to next page - setPageComplete(); - - // now go through each page and clear error message if there is one - if (callerInstanceOfWizardPage) { - IWizard wizard = ((WizardPage)caller).getWizard(); - - IWizardPage[] pages = null; - - if (wizard instanceof RSEAbstractNewConnectionWizard) { - RSEAbstractNewConnectionWizard connWizard = (RSEAbstractNewConnectionWizard)wizard; - AbstractSystemWizardPage mainPage = (AbstractSystemWizardPage)(connWizard.getStartingPage()); - - Vector pageList = new Vector(); - - IWizardPage page = mainPage; - - while (page != null) { - - if (page != mainPage) { - pageList.add(page); - } - - page = connWizard.getNextPage(page); - } - - pages = new IWizardPage[pageList.size()]; - - for (int j = 0; j < pageList.size(); j++) { - pages[j] = (IWizardPage)(pageList.get(j)); - } - } - else { - pages = wizard.getPages(); - } - - for (int i = 0; i < pages.length; i++) { - - IWizardPage page = pages[i]; - - if (page instanceof AbstractSystemWizardPage) { - ((AbstractSystemWizardPage)page).clearErrorMessage(); - } - else if (page instanceof WizardPage) { - ((WizardPage)page).setErrorMessage(null); - } - } - } - } - } + // if the check box was unselected + if (!verifyHostNameCB.getSelection()) { + + // clear host name not valid or not found error message so that wizard next page is enabled + if (errorMessage != null && errorMessage == RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_HOSTNAME_NOTFOUND)) { + errorMessage = null; + + if (msgLine != null) { + msgLine.clearErrorMessage(); + } + + // set this page to complete so we can go to next page + setPageComplete(); + + // now go through each page and clear error message if there is one + if (callerInstanceOfWizardPage) { + IWizard wizard = ((WizardPage)caller).getWizard(); + + IWizardPage[] pages = null; + + if (wizard instanceof RSEAbstractNewConnectionWizard) { + RSEAbstractNewConnectionWizard connWizard = (RSEAbstractNewConnectionWizard)wizard; + AbstractSystemWizardPage mainPage = (AbstractSystemWizardPage)(connWizard.getStartingPage()); + + Vector pageList = new Vector(); + + IWizardPage page = mainPage; + + while (page != null) { + + if (page != mainPage) { + pageList.add(page); + } + + page = connWizard.getNextPage(page); + } + + pages = new IWizardPage[pageList.size()]; + + for (int j = 0; j < pageList.size(); j++) { + pages[j] = (IWizardPage)(pageList.get(j)); + } + } else { + pages = wizard.getPages(); + } + + for (int i = 0; i < pages.length; i++) { + + IWizardPage page = pages[i]; + + if (page instanceof AbstractSystemWizardPage) { + ((AbstractSystemWizardPage)page).clearErrorMessage(); + } else if (page instanceof WizardPage) { + ((WizardPage)page).setErrorMessage(null); + } + } + } + } + } } } - + /** * Initialize values of input fields based on input */ - private void doInitializeFields() - { + private void doInitializeFields() { // ------- // profile // ------- // ...output-only: - if (labelProfileValue != null) - { - if (defaultProfile != null) - labelProfileValue.setText(defaultProfile); + if (labelProfileValue != null) { + if (defaultProfile != null) + labelProfileValue.setText(defaultProfile); } // ...selectable: - else - { - if (defaultProfileNames != null) - profileCombo.setItems(defaultProfileNames); + else { + if (defaultProfileNames != null) + profileCombo.setItems(defaultProfileNames); - if (defaultProfile != null) - { - int selIdx = profileCombo.indexOf(defaultProfile); - if (selIdx >= 0) - profileCombo.select(selIdx); - else - profileCombo.select(0); - } + if (defaultProfile != null) { + int selIdx = profileCombo.indexOf(defaultProfile); + if (selIdx >= 0) + profileCombo.select(selIdx); + else + profileCombo.select(0); + } } - // ----------- + // ----------- // system type - // ----------- - // ...output-only: - if ((textSystemTypeReadOnly != null) || singleTypeMode) - { - if (restrictSystemTypesTo != null) - { - if (textSystemTypeReadOnly != null) - textSystemTypeReadOnly.setText(restrictSystemTypesTo[0]); - if (defaultSystemType == null) - defaultSystemType = restrictSystemTypesTo[0]; - } - else if (defaultSystemType != null) - { - if (textSystemTypeReadOnly != null) - textSystemTypeReadOnly.setText(defaultSystemType); - } - } - // ...selectable: - else - { - if (defaultSystemType == null) - { - defaultSystemType = RSEPreferencesManager.getSystemType(); - if ((defaultSystemType == null) || (defaultSystemType.length()==0)) - defaultSystemType = lastSystemType; - } - if (defaultSystemType != null) - { - int selIdx = textSystemType.indexOf(defaultSystemType); - if (selIdx >= 0) - textSystemType.select(selIdx); - } - else - { - textSystemType.select(0); - defaultSystemType = textSystemType.getText(); - } - } - - // --------------- - // connection name - // --------------- - if (defaultConnectionName != null) - textConnectionName.setText(defaultConnectionName); - textConnectionName.setTextLimit(connectionNameLength); - - // ----------- - // host name - // ----------- - if (defaultHostName != null) - { - textHostName.setText(defaultHostName); + // ----------- + // ...output-only: + if ((textSystemTypeReadOnly != null) || singleTypeMode) { + if (restrictSystemTypesTo != null) { + if (textSystemTypeReadOnly != null) + textSystemTypeReadOnly.setText(restrictSystemTypesTo[0]); + if (defaultSystemType == null) + defaultSystemType = restrictSystemTypesTo[0]; + } else if (defaultSystemType != null) { + if (textSystemTypeReadOnly != null) + textSystemTypeReadOnly.setText(defaultSystemType); + } } - else if (textHostName.getItemCount() > 0) - { + // ...selectable: + else { + if (defaultSystemType == null) { + defaultSystemType = RSEPreferencesManager.getSystemType(); + if ((defaultSystemType == null) || (defaultSystemType.length() == 0)) + defaultSystemType = lastSystemType; + } + if (defaultSystemType != null) { + int selIdx = textSystemType.indexOf(defaultSystemType); + if (selIdx >= 0) + textSystemType.select(selIdx); + } else { + textSystemType.select(0); + defaultSystemType = textSystemType.getText(); + } + } + + // --------------------------------------------------- + // connection name: Don't set during context creation! + // --------------------------------------------------- + if (defaultConnectionName != null && contentsCreated) + textConnectionName.setText(defaultConnectionName); + textConnectionName.setTextLimit(connectionNameLength); + + // ----------- + // host name + // ----------- + if (defaultHostName != null) { + textHostName.setText(defaultHostName); + } else if (textHostName.getItemCount() > 0) { textHostName.select(0); } textHostName.setTextLimit(hostNameLength); textHostName.clearSelection(); // should unselect the text, but it does not! - // --------------- + // --------------- // default user id - // --------------- - initializeUserIdField(defaultSystemType, defaultUserId); - if (textUserId!=null) - textUserId.setTextLimit(userIdLength); + // --------------- + initializeUserIdField(defaultSystemType, defaultUserId); + if (textUserId != null) + textUserId.setTextLimit(userIdLength); // description if (defaultDescription != null) - textDescription.setText(defaultDescription); - textDescription.setTextLimit(descriptionLength); - + textDescription.setText(defaultDescription); + textDescription.setTextLimit(descriptionLength); + // --------------- // Work offline // --------------- - if (workOfflineCB != null) - { + if (workOfflineCB != null) { workOfflineCB.setSelection(defaultWorkOffline); } - + verify(false); } - + /** * Initialize userId values. * We have to reset after user changes the system type */ - private void initializeUserIdField(String systemType, String currentUserId) - { - // --------------- + private void initializeUserIdField(String systemType, String currentUserId) { + // --------------- // default user id - // --------------- - String parentUserId = RSEPreferencesManager.getUserId(systemType); - if (textUserId!=null) - { - textUserId.setInheritedText(parentUserId); - boolean allowEditingOfInherited = ((parentUserId == null) || (parentUserId.length()==0)); - textUserId.setAllowEditingOfInheritedText(allowEditingOfInherited); // if not set yet, let user set it! + // --------------- + String parentUserId = RSEPreferencesManager.getUserId(systemType); + if (textUserId != null) { + textUserId.setInheritedText(parentUserId); + boolean allowEditingOfInherited = ((parentUserId == null) || (parentUserId.length() == 0)); + textUserId.setAllowEditingOfInheritedText(allowEditingOfInherited); // if not set yet, let user set it! } - // ---------------------------- + // ---------------------------- // default user id: update-mode - // ---------------------------- - if ((currentUserId != null) && (currentUserId.length()>0)) - { - if (textUserId != null) - { - textUserId.setLocalText(currentUserId); - textUserId.setLocal(true); + // ---------------------------- + if ((currentUserId != null) && (currentUserId.length() > 0)) { + if (textUserId != null) { + textUserId.setLocalText(currentUserId); + textUserId.setLocal(true); } } - // ---------------------------- + // ---------------------------- // default user id: create-mode - // ---------------------------- - else - { - if (textUserId != null) - textUserId.setLocalText(""); //$NON-NLS-1$ - if ((parentUserId != null) && (parentUserId.length() > 0)) - { - userIdFromSystemTypeDefault = true; - defaultUserId = parentUserId; - if (textUserId != null) - textUserId.setLocal(false); - } - // there is no local override, and no inherited value. Default to setting inherited value. - else - { - if (textUserId != null) - textUserId.setLocal(false); - } - } + // ---------------------------- + else { + if (textUserId != null) + textUserId.setLocalText(""); //$NON-NLS-1$ + if ((parentUserId != null) && (parentUserId.length() > 0)) { + userIdFromSystemTypeDefault = true; + defaultUserId = parentUserId; + if (textUserId != null) + textUserId.setLocal(false); + } + // there is no local override, and no inherited value. Default to setting inherited value. + else { + if (textUserId != null) + textUserId.setLocal(false); + } + } } - + // ------------------------------------------------------ // INTERNAL METHODS FOR VERIFYING INPUT PER KEYSTROKE ... // ------------------------------------------------------ - - /** + + /** * This hook method is called whenever the text changes in the input field. * The default implementation delegates the request to anISystemValidator
object.
* If the ISystemValidator
reports an error the error message is displayed
* in the Dialog's message line.
* @see #setConnectionNameValidators(ISystemValidator[])
*/
- protected SystemMessage validateConnectionNameInput(boolean userTyped)
- {
+ protected SystemMessage validateConnectionNameInput(boolean userTyped) {
if (!connectionNameListen)
return null;
- errorMessage= null;
- int selectedProfile = 0;
- if (profileCombo != null)
- {
- selectedProfile = profileCombo.getSelectionIndex();
- }
- if (selectedProfile < 0)
- selectedProfile = 0;
- ISystemValidator nameValidator = null;
- if ((nameValidators!=null) && (nameValidators.length>0))
- nameValidator = nameValidators[selectedProfile];
- String connName = textConnectionName.getText().trim();
- if (nameValidator != null)
- {
+ errorMessage = null;
+ int selectedProfile = 0;
+ if (profileCombo != null) {
+ selectedProfile = profileCombo.getSelectionIndex();
+ }
+ if (selectedProfile < 0)
+ selectedProfile = 0;
+ ISystemValidator nameValidator = null;
+ if ((nameValidators != null) && (nameValidators.length > 0))
+ nameValidator = nameValidators[selectedProfile];
+ String connName = textConnectionName.getText().trim();
+ if (nameValidator != null) {
errorMessage = nameValidator.validate(connName);
}
showErrorMessage(errorMessage);
- setPageComplete();
- if (userTyped)
- connectionNameEmpty = (connName.length()==0); // d43191
- return errorMessage;
+ setPageComplete();
+ if (userTyped)
+ connectionNameEmpty = (connName.length() == 0); // d43191
+ return errorMessage;
}
+
/**
* Set the connection name internally without validation
*/
- protected void internalSetConnectionName(String name)
- {
+ protected void internalSetConnectionName(String name) {
SystemMessage currErrorMessage = errorMessage;
- connectionNameListen = false;
- textConnectionName.setText(name);
- connectionNameListen = true;
- errorMessage = currErrorMessage;
+ connectionNameListen = false;
+ textConnectionName.setText(name);
+ connectionNameListen = true;
+ errorMessage = currErrorMessage;
}
- /**
+
+ /**
* This hook method is called whenever the text changes in the input field.
* The default implementation delegates the request to an ISystemValidator
object.
* If the ISystemValidator
reports an error the error message is displayed
@@ -1140,155 +1047,139 @@ public class SystemConnectionForm
*/
protected SystemMessage validateHostNameInput() {
final String hostName = textHostName.getText().trim();
-
+
// d43191
- if (connectionNameEmpty) internalSetConnectionName(hostName);
-
+ if (connectionNameEmpty)
+ internalSetConnectionName(hostName);
+
errorMessage = null;
-
+
if (hostValidator != null)
errorMessage = hostValidator.validate(hostName);
else if (getHostName().length() == 0)
errorMessage = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_VALIDATE_HOSTNAME_EMPTY);
-
+
if (updateMode && !userPickedVerifyHostnameCB) {
boolean hostNameChanged = !hostName.equals(defaultHostName);
verifyHostNameCB.setSelection(hostNameChanged);
}
-
+
showErrorMessage(errorMessage);
setPageComplete();
return errorMessage;
}
-
- /**
- * This hook method is called whenever the text changes in the input field. The default implementation delegates the
- * request to an ISystemValidator
object. If the ISystemValidator
reports an error the
- * error message is displayed in the Dialog's message line.
- * @see #setUserIdValidator(ISystemValidator)
- */
- protected SystemMessage validateUserIdInput()
- {
- errorMessage= null;
- if (textUserId != null)
- {
- if (userIdValidator != null)
- errorMessage= userIdValidator.validate(textUserId.getText());
- else if (getDefaultUserId().length()==0)
- errorMessage = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_VALIDATE_USERID_EMPTY);
- }
- showErrorMessage(errorMessage);
+
+ /**
+ * This hook method is called whenever the text changes in the input field. The default implementation delegates the
+ * request to an ISystemValidator
object. If the ISystemValidator
reports an error the
+ * error message is displayed in the Dialog's message line.
+ * @see #setUserIdValidator(ISystemValidator)
+ */
+ protected SystemMessage validateUserIdInput() {
+ errorMessage = null;
+ if (textUserId != null) {
+ if (userIdValidator != null)
+ errorMessage = userIdValidator.validate(textUserId.getText());
+ else if (getDefaultUserId().length() == 0)
+ errorMessage = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_VALIDATE_USERID_EMPTY);
+ }
+ showErrorMessage(errorMessage);
setPageComplete();
- return errorMessage;
+ return errorMessage;
}
-
+
/**
* Inform caller of page-complete status of this form
*/
- public void setPageComplete()
- {
+ public void setPageComplete() {
boolean complete = isPageComplete();
- if (complete && (textSystemType!=null))
- lastSystemType = textSystemType.getText().trim();
- if (callerInstanceOfWizardPage)
- {
- ((WizardPage)caller).setPageComplete(complete);
+ if (complete && (textSystemType != null))
+ lastSystemType = textSystemType.getText().trim();
+ if (callerInstanceOfWizardPage) {
+ ((WizardPage)caller).setPageComplete(complete);
+ } else if (callerInstanceOfSystemPromptDialog) {
+ ((SystemPromptDialog)caller).setPageComplete(complete);
+ } else if (callerInstanceOfPropertyPage) {
+ ((PropertyPage)caller).setValid(complete);
}
- else if (callerInstanceOfSystemPromptDialog)
- {
- ((SystemPromptDialog)caller).setPageComplete(complete);
- }
- else if (callerInstanceOfPropertyPage)
- {
- ((PropertyPage)caller).setValid(complete);
- }
}
-
- /**
- * Display error message or clear error message
- */
- private void showErrorMessage(SystemMessage msg)
- {
+
+ /**
+ * Display error message or clear error message
+ */
+ private void showErrorMessage(SystemMessage msg) {
if (msgLine != null)
- if (msg != null)
- msgLine.setErrorMessage(msg);
- else
- msgLine.clearErrorMessage();
+ if (msg != null)
+ msgLine.setErrorMessage(msg);
+ else
+ msgLine.clearErrorMessage();
else
- SystemBasePlugin.logDebugMessage(this.getClass().getName(), "MSGLINE NULL. TRYING TO WRITE MSG " + msg); //$NON-NLS-1$
+ SystemBasePlugin.logDebugMessage(this.getClass().getName(), "MSGLINE NULL. TRYING TO WRITE MSG " + msg); //$NON-NLS-1$
}
-
- // ---------------------------------------------------------------
+
+ // ---------------------------------------------------------------
// STATIC METHODS FOR GETTING A CONNECTION NAME VALIDATOR...
// ---------------------------------------------------------------
-
+
/**
* Reusable method to return a name validator for renaming a connection.
* @param conn the current connection object on updates. Can be null for new names. Used
* to remove from the existing name list the current connection.
*/
- public static ISystemValidator getConnectionNameValidator(IHost conn)
- {
+ public static ISystemValidator getConnectionNameValidator(IHost conn) {
ISystemProfile profile = conn.getSystemProfile();
- Vector v = RSEUIPlugin.getTheSystemRegistry().getHostAliasNames(profile);
- v.removeElement(conn.getAliasName());
- ValidatorConnectionName connNameValidator = new ValidatorConnectionName(v);
- return connNameValidator;
- }
+ Vector v = RSEUIPlugin.getTheSystemRegistry().getHostAliasNames(profile);
+ v.removeElement(conn.getAliasName());
+ ValidatorConnectionName connNameValidator = new ValidatorConnectionName(v);
+ return connNameValidator;
+ }
+
/**
* Reusable method to return a name validator for renaming a connection.
* @param profile the current connection object's profile from which to get the existing names.
* Can be null for syntax checking only, versus name-in-use.
*/
- public static ISystemValidator getConnectionNameValidator(ISystemProfile profile)
- {
- Vector v = RSEUIPlugin.getTheSystemRegistry().getHostAliasNames(profile);
- ValidatorConnectionName connNameValidator = new ValidatorConnectionName(v);
- return connNameValidator;
- }
+ public static ISystemValidator getConnectionNameValidator(ISystemProfile profile) {
+ Vector v = RSEUIPlugin.getTheSystemRegistry().getHostAliasNames(profile);
+ ValidatorConnectionName connNameValidator = new ValidatorConnectionName(v);
+ return connNameValidator;
+ }
/**
* Reusable method to return name validators for creating a connection.
* There is one validator per active system profile.
*/
- public static ISystemValidator[] getConnectionNameValidators()
- {
+ public static ISystemValidator[] getConnectionNameValidators() {
ISystemRegistry sr = RSEUIPlugin.getTheSystemRegistry();
ISystemProfile[] profiles = sr.getActiveSystemProfiles();
ISystemValidator[] connNameValidators = new ISystemValidator[profiles.length];
- for (int idx=0; idxDO NOT USE THIS CLASS! - *
This class attempts to wrap the message constructs of eclipse provided property - * and wizard pages with an ISystemMessageLine interface. - * It fails to do this properly and is extremely fragile since it depends on knowledge - * of the internal structure of eclipse provided windows. - *
Use SystemMessageLine instead.
- *
- */
-public class SystemDialogPageMessageLine implements ISystemMessageLine, MouseListener {
- // cached inputs
- private Label msgTextLabel;
- private Label msgIconLabel;
- private CLabel msgIconCLabel;
- private DialogPage dlgPage;
- // state
- private SystemMessage sysErrorMessage;
- private SystemMessage sysMessage;
- private boolean stringErrorMessageShowing = false;
-
- /**
- * Factory method for wizard pages.
- * We only need to configure a single message line for all pages in a given wizard,
- * so this method looks after ensuring there is only one such message line created.
- * @param wizardPage - the wizard page we are configuring
- */
- public static SystemDialogPageMessageLine createWizardMsgLine(WizardPage wizardPage) {
- SystemDialogPageMessageLine msgLine = null;
- Composite pageContainer = wizardPage.getControl().getParent();
- Object pageContainerData = null;
-
- // FIXME why does this need to be commented out?
- //Object pageContainerData = pageContainer.getData();
- //System.out.println("pageContainerData = " + pageContainerData);
- if (pageContainerData == null) {
- // wizardPage.getControl() => returns the composite we created in createControl
- // .getParent() => returns the page container composite created in createPageContainer in WizardDialog, that holds all pages
- // .getParent() => returns the composite created in createDialogArea in TitleAreaDialog. The "dialog area" of the dialog below the top stuff, and above the button bar.
- // .getParent() => returns the workarea composite created in createContents in TitleAreaDialog
- // .getParent() => returns the parent composite passed to createContents in TitleAreaDialog
- // .getChildren() => returns the children of this composite, which includes the stuff at the top, which is placed
- // there by createTitleArea() in TitleAreaDialog, the parent of WizardDialog
- // [0]=> dialog image Label
- // [1]=> title Label
- // [2]=> message image Label
- // [3]=> message Label
- // [4]=> filler Label
- Composite dialogAreaComposite = pageContainer.getParent(); // see createDialogArea in WizardDialog
- Composite workAreaComposite = dialogAreaComposite.getParent(); // see createContents in TitleAreaDialog
- Composite mainComposite = workAreaComposite.getParent(); // whatever is passed into createContents in TitleAreaDialog
- Control[] list = mainComposite.getChildren();
- Label msgImageLabel = null;
- Label msgLabel = null;
- if (list[2] instanceof Label) {
- msgImageLabel = (Label) list[2];
- }
- if (list[3] instanceof Label) {
- msgLabel = (Label) list[3];
- } else if (list[4] instanceof Label) {
- msgLabel = (Label) list[4];
- }
- msgLine = new SystemDialogPageMessageLine(wizardPage, msgImageLabel, msgLabel);
- pageContainer.setData(msgLine);
- } else
- msgLine = (SystemDialogPageMessageLine) pageContainerData;
- return msgLine;
- }
-
- /**
- * Factory method for property pages.
- * We only need to configure a single message line for all pages in a properties dialog,
- * so this method looks after ensuring there is only one such message line created.
- * @param propertyPage - the property page we are configuring
- */
- public static SystemDialogPageMessageLine createPropertyPageMsgLine(PropertyPage propertyPage) {
- SystemDialogPageMessageLine msgLine = null;
- Composite pageContainer = propertyPage.getControl().getParent();
- // propertyPage.getControl() => returns the composite we created in createControl
- // .getParent() => returns the page container composite created in createPageContainer in PreferencesDialog, that holds all pages
- // .getParent() => returns the composite created in createDialogArea in PreferencesDialog. This holds the tree, title area composite, page container composite and separator
- // .getChildren()[1] => returns the title area parent composite, created in createDialogArea in PreferencesDialog
- // .getChildren()[0] => returns the title area composite, created in createTitleArea in PreferencesDialog
- // .getChildren() => returns the children of the title area composite
- // [0]=> message CLabel
- // [1]=> title image
- Composite dialogAreaComposite = pageContainer.getParent(); // see createDialogArea in PreferencesDialog
- Composite titleAreaParentComposite = (Composite) dialogAreaComposite.getChildren()[1];
- Composite titleAreaComposite = (Composite) titleAreaParentComposite.getChildren()[0];
- //Control[] list=titleAreaComposite.getChildren();
- // DKM - trying to figure out this mess for 3.0
- Composite listContainer = (Composite) titleAreaComposite.getChildren()[0];
- Control[] list = listContainer.getChildren();
- Label label1 = null;
- Label label2 = null;
- if (list.length > 0) {
- label1 = (Label) list[0];
- label2 = (Label) list[1];
- }
- msgLine = new SystemDialogPageMessageLine(propertyPage, /*(CLabel)list[0]*/label1, label2);
- pageContainer.setData(msgLine);
- return msgLine;
- }
-
- /**
- * Private constructor.
- */
- private SystemDialogPageMessageLine(DialogPage dialogPage, Label msgIconLabel, Label msgTextLabel) {
- this.msgIconLabel = msgIconLabel;
- this.msgTextLabel = msgTextLabel;
- this.dlgPage = dialogPage;
- msgIconLabel.addMouseListener(this);
- msgTextLabel.addMouseListener(this);
- }
-
- protected SystemMessage getSysErrorMessage() {
- return sysErrorMessage;
- }
-
- protected SystemMessage getSysMessage() {
- return sysMessage;
- }
-
- /**
- * Get the currently displayed error text.
- * @return The error message. If no error message is displayed null
is returned.
- */
- public SystemMessage getSystemErrorMessage() {
- return sysErrorMessage;
- }
-
- /**
- * Clears the currently displayed error message and redisplayes
- * the message which was active before the error message was set.
- */
- public void clearErrorMessage() {
- sysErrorMessage = null;
- stringErrorMessageShowing = false;
- dlgPage.setErrorMessage(null);
- setIconToolTipText();
- }
-
- /**
- * Clears the currently displayed non-error message.
- */
- public void clearMessage() {
- dlgPage.setMessage(null);
- sysMessage = null;
- setIconToolTipText();
- }
-
- /**
- * Get the currently displayed error text.
- * @return The error message. If no error message is displayed null
is returned.
- */
- public String getErrorMessage() {
- return dlgPage.getErrorMessage();
- }
-
- /**
- * Get the currently displayed message.
- * @return The message. If no message is displayed null
is returned.
- */
- public String getMessage() {
- return dlgPage.getMessage();
- }
-
- /**
- * DO NOT CALL THIS METHOD! IT IS ONLY HERE BECAUSE THE INTERFACE NEEDS IT.
- * RATHER, CALL THE SAME MSG THAT DIALOGPAGE NOW SUPPORTS, AND THEN CALL
- * setInternalErrorMessage HERE. WE HAVE TO AVOID INFINITE LOOPS.
- */
- public void setErrorMessage(String emessage) {
- internalSetErrorMessage(emessage);
- //dlgPage.setErrorMessage(emessage);
- }
-
- /**
- * Display the given error message. A currently displayed message
- * is saved and will be redisplayed when the error message is cleared.
- */
- public void setErrorMessage(SystemMessage emessage) {
- // I removed @deprecated... I think it was a mistake! What would be the replacement? Phil
- if (emessage == null)
- clearErrorMessage();
- else {
- dlgPage.setErrorMessage(getMessageText(emessage));
- stringErrorMessageShowing = false;
- sysErrorMessage = emessage;
- logMessage(emessage);
- }
- setIconToolTipText();
- }
-
- /**
- * Convenience method to set an error message from an exception
- */
- public void setErrorMessage(Throwable exc) {
- SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_ERROR_UNEXPECTED);
- msg.makeSubstitution(exc);
- setErrorMessage(msg);
- }
-
- /**
- * DO NOT CALL THIS METHOD! IT IS ONLY HERE BECAUSE THE INTERFACE NEEDS IT.
- * RATHER, CALL THE SAME MSG THAT DIALOGPAGE NOW SUPPORTS, AND THEN CALL
- * setInternalMessage HERE. WE HAVE TO AVOID INFINITE LOOPS.
- */
- public void setMessage(String msg) {
- internalSetMessage(msg);
- dlgPage.setMessage(msg);
- }
-
- /**
- * Set a non-error message to display.
- * If the message line currently displays an error,
- * the message is stored and will be shown after a call to clearErrorMessage
- */
- public void setMessage(SystemMessage smessage) {
- if (smessage == null) {
- clearMessage(); // phil
- return;
- }
- sysMessage = smessage;
- int msgType = IMessageProvider.NONE;
- if ((smessage.getIndicator() == SystemMessage.ERROR) || (smessage.getIndicator() == SystemMessage.UNEXPECTED))
- msgType = IMessageProvider.ERROR;
- else if (smessage.getIndicator() == SystemMessage.WARNING)
- msgType = IMessageProvider.WARNING;
- else if (smessage.getIndicator() == SystemMessage.INFORMATION || (smessage.getIndicator() == SystemMessage.COMPLETION)) msgType = IMessageProvider.INFORMATION;
- dlgPage.setMessage(getMessageText(smessage), msgType);
- logMessage(smessage);
- setIconToolTipText();
- }
-
- /**
- * logs the message in the appropriate log
- */
- private void logMessage(SystemMessage message) {
- Object[] subList = message.getSubVariables();
- for (int i = 0; subList != null && i < subList.length; i++) {
- String msg = message.getFullMessageID() + ": SUB#" + new Integer(i).toString() + ":" + message.getSubValue(subList[i]); //$NON-NLS-1$ //$NON-NLS-2$
- if (message.getIndicator() == SystemMessage.INFORMATION || message.getIndicator() == SystemMessage.INQUIRY || message.getIndicator() == SystemMessage.COMPLETION)
- SystemBasePlugin.logInfo(msg);
- else if (message.getIndicator() == SystemMessage.WARNING)
- SystemBasePlugin.logWarning(msg);
- else if (message.getIndicator() == SystemMessage.ERROR)
- SystemBasePlugin.logError(msg, null);
- else if (message.getIndicator() == SystemMessage.UNEXPECTED) {
- if (i == subList.length - 1)
- SystemBasePlugin.logError(msg, new Exception());
- else
- SystemBasePlugin.logError(msg, null);
- }
- }
- if (subList == null) {
- String msg = message.getFullMessageID();
- if (message.getIndicator() == SystemMessage.INFORMATION || message.getIndicator() == SystemMessage.INQUIRY || message.getIndicator() == SystemMessage.COMPLETION)
- SystemBasePlugin.logInfo(msg);
- else if (message.getIndicator() == SystemMessage.WARNING)
- SystemBasePlugin.logWarning(msg);
- else if (message.getIndicator() == SystemMessage.ERROR)
- SystemBasePlugin.logError(msg, null);
- else if (message.getIndicator() == SystemMessage.UNEXPECTED) SystemBasePlugin.logError(msg, new Exception());
- }
- }
-
- // METHODS THAT NEED TO BE CALLED BY DIALOGPAGE IN THEIR OVERRIDE OF SETMESSAGE OR SETERRORMESSAGE
- /**
- * Someone has called setMessage(String) on the dialog page. It needs to then call this method
- * after calling super.setMessage(String) so we can keep track of what is happening.
- */
- public void internalSetMessage(String msg) {
- sysMessage = null; // overrides it if it was set
- setIconToolTipText();
- }
-
- /**
- * Someone has called setErrorMessage(String) on the dialog page. It needs to then call this method
- * after calling super.setErrorMessage(String) so we can keep track of what is happening.
- */
- public void internalSetErrorMessage(String msg) {
- sysErrorMessage = null; // overrides if it was set
- stringErrorMessageShowing = (msg != null);
- setIconToolTipText();
- }
-
- // MOUSeListener INTERFACE METHODS...
- /**
- * User double clicked with the mouse
- */
- public void mouseDoubleClick(MouseEvent event) {
- }
-
- /**
- * User pressed the mouse button
- */
- public void mouseDown(MouseEvent event) {
- }
-
- /**
- * User released the mouse button after pressing it
- */
- public void mouseUp(MouseEvent event) {
- displayMessageDialog();
- }
-
- /**
- * Method to return the current system message to display. If error message is set, return it,
- * else return message.
- */
- public SystemMessage getCurrentMessage() {
- if (sysErrorMessage != null)
- return sysErrorMessage;
- else if (!stringErrorMessageShowing)
- return sysMessage;
- else
- return null;
- }
-
- /**
- * Method to display an error message when the msg button is clicked
- */
- private void displayMessageDialog() {
- SystemMessage currentMessage = getCurrentMessage();
- if (currentMessage != null) {
- SystemMessageDialog msgDlg = new SystemMessageDialog(dlgPage.getShell(), currentMessage);
- msgDlg.openWithDetails();
- }
- }
-
- /**
- * Method to set the tooltip text on the msg icon to tell the user they can press it for more details
- */
- private void setIconToolTipText() {
- SystemMessage msg = getCurrentMessage();
- String tip = ""; //$NON-NLS-1$
- if (msg != null) {
- //String levelTwo = msg.getLevelTwoText();
- //if ((levelTwo!=null) && (levelTwo.length()>0))
- tip = msg.getFullMessageID() + " " + SystemResources.RESID_MSGLINE_TIP; //$NON-NLS-1$
- }
- if (msgIconLabel != null) msgIconLabel.setToolTipText(tip);
- if (msgTextLabel != null)
- msgTextLabel.setToolTipText(tip);
- else
- msgIconCLabel.setToolTipText(tip);
- }
-
- /**
- * Return the message text to display in the title area, given a system message
- */
- private String getMessageText(SystemMessage msg) {
- //return msg.getFullMessageID()+" " + msg.getLevelOneText();
- return msg.getLevelOneText();
- }
-}
\ No newline at end of file
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 024974346e5..0cfa710110c 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
@@ -137,7 +137,7 @@ public abstract class AbstractSystemNewConnectionWizardPage extends AbstractSyst
IWizardPage wizardPage = ourWizard.getStartingPage();
if (wizardPage instanceof RSEDefaultNewConnectionWizardMainPage) {
- return ((RSEDefaultNewConnectionWizardMainPage)wizardPage).getForm();
+ return ((RSEDefaultNewConnectionWizardMainPage)wizardPage).getSystemConnectionForm();
}
else {
return null;
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/RSEDialogPageMessageLine.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/RSEDialogPageMessageLine.java
new file mode 100644
index 00000000000..b31c84b20e6
--- /dev/null
+++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/RSEDialogPageMessageLine.java
@@ -0,0 +1,120 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Wind River Systems, Inc. and others.
+ * 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:
+ * Uwe Stieber (Wind River) - initial API and implementation.
+ *******************************************************************************/
+package org.eclipse.rse.ui.wizards;
+
+import org.eclipse.jface.dialogs.DialogPage;
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.rse.services.clientserver.messages.SystemMessage;
+import org.eclipse.rse.ui.messages.ISystemMessageLine;
+
+/**
+ * Message line interface implementation which forwards the calls
+ * to the associated parent dialog page.
+ */
+public class RSEDialogPageMessageLine implements ISystemMessageLine {
+ private final DialogPage page;
+ private SystemMessage errorSystemMessage;
+
+ /**
+ * Constructor.
+ *
+ * @param dialogPage The parent dialog page. Must be not
null
.
+ */
+ public RSEDialogPageMessageLine(DialogPage dialogPage) {
+ assert dialogPage != null;
+ page = dialogPage;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.rse.ui.messages.ISystemMessageLine#clearErrorMessage()
+ */
+ public void clearErrorMessage() {
+ assert page != null;
+ if (page.getErrorMessage() != null) page.setErrorMessage(null);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.rse.ui.messages.ISystemMessageLine#clearMessage()
+ */
+ public void clearMessage() {
+ assert page != null;
+ page.setMessage(null, IMessageProvider.NONE);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.rse.ui.messages.ISystemMessageLine#getErrorMessage()
+ */
+ public String getErrorMessage() {
+ assert page != null;
+ return page.getErrorMessage();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.rse.ui.messages.ISystemMessageLine#getMessage()
+ */
+ public String getMessage() {
+ assert page != null;
+ return page.getMessage();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.rse.ui.messages.ISystemMessageLine#getSystemErrorMessage()
+ */
+ public SystemMessage getSystemErrorMessage() {
+ return errorSystemMessage;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.rse.ui.messages.ISystemMessageLine#setErrorMessage(java.lang.String)
+ */
+ public void setErrorMessage(String message) {
+ assert page != null;
+ // Per Eclipse UI style, wizard pager should never start with errors!
+ if (message != null && message.toLowerCase().startsWith("please enter")) { //$NON-NLS-1$
+ errorSystemMessage = null;
+ page.setErrorMessage(null);
+ setMessage(message);
+ } else {
+ page.setErrorMessage(message);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.rse.ui.messages.ISystemMessageLine#setErrorMessage(org.eclipse.rse.services.clientserver.messages.SystemMessage)
+ */
+ public void setErrorMessage(SystemMessage message) {
+ errorSystemMessage = message;
+ if (errorSystemMessage != null) setErrorMessage(errorSystemMessage.getLevelOneText());
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.rse.ui.messages.ISystemMessageLine#setErrorMessage(java.lang.Throwable)
+ */
+ public void setErrorMessage(Throwable exception) {
+ if (exception != null) setErrorMessage(exception.getLocalizedMessage());
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.rse.ui.messages.ISystemMessageLine#setMessage(java.lang.String)
+ */
+ public void setMessage(String message) {
+ assert page != null;
+ page.setMessage(message, IMessageProvider.INFORMATION);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.rse.ui.messages.ISystemMessageLine#setMessage(org.eclipse.rse.services.clientserver.messages.SystemMessage)
+ */
+ public void setMessage(SystemMessage message) {
+ if (message != null) setMessage(message.getLevelOneText());
+ }
+
+}
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 1c78dc538ce..5a139abd68f 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
@@ -94,8 +94,8 @@ public class SubSystemServiceWizardPage extends AbstractSystemNewConnectionWizar
if (getWizard() instanceof RSEDefaultNewConnectionWizard)
{
RSEDefaultNewConnectionWizard wizard = (RSEDefaultNewConnectionWizard)getWizard();
- if (wizard.getMainPage() instanceof RSEDefaultNewConnectionWizardMainPage) {
- dummyHost = new DummyHost(((RSEDefaultNewConnectionWizardMainPage)wizard.getMainPage()).getHostName(),
+ if (wizard.getStartingPage() instanceof RSEDefaultNewConnectionWizardMainPage) {
+ dummyHost = new DummyHost(((RSEDefaultNewConnectionWizardMainPage)wizard.getStartingPage()).getSystemConnectionForm().getHostName(),
wizard.getSystemType() != null ? wizard.getSystemType().getName() : null);
}
}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/SystemSubSystemsPropertiesWizardPage.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/SystemSubSystemsPropertiesWizardPage.java
index 56abbfafa8b..50ad7962dd5 100644
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/SystemSubSystemsPropertiesWizardPage.java
+++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/SystemSubSystemsPropertiesWizardPage.java
@@ -115,7 +115,7 @@ public class SystemSubSystemsPropertiesWizardPage
_thePage = cpage;
//set the hostname for the page in case it's required
- if (getMainPage() != null) cpage.setHostname(getMainPage().getHostName());
+ if (getMainPage() != null) cpage.setHostname(getMainPage().getSystemConnectionForm().getHostName());
numAdded++;
}
@@ -151,7 +151,7 @@ public class SystemSubSystemsPropertiesWizardPage
}
//set the hostname for the page in case it's required
- if (getMainPage() != null) cpage.setHostname(getMainPage().getHostName());
+ if (getMainPage() != null) cpage.setHostname(getMainPage().getSystemConnectionForm().getHostName());
numAdded++;
}
@@ -199,7 +199,7 @@ public class SystemSubSystemsPropertiesWizardPage
*/
public boolean isPageComplete()
{
- String hostName = getMainPage() != null ? getMainPage().getHostName() : null;
+ String hostName = getMainPage() != null ? getMainPage().getSystemConnectionForm().getHostName() : null;
if (hostName != null && !hostName.equals(_lastHostName))
{
hostNameUpdated(hostName);
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 136fcb84a6f..0ebf4dc5e7b 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
@@ -107,20 +107,22 @@ public class RSEDefaultNewConnectionWizard extends RSEAbstractNewConnectionWizar
subsystemFactorySuppliedWizardPages = getAdditionalWizardPages(systemType.getName());
}
}
-
+
/**
* Creates the wizard pages. This method is an override from the parent Wizard class.
*/
public void addPages() {
try {
mainPage = createMainPage(getSystemType());
- mainPage.setConnectionNameValidators(SystemConnectionForm.getConnectionNameValidators());
- mainPage.setCurrentlySelectedConnection(selectedContext);
-
- if (defaultUserId != null) mainPage.setUserId(defaultUserId);
- if (defaultConnectionName != null) mainPage.setConnectionName(defaultConnectionName);
- if (defaultHostName != null) mainPage.setHostName(defaultHostName);
+ SystemConnectionForm form = mainPage.getSystemConnectionForm();
+ if (form != null) {
+ form.setCurrentlySelectedConnection(selectedContext);
+ if (defaultUserId != null) form.setUserId(defaultUserId);
+ if (defaultConnectionName != null) form.setConnectionName(defaultConnectionName);
+ if (defaultHostName != null) form.setHostName(defaultHostName);
+ }
+
if (mainPage != null && getSystemType() != null) mainPage.setSystemType(getSystemType());
updateDefaultSelectedProfile();
@@ -180,7 +182,7 @@ public class RSEDefaultNewConnectionWizard extends RSEAbstractNewConnectionWizar
if (mainPage == null) return;
List profileNames = activeProfileNames != null ? Arrays.asList(activeProfileNames) : new ArrayList();
- mainPage.setProfileNames(activeProfileNames);
+ mainPage.getSystemConnectionForm().setProfileNames(activeProfileNames);
// 1. If a connection is selected, the default profile is the one from the connection.
String defaultProfileName = selectedContext != null ? selectedContext.getSystemProfileName() : null;
@@ -197,14 +199,14 @@ public class RSEDefaultNewConnectionWizard extends RSEAbstractNewConnectionWizar
if (defaultProfileName == null || !profileNames.contains(defaultProfileName)) {
// 4. The first non-empty profile from the list of active profiles is the default profile.
// Note: The profile names get normalized within the constructor.
- if (activeProfileNames.length > 0) defaultProfileName = activeProfileNames[0];
+ if (profileNames.size() > 0) defaultProfileName = (String)profileNames.get(0);
}
}
}
// set the default profile to the page and remember it.
if (defaultProfileName != null) {
- mainPage.setProfileNamePreSelection(defaultProfileName);
+ mainPage.getSystemConnectionForm().setProfileNamePreSelection(defaultProfileName);
// do not update the last selected profile marker if the default profile
// name came for the selected context.
if (selectedContext == null || !defaultProfileName.equals(selectedContext.getSystemProfileName()))
@@ -228,8 +230,7 @@ public class RSEDefaultNewConnectionWizard extends RSEAbstractNewConnectionWizar
*/
public void setUserId(String userId) {
defaultUserId = userId;
- if (mainPage != null)
- mainPage.setUserId(userId);
+ if (mainPage != null) mainPage.getSystemConnectionForm().setUserId(userId);
}
/**
@@ -237,8 +238,7 @@ public class RSEDefaultNewConnectionWizard extends RSEAbstractNewConnectionWizar
*/
public void setConnectionName(String name) {
defaultConnectionName = name;
- if (mainPage != null)
- mainPage.setConnectionName(name);
+ if (mainPage != null) mainPage.getSystemConnectionForm().setConnectionName(name);
}
/**
@@ -246,8 +246,7 @@ public class RSEDefaultNewConnectionWizard extends RSEAbstractNewConnectionWizar
*/
public void setHostName(String name) {
defaultHostName = name;
- if (mainPage != null)
- mainPage.setHostName(name);
+ if (mainPage != null) mainPage.getSystemConnectionForm().setHostName(name);
}
/**
@@ -272,7 +271,7 @@ public class RSEDefaultNewConnectionWizard extends RSEAbstractNewConnectionWizar
* @return whether the wizard finished successfully
*/
public boolean performFinish() {
- boolean ok = mainPage.performFinish();
+ boolean ok = mainPage.getSystemConnectionForm().verify(true);
if (!ok)
setPageError(mainPage);
else if (ok && hasAdditionalPages()) {
@@ -310,8 +309,9 @@ public class RSEDefaultNewConnectionWizard extends RSEAbstractNewConnectionWizar
if (ok) {
try {
String sysType = getSystemType() != null ? getSystemType().getName() : null;
- IHost conn = sr.createHost(mainPage.getProfileName(), sysType, mainPage.getConnectionName(), mainPage.getHostName(),
- mainPage.getConnectionDescription(), mainPage.getDefaultUserId(), mainPage.getDefaultUserIdLocation(),
+ SystemConnectionForm form = mainPage.getSystemConnectionForm();
+ IHost conn = sr.createHost(form.getProfileName(), sysType, form.getConnectionName(), form.getHostName(),
+ form.getConnectionDescription(), form.getDefaultUserId(), form.getUserIdLocation(),
subsystemFactorySuppliedWizardPages);
setBusyCursor(false);
@@ -329,7 +329,7 @@ public class RSEDefaultNewConnectionWizard extends RSEAbstractNewConnectionWizar
sr.expandHost(conn);
}
- lastProfile = mainPage.getProfileName();
+ lastProfile = form.getProfileName();
} catch (Exception exc) {
if (cursorSet)
setBusyCursor(false);
@@ -349,30 +349,6 @@ public class RSEDefaultNewConnectionWizard extends RSEAbstractNewConnectionWizar
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() {
- if (mainPage == null) {
- addPages();
- }
-
- return mainPage;
- }
-
/*
* Private method to get all the wizard pages from all the subsystem factories, given a
* system type.
@@ -390,8 +366,10 @@ public class RSEDefaultNewConnectionWizard extends RSEAbstractNewConnectionWizar
ISystemNewConnectionWizardPage[] pages = adapter.getNewConnectionWizardPages(factories[idx], this);
if (pages != null) {
- for (int widx = 0; widx < pages.length; widx++)
+ for (int widx = 0; widx < pages.length; widx++) {
+ if (pages[widx] instanceof IWizardPage) ((IWizardPage)pages[widx]).setWizard(this);
additionalPages.addElement(pages[widx]);
+ }
}
}
subsystemFactorySuppliedWizardPages = new ISystemNewConnectionWizardPage[additionalPages.size()];
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/RSEDefaultNewConnectionWizardMainPage.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/RSEDefaultNewConnectionWizardMainPage.java
index b66a61b5c29..1566fdb1dd3 100644
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/RSEDefaultNewConnectionWizardMainPage.java
+++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/RSEDefaultNewConnectionWizardMainPage.java
@@ -17,15 +17,17 @@
package org.eclipse.rse.ui.wizards.newconnection;
import org.eclipse.jface.wizard.IWizard;
import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.rse.core.IRSESystemType;
-import org.eclipse.rse.core.model.IHost;
import org.eclipse.rse.ui.ISystemConnectionFormCaller;
import org.eclipse.rse.ui.RSEUIPlugin;
import org.eclipse.rse.ui.SystemConnectionForm;
-import org.eclipse.rse.ui.validators.ISystemValidator;
-import org.eclipse.rse.ui.wizards.AbstractSystemWizardPage;
+import org.eclipse.rse.ui.wizards.RSEDialogPageMessageLine;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.PlatformUI;
@@ -40,20 +42,25 @@ import org.eclipse.swt.widgets.Control;
*
*/
-public class RSEDefaultNewConnectionWizardMainPage extends AbstractSystemWizardPage implements ISystemConnectionFormCaller {
-
- private SystemConnectionForm form;
- private String parentHelpId;
+public class RSEDefaultNewConnectionWizardMainPage extends WizardPage implements ISystemConnectionFormCaller {
+ private final String parentHelpId = RSEUIPlugin.HELPPREFIX + "wncc0000"; //$NON-NLS-1$;
+ private SystemConnectionForm form;
+ private final RSEDialogPageMessageLine messageLine;
+
/**
* Constructor. Use this when you want to supply your own title and
* description strings.
*/
public RSEDefaultNewConnectionWizardMainPage(IWizard wizard, String title, String description) {
- super(wizard, "NewConnection", title, description); //$NON-NLS-1$
+ super(RSEDefaultNewConnectionWizardMainPage.class.getName());
- parentHelpId = RSEUIPlugin.HELPPREFIX + "wncc0000"; //$NON-NLS-1$
- setHelp(parentHelpId);
+ if (wizard != null) setWizard(wizard);
+ if (title != null) setTitle(title);
+ if (description != null) setDescription(description);
+
+// setHelp(parentHelpId);
+ messageLine = new RSEDialogPageMessageLine(this);
}
/**
@@ -65,196 +72,73 @@ public class RSEDefaultNewConnectionWizardMainPage extends AbstractSystemWizardP
if (systemType != null) {
// The page _always_ restrict the system connection form
// to only one system type.
- getForm().restrictSystemType(systemType.getName());
+ getSystemConnectionForm().restrictSystemType(systemType.getName());
}
}
/**
- * 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.
+ * Returns the associated system connection form instance. Override to
+ * return custom system connection forms. As the system connection form
+ * is accessed directly to set and query the managed data of this form,
+ * this method must return always the same instance once the instance has
+ * been created for each subsequent call, until the page is disposed!
+ *
* @see org.eclipse.rse.ui.SystemConnectionForm
+ * @return The associated system connection form. Must be never null
.
*/
- public SystemConnectionForm getForm() {
- if (form == null) form = new SystemConnectionForm(this, this);
+ public SystemConnectionForm getSystemConnectionForm() {
+ if (form == null) {
+ form = new SystemConnectionForm(messageLine, this);
+ form.setConnectionNameValidators(SystemConnectionForm.getConnectionNameValidators());
+ }
return form;
}
- /**
- * Call this to specify a validator for the connection name. It will be called per keystroke.
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.DialogPage#setVisible(boolean)
*/
- public void setConnectionNameValidators(ISystemValidator[] v) {
- getForm().setConnectionNameValidators(v);
+ public void setVisible(boolean visible) {
+ super.setVisible(visible);
+ if (visible && getSystemConnectionForm() != null && getSystemConnectionForm().getInitialFocusControl() != null) {
+ getSystemConnectionForm().getInitialFocusControl().setFocus();
+ }
}
- /**
- * Call this to specify a validator for the hostname. It will be called per keystroke.
+ /* (non-Javadoc)
+ * @see org.eclipse.rse.ui.wizards.AbstractSystemWizardPage#createControl(org.eclipse.swt.widgets.Composite)
*/
- public void setHostNameValidator(ISystemValidator v) {
- getForm().setHostNameValidator(v);
+ public void createControl(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayout(new GridLayout());
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ getSystemConnectionForm().createContents(composite, SystemConnectionForm.CREATE_MODE, parentHelpId);
+
+ setControl(composite);
+
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), parentHelpId);
}
-
- /**
- * Call this to specify a validator for the userId. It will be called per keystroke.
- */
- public void setUserIdValidator(ISystemValidator v) {
- getForm().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) {
- getForm().setUserId(userId);
- }
-
- /**
- * Set the profile names to show in the combo
- */
- public void setProfileNames(String[] names) {
- getForm().setProfileNames(names);
- }
-
- /**
- * Set the profile name to preselect
- */
- public void setProfileNamePreSelection(String name) {
- getForm().setProfileNamePreSelection(name);
- }
-
- /**
- * Set the currently selected connection so as to better initialize input fields
- */
- public void setCurrentlySelectedConnection(IHost connection) {
- getForm().setCurrentlySelectedConnection(connection);
- }
-
- /**
- * Preset the connection name
- */
- public void setConnectionName(String name) {
- getForm().setConnectionName(name);
- }
-
- /**
- * Preset the host name
- */
- public void setHostName(String name) {
- getForm().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 getForm().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 getForm().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 getForm().verify(true);
- }
-
- // --------------------------------- //
- // METHODS FOR EXTRACTING USER DATA ...
- // --------------------------------- //
-
- /**
- * Return user-entered Connection Name.
- * Call this after finish ends successfully.
- */
- public String getConnectionName() {
- return getForm().getConnectionName();
- }
-
- /**
- * Return user-entered Host Name.
- * Call this after finish ends successfully.
- */
- public String getHostName() {
- return getForm().getHostName();
- }
-
- /**
- * Return user-entered Default User Id.
- * Call this after finish ends successfully.
- */
- public String getDefaultUserId() {
- return getForm().getDefaultUserId();
- }
-
- /**
- * Return location where default user id is to be set.
- * @see org.eclipse.rse.core.IRSEUserIdConstants
- */
- public int getDefaultUserIdLocation() {
- return getForm().getUserIdLocation();
- }
-
- /**
- * Return user-entered Description.
- * Call this after finish ends successfully.
- */
- public String getConnectionDescription() {
- return getForm().getConnectionDescription();
- }
-
- /**
- * Return name of profile to contain new connection.
- * Call this after finish ends successfully.
- */
- public String getProfileName() {
- return getForm().getProfileName();
- }
-
-
+
/**
* 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 (getForm() != null)
- return getForm().isPageComplete() && getForm().isConnectionUnique();
- else
- return false;
+ if (getSystemConnectionForm() != null)
+ return getSystemConnectionForm().isPageComplete() && getSystemConnectionForm().isConnectionUnique();
+
+ return false;
}
/**
* Intercept of WizardPage so we know when Next is pressed
*/
public IWizardPage getNextPage() {
- //if (wizard == null)
- //return null;
- //return wizard.getNextPage(this);
-
// verify contents of page before going to main page
// this is done because the main page may have input that is not valid, but can
// only be verified when next is pressed since it requires a long running operation
- boolean verify = getForm().verify(true);
-
- if (!verify) {
- return null;
- }
+ if (!getSystemConnectionForm().verify(true)) return null;
RSEDefaultNewConnectionWizard newConnWizard = getWizard() instanceof RSEDefaultNewConnectionWizard ? (RSEDefaultNewConnectionWizard)getWizard() : null;
if (newConnWizard != null) {
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/RSEMainNewConnectionWizard.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/RSEMainNewConnectionWizard.java
index 0d58358d0aa..4fcdc6c4c64 100644
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/RSEMainNewConnectionWizard.java
+++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/RSEMainNewConnectionWizard.java
@@ -17,6 +17,7 @@
package org.eclipse.rse.ui.wizards.newconnection;
+import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
@@ -48,7 +49,13 @@ import org.eclipse.ui.IWorkbench;
public class RSEMainNewConnectionWizard extends Wizard implements INewWizard, ISelectionProvider {
protected static final String LAST_SELECTED_SYSTEM_TYPE_ID = "lastSelectedSystemTypeId"; //$NON-NLS-1$
- private IHost selectedContext;
+ // The selected context as passed in from the invoking class.
+ // Just pass on to the wizards. Do not interpret here!
+ // @see #setSelectedContext(ISelection).
+ private ISelection selectedContext;
+ // The connection context as determined from the invoking class
+ // @see #setConnectionContext(IHost)
+ private IHost connectionContext;
private IWizard selectedWizard;
private IRSESystemType selectedSystemType;
@@ -133,6 +140,16 @@ public class RSEMainNewConnectionWizard extends Wizard implements INewWizard, IS
onSelectedSystemTypeChanged();
}
+ /**
+ * Returns if or if not the main new connection wizard has been restricted to only
+ * one system type.
+ *
+ * @return True
if the wizard is restricted to only one system type, false
otherwise.
+ */
+ public final boolean isRestrictedToSingleSystemType() {
+ return onlySystemType;
+ }
+
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ISelectionProvider#addSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener)
*/
@@ -167,8 +184,25 @@ public class RSEMainNewConnectionWizard extends Wizard implements INewWizard, IS
* @see org.eclipse.jface.viewers.ISelectionProvider#getSelection()
*/
public ISelection getSelection() {
- IRSESystemType selected = onlySystemType ? restrictedSystemTypes[0] : selectedSystemType;
- return selected != null ? new StructuredSelection(selected) : null;
+ ISelection selection = null;
+
+ // The system type must be available to construct the selection as
+ // the system type is per contract always the first element
+ IRSESystemType selected = isRestrictedToSingleSystemType() ? restrictedSystemTypes[0] : selectedSystemType;
+ if (selected != null) {
+ List selectionElements = new ArrayList();
+ selectionElements.add(selected);
+ // The second element in the selection is the selected context of the
+ // called as passed in to us (if available).
+ if (selectedContext != null) {
+ selectionElements.add(selectedContext);
+ }
+
+ // construct the selection now
+ selection = new StructuredSelection(selectionElements);
+ }
+
+ return selection;
}
/* (non-Javadoc)
@@ -178,23 +212,49 @@ public class RSEMainNewConnectionWizard extends Wizard implements INewWizard, IS
if (selection instanceof IStructuredSelection) {
IStructuredSelection sel = (IStructuredSelection)selection;
if (sel.getFirstElement() instanceof IRSESystemType) {
+ // update the selected system type.
selectedSystemType = (IRSESystemType)((IStructuredSelection)selection).getFirstElement();
- } else if (sel.getFirstElement() instanceof IHost) {
- selectedContext = (IHost)sel.getFirstElement();
- if (selectedContext.getSystemType() != null) {
- String systemTypeName = selectedContext.getSystemType();
- IRSESystemType systemType = RSECorePlugin.getDefault().getRegistry().getSystemType(systemTypeName);
- if (systemType != null) {
- selectedSystemType = systemType;
- }
- }
} else {
selectedSystemType = null;
}
+
+ // signal the system type change
onSelectedSystemTypeChanged();
}
}
+ /**
+ * Sets the currently selected context for the wizard as know by the caller
+ * of this method. The selected context is not interpreted by the main wizard,
+ * the selection is passed on as is to the nested wizards.
+ *
+ * @param selectedContext The selected context or null
.
+ */
+ public void setSelectedContext(ISelection selectedContext) {
+ this.selectedContext = selectedContext;
+ }
+
+ /**
+ * Set the connection context for the wizard as determinded from
+ * the caller of this method. If non-null, the method will query
+ * the connections context system type and invoke
+ * setSelection(...)
to apply the system type as the selected
+ * one.
+ *
+ * @param connectionContext The connection context or null
.
+ */
+ public void setConnectionContext(IHost connectionContext) {
+ this.connectionContext = connectionContext;
+ // If there is an connection context, extract the connections
+ // system type from the connection context as use as default
+ if (connectionContext != null && connectionContext.getSystemType() != null) {
+ String systemTypeName = connectionContext.getSystemType();
+ IRSESystemType systemType = RSECorePlugin.getDefault().getRegistry().getSystemType(systemTypeName);
+ // if we have found the system type object, pass on to setSelection(...)!
+ if (systemType != null) setSelection(new StructuredSelection(systemType));
+ }
+ }
+
/* (non-Javadoc)
* @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
*/
@@ -230,11 +290,16 @@ public class RSEMainNewConnectionWizard extends Wizard implements INewWizard, IS
selectedWizardCanFinishEarly = false;
}
+ // Check on the container association of the selected wizard.
+ if (getContainer() != null && selectedWizard != null && !getContainer().equals(selectedWizard.getContainer())) {
+ selectedWizard.setContainer(getContainer());
+ }
+
// if the newly selected wizard is the default RSE new connection wizard
// and the selected context is non-null, set the selected context to the
// default RSE new connection wizard.
if (selectedWizard instanceof RSEDefaultNewConnectionWizard) {
- ((RSEDefaultNewConnectionWizard)selectedWizard).setSelectedContext(selectedContext);
+ ((RSEDefaultNewConnectionWizard)selectedWizard).setSelectedContext(connectionContext);
}
// register the newly selected wizard as selection changed listener
@@ -242,15 +307,15 @@ public class RSEMainNewConnectionWizard extends Wizard implements INewWizard, IS
addSelectionChangedListener((ISelectionChangedListener)selectedWizard);
}
- // notify the selection changed event to the listeners
- fireSelectionChanged();
-
// Initialize the wizard pages and remember which wizard we have initialized already
if (selectedWizard != null && !initializedWizards.contains(selectedWizard)) {
selectedWizard.addPages();
initializedWizards.add(selectedWizard);
}
+ // notify the selection changed event to the listeners
+ fireSelectionChanged();
+
// Update the wizard container UI elements
IWizardContainer container = getContainer();
if (container != null && container.getCurrentPage() != null) {
@@ -261,20 +326,10 @@ public class RSEMainNewConnectionWizard extends Wizard implements INewWizard, IS
}
/* (non-Javadoc)
- * @see org.eclipse.jface.wizard.Wizard#getStartingPage()
- */
- public IWizardPage getStartingPage() {
- if (onlySystemType && getSelectedWizard() != null) return getSelectedWizard().getStartingPage();
- return super.getStartingPage();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.rse.ui.wizards.AbstractSystemWizard#addPages()
+ * @see org.eclipse.jface.wizard.Wizard#addPages()
*/
public void addPages() {
- // It we are not restricted to only one system type, add the
- // system type selection page.
- if (!onlySystemType) addPage(mainPage);
+ addPage(mainPage);
}
/* (non-Javadoc)
@@ -305,10 +360,6 @@ public class RSEMainNewConnectionWizard extends Wizard implements INewWizard, IS
* @see org.eclipse.rse.ui.wizards.AbstractSystemWizard#performFinish()
*/
public boolean performFinish() {
- // Note: Do _NOT_ delegate the performFinish from here to the selected
- // wizard!! The outer wizard dialog is handling the nested wizards by
- // default already itself!!
-
// Save the current selection to the dialog settings
IDialogSettings dialogSettings = getDialogSettings();
if (dialogSettings != null && getSelection() instanceof IStructuredSelection) {
@@ -318,6 +369,8 @@ public class RSEMainNewConnectionWizard extends Wizard implements INewWizard, IS
}
}
+ if (mainPage != null) mainPage.saveWidgetValues();
+
return true;
}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/RSENewConnectionWizardSelectionPage.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/RSENewConnectionWizardSelectionPage.java
index b4fdd0b9cc4..7b3105fe113 100644
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/RSENewConnectionWizardSelectionPage.java
+++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/RSENewConnectionWizardSelectionPage.java
@@ -11,7 +11,9 @@
package org.eclipse.rse.ui.wizards.newconnection;
+import java.util.ArrayList;
import java.util.Arrays;
+import java.util.List;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogSettings;
@@ -37,7 +39,10 @@ import org.eclipse.rse.core.IRSESystemType;
import org.eclipse.rse.ui.RSESystemTypeAdapter;
import org.eclipse.rse.ui.RSEUIPlugin;
import org.eclipse.rse.ui.SystemResources;
+import org.eclipse.rse.ui.wizards.registries.IRSEWizardCategory;
+import org.eclipse.rse.ui.wizards.registries.IRSEWizardRegistryElement;
import org.eclipse.rse.ui.wizards.registries.RSEWizardSelectionTreeContentProvider;
+import org.eclipse.rse.ui.wizards.registries.RSEWizardSelectionTreeElement;
import org.eclipse.rse.ui.wizards.registries.RSEWizardSelectionTreeLabelProvider;
import org.eclipse.rse.ui.wizards.registries.RSEWizardSelectionTreePatternFilter;
import org.eclipse.swt.SWT;
@@ -55,6 +60,9 @@ import org.eclipse.ui.dialogs.PatternFilter;
public class RSENewConnectionWizardSelectionPage extends WizardPage {
private final String helpId = RSEUIPlugin.HELPPREFIX + "wncc0000"; //$NON-NLS-1$;
+ private static final String EXPANDED_CATEGORIES_SETTINGS_ID = "filteredTree.expandedCatogryIds"; //$NON-NLS-1$
+ private static final String[] DEFAULT_EXPANDED_CATEGORY_IDS = new String[] { "org.eclipse.rse.ui.wizards.newconnection.default.category" }; //$NON-NLS-1$
+
private IRSESystemType[] restrictedSystemTypes;
private FilteredTree filteredTree;
@@ -184,7 +192,6 @@ public class RSENewConnectionWizardSelectionPage extends WizardPage {
// Explicitly allow the tree items to get decorated!!!
treeViewer.setLabelProvider(new DecoratingLabelProvider(new RSEWizardSelectionTreeLabelProvider(), PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator()));
treeViewer.setComparator(new NewConnectionWizardViewerComparator());
- treeViewer.setAutoExpandLevel(2);
filteredTreeWizardStateFilter = new NewConnectionWizardStateFilter();
treeViewer.addFilter(filteredTreeWizardStateFilter);
@@ -208,6 +215,10 @@ public class RSENewConnectionWizardSelectionPage extends WizardPage {
setControl(composite);
+ // Restore the expanded state of the category items within the tree
+ // before initializing the selection.
+ restoreWidgetValues();
+
// Initialize the selection in the tree
if (getWizard() instanceof ISelectionProvider) {
ISelectionProvider selectionProvider = (ISelectionProvider)getWizard();
@@ -220,13 +231,12 @@ public class RSENewConnectionWizardSelectionPage extends WizardPage {
}
}
}
- }
+
+ // we put the initial focus into the filter field
+ filteredTree.getFilterControl().setFocus();
+
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), helpId);
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.DialogPage#performHelp()
- */
- public void performHelp() {
- PlatformUI.getWorkbench().getHelpSystem().displayHelp(helpId);
}
/**
@@ -275,4 +285,61 @@ public class RSENewConnectionWizardSelectionPage extends WizardPage {
return settings;
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.DialogPage#setVisible(boolean)
+ */
+ public void setVisible(boolean visible) {
+ super.setVisible(visible);
+ // if the page will become hidden, save the expansion state of
+ // the tree elements.
+ if (!visible) saveWidgetValues();
+ }
+
+ /**
+ * Restore the tree state from the dialog settings.
+ */
+ public void restoreWidgetValues() {
+ IDialogSettings settings = getDialogSettings();
+ if (settings != null) {
+ String[] expandedCategories = settings.getArray(EXPANDED_CATEGORIES_SETTINGS_ID);
+ // by default we expand always the "General" category.
+ if (expandedCategories == null) expandedCategories = DEFAULT_EXPANDED_CATEGORY_IDS;
+ if (expandedCategories != null) {
+ List expanded = new ArrayList();
+ for (int i = 0; i < expandedCategories.length; i++) {
+ String categoryId = expandedCategories[i];
+ if (categoryId != null && !"".equals(categoryId.trim())) { //$NON-NLS-1$
+ IRSEWizardRegistryElement registryElement = RSENewConnectionWizardRegistry.getInstance().findElementById(categoryId);
+ if (registryElement instanceof IRSEWizardCategory) {
+ RSEWizardSelectionTreeElement treeElement = filteredTreeDataManager.getTreeElementForCategory((IRSEWizardCategory)registryElement);
+ if (treeElement != null) expanded.add(treeElement);
+ }
+ }
+ }
+
+ if (expanded.size() > 0) filteredTree.getViewer().setExpandedElements(expanded.toArray());
+ }
+ }
+ }
+
+ /**
+ * Saves the tree state to the dialog settings.
+ */
+ public void saveWidgetValues() {
+ IDialogSettings settings = getDialogSettings();
+ if (settings != null) {
+ List expandedCategories = new ArrayList();
+ Object[] expanded = filteredTree.getViewer().getVisibleExpandedElements();
+ for (int i = 0; i < expanded.length; i++) {
+ if (expanded[i] instanceof RSEWizardSelectionTreeElement) {
+ IRSEWizardRegistryElement registryElement = ((RSEWizardSelectionTreeElement)expanded[i]).getWizardRegistryElement();
+ if (registryElement instanceof IRSEWizardCategory) {
+ expandedCategories.add(((IRSEWizardCategory)registryElement).getId());
+ }
+ }
+ }
+ settings.put(EXPANDED_CATEGORIES_SETTINGS_ID, (String[])expandedCategories.toArray(new String[expandedCategories.size()]));
+ }
+ }
}
\ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/RSENewConnectionWizardSelectionTreeDataManager.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/RSENewConnectionWizardSelectionTreeDataManager.java
index edc69fe44d4..9ea231139ec 100644
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/RSENewConnectionWizardSelectionTreeDataManager.java
+++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/RSENewConnectionWizardSelectionTreeDataManager.java
@@ -31,6 +31,9 @@ public class RSENewConnectionWizardSelectionTreeDataManager extends RSEAbstractW
// and the wizard using these different object instances in their selections!
private Map elementMap;
+ // The category map is doing the same as the element but for categories.
+ private Map categoryMap;
+
/**
* Constructor.
*/
@@ -50,6 +53,17 @@ public class RSENewConnectionWizardSelectionTreeDataManager extends RSEAbstractW
return (RSENewConnectionWizardSelectionTreeElement)elementMap.get(systemType);
}
+ /**
+ * Returns the corresponding wizard selection tree element for the specified category.
+ *
+ * @param category The category. Must be not null
.
+ * @return The wizard selection tree element or null
.
+ */
+ public RSEWizardSelectionTreeElement getTreeElementForCategory(IRSEWizardCategory category) {
+ assert category != null;
+ return (RSEWizardSelectionTreeElement)categoryMap.get(category);
+ }
+
/* (non-Javadoc)
* @see org.eclipse.rse.ui.internal.wizards.newconnection.RSEAbstractWizardSelectionTreeDataManager#initialize(java.util.Set)
*/
@@ -60,7 +74,8 @@ public class RSENewConnectionWizardSelectionTreeDataManager extends RSEAbstractW
if (elementMap == null) elementMap = new HashMap();
elementMap.clear();
- Map categoryCache = new HashMap();
+ if (categoryMap == null) categoryMap = new HashMap();
+ categoryMap.clear();
// The new connection wizard selection is combining system types
// with registered new connection wizard.
@@ -106,11 +121,11 @@ public class RSENewConnectionWizardSelectionTreeDataManager extends RSEAbstractW
// if the category id is not null, check if we have accessed the category
// already once.
- RSEWizardSelectionTreeElement categoryElement = (RSEWizardSelectionTreeElement)categoryCache.get(category);
+ RSEWizardSelectionTreeElement categoryElement = (RSEWizardSelectionTreeElement)categoryMap.get(category);
if (categoryElement == null) {
categoryElement = new RSEWizardSelectionTreeElement(category);
categoryElement.setParentElement(null);
- categoryCache.put(category, categoryElement);
+ categoryMap.put(category, categoryElement);
}
categoryElement.add(wizardElement);
wizardElement.setParentElement(categoryElement);
@@ -131,11 +146,11 @@ public class RSENewConnectionWizardSelectionTreeDataManager extends RSEAbstractW
category = (IRSEWizardCategory)candidate;
- RSEWizardSelectionTreeElement parentElement = (RSEWizardSelectionTreeElement)categoryCache.get(category);
+ RSEWizardSelectionTreeElement parentElement = (RSEWizardSelectionTreeElement)categoryMap.get(category);
if (parentElement == null) {
parentElement = new RSEWizardSelectionTreeElement(category);
parentElement.setParentElement(null);
- categoryCache.put(category, parentElement);
+ categoryMap.put(category, parentElement);
}
parentElement.add(categoryElement);
categoryElement.setParentElement(parentElement);
diff --git a/rse/plugins/org.eclipse.rse.ui/schema/newConnectionWizards.exsd b/rse/plugins/org.eclipse.rse.ui/schema/newConnectionWizards.exsd
index 9cc195435e7..77aa9924572 100644
--- a/rse/plugins/org.eclipse.rse.ui/schema/newConnectionWizards.exsd
+++ b/rse/plugins/org.eclipse.rse.ui/schema/newConnectionWizards.exsd
@@ -10,7 +10,14 @@
<p>
Each system type must have exactly one new connection wizard associated. In case multiple new connection wizard contributions would match the same system type, the new connection wizard which matched the system type first, will be used.
<p>
-One new connection wizard may be registered for multiple system types. Such wizards should implement the <code>org.eclipse.jface.viewers.ISelectionChangedListener</code> interface to get notified about the currently selected system type within the new connection system type selection page.
+One new connection wizard may be registered for multiple system types. Such wizards should implement the <code>org.eclipse.jface.viewers.ISelectionChangedListener</code> interface. to get notified about the currently selected system type within the new connection system type selection page.
+<p>
+<b>Note:</b> The main RSE new connection wizard is using the <code>selectionChanged(SelectionChangedEvent)</code> to notify the nested wizards about
+ <ul>
+ <li> system type selection changes in the RSE new connection wizard selection page and</li>
+ <li> the selected context of a view or toolbar or menu the caller of the main RSE new connection wizard is passing in.</li>
+ </ul><br>
+ If the caller of the main RSE new connection wizard has passed in a selected context, the structured selection given via the <code>selectionChanged</code> call has two elements. The first element is always the selected system type (instance of type <code>IRSESystemType</code>) and the second one, if present, is the selected context from the caller (instance of type <code>ISelection</code>).
<p>
New connection wizard may have the need of contributing different attribute values for the same attribute dependent on the current system type selection. These wizards should implement the <code>org.eclipse.rse.ui.wizards.newconnection.IRSEDynamicNewConnectionWizard</code>.
@@ -164,18 +171,17 @@ The default RSE wizard category id is "org.eclipse.rse.ui.wizards.newconnec
<p>
<pre>
- <extension
- point="org.eclipse.rse.ui.newConnectionWizard">
- <category id="org.eclipse.rse.ui.wizards.newconnection.default.category"
- name="%Creation.category.name"/>
- <newConnectionWizard
- id="org.eclipse.rse.ui.wizards.newconnection.RSEDefaultnNewConnectionWizard"
+ <extension point="org.eclipse.rse.ui.newConnectionWizard">
+ <category id="org.eclipse.rse.ui.wizards.newconnection.default.category"
+ name="%Creation.category.name"/>
+ <newConnectionWizard
+ id="org.eclipse.rse.ui.wizards.newconnection.RSEDefaultNewConnectionWizard"
class="org.eclipse.rse.ui.wizards.newconnection.RSEDefaultNewConnectionWizard"
name="%DefaultRSENewConnectionWizard.name"
- canFinishEarly="false"
+ canFinishEarly="false"
categoryId="org.eclipse.rse.ui.wizards.newconnection.default.category"
hasPages="true">
- </newConnectionWizard>
+ </newConnectionWizard>
</extension>
</pre>
</p>
diff --git a/rse/plugins/org.eclipse.rse.ui/systemmessages.xml b/rse/plugins/org.eclipse.rse.ui/systemmessages.xml
index e2642b9de0b..7144f88a294 100644
--- a/rse/plugins/org.eclipse.rse.ui/systemmessages.xml
+++ b/rse/plugins/org.eclipse.rse.ui/systemmessages.xml
@@ -93,19 +93,19 @@ Contributors: