Author: jjohnstn
Date: 2010-08-04 18:15:49 -0400 (Wed, 04 Aug 2010)
New Revision: 23928
Added:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/ProfileComposite.java
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewCloudConnectionPage.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/WizardMessages.properties
Log:
2010-08-04 Jeff Johnston <jjohnstn(a)redhat.com>
* src/org/jboss/tools/internal/deltacloud/ui/wizards/ProfileComposite.java: New file.
* src/org/jboss/tools/internal/deltacloud/ui/wizards/NewCloudConnectionPage.java
(createControl): Clean
up format.
* src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java
(NewInstancePage): Calculate
the possible hardware profiles using getPossibleProfiles method.
(.modifyText): New method for handling name text control.
(getPossibleProfiles): New method.
(createControl): Start fleshing out actual controls.
(validate): New method.
(getProfileIds): Ditto.
* src/org/jboss/tools/internal/deltacloud/ui/wizards/WizardMessages.properties: Add new
messages for create instance wizard.
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-08-04 18:40:03
UTC (rev 23927)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-08-04 22:15:49
UTC (rev 23928)
@@ -1,6 +1,22 @@
2010-08-04 Jeff Johnston <jjohnstn(a)redhat.com>
- * src/org/jboss/tools/internal/deltacloud/ui/wizards/NewCloudConnection.java (addPages):
+ * src/org/jboss/tools/internal/deltacloud/ui/wizards/ProfileComposite.java: New file.
+ * src/org/jboss/tools/internal/deltacloud/ui/wizards/NewCloudConnectionPage.java
(createControl): Clean
+ up format.
+ * src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java
(NewInstancePage): Calculate
+ the possible hardware profiles using getPossibleProfiles method.
+ (.modifyText): New method for handling name text control.
+ (getPossibleProfiles): New method.
+ (createControl): Start fleshing out actual controls.
+ (validate): New method.
+ (getProfileIds): Ditto.
+ * src/org/jboss/tools/internal/deltacloud/ui/wizards/WizardMessages.properties: Add new
+ messages for create instance wizard.
+
+2010-08-04 Jeff Johnston <jjohnstn(a)redhat.com>
+
+ * src/org/jboss/tools/internal/deltacloud/ui/wizards/NewCloudConnection.java (addPages):
Add
+ this to page constructor.
(performTest): New method to test connection.
* src/org/jboss/tools/internal/deltacloud/ui/wizards/NewCloudConnectionPage.java
(checkURL):
(NewCloudConnectionPage): Pass in calling wizard.
@@ -9,6 +25,7 @@
(validate): Clear the message area each time.
* src/org/jboss/tools/internal/deltacloud/ui/wizards/WizardMessages.properties: Add new
messages for connection testing purposes.
+
2010-08-03 Jeff Johnston <jjohnstn(a)redhat.com>
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewCloudConnectionPage.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewCloudConnectionPage.java 2010-08-04
18:40:03 UTC (rev 23927)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewCloudConnectionPage.java 2010-08-04
22:15:49 UTC (rev 23928)
@@ -64,7 +64,6 @@
private NewCloudConnection wizard;
- private Label errorLabel;
private Button testButton;
private Text nameText;
@@ -297,7 +296,7 @@
layout.marginWidth = 5;
container.setLayout(layout);
- errorLabel = new Label(container, SWT.NULL);
+ Label dummyLabel = new Label(container, SWT.NULL);
//
errorLabel.setForeground(JFaceResources.getColorRegistry().get(JFacePreferences.ERROR_COLOR));
Label nameLabel = new Label(container, SWT.NULL);
@@ -345,14 +344,14 @@
FormData f = new FormData();
f.left = new FormAttachment(0, 0);
f.right = new FormAttachment(100, 0);
- errorLabel.setLayoutData(f);
+ dummyLabel.setLayoutData(f);
f = new FormData();
- f.top = new FormAttachment(errorLabel, 11);
+ f.top = new FormAttachment(dummyLabel, 11);
nameLabel.setLayoutData(f);
f = new FormData();
- f.top = new FormAttachment(errorLabel, 8);
+ f.top = new FormAttachment(dummyLabel, 8);
f.left = new FormAttachment(usernameLabel, 5);
f.right = new FormAttachment(100, 0);
nameText.setLayoutData(f);
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-04
18:40:03 UTC (rev 23927)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java 2010-08-04
22:15:49 UTC (rev 23928)
@@ -1,38 +1,207 @@
package org.jboss.tools.internal.deltacloud.ui.wizards;
+import java.util.ArrayList;
+
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.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+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.DeltaCloudHardwareProperty;
import org.jboss.tools.deltacloud.core.DeltaCloudImage;
-import org.jboss.tools.deltacloud.ui.SWTImagesFactory;
public class NewInstancePage extends WizardPage {
private final static String NAME = "NewInstance.name"; //$NON-NLS-1$
private final static String DESCRIPTION = "NewInstance.desc"; //$NON-NLS-1$
private final static String TITLE = "NewInstance.title"; //$NON-NLS-1$
+
+ private static final String NAME_LABEL = "Name.label"; //$NON-NLS-1$
+ private static final String IMAGE_LABEL = "Image.label"; //$NON-NLS-1$
+ private static final String ARCH_LABEL = "Arch.label"; //$NON-NLS-1$
+ private static final String HARDWARE_LABEL = "Profiles.label"; //$NON-NLS-1$
+ private static final String NAME_ALREADY_IN_USE = "ErrorNameInUse.text";
//$NON-NLS-1$
+
private DeltaCloud cloud;
private DeltaCloudImage image;
+ private ArrayList<DeltaCloudHardwareProfile> profiles;
+ private Text nameText;
+ private Combo hardware;
+ private String[] profileIds;
+ private ProfileComposite currPage;
+ private ProfileComposite[] profilePages;
+
+
+ private ModifyListener textListener = new ModifyListener() {
+
+ @Override
+ public void modifyText(ModifyEvent e) {
+ validate();
+ }
+ };
+
+ private ModifyListener comboListener = new ModifyListener() {
+
+ @Override
+ public void modifyText(ModifyEvent e) {
+ int index = hardware.getSelectionIndex();
+ currPage.setVisible(false);
+ profilePages[index].setVisible(true);
+ }
+ };
+
public NewInstancePage(DeltaCloud cloud, DeltaCloudImage image) {
super(WizardMessages.getString(NAME));
this.cloud = cloud;
this.image = image;
+ getPossibleProfiles();
setDescription(WizardMessages.getString(DESCRIPTION));
setTitle(WizardMessages.getString(TITLE));
setPageComplete(false);
}
+
+ private void validate() {
+ boolean complete = true;
+ boolean errorFree = true;
+
+ setMessage(null);
+
+ String name = nameText.getText();
+ if (name.length() == 0) {
+ complete = false;
+ }
+
+ if (errorFree)
+ setErrorMessage(null);
+ setPageComplete(complete & errorFree);
+ }
+ private void getPossibleProfiles() {
+ profiles = new ArrayList<DeltaCloudHardwareProfile>();
+ DeltaCloudHardwareProfile[] allProfiles = cloud.getProfiles();
+ for (DeltaCloudHardwareProfile p : allProfiles) {
+ if (image.getArchitecture().equals(p.getArchitecture())) {
+ profiles.add(p);
+ }
+ }
+ }
+
+ private String[] getProfileIds(Composite container) {
+ String[] ids = new String[profiles.size()];
+ profilePages = new ProfileComposite[profiles.size()];
+ for (int i = 0; i < profiles.size(); ++i) {
+ DeltaCloudHardwareProfile p = profiles.get(i);
+ ids[i] = p.getId();
+ profilePages[i] = new ProfileComposite(p, container);
+ }
+ return ids;
+ }
+
@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);
+ container.setLayout(layout);
+
+ Label dummyLabel = new Label(container, SWT.NULL);
+
+ Label imageLabel = new Label(container, SWT.NULL);
+ imageLabel.setText(WizardMessages.getString(IMAGE_LABEL));
+
+ Label imageId = new Label(container, SWT.NULL);
+ imageId.setText(image.getName());
+
+ Label archLabel = new Label(container, SWT.NULL);
+ archLabel.setText(WizardMessages.getString(ARCH_LABEL));
+
+ Label arch = new Label(container, SWT.NULL);
+ arch.setText(image.getArchitecture());
+
+ 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 hardwareLabel = new Label(container, SWT.NULL);
+ hardwareLabel.setText(WizardMessages.getString(HARDWARE_LABEL));
+
+ hardware = new Combo(container, SWT.READ_ONLY);
+ Composite groupContainer = new Composite(container, SWT.NULL);
+ FormLayout groupLayout = new FormLayout();
+ groupLayout.marginHeight = 0;
+ groupLayout.marginWidth = 0;
+ groupContainer.setLayout(groupLayout);
+
+ profileIds = getProfileIds(groupContainer);
+
+ if (profileIds.length > 0) {
+ hardware.setItems(profileIds);
+ hardware.setText(profileIds[0]);
+// hardware.addModifyListener(comboListener);
+ }
+
+ 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);
+ f.left = new FormAttachment(0, 0);
+ imageLabel.setLayoutData(f);
+
+ f = new FormData();
+ f.top = new FormAttachment(dummyLabel, 8);
+ f.left = new FormAttachment(hardwareLabel, 5);
+ f.right = new FormAttachment(100, 0);
+ imageId.setLayoutData(f);
+
+ f = new FormData();
+ f.top = new FormAttachment(imageLabel, 8);
+ f.left = new FormAttachment(0, 0);
+ archLabel.setLayoutData(f);
+
+ f = new FormData();
+ f.top = new FormAttachment(imageLabel, 8);
+ f.left = new FormAttachment(hardwareLabel, 5);
+ arch.setLayoutData(f);
+
+ f = new FormData();
+ f.top = new FormAttachment(archLabel, 8);
+ f.left = new FormAttachment(0, 0);
+ nameLabel.setLayoutData(f);
+
+ f = new FormData();
+ f.top = new FormAttachment(arch, 5);
+ f.left = new FormAttachment(hardwareLabel, 5);
+ f.right = new FormAttachment(100, 0);
+ nameText.setLayoutData(f);
+
+ f = new FormData();
+ f.top = new FormAttachment(nameText, 8);
+ f.left = new FormAttachment(0, 0);
+ hardwareLabel.setLayoutData(f);
+
+ f = new FormData();
+ f.top = new FormAttachment(nameText, 5);
+ f.left = new FormAttachment(hardwareLabel, 5);
+ f.right = new FormAttachment(100, 0);
+ hardware.setLayoutData(f);
+
setControl(container);
}
Added:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/ProfileComposite.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/ProfileComposite.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/ProfileComposite.java 2010-08-04
22:15:49 UTC (rev 23928)
@@ -0,0 +1,97 @@
+package org.jboss.tools.internal.deltacloud.ui.wizards;
+
+import java.util.List;
+
+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.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Spinner;
+import org.jboss.tools.deltacloud.core.DeltaCloudHardwareProfile;
+import org.jboss.tools.deltacloud.core.DeltaCloudHardwareProperty;
+
+public class ProfileComposite {
+
+ private static final String CPU_LABEL = "Cpu.label"; //$NON-NLS-1$
+
+ private Composite container;
+ private DeltaCloudHardwareProfile profile;
+ private String cpu;
+ private String cpuDefaultValue;
+ private Button[] cpuButtons;
+
+ private ModifyListener cpuSpinnerListener = new ModifyListener() {
+
+ @Override
+ public void modifyText(ModifyEvent e) {
+ cpu = ((Spinner)e.widget).getText();
+ }
+ };
+
+ private SelectionListener cpuButtonListener = new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ for (int i = 0; i < cpuButtons.length; ++i) {
+ Button b = cpuButtons[i];
+ if (b != e.widget) {
+ b.setSelection(false);
+ } else {
+ b.setSelection(true);
+ cpu = b.getText();
+ }
+ }
+ }
+
+ };
+
+ public ProfileComposite(DeltaCloudHardwareProfile profile, Composite parent) {
+ this.profile = profile;
+ container = new Composite(parent, SWT.NULL);
+
+ DeltaCloudHardwareProperty cpuProperty = profile.getNamedProperty("cpu");
+ if (cpuProperty != null) {
+ Label cpuLabel = new Label(container, SWT.NULL);
+ cpuLabel.setText(WizardMessages.getString(CPU_LABEL));
+ if (cpuProperty.getKind() == DeltaCloudHardwareProperty.Kind.FIXED) {
+ Label cpu = new Label(container, SWT.NULL);
+ cpu.setText(cpuProperty.getValue());
+ } else if (cpuProperty.getKind() == DeltaCloudHardwareProperty.Kind.RANGE) {
+ cpuDefaultValue = cpuProperty.getValue();
+ Spinner cpuSpinner = new Spinner(container, SWT.READ_ONLY);
+ cpuSpinner.setMinimum(Integer.valueOf(cpuProperty.getRange().getFirst()));
+ cpuSpinner.setMaximum(Integer.valueOf(cpuProperty.getRange().getLast()));
+ cpuSpinner.addModifyListener(cpuSpinnerListener);
+ cpuSpinner.setSelection(Integer.valueOf(cpuDefaultValue));
+ } else if (cpuProperty.getKind() == DeltaCloudHardwareProperty.Kind.ENUM) {
+ cpuDefaultValue = cpuProperty.getValue();
+ List<String> values = cpuProperty.getEnums();
+ cpuButtons = new Button[values.size()];
+ for (int i = 0; i < values.size(); ++i) {
+ Button button = new Button(container, SWT.RADIO);
+ String value = values.get(i);
+ button.setText(value);
+ if (value.equals(cpuDefaultValue))
+ button.setSelection(true);
+ button.addSelectionListener(cpuButtonListener);
+ cpuButtons[i] = button;
+ }
+ }
+ }
+ }
+
+ public void setVisible(boolean visible) {
+ container.setVisible(visible);
+ }
+
+ public String getCPU() {
+ if (cpu != null && !cpu.equals(cpuDefaultValue))
+ return cpu;
+ return null;
+ }
+}
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-04
18:40:03 UTC (rev 23927)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/WizardMessages.properties 2010-08-04
22:15:49 UTC (rev 23928)
@@ -11,6 +11,10 @@
Password.label=Password:
TestButton.label=Test
UnknownType.label=Unknown
+Image.label=Image:
+Arch.label=Architecture:
+Profiles.label=Hardware Profiles:
+Cpu.label=CPUs:
EC2UserNameLink.text=For EC2 use the <a
href="https://console.aws.amazon.com/ec2/home">Access ID</a>
EC2PasswordLink.text=For EC2 use the <a
href="https://console.aws.amazon.com/ec2/home">Access Secret Key</a>