1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-09 18:56:02 +02:00

[cleanup] minor cleanups of SystemConnectionForm and RSEDefaultNewConnectionMainPage page validations

This commit is contained in:
Uwe Stieber 2007-02-21 12:57:17 +00:00
parent 67281ca129
commit 656e656e27
4 changed files with 48 additions and 76 deletions

View file

@ -18,6 +18,7 @@
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;
@ -36,6 +37,7 @@ import org.eclipse.rse.core.model.IHost;
import org.eclipse.rse.core.model.ISystemProfile;
import org.eclipse.rse.core.model.ISystemRegistry;
import org.eclipse.rse.services.clientserver.messages.SystemMessage;
import org.eclipse.rse.ui.dialogs.ISystemPromptDialog;
import org.eclipse.rse.ui.dialogs.SystemPromptDialog;
import org.eclipse.rse.ui.messages.ISystemMessageLine;
import org.eclipse.rse.ui.validators.ISystemValidator;
@ -56,6 +58,7 @@ import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.IWorkbenchPropertyPage;
import org.eclipse.ui.dialogs.PropertyPage;
@ -140,9 +143,9 @@ public class SystemConnectionForm
this.msgLine = msgLine;
this.caller = caller;
this.defaultProfileNames = RSEUIPlugin.getTheSystemRegistry().getActiveSystemProfileNames();
callerInstanceOfWizardPage = (caller instanceof WizardPage);
callerInstanceOfSystemPromptDialog = (caller instanceof SystemPromptDialog);
callerInstanceOfPropertyPage = (caller instanceof PropertyPage);
callerInstanceOfWizardPage = caller instanceof IWizardPage;
callerInstanceOfSystemPromptDialog = caller instanceof ISystemPromptDialog;
callerInstanceOfPropertyPage = caller instanceof IWorkbenchPropertyPage;
userIdValidator = new ValidatorUserId(true); // false => allow empty? Yes.
defaultUserId = ""; //$NON-NLS-1$
@ -1135,32 +1138,35 @@ public class SystemConnectionForm
* in the Dialog's message line.
* @see #setHostNameValidator(ISystemValidator)
*/
protected SystemMessage validateHostNameInput()
{
String hostName = textHostName.getText().trim();
if (connectionNameEmpty) // d43191
internalSetConnectionName(hostName);
errorMessage= null;
protected SystemMessage validateHostNameInput() {
final String hostName = textHostName.getText().trim();
// d43191
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)
{
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;
setPageComplete();
return errorMessage;
}
/**
* 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.
* If the <code>ISystemValidator</code> reports an error the error message is displayed
* in the Dialog's message line.
* @see #setUserIdValidator(ISystemValidator)
*/
* 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. If the <code>ISystemValidator</code> reports an error the
* error message is displayed in the Dialog's message line.
* @see #setUserIdValidator(ISystemValidator)
*/
protected SystemMessage validateUserIdInput()
{
errorMessage= null;

View file

@ -85,7 +85,7 @@ public class SubSystemServiceWizardPage extends AbstractSystemNewConnectionWizar
IServiceSubSystemConfiguration currentFactory = (IServiceSubSystemConfiguration)getSubSystemConfiguration();
IRSESystemType systemType = getMainPage() != null ? getMainPage().getSystemType() : null;
IRSESystemType systemType = getMainPage() != null && getMainPage().getWizard() instanceof RSEDefaultNewConnectionWizard ? ((RSEDefaultNewConnectionWizard)getMainPage().getWizard()).getSystemType() : null;
String systemTypeName = systemType != null ? systemType.getName() : null;
IServiceSubSystemConfiguration[] factories = getServiceSubSystemFactories(systemTypeName, currentFactory.getServiceType());

View file

@ -93,9 +93,10 @@ public class RSEDefaultNewConnectionWizard extends RSEAbstractNewConnectionWizar
public void selectionChanged(SelectionChangedEvent event) {
super.selectionChanged(event);
if (mainPage != null && getSystemType() != null) {
mainPage.restrictSystemType(getSystemType().getName());
IRSESystemType systemType = getSystemType();
mainPage.setTitle(getPageTitle());
systemTypeSelected(getSystemType().getName(), true);
mainPage.setSystemType(systemType);
subsystemFactorySuppliedWizardPages = getAdditionalWizardPages(systemType.getName());
}
}
@ -116,7 +117,7 @@ public class RSEDefaultNewConnectionWizard extends RSEAbstractNewConnectionWizar
mainPage.setHostName(defaultHostName);
if (mainPage != null && getSystemType() != null)
mainPage.restrictSystemType(getSystemType().getName());
mainPage.setSystemType(getSystemType());
String defaultProfileName = RSEUIPlugin.getDefault().getSystemRegistry().getSystemProfileManager().getDefaultPrivateSystemProfile().getName();
@ -337,25 +338,6 @@ public class RSEDefaultNewConnectionWizard extends RSEAbstractNewConnectionWizar
return mainPage;
}
/**
* Return the form of the main page of this wizard
*/
// public SystemConnectionForm getMainPageForm()
// {
// return (mainPage).getForm();
// }
// ----------------------------------------
// CALLBACKS FROM SYSTEM CONNECTION PAGE...
// ----------------------------------------
/**
* Event: the user has selected a system type.
*/
public void systemTypeSelected(String systemType, boolean duringInitialization) {
subsystemFactorySuppliedWizardPages = getAdditionalWizardPages(systemType);
if (!duringInitialization)
getContainer().updateButtons();
}
/*
* Private method to get all the wizard pages from all the subsystem factories, given a
* system type.

View file

@ -42,7 +42,6 @@ import org.eclipse.swt.widgets.Control;
public class RSEDefaultNewConnectionWizardMainPage extends AbstractSystemWizardPage implements ISystemConnectionFormCaller {
private String[] restrictSystemTypesTo;
private SystemConnectionForm form;
private String parentHelpId;
@ -58,16 +57,18 @@ public class RSEDefaultNewConnectionWizardMainPage extends AbstractSystemWizardP
}
/**
* Call this to restrict the system type that the user is allowed to choose
* Set the system type the page is working with.
*
* @param systemType The system type to restrict the page to. Must be not <code>null</code>.
* @param systemType The system type.
*/
public void restrictSystemType(String systemType) {
assert systemType != null;
restrictSystemTypesTo = new String[] { systemType };
getForm().restrictSystemTypes(restrictSystemTypesTo);
public void setSystemType(IRSESystemType systemType) {
if (systemType != null) {
// The page _always_ restrict the system connection form
// to only one system type.
getForm().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
@ -271,34 +272,17 @@ public class RSEDefaultNewConnectionWizardMainPage extends AbstractSystemWizardP
RSEDefaultNewConnectionWizard newConnWizard = getWizard() instanceof RSEDefaultNewConnectionWizard ? (RSEDefaultNewConnectionWizard)getWizard() : null;
if (newConnWizard != null) {
return (isPageComplete() && newConnWizard.hasAdditionalPages() && getForm().isConnectionUnique());
} else
return super.canFlipToNextPage();
}
// ----------------------------------------
// CALLBACKS FROM SYSTEM CONNECTION FORM...
// ----------------------------------------
/**
* Event: the user has selected a system type.
*/
public void systemTypeSelected(String systemType, boolean duringInitialization) {
RSEDefaultNewConnectionWizard newConnWizard = getWizard() instanceof RSEDefaultNewConnectionWizard ? (RSEDefaultNewConnectionWizard)getWizard() : null;
if (newConnWizard != null) {
newConnWizard.systemTypeSelected(systemType, duringInitialization);
return (isPageComplete() && newConnWizard.hasAdditionalPages());
}
return super.canFlipToNextPage();
}
/* (non-Javadoc)
* @see org.eclipse.rse.ui.wizards.ISystemNewConnectionWizardMainPage#getSystemType()
* @see org.eclipse.rse.ui.ISystemConnectionFormCaller#systemTypeSelected(java.lang.String, boolean)
*/
public IRSESystemType getSystemType() {
if (getWizard() instanceof RSEDefaultNewConnectionWizard) {
RSEDefaultNewConnectionWizard wizard = (RSEDefaultNewConnectionWizard)getWizard();
return wizard.getSystemType();
}
return null;
public void systemTypeSelected(String systemType, boolean duringInitialization) {
// Not applicable: The Page is driving the system connection form and not the way around!!!
}
}