[jbosstools-commits] JBoss Tools SVN: r44037 - in trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh: databinding and 1 other directory.
jbosstools-commits at lists.jboss.org
jbosstools-commits at lists.jboss.org
Wed Sep 26 09:46:18 EDT 2012
Author: adietish
Date: 2012-09-26 09:46:18 -0400 (Wed, 26 Sep 2012)
New Revision: 44037
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/AddSSHKeyWizardPage.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/databinding/SSHPublicKeyValidator.java
Log:
[JBIDE-12715] forcing revalidation when getting back from ssh2 preferences
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/AddSSHKeyWizardPage.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/AddSSHKeyWizardPage.java 2012-09-26 13:35:29 UTC (rev 44036)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/AddSSHKeyWizardPage.java 2012-09-26 13:46:18 UTC (rev 44037)
@@ -12,7 +12,6 @@
import org.eclipse.core.databinding.Binding;
import org.eclipse.core.databinding.DataBindingContext;
-import org.eclipse.core.databinding.ValidationStatusProvider;
import org.eclipse.core.databinding.beans.BeanProperties;
import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.core.runtime.IStatus;
@@ -110,7 +109,7 @@
GridDataFactory.fillDefaults()
.align(SWT.FILL, SWT.CENTER).applyTo(browseButton);
- ValidationStatusProvider sshPublicKeyValidator = new SSHPublicKeyValidator(publicKeyObservable, pageModel);
+ SSHPublicKeyValidator sshPublicKeyValidator = new SSHPublicKeyValidator(publicKeyObservable, pageModel);
dbc.addValidationStatusProvider(sshPublicKeyValidator);
ControlDecorationSupport.create(
sshPublicKeyValidator, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater());
@@ -120,7 +119,7 @@
.setText("Please make sure that your private key for this public key is listed in the\n<a>SSH2 Preferences</a>");
GridDataFactory.fillDefaults()
.align(SWT.FILL, SWT.CENTER).applyTo(sshPrefsLink);
- sshPrefsLink.addSelectionListener(onSshPrefs(dbc));
+ sshPrefsLink.addSelectionListener(onSshPrefs(sshPublicKeyValidator));
}
@@ -131,8 +130,8 @@
public void widgetSelected(SelectionEvent e) {
FileDialog dialog = new FileDialog(getShell(), SWT.OPEN);
dialog.setFilterPath(SSHUtils.getSSH2Home());
- dialog.setFilterExtensions(new String[] {FILTEREXPRESSION_PUBLIC_SSH_KEY });
- dialog.setFilterNames(new String[]{FILTERNAME_PUBLIC_SSH_KEY});
+ dialog.setFilterExtensions(new String[] { FILTEREXPRESSION_PUBLIC_SSH_KEY });
+ dialog.setFilterNames(new String[] { FILTERNAME_PUBLIC_SSH_KEY });
String filePath = null;
if ((filePath = dialog.open()) != null) {
pageModel.setPublicKeyPath(filePath);
@@ -141,14 +140,17 @@
};
}
- private SelectionAdapter onSshPrefs(final DataBindingContext dbc) {
+ private SelectionAdapter onSshPrefs(final SSHPublicKeyValidator sshPublicKeyValidator) {
return new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
SSHUtils.openPreferencesPage(getShell());
// trigger revalidation after prefs were changed
- dbc.updateTargets();
+ // we should be able to listen to prefs changes in jsch, but
+ // obviously they dont fire change event when changing private
+ // keys
+ sshPublicKeyValidator.forceRevalidate();
}
};
}
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/databinding/SSHPublicKeyValidator.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/databinding/SSHPublicKeyValidator.java 2012-09-26 13:35:29 UTC (rev 44036)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/databinding/SSHPublicKeyValidator.java 2012-09-26 13:46:18 UTC (rev 44037)
@@ -49,7 +49,8 @@
try {
SSHPublicKey sshPublicKey = new SSHPublicKey(filePath);
if (model.hasPublicKey(sshPublicKey.getPublicKey())) {
- return ValidationStatus.error("The public key in " + filePath + " is already in use on OpenShift. Choose another key.");
+ return ValidationStatus.error("The public key in " + filePath
+ + " is already in use on OpenShift. Choose another key.");
}
} catch (FileNotFoundException e) {
return ValidationStatus.error("Could not load file: " + e.getMessage());
@@ -62,14 +63,14 @@
if (hasSSHConfigurationIdentityKey()) {
return ValidationStatus.warning(
NLS.bind("Your SSH config ({0}) contains fixed keys for OpenShift servers. " +
- "This can override any Eclipse specific SSH key preferences.", new SSHUserConfig(SSHUtils.getSSH2Home()).getFile()));
+ "This can override any Eclipse specific SSH key preferences.",
+ new SSHUserConfig(SSHUtils.getSSH2Home()).getFile()));
} else if (!SSHUtils.publicKeyMatchesPrivateKeyInPreferences(new File(filePath))) {
return ValidationStatus.warning(
NLS.bind("Could not find the private key for your public key in the preferences. "
+ "Make sure it is listed in the ssh2 preferences.", filePath));
}
-
-
+
return ValidationStatus.ok();
}
@@ -82,4 +83,12 @@
}
}
+ /**
+ * Workaround since JSchUIPlugin seems not to fire property change events if
+ * you change the private keys. Need to force revalidation manually.
+ */
+ public void forceRevalidate() {
+ revalidate();
+ }
+
}
More information about the jbosstools-commits
mailing list