Author: jjohnstn
Date: 2010-09-17 17:24:49 -0400 (Fri, 17 Sep 2010)
New Revision: 25005
Added:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudConnection.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/EditCloudConnection.java
Removed:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewCloudConnectionPage.java
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/META-INF/MANIFEST.MF
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVMessages.properties
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/DeltaCloudView.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/ImageView.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/InstanceView.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewCloudConnection.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/WizardMessages.properties
Log:
2010-09-17 Jeff Johnston <jjohnstn(a)redhat.com>
* src/org/jboss/tools/internal/deltacloud/ui/wizards/NewCloudConnectionPage.java:
Renamed.
* src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudConnectionPage.java: New name.
* src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudConnection.java: New file.
* src/org/jboss/tools/internal/deltacloud/ui/wizards/EditCloudConnection.java: New file.
* META-INF/MANIFEST.MF: Add dependency on equinox security for editing cloud connection
and
restoring saved password.
* src/org/jboss/tools/deltacloud/ui/views/CVMessages.properties: Add messages.
* src/org/jboss/tools/deltacloud/ui/views/DeltaCloudView.java (fillLocalPullDown): Add
edit
cloud connection action.
(fillContextMenu): Ditto.
(makeActions): Add new edit cloud connection action.
(.run): New edit cloud action.
* src/org/jboss/tools/deltacloud/ui/views/ImageView.java (changeEvent): Add check for
rename
cloud event.
* src/org/jboss/tools/deltacloud/ui/views/InstanceView.java (changeEvent): Ditto.
* src/org/jboss/tools/internal/deltacloud/ui/wizards/NewCloudConnection.java (addPages):
Use
new renamed CloudConnectionPage class.
* src/org/jboss/tools/internal/deltacloud/ui/wizards/WizardMessages.properties: Add new
messages.
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-09-17 20:47:08
UTC (rev 25004)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-09-17 21:24:49
UTC (rev 25005)
@@ -1,3 +1,24 @@
+2010-09-17 Jeff Johnston <jjohnstn(a)redhat.com>
+
+ * src/org/jboss/tools/internal/deltacloud/ui/wizards/NewCloudConnectionPage.java:
Renamed.
+ * src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudConnectionPage.java: New
name.
+ * src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudConnection.java: New file.
+ * src/org/jboss/tools/internal/deltacloud/ui/wizards/EditCloudConnection.java: New
file.
+ * META-INF/MANIFEST.MF: Add dependency on equinox security for editing cloud connection
and
+ restoring saved password.
+ * src/org/jboss/tools/deltacloud/ui/views/CVMessages.properties: Add messages.
+ * src/org/jboss/tools/deltacloud/ui/views/DeltaCloudView.java (fillLocalPullDown): Add
edit
+ cloud connection action.
+ (fillContextMenu): Ditto.
+ (makeActions): Add new edit cloud connection action.
+ (.run): New edit cloud action.
+ * src/org/jboss/tools/deltacloud/ui/views/ImageView.java (changeEvent): Add check for
rename
+ cloud event.
+ * src/org/jboss/tools/deltacloud/ui/views/InstanceView.java (changeEvent): Ditto.
+ * src/org/jboss/tools/internal/deltacloud/ui/wizards/NewCloudConnection.java (addPages):
Use
+ new renamed CloudConnectionPage class.
+ * src/org/jboss/tools/internal/deltacloud/ui/wizards/WizardMessages.properties: Add new
messages.
+
2010-09-16 Jeff Johnston <jjohnstn(a)redhat.com>
* src/org/jboss/tools/internal/deltacloud/ui/wizards/NewCloudConnectionPage.java
(createControl): Remove
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/META-INF/MANIFEST.MF 2010-09-17
20:47:08 UTC (rev 25004)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/META-INF/MANIFEST.MF 2010-09-17
21:24:49 UTC (rev 25005)
@@ -7,6 +7,7 @@
Bundle-Vendor: Red Hat Inc.
Bundle-Localization: plugin
Require-Bundle: org.eclipse.ui,
+ org.eclipse.equinox.security;bundle-version="1.0.100",
org.eclipse.core.runtime,
org.eclipse.ui.views;bundle-version="3.4.1",
org.eclipse.ui.views.properties.tabbed;bundle-version="3.5.0",
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVMessages.properties
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVMessages.properties 2010-09-17
20:47:08 UTC (rev 25004)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVMessages.properties 2010-09-17
21:24:49 UTC (rev 25005)
@@ -31,6 +31,7 @@
CloudSelector.label=Select Cloud:
RemoveCloud.label=Disconnect Cloud
+EditCloud.label=Edit Connection
Refresh.label=Refresh Cloud
CreateInstance.label=Launch Instance
DeleteInstance.label=Delete Instance
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/DeltaCloudView.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/DeltaCloudView.java 2010-09-17
20:47:08 UTC (rev 25004)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/DeltaCloudView.java 2010-09-17
21:24:49 UTC (rev 25005)
@@ -43,6 +43,7 @@
import org.jboss.tools.deltacloud.core.DeltaCloudManager;
import org.jboss.tools.deltacloud.core.ICloudManagerListener;
import org.jboss.tools.deltacloud.ui.SWTImagesFactory;
+import org.jboss.tools.internal.deltacloud.ui.wizards.EditCloudConnection;
import org.jboss.tools.internal.deltacloud.ui.wizards.NewInstance;
@@ -55,6 +56,7 @@
public static final String ID =
"org.jboss.tools.deltacloud.ui.views.DeltaCloudView";
private static final String REMOVE_CLOUD = "RemoveCloud.label"; //$NON-NLS-1$
+ private static final String EDIT_CLOUD = "EditCloud.label"; //$NON-NLS-1$
private static final String REFRESH = "Refresh.label"; //$NON-NLS-1$
private static final String CREATE_INSTANCE = "CreateInstance.label";
//$NON-NLS-1$
private static final String CONFIRM_CLOUD_DELETE_TITLE =
"ConfirmCloudDelete.title"; //$NON-NLS-1$
@@ -68,6 +70,7 @@
private Action collapseall;
private Action doubleClickAction;
private Action createInstance;
+ private Action editCloud;
private CloudViewElement selectedElement;
@@ -146,6 +149,7 @@
private void fillLocalPullDown(IMenuManager manager) {
manager.removeAll();
+ manager.add(editCloud);
manager.add(removeCloud);
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
CloudViewElement element = (CloudViewElement)selection.getFirstElement();
@@ -162,6 +166,7 @@
} else if (selectedElement instanceof CVInstanceElement){
//TODO: add meaningful actions here
}
+ manager.add(editCloud);
manager.add(removeCloud);
// Other plug-ins can contribute there actions here
manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
@@ -227,6 +232,27 @@
createInstance.setToolTipText(CVMessages.getString(CREATE_INSTANCE));
createInstance.setImageDescriptor(SWTImagesFactory.DESC_INSTANCE);
+ editCloud = new Action() {
+ public void run() {
+ IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
+ CloudViewElement element = (CloudViewElement)selection.getFirstElement();
+ while (element != null && !(element instanceof CVCloudElement)) {
+ element = (CloudViewElement)element.getParent();
+ }
+ if (element != null) {
+ CVCloudElement cloudElement = (CVCloudElement)element;
+ DeltaCloud cloud = (DeltaCloud)cloudElement.getElement();
+ IWizard wizard = new EditCloudConnection(cloud);
+ Shell shell = viewer.getControl().getShell();
+ WizardDialog dialog = new WizardDialog(shell, wizard);
+ dialog.create();
+ dialog.open();
+ }
+ }
+ };
+ editCloud.setText(CVMessages.getString(EDIT_CLOUD));
+ editCloud.setToolTipText(CVMessages.getString(EDIT_CLOUD));
+
refreshAction = new Action() {
public void run() {
ISelection selection = viewer.getSelection();
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/ImageView.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/ImageView.java 2010-09-17
20:47:08 UTC (rev 25004)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/ImageView.java 2010-09-17
21:24:49 UTC (rev 25005)
@@ -358,9 +358,11 @@
public void changeEvent(int type) {
String currName = null;
+ int currIndex = 0;
clouds = DeltaCloudManager.getDefault().getClouds();
if (currCloud != null) {
currName = currCloud.getName();
+ currIndex = cloudSelector.getSelectionIndex();
}
String[] cloudNames = new String[clouds.length];
int index = 0;
@@ -369,6 +371,9 @@
if (cloudNames[i].equals(currName))
index = i;
}
+ if (type == ICloudManagerListener.RENAME_EVENT) {
+ index = currIndex; // no change in cloud displayed
+ }
cloudSelector.removeModifyListener(cloudModifyListener);
cloudSelector.setItems(cloudNames);
if (cloudNames.length > 0) {
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/InstanceView.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/InstanceView.java 2010-09-17
20:47:08 UTC (rev 25004)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/InstanceView.java 2010-09-17
21:24:49 UTC (rev 25005)
@@ -606,8 +606,10 @@
public void changeEvent(int type) {
String currName = null;
+ int currIndex = 0;
if (currCloud != null) {
currName = currCloud.getName();
+ currIndex = cloudSelector.getSelectionIndex();
}
clouds = DeltaCloudManager.getDefault().getClouds();
String[] cloudNames = new String[clouds.length];
@@ -617,6 +619,9 @@
if (cloudNames[i].equals(currName))
index = i;
}
+ if (type == ICloudManagerListener.RENAME_EVENT) {
+ index = currIndex; // no change in cloud displayed
+ }
cloudSelector.removeModifyListener(cloudModifyListener);
cloudSelector.setItems(cloudNames);
if (cloudNames.length > 0) {
Added:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudConnection.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudConnection.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudConnection.java 2010-09-17
21:24:49 UTC (rev 25005)
@@ -0,0 +1,7 @@
+package org.jboss.tools.internal.deltacloud.ui.wizards;
+
+public interface CloudConnection {
+
+ public boolean performTest();
+
+}
Added:
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
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudConnectionPage.java 2010-09-17
21:24:49 UTC (rev 25005)
@@ -0,0 +1,491 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat Inc..
+ * All rights reserved. This program and the accompanying materials
+ * are 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 Incorporated - 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.net.MalformedURLException;
+import java.net.URL;
+
+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;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Link;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.PlatformUI;
+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 {
+
+ private static final String DESCRIPTION = "NewCloudConnection.desc";
//$NON-NLS-1$
+ private static final String TITLE = "NewCloudConnection.title"; //$NON-NLS-1$
+ private static final String URL_LABEL = "Url.label"; //$NON-NLS-1$
+ private static final String NAME_LABEL = "Name.label"; //$NON-NLS-1$
+ private static final String USERNAME_LABEL = "UserName.label"; //$NON-NLS-1$
+ 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$
+
+ private CloudConnection wizard;
+
+ private Button testButton;
+
+ private Text nameText;
+ private Text urlText;
+ private Label typeText;
+ private Text usernameText;
+ private Text passwordText;
+
+ private String name;
+ private String url;
+ private String username;
+ private String password;
+ private String cloudType;
+
+ private String defaultName = "";
+ private String defaultURL = "";
+ private String defaultUsername = "";
+ private String defaultPassword = "";
+
+ private boolean urlValid;
+
+ private class CheckURLThread extends Thread {
+
+ @Override
+ public void run() {
+ try {
+ checkURL();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ private Listener linkListener = new Listener() {
+
+ public void handleEvent(Event event) {
+ try {
+ URL url = new URL(event.text);
+ PlatformUI.getWorkbench().getBrowserSupport().getExternalBrowser().openURL(url);
+ } catch (Exception e) {
+ Activator.log(e);
+ }
+ }
+
+ };
+
+ private SelectionListener buttonListener = new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent event) {
+ boolean successful = false;
+ if (getURLValid()) {
+ successful = wizard.performTest();
+ }
+ if (successful) {
+ setMessage(WizardMessages.getString(TEST_SUCCESSFUL));
+ } else {
+ setErrorMessage(WizardMessages.getString(TEST_FAILURE));
+ }
+ }
+
+ };
+
+ public CloudConnectionPage(String pageName, CloudConnection wizard) {
+ super(pageName);
+ this.wizard= wizard;
+ setDescription(WizardMessages.getString(DESCRIPTION));
+ setTitle(WizardMessages.getString(TITLE));
+ setImageDescriptor(SWTImagesFactory.DESC_DELTA_LARGE);
+ setPageComplete(false);
+ }
+
+ public CloudConnectionPage(String pageName, String defaultName, String defaultURL,
+ String defaultUsername, String defaultPassword, String defaultCloudType,
+ CloudConnection wizard) {
+ super(pageName);
+ this.wizard= wizard;
+ this.defaultName = defaultName;
+ this.defaultURL = defaultURL;
+ this.defaultUsername = defaultUsername;
+ this.defaultPassword = defaultPassword;
+ this.cloudType = defaultCloudType;
+ setDescription(WizardMessages.getString(DESCRIPTION));
+ setTitle(WizardMessages.getString(TITLE));
+ setImageDescriptor(SWTImagesFactory.DESC_DELTA_LARGE);
+ setPageComplete(false);
+ }
+
+ private ModifyListener textListener = new ModifyListener() {
+
+ @Override
+ public void modifyText(ModifyEvent e) {
+ validate();
+ }
+ };
+
+ public String getName() {
+ return name;
+ }
+
+ public String getURL() {
+ return url;
+ }
+
+ public String getUsername() {
+ return username;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public String getType() {
+ return typeText.getText();
+ }
+
+ private void validate() {
+ boolean complete = true;
+ boolean errorFree = true;
+
+ setMessage(null);
+
+ name = nameText.getText();
+ if (name.length() > 0) {
+ if (!name.equals(defaultName)) {
+ if (DeltaCloudManager.getDefault().findCloud(name) != null) {
+ errorFree = false;
+ setErrorMessage(WizardMessages.getString(NAME_ALREADY_IN_USE));
+ }
+ }
+ } else {
+ complete = false;
+ }
+
+ // Run check for valid DeltaCloud URL in separate thread
+ String urlValue = urlText.getText();
+ if (urlValue.length() > 5) {
+ CheckURLThread t = new CheckURLThread();
+ t.start();
+ } 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 boolean checkURL() {
+ boolean valid = false;
+ String oldurl = url;
+ Display.getDefault().syncExec(new Runnable() {
+
+ @Override
+ public void run() {
+ cloudType = typeText.getText();
+ url = urlText.getText();
+ }
+ });
+ String oldCloudType = cloudType;
+ if (url.length() > 0) {
+ if (!url.equals(oldurl)) {
+ try {
+ URL u = new URL(url + "/api.xml"); //$NON-NLS-1$
+ Object o = u.getContent();
+ 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);
+ }
+ if (!oldCloudType.equals(cloudType)) {
+ Display.getDefault().asyncExec(new Runnable() {
+
+ @Override
+ public void run() {
+ testButton.setEnabled(getURLValid());
+ typeText.setText(cloudType);
+ }
+
+ });
+ }
+ }
+ return valid;
+ }
+
+ /**
+ * 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) {
+ final Composite container = new Composite(parent, SWT.NULL);
+ FormLayout layout = new FormLayout();
+ layout.marginHeight = 5;
+ layout.marginWidth = 5;
+ container.setLayout(layout);
+
+ Label dummyLabel = new Label(container, SWT.NULL);
+ //
errorLabel.setForeground(JFaceResources.getColorRegistry().get(JFacePreferences.ERROR_COLOR));
+
+ Label nameLabel = new Label(container, SWT.NULL);
+ nameLabel.setText(WizardMessages.getString(NAME_LABEL));
+ nameText = new Text(container, SWT.BORDER | SWT.SINGLE);
+ nameText.setText(defaultName);
+ nameText.addModifyListener(textListener);
+
+ Label urlLabel = new Label(container, SWT.NULL);
+ urlLabel.setText(WizardMessages.getString(URL_LABEL));
+ Point p1 = urlLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+
+ urlText = new Text(container, SWT.BORDER | SWT.SINGLE);
+ urlText.setText(defaultURL);
+ if (!defaultURL.equals(""))
+ setURLValid(true);
+ urlText.addModifyListener(textListener);
+ Point p2 = urlText.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+
+ int centering = (p2.y - p1.y + 1) / 2;
+
+ Label typeLabel = new Label(container, SWT.NULL);
+ typeLabel.setText(WizardMessages.getString(TYPE_LABEL));
+
+ typeText = new Label(container, SWT.NULL);
+ if (cloudType == null)
+ cloudType = WizardMessages.getString(UNKNOWN_TYPE_LABEL);
+ typeText.setText(cloudType);
+
+ Label usernameLabel = new Label(container, SWT.NULL);
+ usernameLabel.setText(WizardMessages.getString(USERNAME_LABEL));
+
+ usernameText = new Text(container, SWT.BORDER | SWT.SINGLE);
+ usernameText.setText(defaultUsername);
+ usernameText.addModifyListener(textListener);
+
+ Label passwordLabel = new Label(container, SWT.NULL);
+ passwordLabel.setText(WizardMessages.getString(PASSWORD_LABEL));
+
+ passwordText = new Text(container, SWT.BORDER | SWT.PASSWORD | SWT.SINGLE);
+ passwordText.setText(defaultPassword);
+ passwordText.addModifyListener(textListener);
+
+ testButton = new Button(container, SWT.NULL);
+ testButton.setText(WizardMessages.getString(TESTBUTTON_LABEL));
+ testButton.setEnabled(!defaultName.equals(""));
+ testButton.addSelectionListener(buttonListener);
+
+ Link ec2userLink = new Link(container, SWT.NULL);
+ ec2userLink.setText(WizardMessages.getString(EC2_USER_INFO));
+ ec2userLink.addListener(SWT.Selection, linkListener);
+
+ Link ec2pwLink = new Link(container, SWT.NULL);
+ ec2pwLink.setText(WizardMessages.getString(EC2_PASSWORD_INFO));
+ ec2pwLink.addListener(SWT.Selection, linkListener);
+
+ FormData f = new FormData();
+ f.left = new FormAttachment(0, 0);
+ f.right = new FormAttachment(100, 0);
+ dummyLabel.setLayoutData(f);
+
+ f = new FormData();
+ f.top = new FormAttachment(dummyLabel, 8 + centering);
+ nameLabel.setLayoutData(f);
+
+ f = new FormData();
+ f.top = new FormAttachment(dummyLabel, 8);
+ f.left = new FormAttachment(usernameLabel, 5);
+ f.right = new FormAttachment(100, 0);
+ nameText.setLayoutData(f);
+
+ f = new FormData();
+ f.top = new FormAttachment(nameText, 5 + centering);
+ urlLabel.setLayoutData(f);
+
+ f = new FormData();
+ f.left = new FormAttachment(nameText, 0, SWT.LEFT);
+ f.top = new FormAttachment(nameText, 5);
+ f.right = new FormAttachment(100, 0);
+ urlText.setLayoutData(f);
+
+ f = new FormData();
+ f.top = new FormAttachment(urlText, 5 + centering);
+ typeLabel.setLayoutData(f);
+
+ f = new FormData();
+ f.left = new FormAttachment(urlText, 0, SWT.LEFT);
+ f.top = new FormAttachment(urlText, 5 + centering);
+ f.right = new FormAttachment(100, 0);
+ typeText.setLayoutData(f);
+
+ f = new FormData();
+ f.top = new FormAttachment(typeText, 10 + centering);
+ usernameLabel.setLayoutData(f);
+
+ f = new FormData();
+ f.left = new FormAttachment(typeText, 0, SWT.LEFT);
+ f.top = new FormAttachment(typeText, 10);
+ f.right = new FormAttachment(100, -70);
+ usernameText.setLayoutData(f);
+
+ f = new FormData();
+ f.left = new FormAttachment(usernameText, 0, SWT.LEFT);
+ f.top = new FormAttachment(usernameText, 5);
+ ec2userLink.setLayoutData(f);
+
+ f = new FormData();
+ f.top = new FormAttachment(ec2userLink, 5 + centering);
+ passwordLabel.setLayoutData(f);
+
+ f = new FormData();
+ f.left = new FormAttachment(usernameText, 0, SWT.LEFT);
+ f.top = new FormAttachment(ec2userLink, 5);
+ f.right = new FormAttachment(100, -70);
+ passwordText.setLayoutData(f);
+
+ f = new FormData();
+ int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
+ Point minSize = testButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
+ f.width = Math.max(widthHint, minSize.x);
+ f.left = new FormAttachment(usernameText, 10);
+ f.top = new FormAttachment(usernameText, 0);
+ f.right = new FormAttachment(100, 0);
+ testButton.setLayoutData(f);
+
+ f = new FormData();
+ f.left = new FormAttachment(passwordText, 0, SWT.LEFT);
+ f.top = new FormAttachment(passwordText, 5);
+ ec2pwLink.setLayoutData(f);
+
+ setControl(container);
+ validate();
+}
+
+}
Added:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/EditCloudConnection.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/EditCloudConnection.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/EditCloudConnection.java 2010-09-17
21:24:49 UTC (rev 25005)
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat Inc..
+ * All rights reserved. This program and the accompanying materials
+ * are 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 Incorporated - initial API and implementation
+ *******************************************************************************/
+package org.jboss.tools.internal.deltacloud.ui.wizards;
+
+import java.net.MalformedURLException;
+
+import org.eclipse.equinox.security.storage.ISecurePreferences;
+import org.eclipse.equinox.security.storage.SecurePreferencesFactory;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+import org.jboss.tools.deltacloud.core.DeltaCloud;
+import org.jboss.tools.deltacloud.core.DeltaCloudManager;
+import org.jboss.tools.deltacloud.ui.Activator;
+
+public class EditCloudConnection extends Wizard implements INewWizard, CloudConnection {
+
+ private static final String MAINPAGE_NAME = "EditCloudConnection.name";
//$NON-NLS-1$
+ private CloudConnectionPage mainPage;
+ private DeltaCloud cloud;
+
+ public EditCloudConnection(DeltaCloud cloud) {
+ super();
+ this.cloud = cloud;
+ }
+
+ @Override
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ // TODO Auto-generated method stub
+ }
+
+ @Override
+ public void addPages() {
+ String password = "";
+ String key = DeltaCloud.getPreferencesKey(cloud.getURL(), cloud.getUsername());
+ ISecurePreferences root = SecurePreferencesFactory.getDefault();
+ ISecurePreferences node = root.node(key);
+ try {
+ password = node.get("password", null); //$NON-NLS-1$
+ } catch (Exception e) {
+ Activator.log(e);
+ }
+ mainPage = new CloudConnectionPage(WizardMessages.getString(MAINPAGE_NAME),
+ cloud.getName(), cloud.getURL(), cloud.getUsername(), password,
+ cloud.getType(), this);
+ addPage(mainPage);
+ }
+
+ @Override
+ public boolean canFinish() {
+ return mainPage.isPageComplete();
+ }
+
+ public boolean performTest() {
+ String name = mainPage.getName();
+ String url = mainPage.getURL();
+ String username = mainPage.getUsername();
+ String password = mainPage.getPassword();
+ try {
+ DeltaCloud newCloud = new DeltaCloud(name, url, username, password);
+ return newCloud.testConnection();
+ } catch (MalformedURLException e) {
+ Activator.log(e);
+ return false;
+ }
+ }
+
+ @Override
+ public boolean performFinish() {
+ String name = mainPage.getName();
+ String url = mainPage.getURL();
+ String username = mainPage.getUsername();
+ String password = mainPage.getPassword();
+ String type = mainPage.getType();
+ try {
+ String oldName = cloud.getName();
+ cloud.editCloud(name, url, username, password, type);
+ if (!name.equals(oldName))
+ DeltaCloudManager.getDefault().notifyCloudRename();
+ } catch (MalformedURLException e) {
+ Activator.log(e);
+ }
+ return true;
+ }
+
+}
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewCloudConnection.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewCloudConnection.java 2010-09-17
20:47:08 UTC (rev 25004)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewCloudConnection.java 2010-09-17
21:24:49 UTC (rev 25005)
@@ -20,10 +20,10 @@
import org.jboss.tools.deltacloud.core.DeltaCloudManager;
import org.jboss.tools.deltacloud.ui.Activator;
-public class NewCloudConnection extends Wizard implements INewWizard {
+public class NewCloudConnection extends Wizard implements INewWizard, CloudConnection {
private static final String MAINPAGE_NAME = "NewCloudConnection.name";
//$NON-NLS-1$
- private NewCloudConnectionPage mainPage;
+ private CloudConnectionPage mainPage;
public NewCloudConnection() {
super();
@@ -37,7 +37,7 @@
@Override
public void addPages() {
// TODO Auto-generated method stub
- mainPage = new NewCloudConnectionPage(WizardMessages.getString(MAINPAGE_NAME), this);
+ mainPage = new CloudConnectionPage(WizardMessages.getString(MAINPAGE_NAME), this);
addPage(mainPage);
}
@@ -72,7 +72,6 @@
DeltaCloudManager.getDefault().addCloud(newCloud);
} catch (MalformedURLException e) {
Activator.log(e);
- return false;
}
return true;
}
Deleted:
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-09-17
20:47:08 UTC (rev 25004)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewCloudConnectionPage.java 2010-09-17
21:24:49 UTC (rev 25005)
@@ -1,460 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Red Hat Inc..
- * All rights reserved. This program and the accompanying materials
- * are 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 Incorporated - 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.net.MalformedURLException;
-import java.net.URL;
-
-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;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Link;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.PlatformUI;
-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 NewCloudConnectionPage extends WizardPage {
-
- private static final String DESCRIPTION = "NewCloudConnection.desc";
//$NON-NLS-1$
- private static final String TITLE = "NewCloudConnection.title"; //$NON-NLS-1$
- private static final String URL_LABEL = "Url.label"; //$NON-NLS-1$
- private static final String NAME_LABEL = "Name.label"; //$NON-NLS-1$
- private static final String USERNAME_LABEL = "UserName.label"; //$NON-NLS-1$
- 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$
-
- private NewCloudConnection wizard;
-
- private Button testButton;
-
- private Text nameText;
- private Text urlText;
- private Label typeText;
- private Text usernameText;
- private Text passwordText;
-
- private String name;
- private String url;
- private String username;
- private String password;
- private String cloudType;
-
- private boolean urlValid;
-
- private class CheckURLThread extends Thread {
-
- @Override
- public void run() {
- try {
- checkURL();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
-
- private Listener linkListener = new Listener() {
-
- public void handleEvent(Event event) {
- try {
- URL url = new URL(event.text);
- PlatformUI.getWorkbench().getBrowserSupport().getExternalBrowser().openURL(url);
- } catch (Exception e) {
- Activator.log(e);
- }
- }
-
- };
-
- private SelectionListener buttonListener = new SelectionAdapter() {
-
- public void widgetSelected(SelectionEvent event) {
- boolean successful = false;
- if (getURLValid()) {
- successful = wizard.performTest();
- }
- if (successful) {
- setMessage(WizardMessages.getString(TEST_SUCCESSFUL));
- } else {
- setErrorMessage(WizardMessages.getString(TEST_FAILURE));
- }
- }
-
- };
-
- public NewCloudConnectionPage(String pageName, NewCloudConnection wizard) {
- super(pageName);
- this.wizard= wizard;
- setDescription(WizardMessages.getString(DESCRIPTION));
- setTitle(WizardMessages.getString(TITLE));
- setImageDescriptor(SWTImagesFactory.DESC_DELTA_LARGE);
- setPageComplete(false);
- }
-
- private ModifyListener textListener = new ModifyListener() {
-
- @Override
- public void modifyText(ModifyEvent e) {
- validate();
- }
- };
-
- public String getName() {
- return name;
- }
-
- public String getURL() {
- return url;
- }
-
- public String getUsername() {
- return username;
- }
-
- public String getPassword() {
- return password;
- }
-
- public String getType() {
- return typeText.getText();
- }
-
- private void validate() {
- boolean complete = true;
- boolean errorFree = true;
-
- setMessage(null);
-
- name = nameText.getText();
- if (name.length() > 0) {
- if (DeltaCloudManager.getDefault().findCloud(name) != null) {
- errorFree = false;
- setErrorMessage(WizardMessages.getString(NAME_ALREADY_IN_USE));
- }
- } else {
- complete = false;
- }
-
- // Run check for valid DeltaCloud URL in separate thread
- String urlValue = urlText.getText();
- if (urlValue.length() > 5) {
- CheckURLThread t = new CheckURLThread();
- t.start();
- } 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 boolean checkURL() {
- boolean valid = false;
- String oldurl = url;
- Display.getDefault().syncExec(new Runnable() {
-
- @Override
- public void run() {
- cloudType = typeText.getText();
- url = urlText.getText();
- }
- });
- String oldCloudType = cloudType;
- if (url.length() > 0) {
- if (!url.equals(oldurl)) {
- try {
- URL u = new URL(url + "/api.xml"); //$NON-NLS-1$
- Object o = u.getContent();
- 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);
- }
- if (!oldCloudType.equals(cloudType)) {
- Display.getDefault().asyncExec(new Runnable() {
-
- @Override
- public void run() {
- testButton.setEnabled(getURLValid());
- typeText.setText(cloudType);
- }
-
- });
- }
- }
- return valid;
- }
-
- /**
- * 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) {
- final Composite container = new Composite(parent, SWT.NULL);
- FormLayout layout = new FormLayout();
- layout.marginHeight = 5;
- layout.marginWidth = 5;
- container.setLayout(layout);
-
- Label dummyLabel = new Label(container, SWT.NULL);
- //
errorLabel.setForeground(JFaceResources.getColorRegistry().get(JFacePreferences.ERROR_COLOR));
-
- Label nameLabel = new Label(container, SWT.NULL);
- nameLabel.setText(WizardMessages.getString(NAME_LABEL));
- nameText = new Text(container, SWT.BORDER | SWT.SINGLE);
- nameText.addModifyListener(textListener);
-
- Label urlLabel = new Label(container, SWT.NULL);
- urlLabel.setText(WizardMessages.getString(URL_LABEL));
- Point p1 = urlLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT);
-
- urlText = new Text(container, SWT.BORDER | SWT.SINGLE);
- urlText.addModifyListener(textListener);
- Point p2 = urlText.computeSize(SWT.DEFAULT, SWT.DEFAULT);
-
- int centering = (p2.y - p1.y + 1) / 2;
-
- Label typeLabel = new Label(container, SWT.NULL);
- typeLabel.setText(WizardMessages.getString(TYPE_LABEL));
-
- typeText = new Label(container, SWT.NULL);
- cloudType = WizardMessages.getString(UNKNOWN_TYPE_LABEL);
- typeText.setText(cloudType);
-
- Label usernameLabel = new Label(container, SWT.NULL);
- usernameLabel.setText(WizardMessages.getString(USERNAME_LABEL));
-
- usernameText = new Text(container, SWT.BORDER | SWT.SINGLE);
- usernameText.addModifyListener(textListener);
-
- Label passwordLabel = new Label(container, SWT.NULL);
- passwordLabel.setText(WizardMessages.getString(PASSWORD_LABEL));
-
- passwordText = new Text(container, SWT.BORDER | SWT.PASSWORD | SWT.SINGLE);
- passwordText.addModifyListener(textListener);
-
- testButton = new Button(container, SWT.NULL);
- testButton.setText(WizardMessages.getString(TESTBUTTON_LABEL));
- testButton.setEnabled(false);
- testButton.addSelectionListener(buttonListener);
-
- Link ec2userLink = new Link(container, SWT.NULL);
- ec2userLink.setText(WizardMessages.getString(EC2_USER_INFO));
- ec2userLink.addListener(SWT.Selection, linkListener);
-
- Link ec2pwLink = new Link(container, SWT.NULL);
- ec2pwLink.setText(WizardMessages.getString(EC2_PASSWORD_INFO));
- ec2pwLink.addListener(SWT.Selection, linkListener);
-
- FormData f = new FormData();
- f.left = new FormAttachment(0, 0);
- f.right = new FormAttachment(100, 0);
- dummyLabel.setLayoutData(f);
-
- f = new FormData();
- f.top = new FormAttachment(dummyLabel, 8 + centering);
- nameLabel.setLayoutData(f);
-
- f = new FormData();
- f.top = new FormAttachment(dummyLabel, 8);
- f.left = new FormAttachment(usernameLabel, 5);
- f.right = new FormAttachment(100, 0);
- nameText.setLayoutData(f);
-
- f = new FormData();
- f.top = new FormAttachment(nameText, 5 + centering);
- urlLabel.setLayoutData(f);
-
- f = new FormData();
- f.left = new FormAttachment(nameText, 0, SWT.LEFT);
- f.top = new FormAttachment(nameText, 5);
- f.right = new FormAttachment(100, 0);
- urlText.setLayoutData(f);
-
- f = new FormData();
- f.top = new FormAttachment(urlText, 5 + centering);
- typeLabel.setLayoutData(f);
-
- f = new FormData();
- f.left = new FormAttachment(urlText, 0, SWT.LEFT);
- f.top = new FormAttachment(urlText, 5 + centering);
- f.right = new FormAttachment(100, 0);
- typeText.setLayoutData(f);
-
- f = new FormData();
- f.top = new FormAttachment(typeText, 10 + centering);
- usernameLabel.setLayoutData(f);
-
- f = new FormData();
- f.left = new FormAttachment(typeText, 0, SWT.LEFT);
- f.top = new FormAttachment(typeText, 10);
- f.right = new FormAttachment(100, -70);
- usernameText.setLayoutData(f);
-
- f = new FormData();
- f.left = new FormAttachment(usernameText, 0, SWT.LEFT);
- f.top = new FormAttachment(usernameText, 5);
- ec2userLink.setLayoutData(f);
-
- f = new FormData();
- f.top = new FormAttachment(ec2userLink, 5 + centering);
- passwordLabel.setLayoutData(f);
-
- f = new FormData();
- f.left = new FormAttachment(usernameText, 0, SWT.LEFT);
- f.top = new FormAttachment(ec2userLink, 5);
- f.right = new FormAttachment(100, -70);
- passwordText.setLayoutData(f);
-
- f = new FormData();
- int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
- Point minSize = testButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
- f.width = Math.max(widthHint, minSize.x);
- f.left = new FormAttachment(usernameText, 10);
- f.top = new FormAttachment(usernameText, 0);
- f.right = new FormAttachment(100, 0);
- testButton.setLayoutData(f);
-
- f = new FormData();
- f.left = new FormAttachment(passwordText, 0, SWT.LEFT);
- f.top = new FormAttachment(passwordText, 5);
- ec2pwLink.setLayoutData(f);
-
- setControl(container);
-}
-
-}
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-09-17
20:47:08 UTC (rev 25004)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/WizardMessages.properties 2010-09-17
21:24:49 UTC (rev 25005)
@@ -14,6 +14,8 @@
NewCloudConnectionTest.success=Connection Test successful
NewCloudConnectionTest.failure=Connection Test failed
+EditCloudConnection.name=Edit Cloud Connection
+
Url.label=URL:
Name.label=Name:
Type.label=Type: