Author: adietish
Date: 2011-10-19 09:31:52 -0400 (Wed, 19 Oct 2011)
New Revision: 35803
Modified:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPage.java
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPageModel.java
Log:
[JBIDE-9943] disabling git-uri and host widgets + "Finish" while loading
Modified:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPage.java
===================================================================
---
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPage.java 2011-10-19
12:39:25 UTC (rev 35802)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPage.java 2011-10-19
13:31:52 UTC (rev 35803)
@@ -18,7 +18,11 @@
import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.databinding.UpdateValueStrategy;
import org.eclipse.core.databinding.beans.BeanProperties;
+import org.eclipse.core.databinding.conversion.Converter;
import org.eclipse.core.databinding.observable.value.IObservableValue;
+import org.eclipse.core.databinding.observable.value.WritableValue;
+import org.eclipse.core.databinding.validation.IValidator;
+import org.eclipse.core.databinding.validation.ValidationStatus;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
@@ -42,7 +46,6 @@
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.DirectoryDialog;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Link;
@@ -63,14 +66,13 @@
import org.jboss.tools.common.ui.databinding.DataBindingUtils;
import org.jboss.tools.common.ui.databinding.InvertingBooleanConverter;
import org.jboss.tools.common.ui.ssh.SshPrivateKeysPreferences;
-import org.jboss.tools.openshift.express.client.IApplication;
import org.jboss.tools.openshift.express.client.ICartridge;
import org.jboss.tools.openshift.express.client.OpenShiftException;
import org.jboss.tools.openshift.express.internal.ui.OpenShiftUIActivator;
public class AdapterWizardPage extends AbstractOpenShiftWizardPage implements
IWizardPage, PropertyChangeListener {
private Text gitUriValueText;
-
+
private AdapterWizardPageModel model;
private Combo suitableRuntimes;
private IServerType serverTypeToCreate;
@@ -118,18 +120,41 @@
gitUriValueText = new Text(cloneGroup, SWT.BORDER);
gitUriValueText.setEditable(false);
-// gitUriValueText.setBackground(cloneGroup.getBackground());
- GridDataFactory.fillDefaults().span(3, 1).align(SWT.FILL, SWT.CENTER).grab(true,
false).applyTo(gitUriValueText);
+ // gitUriValueText.setBackground(cloneGroup.getBackground());
+ GridDataFactory.fillDefaults().span(3, 1).align(SWT.FILL, SWT.CENTER).grab(true,
false)
+ .applyTo(gitUriValueText);
dbc.bindValue(
WidgetProperties.text(SWT.Modify).observe(gitUriValueText)
, BeanProperties.value(AdapterWizardPageModel.PROPERTY_GIT_URI).observe(model)
, new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER)
, null);
-
+ dbc.bindValue(
+ WidgetProperties.enabled().observe(gitUriValueText)
+ , BeanProperties.value(AdapterWizardPageModel.PROPERTY_LOADING).observe(model)
+ , new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER)
+ , new UpdateValueStrategy().setConverter(new InvertingBooleanConverter()));
+
+ // bind loading state to page complete
+ dbc.bindValue(
+ new WritableValue(false, Boolean.class)
+ , BeanProperties.value(AdapterWizardPageModel.PROPERTY_LOADING).observe(model)
+ , new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER)
+ , new UpdateValueStrategy().setAfterGetValidator(new IValidator() {
+
+ @Override
+ public IStatus validate(Object value) {
+ if (Boolean.FALSE.equals(value)) {
+ return ValidationStatus.ok();
+ } else {
+ return ValidationStatus.cancel("Loading...");
+ }
+ }
+ }));
+
Label repoPathLabel = new Label(cloneGroup, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(repoPathLabel);
repoPathLabel.setText("Destination");
-
+
Button defaultRepoPathButton = new Button(cloneGroup, SWT.CHECK);
defaultRepoPathButton.setText("default");
GridDataFactory.fillDefaults()
@@ -257,7 +282,7 @@
suitableRuntimes.setEnabled(enabled);
runtimeLabel.setEnabled(enabled);
addRuntimeLink.setEnabled(enabled);
- domainLabel.setEnabled(enabled);
+ // domainLabel.setEnabled(enabled);
modeLabel.setEnabled(enabled);
}
@@ -286,6 +311,23 @@
addRuntimeLink.setText("<a>" + Messages.addRuntime +
"</a>");
domainLabel = new Label(c, SWT.NONE);
+ DataBindingContext dbc = getDatabindingContext();
+ dbc.bindValue(
+ WidgetProperties.text().observe(domainLabel)
+ ,
BeanProperties.value(AdapterWizardPageModel.PROPERTY_APPLICATION_URL).observe(model)
+ , new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER)
+ , new UpdateValueStrategy().setConverter(new Converter(String.class, String.class) {
+
+ @Override
+ public Object convert(Object fromObject) {
+ String host = "";
+ if (fromObject instanceof String && ((String) fromObject).length() > 0)
{
+ host = (String) fromObject;
+ }
+ return "Host: " + host;
+ }
+
+ }));
// appLabel = new Label(c, SWT.NONE);
modeLabel = new Label(c, SWT.NONE);
@@ -360,8 +402,6 @@
}
protected void onPageActivated(DataBindingContext dbc) {
- gitUriValueText.setEnabled(false);
- gitUriValueText.setText("Loading...");
model.resetRepositoryPath();
serverTypeToCreate = getServerTypeToCreate();
@@ -375,34 +415,20 @@
addRuntimeLink.setEnabled(type != null);
modeLabel.setText("Mode: Source");
model.getParentModel().setProperty(AdapterWizardPageModel.MODE,
AdapterWizardPageModel.MODE_SOURCE);
-
+
setPageComplete(false);
getWizard().getContainer().updateButtons();
onPageActivatedBackground(dbc);
}
-
- protected void onPageActivatedBackground2(DataBindingContext dbc) throws
OpenShiftException {
- model.updateGitUri();
- gitUriValueText.setEnabled(true);
- domainLabel.setText("Host: " +
model.getParentModel().getApplication().getApplicationUrl());
- setPageComplete(true);
- getWizard().getContainer().updateButtons();
- }
-
+
protected void onPageActivatedBackground(final DataBindingContext dbc) {
new Job("Loading remote OpenShift application") {
public IStatus run(IProgressMonitor monitor) {
- final IApplication application = model.getParentModel().getApplication();
- if (application != null) {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- try {
- onPageActivatedBackground2(dbc);
- } catch( OpenShiftException e) {
- OpenShiftUIActivator.log(OpenShiftUIActivator.createErrorStatus(e.getMessage(),
e));
- }
- }
- });
+ try {
+ model.loadGitUri();
+ model.loadApplicationUrl();
+ } catch (OpenShiftException e) {
+ OpenShiftUIActivator.log(OpenShiftUIActivator.createErrorStatus(e.getMessage(),
e));
}
return Status.OK_STATUS;
}
Modified:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPageModel.java
===================================================================
---
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPageModel.java 2011-10-19
12:39:25 UTC (rev 35802)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPageModel.java 2011-10-19
13:31:52 UTC (rev 35803)
@@ -25,8 +25,10 @@
private static final String REMOTE_NAME_DEFAULT = "origin";
public static final String PROPERTY_GIT_URI = "gitUri";
+ public static final String PROPERTY_APPLICATION_URL = "applicationUrl";
public static final String PROPERTY_REPO_PATH = "repositoryPath";
public static final String PROPERTY_REMOTE_NAME = "remoteName";
+ public static final String PROPERTY_LOADING = "loading";
public static final String CREATE_SERVER = "createServer";
public static final String MODE = "serverMode";
@@ -36,28 +38,53 @@
public static final String SERVER_TYPE = "serverType";
private ImportProjectWizardModel wizardModel;
- private String gitUri;
+// private String gitUri;
+// private String applicationUrl;
+ private boolean loading;
public AdapterWizardPageModel(ImportProjectWizardModel wizardModel) {
this.wizardModel = wizardModel;
setRemoteName(REMOTE_NAME_DEFAULT);
}
- public void updateGitUri() throws OpenShiftException {
+ public void loadGitUri() throws OpenShiftException {
+ setLoading(true);
+ setGitUri(null);
+ setGitUri(getGitUri());
+ setLoading(false);
+ }
+
+ private void setGitUri(String gitUri) {
+ firePropertyChange(PROPERTY_GIT_URI, null, gitUri);
+ }
+
+ public String getGitUri() throws OpenShiftException {
IApplication application = wizardModel.getApplication();
- if (application != null) {
- setGitUri(application.getGitUri());
+ if (application == null) {
+ return null;
}
+ return application.getGitUri();
}
- public void setGitUri(String gitUri) {
- firePropertyChange(PROPERTY_GIT_URI, this.gitUri, this.gitUri = gitUri);
+ public void loadApplicationUrl() throws OpenShiftException {
+ setLoading(true);
+ setApplicationUrl(null);
+ setApplicationUrl(getApplicationUrl());
+ setLoading(false);
}
- public String getGitUri() {
- return this.gitUri;
+ public String getApplicationUrl() throws OpenShiftException {
+ IApplication application = wizardModel.getApplication();
+ if (application == null) {
+ return null;
+ }
+ return application.getApplicationUrl();
}
+ public void setApplicationUrl(String applicationUrl) {
+ firePropertyChange(PROPERTY_APPLICATION_URL, null, applicationUrl);
+ }
+
public String getRepositoryPath() {
return wizardModel.getRepositoryPath();
}
@@ -98,4 +125,13 @@
public ImportProjectWizardModel getParentModel() {
return wizardModel;
}
+
+ public boolean isLoading() {
+ return loading;
+ }
+
+ public void setLoading(boolean loading) {
+ firePropertyChange(PROPERTY_LOADING, this.loading, this.loading = loading);
+ }
+
}