Author: adietish
Date: 2011-10-19 05:18:50 -0400 (Wed, 19 Oct 2011)
New Revision: 35794
Modified:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AbstractOpenShiftWizardPage.java
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPage.java
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPageModel.java
Log:
[JBIDE-9928] implemented validating credentials on hitting "Next >"
Modified:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AbstractOpenShiftWizardPage.java
===================================================================
---
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AbstractOpenShiftWizardPage.java 2011-10-19
08:08:26 UTC (rev 35793)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AbstractOpenShiftWizardPage.java 2011-10-19
09:18:50 UTC (rev 35794)
@@ -13,7 +13,9 @@
import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.dialogs.IPageChangedListener;
+import org.eclipse.jface.dialogs.IPageChangingListener;
import org.eclipse.jface.dialogs.PageChangedEvent;
+import org.eclipse.jface.dialogs.PageChangingEvent;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.jface.wizard.IWizard;
@@ -73,6 +75,17 @@
}
}
});
+ ((WizardDialog) getContainer()).addPageChangingListener(new IPageChangingListener() {
+
+ @Override
+ public void handlePageChanging(PageChangingEvent event) {
+ if (event.getTargetPage() == AbstractOpenShiftWizardPage.this) {
+ onPageWillGetActivated(event, dbc);
+ } else {
+ onPageWillGetDeactivated(event, dbc);
+ }
+ }
+ });
}
}
@@ -86,6 +99,11 @@
protected void onPageDeactivated(DataBindingContext dbc) {
}
+ protected void onPageWillGetActivated(PageChangingEvent event, DataBindingContext dbc)
{
+ }
+
+ protected void onPageWillGetDeactivated(PageChangingEvent event, DataBindingContext dbc)
{
+ }
protected abstract void doCreateControls(Composite parent, DataBindingContext dbc);
Modified:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPage.java
===================================================================
---
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPage.java 2011-10-19
08:08:26 UTC (rev 35793)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPage.java 2011-10-19
09:18:50 UTC (rev 35794)
@@ -10,6 +10,9 @@
******************************************************************************/
package org.jboss.tools.openshift.express.internal.ui.wizard;
+import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.TimeUnit;
+
import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.databinding.UpdateValueStrategy;
import org.eclipse.core.databinding.beans.BeanProperties;
@@ -20,6 +23,7 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.dialogs.PageChangingEvent;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.jface.wizard.IWizard;
@@ -34,6 +38,7 @@
import org.jboss.tools.common.ui.BrowserUtil;
import org.jboss.tools.common.ui.WizardUtils;
import org.jboss.tools.common.ui.databinding.DataBindingUtils;
+import org.jboss.tools.common.ui.databinding.ParametrizableWizardPageSupport;
import org.jboss.tools.openshift.express.internal.ui.OpenShiftUIActivator;
/**
@@ -61,25 +66,6 @@
GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).span(3, 1).hint(SWT.DEFAULT,
30).applyTo(signupLink);
signupLink.addSelectionListener(onSignupLinkClicked());
- // Label serverUrlLabel = new Label(container, SWT.NONE);
- // serverUrlLabel.setText("Server URL");
- // GridDataFactory.fillDefaults().align(SWT.LEFT,
- // SWT.CENTER).applyTo(serverUrlLabel);
- // Text serverUrlText = new Text(container, SWT.BORDER);
- // GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true,
- // false).span(2, 1).applyTo(serverUrlText);
- // dbc.bindValue(
- // WidgetProperties.text(SWT.Modify).observe(serverUrlText),
- // BeanProperties.value(
- // ImportProjectWizardModel.class,
- // ImportProjectWizardModel.PROPERTY_SERVER_URL).observe(model),
- // new UpdateValueStrategy()
- // .setAfterGetValidator(new
- // MandatoryStringValidator("You have to provide a value for the server
url."))
- // .setBeforeSetValidator(new SimpleUrlStringValidator())
- // .setConverter(new TrimTrailingSlashConverter()),
- // null);
-
Label rhLoginLabel = new Label(container, SWT.NONE);
rhLoginLabel.setText("&Username");
GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(rhLoginLabel);
@@ -105,10 +91,11 @@
this.validateButton = new Button(container, SWT.NONE);
validateButton.setText("&Validate");
- GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).span(2, 1).indent(0,
10).hint(100, SWT.DEFAULT).applyTo(validateButton);
+ GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).span(2, 1).indent(0,
10).hint(100, SWT.DEFAULT)
+ .applyTo(validateButton);
DataBindingUtils.bindEnablementToValidationStatus(
validateButton
- , IStatus.INFO
+ , IStatus.INFO
, dbc);
validateButton.addSelectionListener(onValidate(dbc));
dbc.bindValue(
@@ -128,7 +115,7 @@
public void widgetSelected(SelectionEvent e) {
try {
WizardUtils.runInWizard(
- new Job("Testing user credentials") {
+ new Job("Testing user credentials...") {
@Override
protected IStatus run(IProgressMonitor monitor) {
@@ -154,7 +141,14 @@
}
};
}
-
+
+ @Override
+ protected void setupWizardPageSupport(DataBindingContext dbc) {
+ ParametrizableWizardPageSupport.create(
+ IStatus.ERROR | IStatus.CANCEL, this,
+ dbc);
+ }
+
private static class CredentialsStatusValidator implements IValidator {
public IStatus validate(Object value) {
if (value instanceof IStatus) {
@@ -169,4 +163,27 @@
}
}
+ @Override
+ protected void onPageWillGetDeactivated(PageChangingEvent event, DataBindingContext dbc)
{
+ if (!model.areCredentialsValidated()) {
+ try {
+ final ArrayBlockingQueue<IStatus> queue = new
ArrayBlockingQueue<IStatus>(1);
+ WizardUtils.runInWizard(
+ new Job("Testing user credentials...") {
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ IStatus status = model.validateCredentials();
+ queue.offer(status);
+ return Status.OK_STATUS;
+ }
+ }, getContainer(), getDatabindingContext());
+ queue.poll(10, TimeUnit.SECONDS);
+ event.doit = model.areCredentialsValid();
+ } catch (Exception ex) {
+ // ignore
+ }
+ }
+
+ }
}
Modified:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPageModel.java
===================================================================
---
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPageModel.java 2011-10-19
08:08:26 UTC (rev 35793)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPageModel.java 2011-10-19
09:18:50 UTC (rev 35794)
@@ -119,6 +119,12 @@
public IStatus getCredentialsValidity() {
return credentialsValidity;
}
+
+ public boolean areCredentialsValid() {
+ IStatus validationStatus = getCredentialsValidity();
+ return validationStatus != null
+ && validationStatus.isOK();
+ }
public boolean areCredentialsValidated() {
return credentialsValidity != null;