Exemple #1
0
  /**
   * Change internal settings based on what was chosen in the prefs,
   * then send a message to the editor saying that it's time to do the same.
   */
  protected void applyFrame() {
    // put each of the settings into the table
    setBoolean("build.verbose", verboseCompilationBox.isSelected());
    setBoolean("upload.verbose", verboseUploadBox.isSelected());
    setBoolean("upload.verify", verifyUploadBox.isSelected());

//    setBoolean("sketchbook.closing_last_window_quits",
//               closingLastQuitsBox.isSelected());
    //setBoolean("sketchbook.prompt", sketchPromptBox.isSelected());
    //setBoolean("sketchbook.auto_clean", sketchCleanBox.isSelected());

    // if the sketchbook path has changed, rebuild the menus
    String oldPath = get("sketchbook.path");
    String newPath = sketchbookLocationField.getText();
    if (!newPath.equals(oldPath)) {
      editor.base.rebuildSketchbookMenus();
      set("sketchbook.path", newPath);
    }

    setBoolean("editor.external", externalEditorBox.isSelected());
    setBoolean("update.check", checkUpdatesBox.isSelected());

    /*
      // was gonna use this to check memory settings,
      // but it quickly gets much too messy
    if (getBoolean("run.options.memory")) {
      Process process = Runtime.getRuntime().exec(new String[] {
          "java", "-Xms" + memoryMin + "m", "-Xmx" + memoryMax + "m"
        });
      processInput = new SystemOutSiphon(process.getInputStream());
      processError = new MessageSiphon(process.getErrorStream(), this);
    }
    */

    String newSizeText = fontSizeField.getText();
    try {
      int newSize = Integer.parseInt(newSizeText.trim());
      String pieces[] = PApplet.split(get("editor.font"), ',');
      pieces[2] = String.valueOf(newSize);
      set("editor.font", PApplet.join(pieces, ','));

    } catch (Exception e) {
      System.err.println(I18n.format(_("ignoring invalid font size {0}"), newSizeText));
    }

    if (autoAssociateBox != null) {
      setBoolean("platform.auto_file_type_associations",
                 autoAssociateBox.isSelected());
    }

    setBoolean("editor.update_extension", updateExtensionBox.isSelected());

    // adds the selected language to the preferences file
    Object newItem = comboLanguage.getSelectedItem();
    int pos = (Arrays.asList(languages)).indexOf(newItem.toString());  // position in the languages array
    set("editor.languages.current",(Arrays.asList(languagesISO)).get(pos));

    set("tftp.secretPass",tftpPassField.getText());
    if (domainPortField.getText().contains(":")){
      set("tftp.domain",domainPortField.getText().split(":")[0]);
      try{
        set("tftp.port",String.valueOf(Integer.parseInt(domainPortField.getText().split(":")[1])));
      }catch (NumberFormatException nfe){
        set("tftp.port","69");
      }
    }else{
      set("tftp.domain",domainPortField.getText());
      set("tftp.port","69");
    }
    if ("".equals(autoResetPortField.getText())){
      set("tftp.autoreset","46969");
    }else{
      try{
        set("tftp.autoreset",String.valueOf(Integer.parseInt(autoResetPortField.getText())));
      }catch (NumberFormatException nfe){
        set("tftp.autoreset","46969");
      }
    }

      editor.applyPreferences();
  }