Add support for different SdkListItem on BasicJComboBoxCellReader

IntelliJ supports different types of items as part of JComboBox,
described on SdkListItem. We recently started to use SdkReferenceItem
allowing us to don't create a linked jdk.table entry, something
fundamental in the case of macros like #JAVA_HOME. This allowed us to
move away from the hardcoded jdk naming we had for the same purpose.

This change allows us in those cases to be able to return properly
the value of the cell, instead of avoiding processing SdkListItem
as text, and unable to return its value.

Bug: 263797479
Test: StudioDefaultJDKTest and existing
Change-Id: I39e3da009eafb424c3afb1b659bb1dc7d75de62b
diff --git a/fest-swing/src/main/java/org/fest/swing/driver/BasicJComboBoxCellReader.java b/fest-swing/src/main/java/org/fest/swing/driver/BasicJComboBoxCellReader.java
index afdf654..6a390dc 100644
--- a/fest-swing/src/main/java/org/fest/swing/driver/BasicJComboBoxCellReader.java
+++ b/fest-swing/src/main/java/org/fest/swing/driver/BasicJComboBoxCellReader.java
@@ -18,6 +18,7 @@
 import static org.fest.swing.edt.GuiActionRunner.execute;
 import static org.fest.util.Preconditions.checkNotNull;
 
+import com.intellij.openapi.roots.ui.configuration.SdkListItem;
 import java.awt.Component;
 
 import org.jetbrains.annotations.NotNull;
@@ -71,7 +72,8 @@
 
   /**
    * <p>
-   * Returns the internal value of a cell in a {@code JComboBox} as expected in a test.
+   * Returns the internal value of a cell in a {@code JComboBox} as expected in a test, taking into consideration
+   * different cell types defined on {@link SdkListItem}.
    * </p>
    * 
    * <p>
@@ -92,7 +94,17 @@
     if (value != null) {
       return value;
     }
-    return asText(comboBox.getItemAt(index));
+
+    Object comboBoxItem = comboBox.getItemAt(index);
+    if (comboBoxItem instanceof SdkListItem.SdkReferenceItem) {
+      return ((SdkListItem.SdkReferenceItem)comboBoxItem).name;
+    } else if (comboBoxItem instanceof SdkListItem.SdkItem) {
+      return ((SdkListItem.SdkItem)comboBoxItem).sdk.getName();
+    } else if (comboBoxItem instanceof SdkListItem.InvalidSdkItem) {
+      return ((SdkListItem.InvalidSdkItem)comboBoxItem).sdkName;
+    } else {
+      return asText(comboBoxItem);
+    }
   }
 
   @RunsInCurrentThread