Author: jjohnstn
Date: 2010-08-03 11:56:20 -0400 (Tue, 03 Aug 2010)
New Revision: 23879
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewCloudConnectionPage.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/WizardMessages.properties
Log:
2010-08-03 Jeff Johnston <jjohnstn(a)redhat.com>
* src/org/jboss/tools/internal/deltacloud/ui/wizards/NewCloudConnectionPage.java
(getURLValid): New
method.
(setURLValid): Ditto.
(checkURL): Ditto. Used to check URL is valid and to get the driver info.
(isPageComplete): Override to check URL in addition to normal page complete flag.
(.handleException): New method of ISafeRunnable to use to run checkURL in thread.
(.run): Ditto.
(createControl): Change how type label gets initially set.
(validate): Change to use checkURL method in safe thread when the URL at least
ends in "api". Otherwise, don't bother checking the URL and don't mark
the page
as complete.
* src/org/jboss/tools/internal/deltacloud/ui/wizards/WizardMessages.properties: Change
error message for URL as it now appears in the type label and not the error message
area.
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-08-03 15:42:49
UTC (rev 23878)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-08-03 15:56:20
UTC (rev 23879)
@@ -1,3 +1,20 @@
+2010-08-03 Jeff Johnston <jjohnstn(a)redhat.com>
+
+ * src/org/jboss/tools/internal/deltacloud/ui/wizards/NewCloudConnectionPage.java
(getURLValid): New
+ method.
+ (setURLValid): Ditto.
+ (checkURL): Ditto. Used to check URL is valid and to get the driver info.
+ (isPageComplete): Override to check URL in addition to normal page complete flag.
+ (.handleException): New method of ISafeRunnable to use to run checkURL in thread.
+ (.run): Ditto.
+ (createControl): Change how type label gets initially set.
+ (validate): Change to use checkURL method in safe thread when the URL at least
+ ends in "api". Otherwise, don't bother checking the URL and don't
mark the page
+ as complete.
+ * src/org/jboss/tools/internal/deltacloud/ui/wizards/WizardMessages.properties: Change
+ error message for URL as it now appears in the type label and not the error message
+ area.
+
2010-07-28 Jeff Johnston <jjohnstn(a)redhat.com>
* src/org/jboss/tools/internal/deltacloud/ui/wizards/NewCloudConnection.java: New file.
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewCloudConnectionPage.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewCloudConnectionPage.java 2010-08-03
15:42:49 UTC (rev 23878)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewCloudConnectionPage.java 2010-08-03
15:56:20 UTC (rev 23879)
@@ -12,6 +12,8 @@
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
+import org.eclipse.core.runtime.ISafeRunnable;
+import org.eclipse.core.runtime.SafeRunner;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
@@ -62,7 +64,10 @@
private String url;
private String username;
private String password;
+ private String cloudType;
+ private boolean urlValid;
+
private Listener linkListener = new Listener() {
public void handleEvent(Event event) {
@@ -119,6 +124,56 @@
} else {
complete = false;
}
+
+ // Run check for valid DeltaCloud URL in separate thread
+ String urlValue = urlText.getText();
+ if (urlValue.endsWith("api")) {
+ ISafeRunnable runner = new ISafeRunnable() {
+
+ @Override
+ public void handleException(Throwable exception) {
+ setURLValid(false);
+ }
+
+ @Override
+ public void run() throws Exception {
+ // TODO Auto-generated method stub
+ checkURL();
+ }
+ };
+ SafeRunner.run(runner);
+ } else if (urlValue.length() > 0){
+ typeText.setText(WizardMessages.getString(NONCLOUD_URL));
+ complete = false;
+ } else {
+ typeText.setText(WizardMessages.getString(UNKNOWN_TYPE_LABEL));
+ complete = false;
+ }
+
+ username = usernameText.getText();
+ if (username.length() <= 0) {
+ complete = false;
+ }
+ password = passwordText.getText();
+ if (password.length() <= 0) {
+ complete = false;
+ }
+ if (errorFree)
+ setErrorMessage(null);
+ setPageComplete(complete & errorFree);
+ }
+
+ @Override
+ public boolean isPageComplete() {
+ return super.isPageComplete() & getURLValid();
+ }
+
+
+ // Method to check the URL for validity as Delta-cloud API specifier.
+ // Since this is run in thread, it does not use the setErrorMessage()
+ // method and instead writes error messages to the typeText label.
+ private synchronized void checkURL() {
+ boolean valid = false;
String oldurl = url;
url = urlText.getText();
if (url.length() > 0) {
@@ -158,42 +213,47 @@
Node n = elements.item(0);
Node driver = n.getAttributes().getNamedItem("driver"); //$NON-NLS-1$
if (driver != null) {
+ valid = true;
String driverValue = driver.getNodeValue();
- typeText.setText(driverValue.toUpperCase());
+ cloudType = driverValue.toUpperCase();
+ } else {
+ cloudType = WizardMessages.getString(UNKNOWN_TYPE_LABEL);
}
}
}
} catch (MalformedURLException e) {
- errorFree = false;
- setErrorMessage(WizardMessages.getString(INVALID_URL));
+ cloudType = WizardMessages.getString(INVALID_URL);
} catch (IOException e) {
- // TODO Auto-generated catch block
- errorFree = false;
- setErrorMessage(WizardMessages.getString(NONCLOUD_URL));
+ cloudType = WizardMessages.getString(NONCLOUD_URL);
} catch (ParserConfigurationException e) {
- errorFree = false;
- setErrorMessage(WizardMessages.getString(NONCLOUD_URL));
+ cloudType = WizardMessages.getString(NONCLOUD_URL);
} catch (SAXException e) {
- errorFree = false;
- setErrorMessage(WizardMessages.getString(NONCLOUD_URL));
+ cloudType = WizardMessages.getString(NONCLOUD_URL);
}
+ setURLValid(valid);
}
- } else {
- complete = false;
+ typeText.setText(cloudType);
}
- username = usernameText.getText();
- if (username.length() <= 0) {
- complete = false;
- }
- password = passwordText.getText();
- if (password.length() <= 0) {
- complete = false;
- }
- if (errorFree)
- setErrorMessage(null);
- setPageComplete(complete & errorFree);
}
+ /**
+ * Set whether the URL is a valid Delta-cloud API URL.
+ *
+ * @param value boolean to set
+ */
+ private synchronized void setURLValid(boolean value) {
+ urlValid = value;
+ }
+
+ /**
+ * Return the validity of the Delta-cloud URL.
+ *
+ * @return true if URL valid, false otherwise
+ */
+ private synchronized boolean getURLValid() {
+ return urlValid;
+ }
+
@Override
public void createControl(Composite parent) {
// TODO Auto-generated method stub
@@ -221,7 +281,8 @@
typeLabel.setText(WizardMessages.getString(TYPE_LABEL));
typeText = new Label(container, SWT.NULL);
- typeText.setText(WizardMessages.getString(UNKNOWN_TYPE_LABEL));
+ cloudType = WizardMessages.getString(UNKNOWN_TYPE_LABEL);
+ typeText.setText(cloudType);
Label usernameLabel = new Label(container, SWT.NULL);
usernameLabel.setText(WizardMessages.getString(USERNAME_LABEL));
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/WizardMessages.properties
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/WizardMessages.properties 2010-08-03
15:42:49 UTC (rev 23878)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/WizardMessages.properties 2010-08-03
15:56:20 UTC (rev 23879)
@@ -15,4 +15,4 @@
ErrorNameInUse.text=Error: the name chosen is already in use
ErrorInvalidURL.text=Error: the URL specified is invalid
-ErrorNonCloudURL.text=Error: the URL specified is not a valid cloud address
\ No newline at end of file
+ErrorNonCloudURL.text=URL specified is not a valid Delta-cloud address
\ No newline at end of file
Show replies by date