private SourceLevelKey[] getSourceLevels() {
    if (sourceLevelCache == null) {
      JavacardPlatform platform = props.getPlatform();
      List<SourceLevelKey> sLevels = new ArrayList<SourceLevelKey>();
      // if platform == null => broken platform, the source level range is unknown
      // the source level combo box should be empty and disabled
      boolean selSourceLevelValid = false;
      SpecificationVersion version =
          platform == null
              ? new SpecificationVersion("9.9")
              : // NOI18N
              platform.getSpecification().getVersion();
      Pattern p = Pattern.compile("\\d*.\\.(\\d).*?"); // NOI18N
      int maxVersion = 6;
      Matcher m = p.matcher(version.toString());
      if (m.find() && m.groupCount() > 0) {
        maxVersion = Integer.parseInt(m.group(1));
      }

      int min = getMinimalIndex(version);
      for (int i = min; i < maxVersion + 1; i++) {
        SpecificationVersion ver = new SpecificationVersion("1." + i); // NOI18N
        sLevels.add(new SourceLevelKey(ver));
        selSourceLevelValid |= ver.equals(selectedSourceLevel);
      }
      sourceLevelCache = sLevels.toArray(new SourceLevelKey[sLevels.size()]);
      if (!selSourceLevelValid) {
        selectedSourceLevel =
            sourceLevelCache.length == 0
                ? null
                : sourceLevelCache[sourceLevelCache.length - 1].getSourceLevel();
      }
    }
    return sourceLevelCache;
  }
 public void platformChanged() {
   if (inPlatformChanged) {
     return;
   }
   inPlatformChanged = true;
   try {
     JavacardPlatform platform = activePlatform;
     if (platform != null) {
       SpecificationVersion version = platform.getSpecification().getVersion();
       if (selectedSourceLevel != null
           && selectedSourceLevel.compareTo(version) > 0
           && !shouldChangePlatform(selectedSourceLevel, version)) {
         props.setPlatformName(platform.getSystemName());
         // restore original
         return;
       } else {
         originalSourceLevel = null;
       }
     }
     activePlatform = props.getPlatform();
     resetCache();
   } finally {
     inPlatformChanged = false;
   }
 }