Author: adietish
Date: 2010-12-15 15:31:23 -0500 (Wed, 15 Dec 2010)
New Revision: 27525
Added:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/Driver.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudDriverValidator.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/Url2DriverConverter.java
Removed:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudTypeValidator.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/Url2DeltaCloudTypeConverter.java
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloud.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloudManager.java
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/CloudConnectionModel.java
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/EditCloudConnectionWizard.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewCloudConnectionWizard.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java
Log:
[JBIDE-7864]
* DeltaCloud: replaced cloud type strings by Driver enum
* removing references to DeltaCloudClient#DeltaCloudServerType, replacing by
DeltaCloud#Type
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog 2010-12-15 20:24:34
UTC (rev 27524)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog 2010-12-15 20:31:23
UTC (rev 27525)
@@ -1,6 +1,9 @@
2010-12-15 André Dietisheim <adietish(a)redhat.com>
* src/org/jboss/tools/deltacloud/core/DeltaCloud.java
+ (Driver):
+ [JBIDE-7864] replacing cloud type strings by Driver enum
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java
(getInstanceJob):
(waitWhilePending):
(registerInstanceJob):
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloud.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloud.java 2010-12-15
20:24:34 UTC (rev 27524)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloud.java 2010-12-15
20:31:23 UTC (rev 27525)
@@ -21,6 +21,7 @@
import org.jboss.tools.deltacloud.core.client.DeltaCloudAuthException;
import org.jboss.tools.deltacloud.core.client.DeltaCloudClientException;
import org.jboss.tools.deltacloud.core.client.DeltaCloudClientImpl;
+import org.jboss.tools.deltacloud.core.client.DeltaCloudClientImpl.DeltaCloudServerType;
import org.jboss.tools.deltacloud.core.client.DeltaCloudNotFoundClientException;
import org.jboss.tools.deltacloud.core.client.HardwareProfile;
import org.jboss.tools.deltacloud.core.client.Image;
@@ -35,9 +36,6 @@
*/
public class DeltaCloud extends ObservablePojo {
- public final static String MOCK_TYPE = "MOCK"; //$NON-NLS-1$
- public final static String EC2_TYPE = "EC2"; //$NON-NLS-1$
-
public static final String PROP_INSTANCES = "instances";
public static final String PROP_INSTANCES_ADDED = "instancesAdded";
public static final String PROP_INSTANCES_REMOVED = "instancesRemoved";
@@ -47,7 +45,7 @@
private String name;
private String username;
private String url;
- private String type;
+ private Driver driver;
private String lastKeyname = "";
private String lastImageId = "";
@@ -69,31 +67,31 @@
this(name, url, username, passwd, null);
}
- public DeltaCloud(String name, String url, String username, String password, String
type)
+ public DeltaCloud(String name, String url, String username, String password, Driver
driver)
throws DeltaCloudException {
- this(name, url, username, password, type, IImageFilter.ALL_STRING,
IInstanceFilter.ALL_STRING);
+ this(name, url, username, password, driver, IImageFilter.ALL_STRING,
IInstanceFilter.ALL_STRING);
}
- public DeltaCloud(String name, String url, String username, String type, String
imageFilterRules,
+ public DeltaCloud(String name, String url, String username, Driver driver, String
imageFilterRules,
String instanceFilterRules) throws DeltaCloudException {
- this(name, url, username, null, type, imageFilterRules, instanceFilterRules);
+ this(name, url, username, null, driver, imageFilterRules, instanceFilterRules);
}
public DeltaCloud(String name, String url, String username, String password,
- String type, String imageFilterRules, String instanceFilterRules) throws
DeltaCloudException {
+ Driver driver, String imageFilterRules, String instanceFilterRules) throws
DeltaCloudException {
this.url = url;
this.name = name;
this.username = username;
- this.type = type;
+ this.driver = driver;
this.passwordStore = createSecurePasswordStore(name, username, password);
this.client = createClient(name, url, username, passwordStore.getPassword());
imageFilter = createImageFilter(imageFilterRules);
instanceFilter = createInstanceFilter(instanceFilterRules);
}
- public void update(String name, String url, String username, String password, String
type)
+ public void update(String name, String url, String username, String password, Driver
driver)
throws DeltaCloudException {
- this.type = type;
+ this.driver = driver;
boolean nameChanged = updateName(name);
boolean connectionPropertiesChanged = updateConnectionProperties(url, username,
password);
@@ -170,8 +168,8 @@
return passwordStore.getPassword();
}
- public String getType() {
- return type;
+ public Driver getDriver() {
+ return driver;
}
public String getLastImageId() {
@@ -576,4 +574,14 @@
public String toString() {
return name;
}
+
+ public static Driver getServerDriver(String url) throws DeltaCloudException {
+ try {
+ DeltaCloudServerType serverType = new DeltaCloudClientImpl(url, "",
"").getServerType();
+ return Driver.valueOf(serverType);
+ } catch (Exception e) {
+ // TODO internationalize strings
+ throw new DeltaCloudException("Could not determine the driver of the server on
url " + url, e);
+ }
+ }
}
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloudManager.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloudManager.java 2010-12-15
20:24:34 UTC (rev 27524)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloudManager.java 2010-12-15
20:31:23 UTC (rev 27525)
@@ -30,6 +30,10 @@
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
+/**
+ * @author Jeff Johnston
+ * @author André Dietisheim
+ */
public class DeltaCloudManager {
private static final DeltaCloudManager INSTANCE = new DeltaCloudManager();
@@ -80,12 +84,12 @@
name = attrs.getNamedItem("name").getNodeValue(); // $NON-NLS-1$
String url = attrs.getNamedItem("url").getNodeValue(); // $NON-NLS-1$
String username = attrs.getNamedItem("username").getNodeValue(); //
$NON-NLS-1$
- String type = attrs.getNamedItem("type").getNodeValue(); // $NON-NLS-1$
+ Driver driver =
Driver.checkedValueOf(attrs.getNamedItem("type").getNodeValue()); //
$NON-NLS-1$
String imageFilterRules =
getImageFilterRules(attrs.getNamedItem("imagefilter")); // $NON-NLS-1$
String instanceFilterRules =
getInstanceFilterRules(attrs.getNamedItem("instancefilter")); // $NON-NLS-1$
String lastKeyName = getLastKeyName(attrs.getNamedItem("lastkeyname")); //
$NON-NLS-1$
String lastImageId = getLastKeyName(attrs.getNamedItem("lastimage")); //
$NON-NLS-1$
- cloud = new DeltaCloud(name, url, username, type, imageFilterRules,
instanceFilterRules);
+ cloud = new DeltaCloud(name, url, username, driver, imageFilterRules,
instanceFilterRules);
clouds.add(cloud);
cloud.setLastImageId(lastImageId);
cloud.setLastKeyname(lastKeyName);
@@ -144,7 +148,7 @@
private String createCloudXML(DeltaCloud d) {
return "<cloud name=\"" + d.getName() + "\"
url=\"" //$NON-NLS-1$ //$NON-NLS-2$
+ d.getURL() + "\" username=\"" + d.getUsername() + //$NON-NLS-1$
//$NON-NLS-2$
- "\" type=\"" + d.getType() + //$NON-NLS-1$ //$NON-NLS-2$
+ "\" type=\"" + d.getDriver() + //$NON-NLS-1$ //$NON-NLS-2$
"\" imagefilter=\"" + d.getImageFilter() + //$NON-NLS-1$
//$NON-NLS-2$
"\" instancefilter=\"" + d.getInstanceFilter() + //$NON-NLS-1$
//$NON-NLS-2$
"\" lastkeyname=\"" + d.getLastKeyname() + //$NON-NLS-1$
//$NON-NLS-2$
Added:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/Driver.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/Driver.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/Driver.java 2010-12-15
20:31:23 UTC (rev 27525)
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * 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.deltacloud.core;
+
+import org.jboss.tools.deltacloud.core.client.DeltaCloudClientImpl.DeltaCloudServerType;
+
+/**
+ * @author André Dietisheim
+ */
+public enum Driver {
+
+ MOCK(DeltaCloudServerType.MOCK), EC2(DeltaCloudServerType.EC2),
UNKNOWN(DeltaCloudServerType.UNKNOWN);
+
+ private DeltaCloudServerType deltaCloudServerType;
+
+ private Driver(DeltaCloudServerType deltaCloudServerType) {
+ this.deltaCloudServerType = deltaCloudServerType;
+ }
+
+ public static Driver valueOf(DeltaCloudServerType deltaCloudServerType) {
+ for(Driver type : values()) {
+ if (type.deltaCloudServerType.equals(deltaCloudServerType)) {
+ return type;
+ }
+ }
+ return UNKNOWN;
+ }
+
+ public static Driver checkedValueOf(String name) {
+ for (Driver type : values()) {
+ if (type.name().equals(name)) {
+ return type;
+ }
+ }
+ return UNKNOWN;
+ }
+
+}
Property changes on:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/Driver.java
___________________________________________________________________
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-12-15 20:24:34
UTC (rev 27524)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-12-15 20:31:23
UTC (rev 27525)
@@ -1,5 +1,12 @@
2010-12-15 André Dietisheim <adietish(a)redhat.com>
+ * src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java:
+ * src/org/jboss/tools/internal/deltacloud/ui/wizards/NewCloudConnectionWizard.java:
+ * src/org/jboss/tools/internal/deltacloud/ui/wizards/EditCloudConnectionWizard.java:
+ * src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudTypeValidator.java:
+ * src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudConnectionPage.java:
+ * src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudConnectionModel.java:
+ [JBIDE-7864] removing references to DeltaCloudClient#DeltaCloudServerType, replacing by
DeltaCloud#Type
* src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstanceWizard.java
(WatchCreateJob):
[JBIDE-7912] replaced custom WatchCreateJob and replaced with InstanceStateJob to have
consistent scheduling across jobs
in the client
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudConnectionModel.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudConnectionModel.java 2010-12-15
20:24:34 UTC (rev 27524)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudConnectionModel.java 2010-12-15
20:31:23 UTC (rev 27525)
@@ -12,8 +12,7 @@
import java.net.MalformedURLException;
-import org.jboss.tools.deltacloud.core.client.DeltaCloudClientImpl;
-import org.jboss.tools.deltacloud.core.client.DeltaCloudClientImpl.DeltaCloudServerType;
+import org.jboss.tools.deltacloud.core.Driver;
import org.jboss.tools.internal.deltacloud.core.observable.ObservablePojo;
/**
@@ -25,7 +24,7 @@
public static final String PROPERTY_NAME = "name"; //$NON-NLS-1$
public static final String PROPERTY_PASSWORD = "password"; //$NON-NLS-1$
public static final String PROPERTY_USERNAME = "username"; //$NON-NLS-1$
- public static final String PROPERTY_TYPE = "type"; //$NON-NLS-1$
+ public static final String PROPERTY_DRIVER = "type"; //$NON-NLS-1$
public static final String UNKNOWN_TYPE_LABEL = "UnknownType.label";
//$NON-NLS-1$
public static final String INVALID_URL = "ErrorInvalidURL.text";
//$NON-NLS-1$
@@ -36,46 +35,26 @@
private String username;
private String password;
- private DeltaCloudClientImpl.DeltaCloudServerType cloudType;
+ private Driver driver;
private String initialName;
public CloudConnectionModel() {
- this("", "", "", "", (DeltaCloudServerType)
null);
+ this("", "", "", "", (Driver) null);
}
- public CloudConnectionModel(String name, String url, String username, String password,
String cloudType) throws MalformedURLException {
- this(name, url, username, password, getDeltaCloudType(cloudType, url));
- }
-
public CloudConnectionModel(String name, String url, String username, String password)
throws MalformedURLException {
- this(name, url, username, password, getDeltaCloudTypeFromUrl(url));
+ this(name, url, username, password, (Driver) null);
}
- public CloudConnectionModel(String name, String url, String username, String password,
DeltaCloudServerType deltaCloudType) {
+ public CloudConnectionModel(String name, String url, String username, String password,
Driver cloudType) {
this.name = name;
this.initialName = name;
this.url = url;
this.username = username;
this.password = password;
- this.cloudType = deltaCloudType;
+ this.driver = cloudType;
}
-
- private static DeltaCloudServerType getDeltaCloudTypeFromUrl(String url) throws
MalformedURLException {
- return new DeltaCloudClientImpl(url, "", "").getServerType();
- }
- private static DeltaCloudServerType getDeltaCloudType(String cloudType, String url)
throws MalformedURLException {
- if (cloudType == null) {
- return null;
- }
-
- try {
- return DeltaCloudServerType.valueOf(cloudType);
- } catch (IllegalArgumentException e) {
- return getDeltaCloudTypeFromUrl(url);
- }
- }
-
public String getUsername() {
return username;
}
@@ -112,11 +91,11 @@
getPropertyChangeSupport().firePropertyChange(PROPERTY_URL, this.url, this.url = url);
}
- public DeltaCloudClientImpl.DeltaCloudServerType getType() {
- return cloudType;
+ public Driver getDriver() {
+ return driver;
}
- public void setType(DeltaCloudClientImpl.DeltaCloudServerType cloudType) {
- getPropertyChangeSupport().firePropertyChange(PROPERTY_TYPE, this.cloudType,
this.cloudType = cloudType);
+ public void setType(Driver cloudType) {
+ getPropertyChangeSupport().firePropertyChange(PROPERTY_DRIVER, this.driver, this.driver
= cloudType);
}
}
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-12-15
20:24:34 UTC (rev 27524)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudConnectionPage.java 2010-12-15
20:31:23 UTC (rev 27525)
@@ -25,6 +25,7 @@
import org.eclipse.core.databinding.observable.value.ValueChangeEvent;
import org.eclipse.core.databinding.validation.IValidator;
import org.eclipse.core.databinding.validation.ValidationStatus;
+import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.databinding.fieldassist.ControlDecorationSupport;
@@ -56,6 +57,7 @@
import org.jboss.tools.deltacloud.core.DeltaCloud;
import org.jboss.tools.deltacloud.core.DeltaCloudException;
import org.jboss.tools.deltacloud.core.DeltaCloudManager;
+import org.jboss.tools.deltacloud.core.Driver;
import org.jboss.tools.deltacloud.core.client.DeltaCloudClientImpl.DeltaCloudServerType;
import org.jboss.tools.deltacloud.ui.Activator;
import org.jboss.tools.deltacloud.ui.SWTImagesFactory;
@@ -123,12 +125,12 @@
private Label typeLabel;
- public DeltaCloudTypeLabelAdapter(DeltaCloudServerType cloudType, Label typeLabel) {
+ public DeltaCloudTypeLabelAdapter(Driver cloudType, Label typeLabel) {
this.typeLabel = typeLabel;
init(cloudType);
}
- private void init(DeltaCloudServerType cloudType) {
+ private void init(Driver cloudType) {
setLabelText(cloudType);
}
@@ -139,7 +141,7 @@
}
private void setLabelText(Object cloudType) {
- if (cloudType != null && !DeltaCloudServerType.UNKNOWN.equals(cloudType)) {
+ if (cloudType != null && !Driver.UNKNOWN.equals(cloudType)) {
typeLabel.setText(cloudType.toString());
} else {
typeLabel.setText("?"); // $NON-NLS-1$
@@ -278,15 +280,15 @@
throws MalformedURLException, DeltaCloudException {
this(pageName, initial.getName(), initial.getURL(), initial.getUsername(),
- initial.getPassword(), initial.getType(), connection);
+ initial.getPassword(), initial.getDriver(), connection);
}
public CloudConnectionPage(String pageName, String defaultName, String defaultUrl,
- String defaultUsername, String defaultPassword, String defaultType,
+ String defaultUsername, String defaultPassword, Driver defaultDriver,
CloudConnection cloudConnection) throws MalformedURLException {
super(pageName);
this.connectionModel = new CloudConnectionModel(defaultName, defaultUrl,
defaultUsername, defaultPassword,
- defaultType);
+ defaultDriver);
this.cloudConnection = cloudConnection;
setDescription(WizardMessages.getString(DESCRIPTION));
setTitle(WizardMessages.getString(TITLE));
@@ -318,12 +320,14 @@
urlLabel.setText(WizardMessages.getString(URL_LABEL));
Point p1 = urlLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT);
Text urlText = new Text(container, SWT.BORDER | SWT.SINGLE);
+
dbc.bindValue(
WidgetProperties.text(SWT.Modify).observe(urlText),
BeanProperties.value(
CloudConnectionModel.class,
CloudConnectionModel.PROPERTY_URL).observe(connectionModel),
- new UpdateValueStrategy().setAfterGetValidator(
- new MandatoryStringValidator(WizardMessages.getString(MUST_ENTER_A_URL))), null);
+ new UpdateValueStrategy()
+ .setAfterGetValidator(new
MandatoryStringValidator(WizardMessages.getString(MUST_ENTER_A_URL))),
+ null);
String url = new TextPreferenceValue(IPreferenceKeys.LAST_URL, Activator.getDefault())
.get(urlText.getText());
@@ -497,15 +501,15 @@
*/
private Binding bindCloudType(DataBindingContext dbc, Text urlText, final Label
typeLabel) {
UpdateValueStrategy updateStrategy = new UpdateValueStrategy();
- Url2DeltaCloudTypeConverter urlToCloudTypeConverter = new
Url2DeltaCloudTypeConverter();
+ Url2DriverConverter urlToCloudTypeConverter = new Url2DriverConverter();
updateStrategy.setConverter(urlToCloudTypeConverter);
- updateStrategy.setBeforeSetValidator(new CloudTypeValidator());
+ updateStrategy.setBeforeSetValidator(new CloudDriverValidator());
// bind url to cloud type in model
Binding urlTypeBinding = dbc.bindValue(
WidgetProperties.text(SWT.Modify).observeDelayed(CLOUDTYPE_CHECK_DELAY,
urlText),
- BeanProperties.value(CloudConnectionModel.PROPERTY_TYPE).observe(connectionModel),
+ BeanProperties.value(CloudConnectionModel.PROPERTY_DRIVER).observe(connectionModel),
updateStrategy,
new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER));
/*
@@ -517,8 +521,9 @@
* in the model.
*/
IObservableValue cloudTypeObservable =
urlToCloudTypeConverter.getCloudTypeObservable();
- DeltaCloudTypeLabelAdapter cloudTypeAdapter =
- new DeltaCloudTypeLabelAdapter((DeltaCloudServerType) cloudTypeObservable.getValue(),
typeLabel);
+ Object value = cloudTypeObservable.getValue();
+ Assert.isTrue(value == null || value instanceof Driver);
+ DeltaCloudTypeLabelAdapter cloudTypeAdapter = new DeltaCloudTypeLabelAdapter((Driver)
value, typeLabel);
cloudTypeObservable.addValueChangeListener(cloudTypeAdapter);
ControlDecorationSupport.create(urlTypeBinding, SWT.LEFT | SWT.TOP);
Copied:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudDriverValidator.java
(from rev 27490,
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudTypeValidator.java)
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudDriverValidator.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudDriverValidator.java 2010-12-15
20:31:23 UTC (rev 27525)
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * 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 org.eclipse.core.databinding.validation.IValidator;
+import org.eclipse.core.databinding.validation.ValidationStatus;
+import org.eclipse.core.runtime.IStatus;
+import org.jboss.tools.deltacloud.core.Driver;
+
+/**
+ * @author André Dietisheim
+ */
+public class CloudDriverValidator implements IValidator {
+
+ @Override
+ public IStatus validate(Object value) {
+ if (value != null
+ && !Driver.UNKNOWN.equals(value)) {
+ return ValidationStatus.ok();
+ } else {
+ return
ValidationStatus.warning(WizardMessages.getString("IllegalCloudUrl.msg"));
//$NON-NLS-1$
+ }
+ }
+}
\ No newline at end of file
Property changes on:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudDriverValidator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudTypeValidator.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudTypeValidator.java 2010-12-15
20:24:34 UTC (rev 27524)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudTypeValidator.java 2010-12-15
20:31:23 UTC (rev 27525)
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * 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 org.eclipse.core.databinding.validation.IValidator;
-import org.eclipse.core.databinding.validation.ValidationStatus;
-import org.eclipse.core.runtime.IStatus;
-import org.jboss.tools.deltacloud.core.client.DeltaCloudClientImpl;
-
-public class CloudTypeValidator implements IValidator {
-
- @Override
- public IStatus validate(Object value) {
- if (value != null
- && !DeltaCloudClientImpl.DeltaCloudServerType.UNKNOWN.equals(value)) {
- return ValidationStatus.ok();
- } else {
- return
ValidationStatus.warning(WizardMessages.getString("IllegalCloudUrl.msg"));
//$NON-NLS-1$
- }
- }
-}
\ No newline at end of file
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/EditCloudConnectionWizard.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/EditCloudConnectionWizard.java 2010-12-15
20:24:34 UTC (rev 27524)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/EditCloudConnectionWizard.java 2010-12-15
20:31:23 UTC (rev 27525)
@@ -14,8 +14,13 @@
import org.jboss.tools.deltacloud.core.DeltaCloud;
import org.jboss.tools.deltacloud.core.DeltaCloudManager;
+import org.jboss.tools.deltacloud.core.Driver;
import org.jboss.tools.deltacloud.ui.ErrorUtils;
+/**
+ * @author Jeff Johnston
+ * @author André Dietisheim
+ */
public class EditCloudConnectionWizard extends NewCloudConnectionWizard {
private static final String MAINPAGE_NAME = "EditCloudConnection.name";
//$NON-NLS-1$
@@ -30,9 +35,9 @@
String url = mainPage.getModel().getUrl();
String username = mainPage.getModel().getUsername();
String password = mainPage.getModel().getPassword();
- String type = getServerType();
+ Driver driver = mainPage.getModel().getDriver();
try {
- initialCloud.update(name, url, username, password, type);
+ initialCloud.update(name, url, username, password, driver);
DeltaCloudManager.getDefault().saveClouds();
} catch (Exception e) {
// TODO internationalize strings
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewCloudConnectionWizard.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewCloudConnectionWizard.java 2010-12-15
20:24:34 UTC (rev 27524)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewCloudConnectionWizard.java 2010-12-15
20:31:23 UTC (rev 27525)
@@ -19,12 +19,17 @@
import org.jboss.tools.deltacloud.core.DeltaCloud;
import org.jboss.tools.deltacloud.core.DeltaCloudException;
import org.jboss.tools.deltacloud.core.DeltaCloudManager;
-import org.jboss.tools.deltacloud.core.client.DeltaCloudClientImpl.DeltaCloudServerType;
+import org.jboss.tools.deltacloud.core.Driver;
import org.jboss.tools.deltacloud.ui.Activator;
import org.jboss.tools.deltacloud.ui.ErrorUtils;
import org.jboss.tools.internal.deltacloud.ui.preferences.IPreferenceKeys;
import org.jboss.tools.internal.deltacloud.ui.preferences.TextPreferenceValue;
+/**
+ * @author Jeff Johnston
+ * @author Andre Dietisheim
+ *
+ */
public class NewCloudConnectionWizard extends Wizard implements INewWizard,
CloudConnection {
private static final String MAINPAGE_NAME = "NewCloudConnection.name";
//$NON-NLS-1$
@@ -92,15 +97,6 @@
}
}
- protected String getServerType() {
- DeltaCloudServerType type = mainPage.getModel().getType();
- if (type == null) {
- return null;
- }
-
- return type.toString();
- }
-
@Override
public boolean needsProgressMonitor() {
return true;
@@ -116,10 +112,10 @@
String username = mainPage.getModel().getUsername();
String password = mainPage.getModel().getPassword();
- String type = getServerType();
+ Driver driver = mainPage.getModel().getDriver();
try {
- DeltaCloud newCloud = new DeltaCloud(name, url, username, password, type);
+ DeltaCloud newCloud = new DeltaCloud(name, url, username, password, driver);
DeltaCloudManager.getDefault().addCloud(newCloud);
DeltaCloudManager.getDefault().saveClouds();
} catch (Exception e) {
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java 2010-12-15
20:24:34 UTC (rev 27524)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java 2010-12-15
20:31:23 UTC (rev 27525)
@@ -63,6 +63,7 @@
import org.jboss.tools.deltacloud.core.DeltaCloudHardwareProfile;
import org.jboss.tools.deltacloud.core.DeltaCloudImage;
import org.jboss.tools.deltacloud.core.DeltaCloudRealm;
+import org.jboss.tools.deltacloud.core.Driver;
import org.jboss.tools.deltacloud.core.job.AbstractCloudElementJob;
import org.jboss.tools.deltacloud.core.job.AbstractCloudElementJob.CLOUDELEMENT;
import org.jboss.tools.deltacloud.ui.ErrorUtils;
@@ -287,7 +288,7 @@
Button keyManageButton = new Button(container, SWT.NULL);
keyManageButton.setText(WizardMessages.getString(MANAGE_BUTTON_LABEL));
keyManageButton.addSelectionListener(manageListener);
- if (cloud.getType().equals(DeltaCloud.MOCK_TYPE)) {
+ if (Driver.MOCK.equals(cloud.getDriver())) {
keyManageButton.setEnabled(false);
}
Deleted:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/Url2DeltaCloudTypeConverter.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/Url2DeltaCloudTypeConverter.java 2010-12-15
20:24:34 UTC (rev 27524)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/Url2DeltaCloudTypeConverter.java 2010-12-15
20:31:23 UTC (rev 27525)
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * 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.net.MalformedURLException;
-
-import org.eclipse.core.databinding.conversion.IConverter;
-import org.eclipse.core.databinding.observable.value.IObservableValue;
-import org.eclipse.core.databinding.observable.value.WritableValue;
-import org.jboss.tools.deltacloud.core.client.DeltaCloudClientImpl;
-import org.jboss.tools.deltacloud.core.client.DeltaCloudClientImpl.DeltaCloudServerType;
-
-/**
- * A class that converts an url (string) to a DeltaCloudType (enum). The state
- * of the converter may be tracked by tracking its observable value cloudType
- * observable.
- *
- * @author Andre Dietisheim
- *
- * @see IConverter
- * @see IObservableValue
- * @see #getCloudTypeObservable()
- */
-public class Url2DeltaCloudTypeConverter implements IConverter {
-
- IObservableValue cloudTypeObservable = new WritableValue();
-
- @Override
- public Object getFromType() {
- return String.class;
- }
-
- @Override
- public Object getToType() {
- return DeltaCloudClientImpl.DeltaCloudServerType.class;
- }
-
- @Override
- public Object convert(Object fromObject) {
- String deltaCloudUrl = (String) fromObject;
- DeltaCloudServerType cloudType = getCloudType(deltaCloudUrl);
- cloudTypeObservable.setValue(cloudType);
- return cloudType;
- }
-
- private DeltaCloudServerType getCloudType(String deltaCloudUrl) {
- try {
- return new DeltaCloudClientImpl(deltaCloudUrl, "",
"").getServerType();
- } catch (MalformedURLException e) {
- return null;
- }
- }
-
- public IObservableValue getCloudTypeObservable() {
- return cloudTypeObservable;
- }
-}
Copied:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/Url2DriverConverter.java
(from rev 27490,
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/Url2DeltaCloudTypeConverter.java)
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/Url2DriverConverter.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/Url2DriverConverter.java 2010-12-15
20:31:23 UTC (rev 27525)
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * 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 org.eclipse.core.databinding.conversion.Converter;
+import org.eclipse.core.databinding.conversion.IConverter;
+import org.eclipse.core.databinding.observable.value.IObservableValue;
+import org.eclipse.core.databinding.observable.value.WritableValue;
+import org.jboss.tools.deltacloud.core.DeltaCloud;
+import org.jboss.tools.deltacloud.core.DeltaCloudException;
+import org.jboss.tools.deltacloud.core.Driver;
+
+/**
+ * A class that converts an url (string) to a DeltaCloudType (enum). The state
+ * of the converter may be tracked by tracking its observable value cloudType
+ * observable.
+ *
+ * @author Andre Dietisheim
+ *
+ * @see IConverter
+ * @see IObservableValue
+ * @see #getCloudTypeObservable()
+ */
+public class Url2DriverConverter extends Converter {
+
+ IObservableValue cloudTypeObservable = new WritableValue();
+
+ public Url2DriverConverter() {
+ super(String.class, Driver.class);
+ }
+
+ @Override
+ public Object convert(Object fromObject) {
+ String deltaCloudUrl = (String) fromObject;
+ Driver cloudType = getCloudType(deltaCloudUrl);
+ cloudTypeObservable.setValue(cloudType);
+ return cloudType;
+ }
+
+ private Driver getCloudType(String url) {
+ try {
+ return DeltaCloud.getServerDriver(url);
+ } catch (DeltaCloudException e) {
+ return Driver.UNKNOWN;
+ }
+ }
+
+ public IObservableValue getCloudTypeObservable() {
+ return cloudTypeObservable;
+ }
+}
Property changes on:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/Url2DriverConverter.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain