Ejemplo n.º 1
0
  /**
   * Saves the options of the specified seek to be used for the next time when this action is run.
   */
  private void saveSeekOptions(UserSeek seek) {
    Preferences prefs = getPrefs();

    prefs.setInt("time", seek.getTime());
    prefs.setInt("inc", seek.getInc());
    prefs.setBool("isRated", seek.isRated());
    prefs.setString("variant", seek.getVariant().getName());
    Player color = seek.getColor();
    prefs.setString("color", color == null ? "auto" : color.isWhite() ? "white" : "black");
    int minRating = seek.getMinRating();
    int maxRating = seek.getMaxRating();
    prefs.setBool(
        "limitRating", (minRating != Integer.MIN_VALUE) || (maxRating != Integer.MAX_VALUE));
    prefs.setInt("minRating", minRating == Integer.MIN_VALUE ? 0 : minRating);
    prefs.setInt("maxRating", maxRating == Integer.MAX_VALUE ? 9999 : maxRating);
    prefs.setBool("manualAccept", seek.isManualAccept());
    prefs.setBool("useFormula", seek.isFormula());
  }
Ejemplo n.º 2
0
    /** Creates a new <code>SeekPanel</code>. */
    public SeekPanel(Component hintParent) {
      setHintParent(hintParent);

      Preferences prefs = getPrefs();
      I18n i18n = getI18n();

      WildVariant[] variants = getConn().getSupportedVariants();

      // Create ui elements
      timeField = new FixedJTextField(new IntegerStrictPlainDocument(0, 9999), "", 3);
      incField = new FixedJTextField(new IntegerStrictPlainDocument(0, 9999), "", 3);
      isRatedBox = i18n.createCheckBox("ratedBox");
      variantChoice = new FixedJComboBox(variants);
      variantChoice.setEditable(false);
      autoColor = i18n.createRadioButton("autoColorRadioButton");
      whiteColor = i18n.createRadioButton("whiteColorRadioButton");
      blackColor = i18n.createRadioButton("blackColorRadioButton");
      limitRatingBox = i18n.createCheckBox("limitRatingCheckBox");
      minRatingField = new FixedJTextField(new IntegerStrictPlainDocument(0, 9999), "", 4);
      maxRatingField = new FixedJTextField(new IntegerStrictPlainDocument(0, 9999), "", 4);
      manualAcceptBox = i18n.createCheckBox("manualAcceptCheckBox");
      useFormulaBox = i18n.createCheckBox("useFormulaCheckBox");

      ButtonGroup colorButtonGroup = new ButtonGroup();
      colorButtonGroup.add(autoColor);
      colorButtonGroup.add(whiteColor);
      colorButtonGroup.add(blackColor);

      String color = prefs.getString("color", "auto");

      // Set initial values of ui elements
      timeField.setText(String.valueOf(prefs.getInt("time", 10)));
      incField.setText(String.valueOf(prefs.getInt("inc", 0)));
      isRatedBox.setSelected(prefs.getBool("isRated", true));
      variantChoice.setSelectedIndex(
          findVariantIndex(variants, prefs.getString("variant", "Chess")));
      autoColor.setSelected("auto".equals(color));
      whiteColor.setSelected("white".equals(color));
      blackColor.setSelected("black".equals(color));
      limitRatingBox.setSelected(prefs.getBool("limitRating", false));
      minRatingField.setText(String.valueOf(prefs.getInt("minRating", 0)));
      maxRatingField.setText(String.valueOf(prefs.getInt("maxRating", 9999)));
      manualAcceptBox.setSelected(prefs.getBool("manualAccept", false));
      useFormulaBox.setSelected(prefs.getBool("useFormula", true));

      // Disable isRated for guests
      if (getUser().isGuest()) {
        isRatedBox.setSelected(false);
        isRatedBox.setEnabled(false);
      }

      createUI();
    }