Author: adietish
Date: 2010-10-07 05:47:08 -0400 (Thu, 07 Oct 2010)
New Revision: 25546
Added:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/.settings/net.sf.jautodoc.prefs
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudType.java
Removed:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/lib/deltacloudclient-1.0.jar
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/.classpath
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog
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/CloudConnectionPage.java
Log:
[JBIDE-7259] removed unneeded jar deltacloudclient from classpath, refactored
CloudConnectionPage
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/.classpath
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/.classpath 2010-10-07
07:57:07 UTC (rev 25545)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/.classpath 2010-10-07
09:47:08 UTC (rev 25546)
@@ -3,7 +3,6 @@
<classpathentry exported="true" kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry exported="true" kind="con"
path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
- <classpathentry exported="true" kind="lib"
path="lib/deltacloudclient-1.0.jar"
sourcepath="/home/cygnus/jjohnstn/deltacloud-tools/DeltaCloudClient/src"/>
<classpathentry exported="true" kind="lib"
path="lib/httpclient-4.0.1.jar"/>
<classpathentry exported="true" kind="lib"
path="lib/httpcore-4.0.1.jar"/>
<classpathentry exported="true" kind="lib"
path="lib/httpcore-nio-4.0.1.jar"/>
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog 2010-10-07 07:57:07
UTC (rev 25545)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog 2010-10-07 09:47:08
UTC (rev 25546)
@@ -1,3 +1,7 @@
+2010-10-07 André Dietisheim <adietish(a)redhat.com>
+
+ * lib/deltacloudclient-1.0.jar: [JBIDE-7259] removed unneeded jar from classpath
+
2010-10-06 Jeff Johnston <jjohnstn(a)redhat.com>
* src/org/jboss/tools/deltacloud/core/AllFieldMatcher.java: New file.
Deleted:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/lib/deltacloudclient-1.0.jar
===================================================================
(Binary files differ)
Added:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/.settings/net.sf.jautodoc.prefs
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/.settings/net.sf.jautodoc.prefs
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/.settings/net.sf.jautodoc.prefs 2010-10-07
09:47:08 UTC (rev 25546)
@@ -0,0 +1,6 @@
+#Thu Oct 07 09:55:38 CEST 2010
+add_header=true
+eclipse.preferences.version=1
+header_text=/*******************************************************************************\n
* Copyright (c) 2010 Red Hat, Inc.\n * Distributed under license by Red Hat, Inc. All
rights reserved.\n * This program is made available under the terms of the\n * Eclipse
Public License v1.0 which accompanies this distribution,\n * and is available at
http\://www.eclipse.org/legal/epl-v10.html\n *\n * Contributors\:\n * Red Hat, Inc. -
initial API and implementation\n
******************************************************************************/
+project_specific_settings=true
+replacements=<?xml version\="1.0"
standalone\="yes"?>\n\n<replacements>\n<replacement
key\="get" scope\="1" mode\="0">Gets
the</replacement>\n<replacement key\="set" scope\="1"
mode\="0">Sets the</replacement>\n<replacement key\="add"
scope\="1" mode\="0">Adds the</replacement>\n<replacement
key\="edit" scope\="1" mode\="0">Edits
the</replacement>\n<replacement key\="remove" scope\="1"
mode\="0">Removes the</replacement>\n<replacement
key\="init" scope\="1" mode\="0">Inits
the</replacement>\n<replacement key\="parse" scope\="1"
mode\="0">Parses the</replacement>\n<replacement
key\="create" scope\="1" mode\="0">Creates
the</replacement>\n<replacement key\="build" scope\="1"
mode\="0">Builds the</replacement>\n<replacement key\="is"
scope\="1" mode\="0">Checks if
is</replacement>\n<replacement key\="print" scope\="1"
mode\="0">Prints the</replacement>\n<replacement
key\="has" scope\="1" mode\="0">Checks
for</replacement>\n</replacements>\n\n
Property changes on:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/.settings/net.sf.jautodoc.prefs
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-10-07 07:57:07
UTC (rev 25545)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-10-07 09:47:08
UTC (rev 25546)
@@ -1,3 +1,8 @@
+2010-10-07 André Dietisheim <adietish(a)redhat.com>
+
+ * src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudConnectionPage.java:
+ [JBIDE-7259] Refactored CloudConnectionPage, created CloudType class.
+
2010-10-06 Jeff Johnston <jjohnstn(a)redhat.com>
* src/org/jboss/tools/internal/deltacloud/ui/wizards/ImageFilter.java: New file.
@@ -2,4 +7,3 @@
* src/org/jboss/tools/internal/deltacloud/ui/wizards/ImageFilterPage.java: New file.
- * src/org/jboss/tools/deltacloud/ui/views/CVImagesCategoryElement.java (listChanged):
- Apply filtering.
+ * src/org/jboss/tools/deltacloud/ui/views/CVImagesCategoryElement.java (listChanged):
Apply filtering.
(getChildren): Ditto.
@@ -20,7 +24,7 @@
Apply filtering.
(filter): New method.
* src/org/jboss/tools/internal/deltacloud/ui/wizards/WizardMessages.properties: Add new
messages.
-
+
2010-10-06 André Dietisheim <adietish(a)redhat.com>
* src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudConnectionPage.java
(checkURL): changed url and added accept headers
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudConnectionPage.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudConnectionPage.java 2010-10-07
07:57:07 UTC (rev 25545)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudConnectionPage.java 2010-10-07
09:47:08 UTC (rev 25546)
@@ -10,19 +10,8 @@
*******************************************************************************/
package org.jboss.tools.internal.deltacloud.ui.wizards;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.StringReader;
-import java.net.MalformedURLException;
import java.net.URL;
-import java.net.URLConnection;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
@@ -47,11 +36,6 @@
import org.jboss.tools.deltacloud.core.DeltaCloudManager;
import org.jboss.tools.deltacloud.ui.Activator;
import org.jboss.tools.deltacloud.ui.SWTImagesFactory;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
public class CloudConnectionPage extends WizardPage {
@@ -63,12 +47,9 @@
private static final String TYPE_LABEL = "Type.label"; //$NON-NLS-1$
private static final String PASSWORD_LABEL = "Password.label"; //$NON-NLS-1$
private static final String TESTBUTTON_LABEL = "TestButton.label";
//$NON-NLS-1$
- private static final String UNKNOWN_TYPE_LABEL = "UnknownType.label";
//$NON-NLS-1$
private static final String EC2_USER_INFO = "EC2UserNameLink.text";
//$NON-NLS-1$
private static final String EC2_PASSWORD_INFO = "EC2PasswordLink.text";
//$NON-NLS-1$
private static final String NAME_ALREADY_IN_USE = "ErrorNameInUse.text";
//$NON-NLS-1$
- private static final String INVALID_URL = "ErrorInvalidURL.text";
//$NON-NLS-1$
- private static final String NONCLOUD_URL = "ErrorNonCloudURL.text";
//$NON-NLS-1$
private static final String TEST_SUCCESSFUL =
"NewCloudConnectionTest.success"; //$NON-NLS-1$
private static final String TEST_FAILURE = "NewCloudConnectionTest.failure";
//$NON-NLS-1$
@@ -87,7 +68,7 @@
private String url;
private String username;
private String password;
- private String cloudType;
+ private String cloudTypeLabel;
private String defaultName = "";
private String defaultURL = "";
@@ -155,7 +136,7 @@
this.defaultURL = defaultURL;
this.defaultUsername = defaultUsername;
this.defaultPassword = defaultPassword;
- this.cloudType = defaultCloudType;
+ this.cloudTypeLabel = defaultCloudType;
setDescription(WizardMessages.getString(DESCRIPTION));
setTitle(WizardMessages.getString(TITLE));
setImageDescriptor(SWTImagesFactory.DESC_DELTA_LARGE);
@@ -214,10 +195,10 @@
CheckURLThread t = new CheckURLThread();
t.start();
} else if (urlValue.length() > 0){
- typeText.setText(WizardMessages.getString(NONCLOUD_URL));
+ typeText.setText(WizardMessages.getString(CloudType.NONCLOUD_URL));
complete = false;
} else {
- typeText.setText(WizardMessages.getString(UNKNOWN_TYPE_LABEL));
+ typeText.setText(WizardMessages.getString(CloudType.UNKNOWN_TYPE_LABEL));
complete = false;
}
@@ -243,97 +224,37 @@
// 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 boolean checkURL() {
- boolean valid = false;
+ private void checkURL() {
String oldurl = url;
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
- cloudType = typeText.getText();
+ cloudTypeLabel = typeText.getText();
url = urlText.getText();
}
});
- String oldCloudType = cloudType;
+ String oldCloudType = cloudTypeLabel;
if (url.length() > 0) {
if (!url.equals(oldurl)) {
- try {
- Object o = getURLContent(url + "/api?format=xml"); //$NON-NLS-1$
- if (o instanceof InputStream) {
- String xml = "";
- InputStream is = (InputStream)o;
- try
- {
- if (is != null)
- {
- StringBuilder sb = new StringBuilder();
- String line;
-
- BufferedReader reader = new BufferedReader(new InputStreamReader(is,
"UTF-8"));
- while ((line = reader.readLine()) != null)
- {
- sb.append(line).append("\n"); //$NON-NLS-1$
- }
- xml = sb.toString();
- }
- }
- finally
- {
- is.close();
- }
-
- DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
- DocumentBuilder db = dbf.newDocumentBuilder();
- Document document = db.parse(new InputSource(new StringReader(xml)));
-
- NodeList elements = document.getElementsByTagName("api"); //$NON-NLS-1$
- if (elements.getLength() > 0) {
- Node n = elements.item(0);
- Node driver = n.getAttributes().getNamedItem("driver"); //$NON-NLS-1$
- if (driver != null) {
- valid = true;
- String driverValue = driver.getNodeValue();
- cloudType = driverValue.toUpperCase();
- } else {
- cloudType = WizardMessages.getString(UNKNOWN_TYPE_LABEL);
- }
- }
- }
- } catch (MalformedURLException e) {
- cloudType = WizardMessages.getString(INVALID_URL);
- } catch (IOException e) {
- cloudType = WizardMessages.getString(NONCLOUD_URL);
- } catch (ParserConfigurationException e) {
- cloudType = WizardMessages.getString(NONCLOUD_URL);
- } catch (SAXException e) {
- cloudType = WizardMessages.getString(NONCLOUD_URL);
- } catch (Exception e) {
- cloudType = WizardMessages.getString(INVALID_URL);
- }
- setURLValid(valid);
+ CloudType cloudType = new CloudType(url);
+ cloudTypeLabel = cloudType.getLabel();
+ setURLValid(cloudType.isValid());
}
- if (!oldCloudType.equals(cloudType)) {
+ if (!oldCloudType.equals(cloudTypeLabel)) {
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
testButton.setEnabled(getURLValid());
- typeText.setText(cloudType);
+ typeText.setText(cloudTypeLabel);
}
});
}
}
- return valid;
}
- private Object getURLContent(String url) throws IOException {
- URL u = new URL(url);
- URLConnection connection = u.openConnection();
- connection.setRequestProperty("Accept", "application/xml;q=1.0");
//$NON-NLS-1$
- return connection.getContent();
- }
-
/**
* Set whether the URL is a valid Delta-cloud API URL.
*
@@ -386,9 +307,9 @@
typeLabel.setText(WizardMessages.getString(TYPE_LABEL));
typeText = new Label(container, SWT.NULL);
- if (cloudType == null)
- cloudType = WizardMessages.getString(UNKNOWN_TYPE_LABEL);
- typeText.setText(cloudType);
+ if (cloudTypeLabel == null)
+ cloudTypeLabel = WizardMessages.getString(CloudType.UNKNOWN_TYPE_LABEL);
+ typeText.setText(cloudTypeLabel);
Label usernameLabel = new Label(container, SWT.NULL);
usernameLabel.setText(WizardMessages.getString(USERNAME_LABEL));
Added:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudType.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudType.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudType.java 2010-10-07
09:47:08 UTC (rev 25546)
@@ -0,0 +1,129 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.internal.deltacloud.ui.wizards;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.StringReader;
+import java.io.UnsupportedEncodingException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLConnection;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+public class CloudType {
+
+ private static final String DOCUMENT_ELEMENT_DRIVER = "driver";
+ private static final String DOCUMENT_ELEMENT_API = "api";
+ private static final String URLCONNECTION_ENCODING = "UTF-8";
+ public static final String UNKNOWN_TYPE_LABEL = "UnknownType.label";
//$NON-NLS-1$
+ private static final String INVALID_URL = "ErrorInvalidURL.text";
//$NON-NLS-1$
+ static final String NONCLOUD_URL = "ErrorNonCloudURL.text"; //$NON-NLS-1$
+
+ private String label;
+ private boolean isValid;
+
+ public CloudType(String url) {
+ init(url);
+ }
+
+ /**
+ * Initializes this instance, sets the cloud type label and the validity. It
+ * tries to connect to the cloud instance that's supposed at the given url,
+ * requests an API response and parses the xml that's returned.
+ *
+ * @param url
+ * the cloud instance url to connect to
+ */
+ private void init(String url) {
+ try {
+ Object o = getURLContent(url + "/api?format=xml"); //$NON-NLS-1$
+ if (o instanceof InputStream) {
+ DocumentBuilderFactory dbf = DocumentBuilderFactory
+ .newInstance();
+ DocumentBuilder db = dbf.newDocumentBuilder();
+ Document document = db.parse(new InputSource(new StringReader(
+ getXML((InputStream) o))));
+
+ NodeList elements = document
+ .getElementsByTagName(DOCUMENT_ELEMENT_API); //$NON-NLS-1$
+ if (elements.getLength() > 0) {
+ Node n = elements.item(0);
+ Node driver = n.getAttributes().getNamedItem(
+ DOCUMENT_ELEMENT_DRIVER); //$NON-NLS-1$
+ if (driver != null) {
+ isValid = true;
+ String driverValue = driver.getNodeValue();
+ label = driverValue.toUpperCase();
+ } else {
+ label = WizardMessages.getString(UNKNOWN_TYPE_LABEL);
+ }
+ }
+ }
+ } catch (MalformedURLException e) {
+ label = WizardMessages.getString(INVALID_URL);
+ } catch (IOException e) {
+ label = WizardMessages.getString(NONCLOUD_URL);
+ } catch (ParserConfigurationException e) {
+ label = WizardMessages.getString(NONCLOUD_URL);
+ } catch (SAXException e) {
+ label = WizardMessages.getString(NONCLOUD_URL);
+ } catch (Exception e) {
+ label = WizardMessages.getString(INVALID_URL);
+ }
+ }
+
+ private String getXML(InputStream is) throws UnsupportedEncodingException,
+ IOException {
+ try {
+ if (is == null) {
+ return "";
+ }
+ StringBuilder sb = new StringBuilder();
+ String line;
+
+ BufferedReader reader = new BufferedReader(new InputStreamReader(
+ is, URLCONNECTION_ENCODING));
+ while ((line = reader.readLine()) != null) {
+ sb.append(line).append("\n"); //$NON-NLS-1$
+ }
+ return sb.toString();
+ } finally {
+ is.close();
+ }
+ }
+
+ public boolean isValid() {
+ return isValid;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ private Object getURLContent(String url) throws IOException {
+ URL u = new URL(url);
+ URLConnection connection = u.openConnection();
+ connection.setRequestProperty("Accept", "application/xml;q=1.0");
//$NON-NLS-1$ $NON-NLS-2$
+ return connection.getContent();
+ }
+}
Property changes on:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudType.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain