From 2f68f038741af8e33c730d0600ad9d0fa3d44e4b Mon Sep 17 00:00:00 2001 From: Alexander Lobas Date: Thu, 1 Nov 2012 14:47:36 +0400 Subject: [PATCH] IDEA-93042 --- .../designer/profile/ProfileManager.java | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/plugins/android-designer/src/com/intellij/android/designer/profile/ProfileManager.java b/plugins/android-designer/src/com/intellij/android/designer/profile/ProfileManager.java index 740453efbca6..687cf123c4bd 100644 --- a/plugins/android-designer/src/com/intellij/android/designer/profile/ProfileManager.java +++ b/plugins/android-designer/src/com/intellij/android/designer/profile/ProfileManager.java @@ -44,6 +44,7 @@ import java.util.*; * @author Alexander Lobas */ public class ProfileManager { + private static final LayoutDevice NO_DEVICES = new LayoutDevice("[None]", LayoutDevice.Type.CUSTOM); private static final LayoutDevice CUSTOM_DEVICE = new LayoutDevice("Edit Devices", LayoutDevice.Type.CUSTOM); private final ModuleProvider myModuleProvider; @@ -84,6 +85,9 @@ public class ProfileManager { @Override protected boolean selectionChanged(LayoutDevice item) { + if (item == NO_DEVICES) { + return false; + } if (item == CUSTOM_DEVICE) { configureCustomDevices(false); } @@ -455,6 +459,9 @@ public class ProfileManager { if (sdkData != null) { myLayoutDeviceManager.loadDevices(sdkData); myDevices = new ArrayList(myLayoutDeviceManager.getCombinedList()); + if (myDevices.isEmpty()) { + myDevices.add(NO_DEVICES); + } myDevices.add(CUSTOM_DEVICE); targets = new ArrayList(); @@ -465,7 +472,7 @@ public class ProfileManager { } } else { - myDevices = Collections.emptyList(); + myDevices = Arrays.asList(NO_DEVICES); } LayoutDevice newDevice = null; @@ -536,8 +543,17 @@ public class ProfileManager { private void updateDevice(@Nullable LayoutDevice device, @Nullable String configurationName) { myProfile.setDevice(device == null ? null : device.getName()); - List configurations = - device == null ? Collections.emptyList() : device.getConfigurations(); + List configurations; + if (device == null) { + configurations = Collections.emptyList(); + } + else { + configurations = device.getConfigurations(); + if (configurations == null) { + configurations = Collections.emptyList(); + } + } + LayoutDeviceConfiguration newConfiguration = null; if (configurationName != null) {