[jbosstools-commits] JBoss Tools SVN: r43876 - in trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui: wizard and 1 other directories.
jbosstools-commits at lists.jboss.org
jbosstools-commits at lists.jboss.org
Thu Sep 20 13:52:21 EDT 2012
Author: adietish
Date: 2012-09-20 13:52:21 -0400 (Thu, 20 Sep 2012)
New Revision: 43876
Added:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/job/LoadKeysJob.java
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/job/VerifySSHSessionJob.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/GitCloningSettingsWizardPage.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/GitCloningSettingsWizardPageModel.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPage.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/ManageSSHKeysWizardPage.java
Log:
[JBIDE-11912] add link to "ssh2 keys management" in "git clonging settings" wizard page. Added validation in "git cloning settings" wizard page that would error if user has no keys on OpenShift
Added: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/job/LoadKeysJob.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/job/LoadKeysJob.java (rev 0)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/job/LoadKeysJob.java 2012-09-20 17:52:21 UTC (rev 43876)
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.openshift.express.internal.ui.job;
+
+import java.util.List;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.jboss.tools.openshift.express.internal.core.console.UserDelegate;
+
+import com.openshift.client.IOpenShiftSSHKey;
+
+/**
+ * @author Andre Dietisheim
+ */
+public class LoadKeysJob extends Job {
+
+ private UserDelegate user;
+ private List<IOpenShiftSSHKey> keys;
+
+ public LoadKeysJob(UserDelegate user) {
+ super("Loading SSH keys... ");
+ this.user = user;
+ }
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ this.keys = user.getSSHKeys();
+ return Status.OK_STATUS;
+ }
+
+ public List<IOpenShiftSSHKey> getKeys() {
+ return keys;
+ }
+}
Property changes on: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/job/LoadKeysJob.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/job/VerifySSHSessionJob.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/job/VerifySSHSessionJob.java 2012-09-20 17:20:08 UTC (rev 43875)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/job/VerifySSHSessionJob.java 2012-09-20 17:52:21 UTC (rev 43876)
@@ -14,12 +14,10 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.osgi.util.NLS;
import org.jboss.tools.openshift.express.internal.ui.OpenShiftUIActivator;
import org.jboss.tools.openshift.express.internal.ui.utils.Logger;
import org.jboss.tools.openshift.express.internal.ui.utils.OpenShiftSshSessionFactory;
-import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.Session;
import com.openshift.client.IApplication;
import com.openshift.client.OpenShiftSSHOperationException;
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/GitCloningSettingsWizardPage.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/GitCloningSettingsWizardPage.java 2012-09-20 17:20:08 UTC (rev 43875)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/GitCloningSettingsWizardPage.java 2012-09-20 17:52:21 UTC (rev 43876)
@@ -11,22 +11,27 @@
package org.jboss.tools.openshift.express.internal.ui.wizard;
import org.eclipse.core.databinding.DataBindingContext;
+import org.eclipse.core.databinding.UpdateValueStrategy;
import org.eclipse.core.databinding.beans.BeanProperties;
import org.eclipse.core.databinding.observable.value.IObservableValue;
+import org.eclipse.core.databinding.validation.IValidator;
import org.eclipse.core.databinding.validation.MultiValidator;
import org.eclipse.core.databinding.validation.ValidationStatus;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.databinding.fieldassist.ControlDecorationSupport;
import org.eclipse.jface.databinding.swt.WidgetProperties;
+import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.PageChangingEvent;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
@@ -41,13 +46,19 @@
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.progress.UIJob;
+import org.eclipse.ui.statushandlers.StatusManager;
+import org.jboss.tools.common.ui.WizardUtils;
import org.jboss.tools.common.ui.databinding.InvertingBooleanConverter;
import org.jboss.tools.common.ui.databinding.ValueBindingBuilder;
import org.jboss.tools.common.ui.ssh.SshPrivateKeysPreferences;
import org.jboss.tools.openshift.egit.core.EGitUtils;
import org.jboss.tools.openshift.express.internal.ui.OpenShiftUIActivator;
+import org.jboss.tools.openshift.express.internal.ui.job.LoadKeysJob;
+import org.jboss.tools.openshift.express.internal.ui.utils.JobChainBuilder;
import org.jboss.tools.openshift.express.internal.ui.utils.StringUtils;
import org.jboss.tools.openshift.express.internal.ui.utils.UIUtils;
+import org.jboss.tools.openshift.express.internal.ui.wizard.ssh.ManageSSHKeysWizard;
/**
* @author Andre Dietisheim
@@ -65,7 +76,8 @@
private Label remoteNameLabel;
private RepoPathValidationStatusProvider repoPathValidator;
- public GitCloningSettingsWizardPage(OpenShiftExpressApplicationWizard wizard, IOpenShiftExpressWizardModel wizardModel) {
+ public GitCloningSettingsWizardPage(OpenShiftExpressApplicationWizard wizard,
+ IOpenShiftExpressWizardModel wizardModel) {
super(
"Import an existing OpenShift application",
"Configure the cloning settings by specifying the clone destination if you create a new project, and the git remote name if you're using an existing project.",
@@ -130,8 +142,9 @@
GitCloningSettingsWizardPageModel.PROPERTY_APPLICATION_NAME).observe(pageModel);
final IObservableValue newProjectModelObservable = BeanProperties.value(
GitCloningSettingsWizardPageModel.PROPERTY_NEW_PROJECT).observe(pageModel);
- this.repoPathValidator =
- new RepoPathValidationStatusProvider(repoPathObservable, applicationNameModelObservable, newProjectModelObservable);
+ this.repoPathValidator =
+ new RepoPathValidationStatusProvider(repoPathObservable, applicationNameModelObservable,
+ newProjectModelObservable);
dbc.addValidationStatusProvider(repoPathValidator);
ControlDecorationSupport.create(repoPathValidator, SWT.LEFT | SWT.TOP);
@@ -178,11 +191,43 @@
new RemoteNameValidationStatusProvider(remoteNameTextObservable, projectNameModelObservable));
Link sshPrefsLink = new Link(parent, SWT.NONE);
- sshPrefsLink.setText("Make sure your SSH key used with your user " + wizardModel.getUser().getUsername() + "\nis listed in <a>SSH2 Preferences</a>.");
- GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).indent(10, 0)
- .applyTo(sshPrefsLink);
+ sshPrefsLink.setText("Make sure your SSH key used with your user " + wizardModel.getUser().getUsername()
+ + "\nis listed in <a>SSH2 Preferences</a>.");
+ GridDataFactory.fillDefaults()
+ .align(SWT.FILL, SWT.CENTER).grab(true, false).indent(10, 0).applyTo(sshPrefsLink);
sshPrefsLink.addSelectionListener(onSshPrefs());
+ Link sshManagementLink = new Link(parent, SWT.NONE);
+ sshManagementLink.setText(
+ "Please make sure that you have SSH keys added to your OpenShift account.\n" +
+ "You may check them in the <a>SSH2 keys wizard</a>");
+ GridDataFactory.fillDefaults()
+ .align(SWT.FILL, SWT.CENTER).grab(true, false).indent(10,0).applyTo(sshManagementLink);
+ sshManagementLink.addSelectionListener(onManageSSHKeys());
+
+ ValueBindingBuilder
+ .bind(WidgetProperties.text().observe(sshManagementLink))
+ .notUpdating(BeanProperties.value(
+ GitCloningSettingsWizardPageModel.PROPERTY_HAS_REMOTEKEYS).observe(pageModel))
+ .withStrategy(new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT))
+ .validatingAfterGet(new IValidator() {
+
+ @Override
+ public IStatus validate(Object value) {
+ if (!(value instanceof Boolean)) {
+ return ValidationStatus.ok();
+ }
+ Boolean hasRemoteKeys = (Boolean) value;
+ if (hasRemoteKeys) {
+ return ValidationStatus.ok();
+ } else {
+ return ValidationStatus
+ .error("You have not added any SSH public keys to OpenShift yet. Please use the SSH2 keys wizard.");
+ }
+ }
+ })
+ .in(dbc);
+ refreshHasRemoteKeys();
return cloneGroup;
}
@@ -203,7 +248,7 @@
DirectoryDialog dialog = new DirectoryDialog(getShell());
dialog.setText("Git clone location");
dialog.setMessage("Choose the location for git clone...");
- dialog.setFilterPath(pageModel.getRepositoryPath());
+ dialog.setFilterPath(pageModel.getRepositoryPath());
String repositoryPath = dialog.open();
if (repositoryPath != null) {
pageModel.setRepositoryPath(repositoryPath);
@@ -225,8 +270,27 @@
protected void onPageActivated(DataBindingContext dbc) {
enableWidgets(pageModel.isNewProject());
repoPathValidator.forceRevalidate();
+ refreshHasRemoteKeys();
}
+ private void refreshHasRemoteKeys() {
+ try {
+ final LoadKeysJob loadKeysJob = new LoadKeysJob(wizardModel.getUser());
+ new JobChainBuilder(loadKeysJob).andRunWhenDone(new UIJob("") {
+
+ @Override
+ public IStatus runInUIThread(IProgressMonitor monitor) {
+ pageModel.setHasRemoteKeys(loadKeysJob.getKeys().size() > 0);
+ return Status.OK_STATUS;
+ }
+ });
+ WizardUtils.runInWizard(loadKeysJob, getContainer());
+ } catch (Exception e) {
+ StatusManager.getManager().handle(
+ OpenShiftUIActivator.createErrorStatus("Could not load ssh keys.", e), StatusManager.LOG);
+ }
+ }
+
@Override
protected void onPageWillGetActivated(Direction direction, PageChangingEvent event, DataBindingContext dbc) {
if (direction == Direction.FORWARDS) {
@@ -234,7 +298,7 @@
dbc.updateTargets();
}
}
-
+
private void enableWidgets(boolean isNewProject) {
if (isNewProject) {
useDefaultRepoPathButton.setEnabled(true);
@@ -296,7 +360,7 @@
public void forceRevalidate() {
revalidate();
}
-
+
}
/**
@@ -308,7 +372,8 @@
private final IObservableValue remoteNameObservable;
private final IObservableValue projectNameObservable;
- public RemoteNameValidationStatusProvider(final IObservableValue remoteNameTextObservable, final IObservableValue projectNameObservable) {
+ public RemoteNameValidationStatusProvider(final IObservableValue remoteNameTextObservable,
+ final IObservableValue projectNameObservable) {
this.remoteNameObservable = remoteNameTextObservable;
this.projectNameObservable = projectNameObservable;
}
@@ -341,7 +406,7 @@
}
return ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
}
-
+
private boolean hasRemoteName(String remoteName, IProject project) {
try {
if (project == null
@@ -361,4 +426,18 @@
}
}
+ private SelectionAdapter onManageSSHKeys() {
+ return new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ WizardDialog manageSSHKeysWizard =
+ new OkButtonWizardDialog(getShell(), new ManageSSHKeysWizard(wizardModel.getUser()));
+ if (manageSSHKeysWizard.open() == Dialog.OK) {
+ refreshHasRemoteKeys();
+ }
+ }
+ };
+ }
+
}
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/GitCloningSettingsWizardPageModel.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/GitCloningSettingsWizardPageModel.java 2012-09-20 17:20:08 UTC (rev 43875)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/GitCloningSettingsWizardPageModel.java 2012-09-20 17:52:21 UTC (rev 43876)
@@ -36,10 +36,12 @@
public static final String PROPERTY_REMOTE_NAME = "remoteName";
public static final String PROPERTY_USE_DEFAULT_REPO_PATH = "useDefaultRepoPath";
public static final String PROPERTY_USE_DEFAULT_REMOTE_NAME = "useDefaultRemoteName";
+ public static final String PROPERTY_HAS_REMOTEKEYS = "hasRemoteKeys";
private IOpenShiftExpressWizardModel wizardModel;
private boolean useDefaultRepoPath = true;
private boolean useDefaultRemoteName = true;
+ private boolean hasRemoteKeys;
public GitCloningSettingsWizardPageModel(IOpenShiftExpressWizardModel wizardModel) {
this.wizardModel = wizardModel;
@@ -174,6 +176,14 @@
return useDefaultRemoteName;
}
+ public boolean getHasRemoteKeys() {
+ return hasRemoteKeys;
+ }
+
+ public void setHasRemoteKeys(boolean hasRemoteKeys) {
+ firePropertyChange(PROPERTY_HAS_REMOTEKEYS, this.hasRemoteKeys, this.hasRemoteKeys = hasRemoteKeys);
+ }
+
public void reset() {
setRemoteName(wizardModel.getRemoteName());
setRepositoryPath(wizardModel.getRepositoryPath());
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPage.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPage.java 2012-09-20 17:20:08 UTC (rev 43875)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPage.java 2012-09-20 17:52:21 UTC (rev 43876)
@@ -70,13 +70,13 @@
ValueBindingBuilder.bind(namespaceTextObservable).to(namespaceModelObservable).in(dbc);
new Label(container, SWT.NONE); // spacer
- Link sshPrefsLink = new Link(container, SWT.NONE);
- sshPrefsLink.setText(
+ Link sshManagementLink = new Link(container, SWT.NONE);
+ sshManagementLink.setText(
"Please make sure that you have SSH keys added to your OpenShift account.\n" +
"You may check them in the <a>SSH2 keys wizard</a>");
GridDataFactory.fillDefaults()
- .span(3, 1).align(SWT.FILL, SWT.CENTER).applyTo(sshPrefsLink);
- sshPrefsLink.addSelectionListener(onManageSSHKeys());
+ .span(3, 1).align(SWT.FILL, SWT.CENTER).applyTo(sshManagementLink);
+ sshManagementLink.addSelectionListener(onManageSSHKeys());
}
private SelectionAdapter onManageSSHKeys() {
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/ManageSSHKeysWizardPage.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/ManageSSHKeysWizardPage.java 2012-09-20 17:20:08 UTC (rev 43875)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/ManageSSHKeysWizardPage.java 2012-09-20 17:52:21 UTC (rev 43876)
@@ -43,6 +43,7 @@
import org.jboss.tools.common.ui.databinding.ValueBindingBuilder;
import org.jboss.tools.openshift.express.internal.core.console.UserDelegate;
import org.jboss.tools.openshift.express.internal.ui.OpenShiftUIActivator;
+import org.jboss.tools.openshift.express.internal.ui.job.LoadKeysJob;
import org.jboss.tools.openshift.express.internal.ui.utils.JobChainBuilder;
import org.jboss.tools.openshift.express.internal.ui.utils.SSHUtils;
import org.jboss.tools.openshift.express.internal.ui.utils.StringUtils;
@@ -243,7 +244,7 @@
@Override
protected void onPageActivated(DataBindingContext dbc) {
try {
- Job loadKeysJob = new LoadKeysJob();
+ Job loadKeysJob = new LoadKeysJob(pageModel.getUser());
new JobChainBuilder(loadKeysJob).andRunWhenDone(new RefreshViewerJob());
WizardUtils.runInWizard(loadKeysJob, getContainer());
} catch (Exception e) {
@@ -306,19 +307,6 @@
}
}
- private class LoadKeysJob extends Job {
-
- private LoadKeysJob() {
- super("Loading SSH keys... ");
- }
-
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- pageModel.loadSSHKeys();
- return Status.OK_STATUS;
- }
- }
-
private class RefreshViewerJob extends UIJob {
public RefreshViewerJob() {
More information about the jbosstools-commits
mailing list