Author: jjohnstn
Date: 2010-08-27 14:58:34 -0400 (Fri, 27 Aug 2010)
New Revision: 24522
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/IDeltaCloudPreferenceConstants.java
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/InstancePropertySource.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstance.java
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/WizardMessages.properties
Log:
2010-08-27 Jeff Johnston <jjohnstn(a)redhat.com>
* src/org/jboss/tools/deltacloud/ui/IDeltaCloudPreferenceConstants.java: Add new
constant
for the last EC2 key used.
* src/org/jboss/tools/deltacloud/ui/views/CVMessages.properties: Change keyname message.
* src/org/jboss/tools/deltacloud/ui/views/InstancePropertySource.java
(getPropertyValue):
Add support for keyname.
(getPropertyDescriptors): Ditto.
* src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstance.java (performFinish):
Return
the return code of the create instance which might fail because the key is invalid in
which
case allow the user to enter a new key.
* src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java
(.widgetSelected):
(createControl): Add a keyname text field and a Manage button if the cloud type is EC2.
(validate): Check the keyname field is filled in for EC2.
(getKeyName): New method.
* 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-08-27 18:54:33
UTC (rev 24521)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-08-27 18:58:34
UTC (rev 24522)
@@ -1,3 +1,21 @@
+2010-08-27 Jeff Johnston <jjohnstn(a)redhat.com>
+
+ * src/org/jboss/tools/deltacloud/ui/IDeltaCloudPreferenceConstants.java: Add new
constant
+ for the last EC2 key used.
+ * src/org/jboss/tools/deltacloud/ui/views/CVMessages.properties: Change keyname message.
+ * src/org/jboss/tools/deltacloud/ui/views/InstancePropertySource.java
(getPropertyValue):
+ Add support for keyname.
+ (getPropertyDescriptors): Ditto.
+ * src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstance.java (performFinish):
Return
+ the return code of the create instance which might fail because the key is invalid in
which
+ case allow the user to enter a new key.
+ * src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java
(.widgetSelected):
+ (createControl): Add a keyname text field and a Manage button if the cloud type is EC2.
+ (validate): Check the keyname field is filled in for EC2.
+ (getKeyName): New method.
+ * src/org/jboss/tools/internal/deltacloud/ui/wizards/WizardMessages.properties: Add new
+ messages.
+
2010-08-26 Jeff Johnston <jjohnstn(a)redhat.com>
* src/org/jboss/tools/deltacloud/ui/views/InstanceView.java (.run): For RSE
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/IDeltaCloudPreferenceConstants.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/IDeltaCloudPreferenceConstants.java 2010-08-27
18:54:33 UTC (rev 24521)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/IDeltaCloudPreferenceConstants.java 2010-08-27
18:58:34 UTC (rev 24522)
@@ -3,5 +3,6 @@
public interface IDeltaCloudPreferenceConstants {
public final static String DONT_CONFIRM_CREATE_INSTANCE =
"dont_confirm_create_instance"; //$NON-NLS-1$
+ public final static String LAST_EC2_KEYNAME = "last_ec2_keyname";
//$NON-NLS-1$
}
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-08-27
18:54:33 UTC (rev 24521)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVMessages.properties 2010-08-27
18:58:34 UTC (rev 24522)
@@ -6,6 +6,7 @@
PropertyId.title=Id
PropertyOwnerId.title=Owner Id
PropertyHostname.title=Hostname
+PropertyKeyname.title=Key Name
PropertyState.title=State
PropertyProfileId.title=Hardware Profile
PropertyRealmId.title=Realm Id
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/InstancePropertySource.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/InstancePropertySource.java 2010-08-27
18:54:33 UTC (rev 24521)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/InstancePropertySource.java 2010-08-27
18:58:34 UTC (rev 24522)
@@ -14,6 +14,7 @@
public static final String PROPERTY_OWNER =
"deltacloud.views.instance.owner"; //$NON-NLS-1$
public static final String PROPERTY_STATE =
"deltacloud.views.instance.state"; //$NON-NLS-1$
private static final String PROPERTY_HOSTNAME =
"deltacloud.views.instance.hostname"; //$NON-NLS-1$
+ private static final String PROPERTY_KEYNAME =
"deltacloud.views.instance.keyname"; //$NON-NLS-1$
private static final String PROPERTY_PROFILEID =
"deltacloud.views.instance.profileid"; //$NON-NLS-1$
private static final String PROPERTY_REALMID =
"deltacloud.views.instance.realmid"; //$NON-NLS-1$
private static final String PROPERTY_IMAGEID =
"deltacloud.views.instance.imageid"; //$NON-NLS-1$
@@ -22,6 +23,7 @@
private static final String PROPERTY_OWNER_TITLE = "PropertyOwnerId.title";
//$NON-NLS-1$
private static final String PROPERTY_STATE_TITLE = "PropertyState.title";
//$NON-NLS-1$
private static final String PROPERTY_HOSTNAME_TITLE =
"PropertyHostname.title"; //$NON-NLS-1$
+ private static final String PROPERTY_KEYNAME_TITLE = "PropertyKeyname.title";
//$NON-NLS-1$
private static final String PROPERTY_PROFILEID_TITLE =
"PropertyProfileId.title"; //$NON-NLS-1$
private static final String PROPERTY_REALMID_TITLE = "PropertyRealmId.title";
//$NON-NLS-1$
private static final String PROPERTY_IMAGEID_TITLE = "PropertyImageId.title";
//$NON-NLS-1$
@@ -57,6 +59,8 @@
CVMessages.getString(PROPERTY_IMAGEID_TITLE));
PropertyDescriptor hostnameDescriptor = new PropertyDescriptor(PROPERTY_HOSTNAME,
CVMessages.getString(PROPERTY_HOSTNAME_TITLE));
+ PropertyDescriptor keyDescriptor = new PropertyDescriptor(PROPERTY_KEYNAME,
+ CVMessages.getString(PROPERTY_KEYNAME_TITLE));
propertyDescriptors = new IPropertyDescriptor[] {
nameDescriptor,
@@ -64,6 +68,7 @@
ownerDescriptor,
stateDescriptor,
hostnameDescriptor,
+ keyDescriptor,
hardwareDescriptor,
realmDescriptor,
imageDescriptor,
@@ -86,6 +91,8 @@
return instance.getRealmId();
if (id.equals(PROPERTY_IMAGEID))
return instance.getImageId();
+ if (id.equals(PROPERTY_KEYNAME))
+ return instance.getKey();
if (id.equals(PROPERTY_STATE)) {
return instance.getState();
}
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstance.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstance.java 2010-08-27
18:54:33 UTC (rev 24521)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstance.java 2010-08-27
18:58:34 UTC (rev 24522)
@@ -111,6 +111,7 @@
String realmId = mainPage.getRealmId();
String memory = mainPage.getMemoryProperty();
String storage = mainPage.getStorageProperty();
+ String keyname = mainPage.getKeyName();
String name = null;
try {
name = URLEncoder.encode(mainPage.getInstanceName(), "UTF-8");
@@ -139,7 +140,7 @@
prefs.putBoolean(IDeltaCloudPreferenceConstants.DONT_CONFIRM_CREATE_INSTANCE,
true);
}
}
- instance = cloud.createInstance(name, imageId, realmId, profileId, memory, storage);
+ instance = cloud.createInstance(name, imageId, realmId, profileId, keyname, memory,
storage);
if (instance != null)
result = true;
if (instance != null &&
instance.getState().equals(DeltaCloudInstance.PENDING)) {
@@ -159,7 +160,7 @@
WizardMessages.getFormattedString(CREATE_INSTANCE_FAILURE_MSG, new String[] {name,
imageId, realmId, profileId}),
new Status(IStatus.ERROR, Activator.PLUGIN_ID, errorMessage));
}
- return true;
+ return result;
}
}
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-08-27
18:54:33 UTC (rev 24521)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java 2010-08-27
18:58:34 UTC (rev 24522)
@@ -1,25 +1,40 @@
package org.jboss.tools.internal.deltacloud.ui.wizards;
+import java.io.File;
import java.util.ArrayList;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+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.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.jboss.tools.deltacloud.core.DeltaCloud;
import org.jboss.tools.deltacloud.core.DeltaCloudHardwareProfile;
import org.jboss.tools.deltacloud.core.DeltaCloudImage;
+import org.jboss.tools.deltacloud.core.DeltaCloudInstance;
import org.jboss.tools.deltacloud.core.DeltaCloudRealm;
+import org.jboss.tools.deltacloud.ui.Activator;
+import org.jboss.tools.deltacloud.ui.IDeltaCloudPreferenceConstants;
import org.jboss.tools.deltacloud.ui.SWTImagesFactory;
+import org.osgi.service.prefs.Preferences;
public class NewInstancePage extends WizardPage {
@@ -32,10 +47,16 @@
private static final String ARCH_LABEL = "Arch.label"; //$NON-NLS-1$
private static final String HARDWARE_LABEL = "Profile.label"; //$NON-NLS-1$
private static final String REALM_LABEL = "Realm.label"; //$NON-NLS-1$
+ private static final String KEY_LABEL = "Key.label"; //$NON-NLS-1$
+ private static final String MANAGE_BUTTON_LABEL = "ManageButton.label";
//$NON-NLS-1$
private static final String PROPERTIES_LABEL = "Properties.label";
//$NON-NLS-1$
+
+ private static final String PEM_NAME = "Pem.name"; //$NON-NLS-1$
+
private static final String NONE_RESPONSE = "None.response"; //$NON-NLS-1$
@SuppressWarnings("unused")
private static final String NAME_ALREADY_IN_USE = "ErrorNameInUse.text";
//$NON-NLS-1$
+ private static final String INVALID_PEM_FILE_MSG = "ErrorInvalidPem.text";
//$NON-NLS-1$
private DeltaCloud cloud;
@@ -43,14 +64,15 @@
private ArrayList<DeltaCloudHardwareProfile> profiles;
private Text nameText;
+ private Text keyText;
private Combo hardware;
+ private Button keyManage;
private Control realm;
private String[] profileIds;
private ProfileComposite currPage;
private ProfileComposite[] profilePages;
private ArrayList<String> realmIds;
-
-
+
private ModifyListener textListener = new ModifyListener() {
@Override
@@ -70,6 +92,23 @@
}
};
+ private SelectionListener manageListener = new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent event) {
+ Display d = Display.getDefault();
+ Shell shell = new Shell(d);
+ FileDialog f = new FileDialog(shell, SWT.NULL);
+ f.setFilterNames(new String[] {WizardMessages.getString(PEM_NAME)});
+ f.setFilterExtensions(new String[] {"*.pem"}); //$NON-NLS-1$
+ String keyname = f.open();
+ if (keyname != null && keyname.length() > 0) {
+ keyname = keyname.substring(0, keyname.length() - 4);
+ keyText.setText(keyname);
+ }
+ }
+
+ };
+
public NewInstancePage(DeltaCloud cloud, DeltaCloudImage image) {
super(WizardMessages.getString(NAME));
this.cloud = cloud;
@@ -110,6 +149,10 @@
return nameText.getText();
}
+ public String getKeyName() {
+ return keyText.getText();
+ }
+
private void validate() {
boolean complete = true;
boolean errorFree = true;
@@ -120,6 +163,20 @@
if (name.length() == 0) {
complete = false;
}
+
+ if (cloud.getType().equals(DeltaCloudInstance.EC2_TYPE)) {
+ String keyname = keyText.getText();
+ if (keyname.length() == 0)
+ complete = false;
+ else {
+ Preferences prefs = new InstanceScope().getNode(Activator.PLUGIN_ID);
+ try {
+ prefs.put(IDeltaCloudPreferenceConstants.LAST_EC2_KEYNAME, keyname);
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+ }
if (errorFree)
setErrorMessage(null);
@@ -177,9 +234,11 @@
Label realmLabel = new Label(container, SWT.NULL);
realmLabel.setText(WizardMessages.getString(REALM_LABEL));
+
nameText = new Text(container, SWT.BORDER | SWT.SINGLE);
nameText.addModifyListener(textListener);
-
+
+
DeltaCloudRealm[] realms = cloud.getRealms();
realmIds = new ArrayList<String>();
ArrayList<String> realmNames = new ArrayList<String>();
@@ -270,13 +329,51 @@
f.right = new FormAttachment(100, 0);
realm.setLayoutData(f);
+ Control control = realm;
+
+ if (cloud.getType().equals(DeltaCloudInstance.EC2_TYPE)) {
+ Label keyLabel = new Label(container, SWT.NULL);
+ keyLabel.setText(WizardMessages.getString(KEY_LABEL));
+
+ keyText = new Text(container, SWT.BORDER | SWT.SINGLE);
+ Preferences prefs = new InstanceScope().getNode(Activator.PLUGIN_ID);
+ String defaultKeyname = prefs.get(IDeltaCloudPreferenceConstants.LAST_EC2_KEYNAME,
"");
+ keyText.setText(defaultKeyname);
+ keyText.addModifyListener(textListener);
+
+ keyManage = new Button(container, SWT.NULL);
+ keyManage.setText(WizardMessages.getString(MANAGE_BUTTON_LABEL));
+ keyManage.addSelectionListener(manageListener);
+
+ f = new FormData();
+ f.top = new FormAttachment(realm, 11);
+ f.left = new FormAttachment(0, 0);
+ keyLabel.setLayoutData(f);
+
+ f = new FormData();
+ int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
+ Point minSize = keyManage.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
+ f.width = Math.max(widthHint, minSize.x);
+ f.top = new FormAttachment(realm, 8);
+ f.right = new FormAttachment(realm, 0, SWT.RIGHT);
+ keyManage.setLayoutData(f);
+
+ f = new FormData();
+ f.top = new FormAttachment(realm, 8);
+ f.left = new FormAttachment(hardwareLabel, 5);
+ f.right = new FormAttachment(keyManage, -10);
+ keyText.setLayoutData(f);
+
+ control = keyText;
+ }
+
f = new FormData();
- f.top = new FormAttachment(realm, 11);
+ f.top = new FormAttachment(control, 11);
f.left = new FormAttachment(0, 0);
hardwareLabel.setLayoutData(f);
f = new FormData();
- f.top = new FormAttachment(realm, 8);
+ f.top = new FormAttachment(control, 8);
f.left = new FormAttachment(hardwareLabel, 5);
f.right = new FormAttachment(100, 0);
hardware.setLayoutData(f);
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/WizardMessages.properties
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/WizardMessages.properties 2010-08-27
18:54:33 UTC (rev 24521)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/WizardMessages.properties 2010-08-27
18:58:34 UTC (rev 24522)
@@ -19,7 +19,12 @@
Memory.label=Memory:
Realm.label=Realm:
Storage.label=Storage:
+Key.label=Key Name:
+BrowseButton.label=Browse...
+ManageButton.label=Manage...
+Pem.name=PEM file (*.pem)
+
BackGround.label=Run In Background
AlwaysRunInBackground.msg=Always run in the background
Progress.msg=Progress
@@ -41,6 +46,7 @@
ErrorNameInUse.text=Error: the name chosen is already in use
ErrorInvalidURL.text=URL specified is invalid
ErrorNonCloudURL.text=URL specified is not a valid Delta-cloud address
+ErrorInvalidPem.text=File specified is not a valid existing key
NewInstance.desc=Specify details for a new instance you wish to launch based on an image
NewInstance.title=Launch Instance