mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-27 19:05:38 +02:00
[cleanup] minor cleanups of SystemConnectionForm and RSEDefaultNewConnectionMainPage page validations
This commit is contained in:
parent
67281ca129
commit
656e656e27
4 changed files with 48 additions and 76 deletions
|
@ -18,6 +18,7 @@
|
||||||
package org.eclipse.rse.ui;
|
package org.eclipse.rse.ui;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
|
import java.net.UnknownHostException;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
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.ISystemProfile;
|
||||||
import org.eclipse.rse.core.model.ISystemRegistry;
|
import org.eclipse.rse.core.model.ISystemRegistry;
|
||||||
import org.eclipse.rse.services.clientserver.messages.SystemMessage;
|
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.dialogs.SystemPromptDialog;
|
||||||
import org.eclipse.rse.ui.messages.ISystemMessageLine;
|
import org.eclipse.rse.ui.messages.ISystemMessageLine;
|
||||||
import org.eclipse.rse.ui.validators.ISystemValidator;
|
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.Label;
|
||||||
import org.eclipse.swt.widgets.Listener;
|
import org.eclipse.swt.widgets.Listener;
|
||||||
import org.eclipse.swt.widgets.Text;
|
import org.eclipse.swt.widgets.Text;
|
||||||
|
import org.eclipse.ui.IWorkbenchPropertyPage;
|
||||||
import org.eclipse.ui.dialogs.PropertyPage;
|
import org.eclipse.ui.dialogs.PropertyPage;
|
||||||
|
|
||||||
|
|
||||||
|
@ -140,9 +143,9 @@ public class SystemConnectionForm
|
||||||
this.msgLine = msgLine;
|
this.msgLine = msgLine;
|
||||||
this.caller = caller;
|
this.caller = caller;
|
||||||
this.defaultProfileNames = RSEUIPlugin.getTheSystemRegistry().getActiveSystemProfileNames();
|
this.defaultProfileNames = RSEUIPlugin.getTheSystemRegistry().getActiveSystemProfileNames();
|
||||||
callerInstanceOfWizardPage = (caller instanceof WizardPage);
|
callerInstanceOfWizardPage = caller instanceof IWizardPage;
|
||||||
callerInstanceOfSystemPromptDialog = (caller instanceof SystemPromptDialog);
|
callerInstanceOfSystemPromptDialog = caller instanceof ISystemPromptDialog;
|
||||||
callerInstanceOfPropertyPage = (caller instanceof PropertyPage);
|
callerInstanceOfPropertyPage = caller instanceof IWorkbenchPropertyPage;
|
||||||
|
|
||||||
userIdValidator = new ValidatorUserId(true); // false => allow empty? Yes.
|
userIdValidator = new ValidatorUserId(true); // false => allow empty? Yes.
|
||||||
defaultUserId = ""; //$NON-NLS-1$
|
defaultUserId = ""; //$NON-NLS-1$
|
||||||
|
@ -1135,32 +1138,35 @@ public class SystemConnectionForm
|
||||||
* in the Dialog's message line.
|
* in the Dialog's message line.
|
||||||
* @see #setHostNameValidator(ISystemValidator)
|
* @see #setHostNameValidator(ISystemValidator)
|
||||||
*/
|
*/
|
||||||
protected SystemMessage validateHostNameInput()
|
protected SystemMessage validateHostNameInput() {
|
||||||
{
|
final String hostName = textHostName.getText().trim();
|
||||||
String hostName = textHostName.getText().trim();
|
|
||||||
if (connectionNameEmpty) // d43191
|
// d43191
|
||||||
internalSetConnectionName(hostName);
|
if (connectionNameEmpty) internalSetConnectionName(hostName);
|
||||||
errorMessage= null;
|
|
||||||
|
errorMessage = null;
|
||||||
|
|
||||||
if (hostValidator != null)
|
if (hostValidator != null)
|
||||||
errorMessage= hostValidator.validate(hostName);
|
errorMessage = hostValidator.validate(hostName);
|
||||||
else if (getHostName().length() == 0)
|
else if (getHostName().length() == 0)
|
||||||
errorMessage = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_VALIDATE_HOSTNAME_EMPTY);
|
errorMessage = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_VALIDATE_HOSTNAME_EMPTY);
|
||||||
if (updateMode && !userPickedVerifyHostnameCB)
|
|
||||||
{
|
if (updateMode && !userPickedVerifyHostnameCB) {
|
||||||
boolean hostNameChanged = !hostName.equals(defaultHostName);
|
boolean hostNameChanged = !hostName.equals(defaultHostName);
|
||||||
verifyHostNameCB.setSelection(hostNameChanged);
|
verifyHostNameCB.setSelection(hostNameChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
showErrorMessage(errorMessage);
|
showErrorMessage(errorMessage);
|
||||||
setPageComplete();
|
setPageComplete();
|
||||||
return errorMessage;
|
return errorMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This hook method is called whenever the text changes in the input field.
|
* This hook method is called whenever the text changes in the input field. The default implementation delegates the
|
||||||
* The default implementation delegates the request to an <code>ISystemValidator</code> object.
|
* request to an <code>ISystemValidator</code> object. If the <code>ISystemValidator</code> reports an error the
|
||||||
* If the <code>ISystemValidator</code> reports an error the error message is displayed
|
* error message is displayed in the Dialog's message line.
|
||||||
* in the Dialog's message line.
|
* @see #setUserIdValidator(ISystemValidator)
|
||||||
* @see #setUserIdValidator(ISystemValidator)
|
*/
|
||||||
*/
|
|
||||||
protected SystemMessage validateUserIdInput()
|
protected SystemMessage validateUserIdInput()
|
||||||
{
|
{
|
||||||
errorMessage= null;
|
errorMessage= null;
|
||||||
|
|
|
@ -85,7 +85,7 @@ public class SubSystemServiceWizardPage extends AbstractSystemNewConnectionWizar
|
||||||
|
|
||||||
IServiceSubSystemConfiguration currentFactory = (IServiceSubSystemConfiguration)getSubSystemConfiguration();
|
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;
|
String systemTypeName = systemType != null ? systemType.getName() : null;
|
||||||
|
|
||||||
IServiceSubSystemConfiguration[] factories = getServiceSubSystemFactories(systemTypeName, currentFactory.getServiceType());
|
IServiceSubSystemConfiguration[] factories = getServiceSubSystemFactories(systemTypeName, currentFactory.getServiceType());
|
||||||
|
|
|
@ -93,9 +93,10 @@ public class RSEDefaultNewConnectionWizard extends RSEAbstractNewConnectionWizar
|
||||||
public void selectionChanged(SelectionChangedEvent event) {
|
public void selectionChanged(SelectionChangedEvent event) {
|
||||||
super.selectionChanged(event);
|
super.selectionChanged(event);
|
||||||
if (mainPage != null && getSystemType() != null) {
|
if (mainPage != null && getSystemType() != null) {
|
||||||
mainPage.restrictSystemType(getSystemType().getName());
|
IRSESystemType systemType = getSystemType();
|
||||||
mainPage.setTitle(getPageTitle());
|
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);
|
mainPage.setHostName(defaultHostName);
|
||||||
|
|
||||||
if (mainPage != null && getSystemType() != null)
|
if (mainPage != null && getSystemType() != null)
|
||||||
mainPage.restrictSystemType(getSystemType().getName());
|
mainPage.setSystemType(getSystemType());
|
||||||
|
|
||||||
String defaultProfileName = RSEUIPlugin.getDefault().getSystemRegistry().getSystemProfileManager().getDefaultPrivateSystemProfile().getName();
|
String defaultProfileName = RSEUIPlugin.getDefault().getSystemRegistry().getSystemProfileManager().getDefaultPrivateSystemProfile().getName();
|
||||||
|
|
||||||
|
@ -337,25 +338,6 @@ public class RSEDefaultNewConnectionWizard extends RSEAbstractNewConnectionWizar
|
||||||
return mainPage;
|
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
|
* Private method to get all the wizard pages from all the subsystem factories, given a
|
||||||
* system type.
|
* system type.
|
||||||
|
|
|
@ -42,7 +42,6 @@ import org.eclipse.swt.widgets.Control;
|
||||||
|
|
||||||
public class RSEDefaultNewConnectionWizardMainPage extends AbstractSystemWizardPage implements ISystemConnectionFormCaller {
|
public class RSEDefaultNewConnectionWizardMainPage extends AbstractSystemWizardPage implements ISystemConnectionFormCaller {
|
||||||
|
|
||||||
private String[] restrictSystemTypesTo;
|
|
||||||
private SystemConnectionForm form;
|
private SystemConnectionForm form;
|
||||||
private String parentHelpId;
|
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) {
|
public void setSystemType(IRSESystemType systemType) {
|
||||||
assert systemType != null;
|
if (systemType != null) {
|
||||||
restrictSystemTypesTo = new String[] { systemType };
|
// The page _always_ restrict the system connection form
|
||||||
getForm().restrictSystemTypes(restrictSystemTypesTo);
|
// to only one system type.
|
||||||
|
getForm().restrictSystemType(systemType.getName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Overrride this if you want to supply your own form. This may be called
|
* 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
|
* 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;
|
RSEDefaultNewConnectionWizard newConnWizard = getWizard() instanceof RSEDefaultNewConnectionWizard ? (RSEDefaultNewConnectionWizard)getWizard() : null;
|
||||||
if (newConnWizard != null) {
|
if (newConnWizard != null) {
|
||||||
return (isPageComplete() && newConnWizard.hasAdditionalPages() && getForm().isConnectionUnique());
|
return (isPageComplete() && newConnWizard.hasAdditionalPages());
|
||||||
} 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 super.canFlipToNextPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.rse.ui.wizards.ISystemNewConnectionWizardMainPage#getSystemType()
|
* @see org.eclipse.rse.ui.ISystemConnectionFormCaller#systemTypeSelected(java.lang.String, boolean)
|
||||||
*/
|
*/
|
||||||
public IRSESystemType getSystemType() {
|
public void systemTypeSelected(String systemType, boolean duringInitialization) {
|
||||||
if (getWizard() instanceof RSEDefaultNewConnectionWizard) {
|
// Not applicable: The Page is driving the system connection form and not the way around!!!
|
||||||
RSEDefaultNewConnectionWizard wizard = (RSEDefaultNewConnectionWizard)getWizard();
|
|
||||||
return wizard.getSystemType();
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue