private void setDefaultButtonState() {
   _useDefaultRE.setEnabled(true);
   _useProjectRE.setEnabled(true);
   boolean isBBDefaultRE = VMUtils.isBlackBerryRuntimeTheWorkspaceDefault();
   // if the default JRE is non-BlackBerry, select project specific JRE
   if (!isBBDefaultRE) {
     _useProjectRE.setSelection(true);
     _useDefaultRE.setSelection(false);
     setLastSelectedJREKind(PROJECT_RE);
   } else {
     int kind = getLastSelectedJREKind();
     _useProjectRE.setSelection(kind == PROJECT_RE);
     _useDefaultRE.setSelection(kind == DEFAULT_RE);
   }
   _RECombo.setEnabled(_useProjectRE.isSelected());
   if (_preferenceLink != null) {
     _preferenceLink.setEnabled(true);
   }
   if (_group != null) {
     _group.setEnabled(true);
   }
 }
 private String getDefaultBBJRE() {
   IVMInstall vm = VMUtils.getDefaultBBVM();
   return vm != null ? vm.getName() : "";
 }
  private void fillInstalledJREs(ComboDialogField comboField) {
    String selectedItem = getLastSelectedJRE();

    int selectionIndex = -1;

    if (_useProjectRE.isSelected()) {
      selectionIndex = comboField.getSelectionIndex();
      if (selectionIndex != -1) { // paranoia
        selectedItem = comboField.getItems()[selectionIndex];
      }
    }

    List<IVMInstall> standins = VMUtils.getInstalledBBVMs();
    _installedVMs = (standins.toArray(new IVMInstall[standins.size()]));

    Arrays.sort(
        _installedVMs,
        new Comparator<IVMInstall>() {
          public int compare(IVMInstall arg0, IVMInstall arg1) {
            String cc0, cc1;

            if (arg1 instanceof IVMInstall2 && arg0 instanceof IVMInstall2) {
              cc0 = JavaModelUtil.getCompilerCompliance((IVMInstall2) arg0, JavaCore.VERSION_1_4);
              cc1 = JavaModelUtil.getCompilerCompliance((IVMInstall2) arg1, JavaCore.VERSION_1_4);
              int result = cc1.compareTo(cc0);

              if (result != 0) return result;
            }
            return Policy.getComparator().compare(arg0.getName(), arg1.getName());
          }
        });

    selectionIndex = -1; // find new index

    String[] jreLabels = new String[_installedVMs.length];

    _RECompliance = new String[_installedVMs.length];

    for (int i = 0; i < _installedVMs.length; i++) {
      jreLabels[i] = _installedVMs[i].getName();
      if (selectedItem != null && jreLabels[i].equals(selectedItem)) {
        selectionIndex = i;
      }
      if (_installedVMs[i] instanceof IVMInstall2) {
        _RECompliance[i] =
            JavaModelUtil.getCompilerCompliance(
                (IVMInstall2) _installedVMs[i], JavaCore.VERSION_1_4);
      } else {
        _RECompliance[i] = JavaCore.VERSION_1_4;
      }
    }

    // don't fire event when setting combobox items.
    _fireEvent = false;
    comboField.setItems(jreLabels);
    if (selectionIndex == -1) {
      comboField.selectItem(getDefaultBBJRE());
    } else {
      comboField.selectItem(selectedItem);
    }
    _fireEvent = true;
  }