aboutsummaryrefslogtreecommitdiffstats
path: root/sdkmanager
diff options
context:
space:
mode:
authorSiva Velusamy <vsiva@google.com>2012-10-10 10:07:30 -0700
committerSiva Velusamy <vsiva@google.com>2012-10-10 10:10:35 -0700
commitb83b7c2b08dcb9449368d0100903fdb8862a95ba (patch)
treeb9fe20b0c8e3dcc929ed4275e239f8b566225c98 /sdkmanager
parenta5b668a9106dc321c8e993d2e53e63fc4cdea616 (diff)
downloadsdk-b83b7c2b08dcb9449368d0100903fdb8862a95ba.zip
sdk-b83b7c2b08dcb9449368d0100903fdb8862a95ba.tar.gz
sdk-b83b7c2b08dcb9449368d0100903fdb8862a95ba.tar.bz2
avd creation dialog: add check for valid AVD names
Change-Id: I8b2dce8147b89e9bbb549840fb879add5cee6638
Diffstat (limited to 'sdkmanager')
-rw-r--r--sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/widgets/AvdCreationDialog.java40
1 files changed, 33 insertions, 7 deletions
diff --git a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/widgets/AvdCreationDialog.java b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/widgets/AvdCreationDialog.java
index d78341b..d788ccd 100644
--- a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/widgets/AvdCreationDialog.java
+++ b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/widgets/AvdCreationDialog.java
@@ -709,29 +709,46 @@ public class AvdCreationDialog extends GridDialog {
String error = null;
String warning = null;
boolean valid = true;
+
if (mAvdName.getText().isEmpty()) {
- valid = false;
+ error = "AVD Name cannot be empty";
+ setPageValid(false, error, warning);
+ return;
+ }
+
+ String avdName = mAvdName.getText();
+ if (!AvdManager.RE_AVD_NAME.matcher(avdName).matches()) {
+ error = String.format(
+ "AVD name '%1$s' contains invalid characters.\nAllowed characters are: %2$s",
+ avdName, AvdManager.CHARS_AVD_NAME);
+ setPageValid(false, error, warning);
+ return;
}
if (mDeviceManufacturer.getSelectionIndex() < 0 || mDeviceName.getSelectionIndex() < 0) {
- valid = false;
+ setPageValid(false, error, warning);
+ return;
}
if (mTarget.getSelectionIndex() < 0 || mAbi.getSelectionIndex() < 0) {
- valid = false;
+ setPageValid(false, error, warning);
+ return;
}
if (mRam.getText().isEmpty()) {
- valid = false;
+ setPageValid(false, error, warning);
+ return;
}
if (mVmHeap.getText().isEmpty()) {
- valid = false;
+ setPageValid(false, error, warning);
+ return;
}
if (mDataPartition.getText().isEmpty() || mDataPartitionSize.getSelectionIndex() < 0) {
- valid = false;
- error = "Data partition must be a valid file size.";
+ error = "Invalid Data partition size.";
+ setPageValid(false, error, warning);
+ return;
}
// validate sdcard size or file
@@ -762,6 +779,10 @@ public class AvdCreationDialog extends GridDialog {
error = "SD Card path isn't valid.";
}
}
+ if (!valid) {
+ setPageValid(valid, error, warning);
+ return;
+ }
if (mForceCreation.isEnabled() && !mForceCreation.getSelection()) {
valid = false;
@@ -782,6 +803,11 @@ public class AvdCreationDialog extends GridDialog {
error = "GPU Emulation and Snapshot cannot be used simultaneously";
}
+ setPageValid(valid, error, warning);
+ return;
+ }
+
+ private void setPageValid(boolean valid, String error, String warning) {
mOkButton.setEnabled(valid);
if (error != null) {
mStatusIcon.setImage(mImageFactory.getImageByName("reject_icon16.png")); //$NON-NLS-1$