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

[417962] - Fix editing connections.

Signed-off-by: Greg Watson <g.watson@computer.org>
This commit is contained in:
Greg Watson 2013-09-24 16:24:52 -04:00
parent d527909629
commit c7f1824eec

View file

@ -160,6 +160,7 @@ public class JSchConnectionPage extends WizardPage {
fPasswordButton.addSelectionListener(new SelectionAdapter() { fPasswordButton.addSelectionListener(new SelectionAdapter() {
@Override @Override
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
validateFields();
updateEnablement(); updateEnablement();
} }
}); });
@ -178,6 +179,7 @@ public class JSchConnectionPage extends WizardPage {
fPublicKeyButton.addSelectionListener(new SelectionAdapter() { fPublicKeyButton.addSelectionListener(new SelectionAdapter() {
@Override @Override
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
validateFields();
updateEnablement(); updateEnablement();
} }
}); });
@ -198,18 +200,17 @@ public class JSchConnectionPage extends WizardPage {
fPasswordButton.setSelection(true); fPasswordButton.setSelection(true);
fPublicKeyButton.setSelection(false); fPublicKeyButton.setSelection(false);
updateEnablement();
} }
public void createControl(Composite parent) { public void createControl(Composite parent) {
if (fConnection == null) { if (fConnection == null) {
setDescription(Messages.JSchNewConnectionPage_New_connection_properties); setDescription(Messages.JSchNewConnectionPage_New_connection_properties);
setTitle(Messages.JSchNewConnectionPage_New_Connection); setTitle(Messages.JSchNewConnectionPage_New_Connection);
setMessage(Messages.JSchConnectionPage_Please_enter_name_for_connection);
} else { } else {
setDescription(Messages.JSchConnectionPage_Edit_properties_of_an_existing_connection); setDescription(Messages.JSchConnectionPage_Edit_properties_of_an_existing_connection);
setTitle(Messages.JSchConnectionPage_Edit_Connection); setTitle(Messages.JSchConnectionPage_Edit_Connection);
} }
setMessage(Messages.JSchConnectionPage_Please_enter_name_for_connection);
setErrorMessage(null); setErrorMessage(null);
GridLayout topLayout = new GridLayout(2, false); GridLayout topLayout = new GridLayout(2, false);
@ -238,17 +239,33 @@ public class JSchConnectionPage extends WizardPage {
* Register listeners after loading values so we don't trigger listeners * Register listeners after loading values so we don't trigger listeners
*/ */
registerListeners(); registerListeners();
if (fConnection != null) {
validateFields();
}
updateEnablement();
} }
public JSchConnectionWorkingCopy getConnection() { public JSchConnectionWorkingCopy getConnection() {
return fConnection; return fConnection;
} }
/**
* Check if the connection name is invalid. This only applies to new connections (when fConnection is null).
*
* @param name
* connection name
* @return true if the name is invalid, false otherwise
*/
private boolean isInvalidName(String name) { private boolean isInvalidName(String name) {
if (fInvalidConnectionNames == null) { if (fConnection == null) {
return fConnectionManager.getConnection(name) != null; if (fInvalidConnectionNames == null) {
return fConnectionManager.getConnection(name) != null;
}
return fInvalidConnectionNames.contains(name);
} }
return fInvalidConnectionNames.contains(name); return false;
} }
private void loadValues() { private void loadValues() {
@ -258,8 +275,10 @@ public class JSchConnectionPage extends WizardPage {
fUserText.setText(fConnection.getUsername()); fUserText.setText(fConnection.getUsername());
fPortText.setText(Integer.toString(fConnection.getPort())); fPortText.setText(Integer.toString(fConnection.getPort()));
fTimeoutText.setText(Integer.toString(fConnection.getTimeout())); fTimeoutText.setText(Integer.toString(fConnection.getTimeout()));
fPasswordButton.setSelection(fConnection.isPasswordAuth()); boolean isPwd = fConnection.isPasswordAuth();
if (fConnection.isPasswordAuth()) { fPasswordButton.setSelection(isPwd);
fPublicKeyButton.setSelection(!isPwd);
if (isPwd) {
fPasswordText.setText(fConnection.getPassword()); fPasswordText.setText(fConnection.getPassword());
} else { } else {
fPassphraseText.setText(fConnection.getPassphrase()); fPassphraseText.setText(fConnection.getPassphrase());
@ -306,6 +325,7 @@ public class JSchConnectionPage extends WizardPage {
fConnectionName.addModifyListener(fDataModifyListener); fConnectionName.addModifyListener(fDataModifyListener);
fHostText.addModifyListener(fDataModifyListener); fHostText.addModifyListener(fDataModifyListener);
fUserText.addModifyListener(fDataModifyListener); fUserText.addModifyListener(fDataModifyListener);
fFileWidget.addModifyListener(fDataModifyListener);
fPortText.addModifyListener(fDataModifyListener); fPortText.addModifyListener(fDataModifyListener);
fTimeoutText.addModifyListener(fDataModifyListener); fTimeoutText.addModifyListener(fDataModifyListener);
} }