private void updateSdkMenu(final JMenu sdkMenu) {
    try {
      ArrayList<AndroidSDK.SDKTarget> targets = androidMode.getSDK().getAvailableSdkTargets();

      if (targets.size() != 0) sdkMenu.removeAll();

      AndroidSDK.SDKTarget lowestTargetAvailable = null;
      JCheckBoxMenuItem lowestTargetMenuItem = null;

      String savedTargetVersion = Preferences.get("android.sdk.version");
      boolean savedTargetSet = false;

      for (final AndroidSDK.SDKTarget target : targets) {
        if (target.version < 11) {
          // We do not support API level less than 11
          continue;
        }
        final JCheckBoxMenuItem item =
            new JCheckBoxMenuItem("API " + target.name + " (" + target.version + ")");

        if (savedTargetSet == false
            && (lowestTargetAvailable == null || lowestTargetAvailable.version > target.version)) {
          lowestTargetAvailable = target;
          lowestTargetMenuItem = item;
        }

        if (Integer.toString(target.version).equals(savedTargetVersion)) {
          AndroidBuild.setSdkTarget(target, sketch);
          item.setState(true);
          savedTargetSet = true;
        }

        item.addChangeListener(
            new ChangeListener() {
              @Override
              public void stateChanged(ChangeEvent e) {
                if (target.name.equals(AndroidBuild.sdkName)) item.setState(true);
                else item.setState(false);
              }
            });

        item.addActionListener(
            new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent e) {
                AndroidBuild.setSdkTarget(target, sketch);

                for (int i = 0; i < sdkMenu.getItemCount(); i++) {
                  ((JCheckBoxMenuItem) sdkMenu.getItem(i)).setState(false);
                }

                item.setState(true);
              }
            });

        sdkMenu.add(item);
      }

      if (!savedTargetSet) {
        AndroidBuild.setSdkTarget(lowestTargetAvailable, sketch);
        lowestTargetMenuItem.setState(true);
      }
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
 public void handleStop() {
   toolbar.deactivateRun();
   //    toolbar.deactivate(AndroidToolbar.RUN);
   stopIndeterminate();
   androidMode.handleStop(this);
 }
 protected AndroidEditor(Base base, String path, EditorState state, Mode mode)
     throws EditorException {
   super(base, path, state, mode);
   androidMode = (AndroidMode) mode;
   androidMode.checkSDK(this);
 }