1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-09 10:05:24 +02:00

[fix] [175153], [175316] and other minor bugs

This commit is contained in:
Uwe Stieber 2007-02-26 14:15:38 +00:00
parent 4ca7fc898f
commit 2f4f34b5b1
14 changed files with 988 additions and 1343 deletions

View file

@ -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,16 +73,12 @@ import org.eclipse.ui.dialogs.PropertyPage;
* </p>
*/
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;
// GUI widgets
protected Label labelType, labelConnectionName, labelHostName, labelUserId, labelDescription, labelProfile;
protected Label labelTypeValue, labelSystemTypeValue, labelProfileValue;
@ -138,8 +133,7 @@ public class SystemConnectionForm
* @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();
@ -159,8 +153,7 @@ public class SystemConnectionForm
* 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,42 +163,39 @@ 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)
{
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)
{
public void setProfileNamePreSelection(String selection) {
this.defaultProfile = selection;
if ((profileCombo != null) && (selection != null))
{
if ((profileCombo != null) && (selection != null)) {
int selIdx = profileCombo.indexOf(selection);
if (selIdx >= 0)
profileCombo.select(selIdx);
@ -219,25 +209,23 @@ public class SystemConnectionForm
* 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)
{
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)
{
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)
{
public void restrictSystemType(String systemType) {
if (systemType.equals("*")) //$NON-NLS-1$
return;
this.restrictSystemTypesTo = new String[1];
@ -245,11 +233,11 @@ public class SystemConnectionForm
if (defaultSystemType == null)
defaultSystemType = systemType;
}
/**
* Call this to restrict the system types that the user is allowed to choose
*/
public void restrictSystemTypes(String[] systemTypes)
{
public void restrictSystemTypes(String[] systemTypes) {
if (systemTypes == null)
return;
else if ((systemTypes.length == 1) && (systemTypes[0].equals("*"))) //$NON-NLS-1$
@ -259,6 +247,16 @@ public class SystemConnectionForm
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.
* <b>This must be called <i>after</i> calling getContents!
* 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) {
initializeInputFields(conn, true);
}
/**
* Initialize input fields to current values in update mode.
@ -267,19 +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)
{
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.
* <b>This must be called <i>after</i> calling getContents!
* 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,8 +275,7 @@ public class SystemConnectionForm
defaultProfile = conn.getSystemProfile().getName();
defaultWorkOffline = conn.isOffline();
if (updateMode)
{
if (updateMode) {
defaultProfileNames = new String[1];
defaultProfileNames[0] = defaultProfile;
}
@ -302,32 +287,27 @@ public class SystemConnectionForm
/**
* 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;
@ -336,15 +316,13 @@ public class SystemConnectionForm
/**
* @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)
@ -357,18 +335,14 @@ public class SystemConnectionForm
if (nameValidator != null)
errorMessage = nameValidator.validate(connName);
if (errorMessage != null)
{
if (errorMessage != null) {
return false;
}
else
{
} else {
return true;
}
}
// ---------------------------------------------
// OUTPUT METHODS FOR EXTRACTING USER DATA ...
// ---------------------------------------------
@ -378,8 +352,7 @@ 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;
@ -393,41 +366,32 @@ public class SystemConnectionForm
controlInError = textConnectionName;
// validate host name...
if ((errorMessage == null) && (textHostName != null))
{
if ((errorMessage == null) && (textHostName != null)) {
errorMessage = validateHostNameInput();
if (errorMessage != null)
controlInError = textHostName;
}
// validate user Id...
if ((errorMessage == null) && (textUserId != null))
{
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 (currentHostName.length() > 0) {
if (verifyingHostName == null) {
verifyingHostName = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_HOSTNAME_VERIFYING);
}
try
{
try {
getRunnableContext().run(true, true, this);
}
catch (InterruptedException e)
{
} catch (InterruptedException e) {
// user canceled
ok = false;
controlInError = textHostName;
}
catch (InvocationTargetException e)
{
} catch (InvocationTargetException e) {
// error found
errorMessage = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_HOSTNAME_NOTFOUND);
errorMessage.makeSubstitution(currentHostName);
@ -437,11 +401,9 @@ public class SystemConnectionForm
}
// 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;
@ -449,8 +411,7 @@ public class SystemConnectionForm
// ...end of validation...
if (!ok || (errorMessage != null))
{
if (!ok || (errorMessage != null)) {
ok = false;
if (okPressed && controlInError != null)
controlInError.setFocus();
@ -458,18 +419,15 @@ public class SystemConnectionForm
}
// 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
userIdLocation = IRSEUserIdConstants.USERID_LOCATION_DEFAULT_SYSTEMTYPE; // edit the preference value
}
else
} else
userIdLocation = IRSEUserIdConstants.USERID_LOCATION_NOTSET;
SystemPreferencesManager.setVerifyConnection(verifyHostNameCB.getSelection());
}
@ -481,18 +439,12 @@ public class SystemConnectionForm
* 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,11 +452,9 @@ 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;
}
@ -517,35 +467,34 @@ public class SystemConnectionForm
* Return user-entered System Type.
* Call this after finish ends successfully.
*/
public String getSystemType()
{
public String getSystemType() {
if (textSystemType != null)
return textSystemType.getText().trim();
else
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();
else
@ -556,14 +505,10 @@ public class SystemConnectionForm
* 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;
}
}
@ -572,16 +517,15 @@ public class SystemConnectionForm
* 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()
{
public String getProfileName() {
return (labelProfileValue != null) ? labelProfileValue.getText() : profileCombo.getText();
}
@ -592,8 +536,7 @@ public class SystemConnectionForm
* @return the user id location
* @see IRSEUserIdConstants
*/
public int getUserIdLocation()
{
public int getUserIdLocation() {
if ((textUserId != null) && (textUserId.getText().trim().length() > 0))
return userIdLocation;
else
@ -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,14 +725,15 @@ public class SystemConnectionForm
doInitializeFields();
contentsCreated = true;
return composite_prompts; // composite;
}
/**
* Return control to recieve initial focus
*/
public Control getInitialFocusControl()
{
public Control getInitialFocusControl() {
if (updateMode || !singleTypeMode)
return textConnectionName;
else
@ -801,42 +743,35 @@ public class SystemConnectionForm
/**
* Default implementation to satisfy Listener interface. Does nothing.
*/
public void handleEvent(Event evt) {}
public void handleEvent(Event evt) {
}
/**
* Combo selection listener method
*/
public void widgetDefaultSelected(SelectionEvent event)
{
public void widgetDefaultSelected(SelectionEvent event) {
}
/**
* Combo selection listener method
*/
public void widgetSelected(SelectionEvent event)
{
public void widgetSelected(SelectionEvent event) {
Object src = event.getSource();
if (src == profileCombo)
{
if (src == profileCombo) {
profileCombo.getDisplay().asyncExec(this);
}
else if (src == textSystemType) // can only happen in create mode
} 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)
{
if (hostNameChanged) {
textHostName.setText(currHostName);
}
else if (textHostName.getItemCount()>0)
{
} else if (textHostName.getItemCount() > 0) {
textHostName.setText(textHostName.getItem(0));
originalHostName = textHostName.getText();
}
else
{
} else {
String connName = textConnectionName.getText().trim();
if (connName.indexOf(' ') == -1)
textHostName.setText(connName);
@ -897,8 +832,7 @@ public class SystemConnectionForm
for (int j = 0; j < pageList.size(); j++) {
pages[j] = (IWizardPage)(pageList.get(j));
}
}
else {
} else {
pages = wizard.getPages();
}
@ -908,8 +842,7 @@ public class SystemConnectionForm
if (page instanceof AbstractSystemWizardPage) {
((AbstractSystemWizardPage)page).clearErrorMessage();
}
else if (page instanceof WizardPage) {
} else if (page instanceof WizardPage) {
((WizardPage)page).setErrorMessage(null);
}
}
@ -922,25 +855,21 @@ public class SystemConnectionForm
/**
* Initialize values of input fields based on input
*/
private void doInitializeFields()
{
private void doInitializeFields() {
// -------
// profile
// -------
// ...output-only:
if (labelProfileValue != null)
{
if (labelProfileValue != null) {
if (defaultProfile != null)
labelProfileValue.setText(defaultProfile);
}
// ...selectable:
else
{
else {
if (defaultProfileNames != null)
profileCombo.setItems(defaultProfileNames);
if (defaultProfile != null)
{
if (defaultProfile != null) {
int selIdx = profileCombo.indexOf(defaultProfile);
if (selIdx >= 0)
profileCombo.select(selIdx);
@ -953,59 +882,47 @@ public class SystemConnectionForm
// system type
// -----------
// ...output-only:
if ((textSystemTypeReadOnly != null) || singleTypeMode)
{
if (restrictSystemTypesTo != null)
{
if ((textSystemTypeReadOnly != null) || singleTypeMode) {
if (restrictSystemTypesTo != null) {
if (textSystemTypeReadOnly != null)
textSystemTypeReadOnly.setText(restrictSystemTypesTo[0]);
if (defaultSystemType == null)
defaultSystemType = restrictSystemTypesTo[0];
}
else if (defaultSystemType != null)
{
} else if (defaultSystemType != null) {
if (textSystemTypeReadOnly != null)
textSystemTypeReadOnly.setText(defaultSystemType);
}
}
// ...selectable:
else
{
if (defaultSystemType == null)
{
else {
if (defaultSystemType == null) {
defaultSystemType = RSEPreferencesManager.getSystemType();
if ((defaultSystemType == null) || (defaultSystemType.length() == 0))
defaultSystemType = lastSystemType;
}
if (defaultSystemType != null)
{
if (defaultSystemType != null) {
int selIdx = textSystemType.indexOf(defaultSystemType);
if (selIdx >= 0)
textSystemType.select(selIdx);
}
else
{
} else {
textSystemType.select(0);
defaultSystemType = textSystemType.getText();
}
}
// ---------------
// connection name
// ---------------
if (defaultConnectionName != null)
// ---------------------------------------------------
// connection name: Don't set during context creation!
// ---------------------------------------------------
if (defaultConnectionName != null && contentsCreated)
textConnectionName.setText(defaultConnectionName);
textConnectionName.setTextLimit(connectionNameLength);
// -----------
// host name
// -----------
if (defaultHostName != null)
{
if (defaultHostName != null) {
textHostName.setText(defaultHostName);
}
else if (textHostName.getItemCount() > 0)
{
} else if (textHostName.getItemCount() > 0) {
textHostName.select(0);
}
textHostName.setTextLimit(hostNameLength);
@ -1025,8 +942,7 @@ public class SystemConnectionForm
// ---------------
// Work offline
// ---------------
if (workOfflineCB != null)
{
if (workOfflineCB != null) {
workOfflineCB.setSelection(defaultWorkOffline);
}
@ -1037,14 +953,12 @@ public class SystemConnectionForm
* 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)
{
if (textUserId != null) {
textUserId.setInheritedText(parentUserId);
boolean allowEditingOfInherited = ((parentUserId == null) || (parentUserId.length() == 0));
textUserId.setAllowEditingOfInheritedText(allowEditingOfInherited); // if not set yet, let user set it!
@ -1052,10 +966,8 @@ public class SystemConnectionForm
// ----------------------------
// default user id: update-mode
// ----------------------------
if ((currentUserId != null) && (currentUserId.length()>0))
{
if (textUserId != null)
{
if ((currentUserId != null) && (currentUserId.length() > 0)) {
if (textUserId != null) {
textUserId.setLocalText(currentUserId);
textUserId.setLocal(true);
}
@ -1063,20 +975,17 @@ public class SystemConnectionForm
// ----------------------------
// default user id: create-mode
// ----------------------------
else
{
else {
if (textUserId != null)
textUserId.setLocalText(""); //$NON-NLS-1$
if ((parentUserId != null) && (parentUserId.length() > 0))
{
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
{
else {
if (textUserId != null)
textUserId.setLocal(false);
}
@ -1094,14 +1003,12 @@ public class SystemConnectionForm
* 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)
{
if (profileCombo != null) {
selectedProfile = profileCombo.getSelectionIndex();
}
if (selectedProfile < 0)
@ -1110,8 +1017,7 @@ public class SystemConnectionForm
if ((nameValidators != null) && (nameValidators.length > 0))
nameValidator = nameValidators[selectedProfile];
String connName = textConnectionName.getText().trim();
if (nameValidator != null)
{
if (nameValidator != null) {
errorMessage = nameValidator.validate(connName);
}
showErrorMessage(errorMessage);
@ -1120,17 +1026,18 @@ public class SystemConnectionForm
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;
}
/**
* This hook method is called whenever the text changes in the input field.
* The default implementation delegates the request to an <code>ISystemValidator</code> object.
@ -1142,7 +1049,8 @@ public class SystemConnectionForm
final String hostName = textHostName.getText().trim();
// d43191
if (connectionNameEmpty) internalSetConnectionName(hostName);
if (connectionNameEmpty)
internalSetConnectionName(hostName);
errorMessage = null;
@ -1167,11 +1075,9 @@ public class SystemConnectionForm
* error message is displayed in the Dialog's message line.
* @see #setUserIdValidator(ISystemValidator)
*/
protected SystemMessage validateUserIdInput()
{
protected SystemMessage validateUserIdInput() {
errorMessage = null;
if (textUserId != null)
{
if (textUserId != null) {
if (userIdValidator != null)
errorMessage = userIdValidator.validate(textUserId.getText());
else if (getDefaultUserId().length() == 0)
@ -1185,21 +1091,15 @@ public class SystemConnectionForm
/**
* 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)
{
if (callerInstanceOfWizardPage) {
((WizardPage)caller).setPageComplete(complete);
}
else if (callerInstanceOfSystemPromptDialog)
{
} else if (callerInstanceOfSystemPromptDialog) {
((SystemPromptDialog)caller).setPageComplete(complete);
}
else if (callerInstanceOfPropertyPage)
{
} else if (callerInstanceOfPropertyPage) {
((PropertyPage)caller).setValid(complete);
}
}
@ -1207,8 +1107,7 @@ public class SystemConnectionForm
/**
* Display error message or clear error message
*/
private void showErrorMessage(SystemMessage msg)
{
private void showErrorMessage(SystemMessage msg) {
if (msgLine != null)
if (msg != null)
msgLine.setErrorMessage(msg);
@ -1227,21 +1126,20 @@ public class SystemConnectionForm
* @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;
}
/**
* 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)
{
public static ISystemValidator getConnectionNameValidator(ISystemProfile profile) {
Vector v = RSEUIPlugin.getTheSystemRegistry().getHostAliasNames(profile);
ValidatorConnectionName connNameValidator = new ValidatorConnectionName(v);
return connNameValidator;
@ -1251,13 +1149,11 @@ public class SystemConnectionForm
* 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; idx<profiles.length; idx++)
{
for (int idx = 0; idx < profiles.length; idx++) {
Vector v = sr.getHostAliasNames(profiles[idx]);
connNameValidators[idx] = new ValidatorConnectionName(v);
}
@ -1268,8 +1164,7 @@ public class SystemConnectionForm
// METHOD REQUIRED BY RUNNABLE, USED IN CALL TO ASYNCEXEC
// -------------------------------------------------------
public void run()
{
public void run() {
verify(false);
}
@ -1277,15 +1172,11 @@ public class SystemConnectionForm
* METHOD REQUIRED BY IRunnableWithProgress, USED TO SHOW PROGRESS WHILE
* VERIFYING HOSTNAME
*/
public void run(IProgressMonitor pm) throws InvocationTargetException, InterruptedException
{
public void run(IProgressMonitor pm) throws InvocationTargetException, InterruptedException {
pm.beginTask(verifyingHostName.getLevelOneText(), IProgressMonitor.UNKNOWN);
try
{
try {
InetAddress.getByName(currentHostName);
}
catch (java.net.UnknownHostException exc)
{
} catch (java.net.UnknownHostException exc) {
pm.done();
throw new InvocationTargetException(exc);
}

View file

@ -18,9 +18,9 @@ package org.eclipse.rse.ui.actions;
import java.util.LinkedList;
import java.util.List;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.wizard.IWizard;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.rse.core.IRSESystemType;
@ -48,7 +48,13 @@ public class SystemNewConnectionAction extends SystemBaseWizardAction {
private boolean fromPopupMenu = true;
private ISelectionProvider sp;
private String[] restrictSystemTypesTo;
private IHost selectedContext;
// The current selection the action is knowing of. Just pass on
// to the wizards. Do not interpret here!
private ISelection selectedContext;
// The associated connection object of the selected context if
// determinable from the selected context
private IHost connectionContext;
/**
* Constructor.
@ -104,12 +110,19 @@ public class SystemNewConnectionAction extends SystemBaseWizardAction {
* Our default implementation is to return <code>RSEMainNewConnectionWizard</code>.
*/
protected IWizard createWizard() {
// create the new connection wizard instance.
RSEMainNewConnectionWizard newConnWizard = new RSEMainNewConnectionWizard();
if (!fromPopupMenu && sp != null) {
setSelection(sp.getSelection());
}
// simulate a selection changed event if the action is not called from
// a popup menu and a selection provider is set
if (!fromPopupMenu && sp != null) setSelection(sp.getSelection());
// First, restrict the wizard in the system types to show if this is
// requested.
if (restrictSystemTypesTo != null) {
// Till now, we get the list of system types to restrict to via system
// type name. This should be changed to be a list of system type objects
// as soon as possible. Till than, we have to translate the lists here.
List systemTypes = new LinkedList();
for (int i = 0; i < restrictSystemTypesTo.length; i++) {
IRSESystemType systemType = RSECorePlugin.getDefault().getRegistry().getSystemType(restrictSystemTypesTo[i]);
@ -119,14 +132,18 @@ public class SystemNewConnectionAction extends SystemBaseWizardAction {
newConnWizard.restrictToSystemTypes((IRSESystemType[])systemTypes.toArray(new IRSESystemType[systemTypes.size()]));
}
// if there is a system type available from the current context, this system type
// is selected by default
if (selectedContext != null){
// send a selection changed event to the wizard with the selected context.
newConnWizard.setSelection(new StructuredSelection(selectedContext));
}
// If there is an remembered selection, we pass on the selected context
// totally untranslated to the wizards. The specific wizards have to
// interpret the selection themself. We simple cannot know here what is
// necessary and what not. Wizard providers may want to get selections
// we have no idea from. Only chance to do so, pass the selection on.
newConnWizard.setSelectedContext(selectedContext);
return newConnWizard;
// if we had determined the connection context of the selected context, pass
// on as well to the new connection wizard.
newConnWizard.setConnectionContext(connectionContext);
return newConnWizard.isRestrictedToSingleSystemType() ? newConnWizard.getSelectedWizard() : newConnWizard;
}
/* (non-Javadoc)
@ -175,12 +192,17 @@ public class SystemNewConnectionAction extends SystemBaseWizardAction {
this.restrictSystemTypesTo = systemTypes;
}
/**
* Override of parent method so we can deduce currently selected connection (direct or indirect if child object selected).
/* (non-Javadoc)
* @see org.eclipse.rse.ui.actions.SystemBaseAction#updateSelection(org.eclipse.jface.viewers.IStructuredSelection)
*/
public boolean updateSelection(IStructuredSelection selection) {
boolean enable = super.updateSelection(selection);
if (enable) {
boolean enabled = super.updateSelection(selection);
// store the selection. The wizard contributor may want to analyse
// the current selection by themself.
selectedContext = selection;
// and try to determine the connection context from the selection
if (enabled) {
Object firstSelection = getFirstSelection();
IHost conn = null;
if (firstSelection != null) {
@ -203,8 +225,9 @@ public class SystemNewConnectionAction extends SystemBaseWizardAction {
}
}
selectedContext = conn;
connectionContext = conn;
}
return enable;
return enabled;
}
}

View file

@ -1,392 +0,0 @@
/********************************************************************************
* Copyright (c) 2002, 2006 IBM Corporation. All rights reserved.
* This program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
*
* Initial Contributors:
* The following IBM employees contributed to the Remote System Explorer
* component that contains this file: David McKnight, Kushal Munir,
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
*
* Contributors:
* {Name} (company) - description of contribution.
********************************************************************************/
package org.eclipse.rse.ui.messages;
import org.eclipse.jface.dialogs.DialogPage;
import org.eclipse.jface.dialogs.IMessageProvider;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.rse.core.SystemBasePlugin;
import org.eclipse.rse.services.clientserver.messages.SystemMessage;
import org.eclipse.rse.ui.ISystemMessages;
import org.eclipse.rse.ui.RSEUIPlugin;
import org.eclipse.rse.ui.SystemResources;
import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.dialogs.PropertyPage;
/**
* @deprecated
* <p>DO NOT USE THIS CLASS!
* <p>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.
* <p>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 <code>null</code> 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 <code>null</code> is returned.
*/
public String getErrorMessage() {
return dlgPage.getErrorMessage();
}
/**
* Get the currently displayed message.
* @return The message. If no message is displayed <code>null<code> 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();
}
}

View file

@ -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;

View file

@ -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 <code>null</code>.
*/
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());
}
}

View file

@ -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);
}
}

View file

@ -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);

View file

@ -114,12 +114,14 @@ public class RSEDefaultNewConnectionWizard extends RSEAbstractNewConnectionWizar
public void addPages() {
try {
mainPage = createMainPage(getSystemType());
mainPage.setConnectionNameValidators(SystemConnectionForm.getConnectionNameValidators());
mainPage.setCurrentlySelectedConnection(selectedContext);
SystemConnectionForm form = mainPage.getSystemConnectionForm();
if (form != null) {
form.setCurrentlySelectedConnection(selectedContext);
if (defaultUserId != null) mainPage.setUserId(defaultUserId);
if (defaultConnectionName != null) mainPage.setConnectionName(defaultConnectionName);
if (defaultHostName != null) mainPage.setHostName(defaultHostName);
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());
@ -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,10 +366,12 @@ 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()];
for (int idx = 0; idx < subsystemFactorySuppliedWizardPages.length; idx++)
subsystemFactorySuppliedWizardPages[idx] = (ISystemNewConnectionWizardPage)additionalPages.elementAt(idx);

View file

@ -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;
* </ul>
*/
public class RSEDefaultNewConnectionWizardMainPage extends AbstractSystemWizardPage implements ISystemConnectionFormCaller {
public class RSEDefaultNewConnectionWizardMainPage extends WizardPage implements ISystemConnectionFormCaller {
private final String parentHelpId = RSEUIPlugin.HELPPREFIX + "wncc0000"; //$NON-NLS-1$;
private SystemConnectionForm form;
private String parentHelpId;
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,177 +72,62 @@ 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 <code>null</code>.
*/
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
if (getSystemConnectionForm() != null)
return getSystemConnectionForm().isPageComplete() && getSystemConnectionForm().isConnectionUnique();
return false;
}
@ -243,18 +135,10 @@ public class RSEDefaultNewConnectionWizardMainPage extends AbstractSystemWizardP
* 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) {

View file

@ -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 <code>True</code> if the wizard is restricted to only one system type, <code>false</code> 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 <code>null</code>.
*/
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 <code>
* setSelection(...)</code> to apply the system type as the selected
* one.
*
* @param connectionContext The connection context or <code>null</code>.
*/
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;
}

View file

@ -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 {
}
}
}
}
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.DialogPage#performHelp()
*/
public void performHelp() {
PlatformUI.getWorkbench().getHelpSystem().displayHelp(helpId);
// we put the initial focus into the filter field
filteredTree.getFilterControl().setFocus();
PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), 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()]));
}
}
}

View file

@ -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 <code>null</code>.
* @return The wizard selection tree element or <code>null</code>.
*/
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);

View file

@ -10,7 +10,14 @@
&lt;p&gt;
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.
&lt;p&gt;
One new connection wizard may be registered for multiple system types. Such wizards should implement the &lt;code&gt;org.eclipse.jface.viewers.ISelectionChangedListener&lt;/code&gt; 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 &lt;code&gt;org.eclipse.jface.viewers.ISelectionChangedListener&lt;/code&gt; interface. to get notified about the currently selected system type within the new connection system type selection page.
&lt;p&gt;
&lt;b&gt;Note:&lt;/b&gt; The main RSE new connection wizard is using the &lt;code&gt;selectionChanged(SelectionChangedEvent)&lt;/code&gt; to notify the nested wizards about
&lt;ul&gt;
&lt;li&gt; system type selection changes in the RSE new connection wizard selection page and&lt;/li&gt;
&lt;li&gt; the selected context of a view or toolbar or menu the caller of the main RSE new connection wizard is passing in.&lt;/li&gt;
&lt;/ul&gt;&lt;br&gt;
If the caller of the main RSE new connection wizard has passed in a selected context, the structured selection given via the &lt;code&gt;selectionChanged&lt;/code&gt; call has two elements. The first element is always the selected system type (instance of type &lt;code&gt;IRSESystemType&lt;/code&gt;) and the second one, if present, is the selected context from the caller (instance of type &lt;code&gt;ISelection&lt;/code&gt;).
&lt;p&gt;
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 &lt;code&gt;org.eclipse.rse.ui.wizards.newconnection.IRSEDynamicNewConnectionWizard&lt;/code&gt;.
</documentation>
@ -164,12 +171,11 @@ The default RSE wizard category id is &quot;org.eclipse.rse.ui.wizards.newconnec
&lt;p&gt;
&lt;pre&gt;
&lt;extension
point=&quot;org.eclipse.rse.ui.newConnectionWizard&quot;&gt;
&lt;extension point=&quot;org.eclipse.rse.ui.newConnectionWizard&quot;&gt;
&lt;category id=&quot;org.eclipse.rse.ui.wizards.newconnection.default.category&quot;
name=&quot;%Creation.category.name&quot;/&gt;
&lt;newConnectionWizard
id=&quot;org.eclipse.rse.ui.wizards.newconnection.RSEDefaultnNewConnectionWizard&quot;
id=&quot;org.eclipse.rse.ui.wizards.newconnection.RSEDefaultNewConnectionWizard&quot;
class=&quot;org.eclipse.rse.ui.wizards.newconnection.RSEDefaultNewConnectionWizard&quot;
name=&quot;%DefaultRSENewConnectionWizard.name&quot;
canFinishEarly=&quot;false&quot;

View file

@ -93,19 +93,19 @@ Contributors:
<LevelTwo>The name must be a valid file name within the workbench and the underlying file system.</LevelTwo>
</Message>
<Message ID="1020" Indicator="E">
<LevelOne>Enter system type</LevelOne>
<LevelOne>Please enter a valid system type.</LevelOne>
<LevelTwo>You must select a system type. The system type is the type of the operating system of the remote sytem.</LevelTwo>
</Message>
<Message ID="1021" Indicator="E">
<LevelOne>Enter connection name</LevelOne>
<LevelOne>Please enter a valid connection name.</LevelOne>
<LevelTwo>You must enter a connection name. This name is arbitrary, but must be unique to the selected profile.</LevelTwo>
</Message>
<Message ID="1022" Indicator="E">
<LevelOne>Connection name is not unique for its profile</LevelOne>
<LevelOne>Connection name is not unique for the selected profile.</LevelOne>
<LevelTwo>Connection names must be unique to the profile that contains the connection. Specify a name not already in use.</LevelTwo>
</Message>
<Message ID="1023" Indicator="E">
<LevelOne>Not a valid connection name</LevelOne>
<LevelOne>Invalid connection name. Must be a valid folder name in the underlaying file system.</LevelOne>
<LevelTwo>The connection name is not syntactically valid. The name must be a valid folder name within the workbench and the underlying file system.</LevelTwo>
</Message>
<Message ID="1024" Indicator="E">