Esempio n. 1
0
  @Test
  public void test() throws IOException {
    Settings config =
        new SettingsBuilder()
            .addDefaultsFromClasspath()
            .addGeneratedDefaultsFromClasspath()
            .build();
    assertNotNull(config);
    assertTrue(config.getBoolean("auto"));

    assertEquals("bar", config.getString("foo"));

    assertFalse(config.getBoolean("hey", false));
    assertNull(config.getString("Nothing!"));

    assertEquals("whoopty", config.getString("whee"));
  }
  @Override
  public void initialize(URL url, ResourceBundle resourceBundle) {
    playMusic.setSelected(settings.getBoolean("playMusic", true));
    playSound.setSelected(settings.getBoolean("playSound", true));
    for (Node checkBox : settingsRegion.getChildrenUnmodifiable()) {
      HBox.setHgrow(checkBox, Priority.ALWAYS);
    }

    logo.fitWidthProperty().bind(root.widthProperty());
  }
Esempio n. 3
0
 private void loadSettings() {
   for (int i = 0; i < DefaultSettings.RESOLUTIONS.length; i++) {
     Dimension resolution = DefaultSettings.RESOLUTIONS[i];
     cbxResolution.addItem(getResolutionString(resolution));
     if ((resolution.getWidth() == Settings.getInteger("resolution_width"))
         && (resolution.getHeight() == Settings.getInteger("resolution_height"))) {
       cbxResolution.setSelectedIndex(i);
     }
   }
   cbxFullscreen.setSelected(Settings.getBoolean("fullscreen"));
   for (int i = 0; i < DefaultSettings.ANTIALIASING_SAMPLES.length; i++) {
     int antiAliasingSamples = DefaultSettings.ANTIALIASING_SAMPLES[i];
     cbxAntialiasing.addItem(
         (antiAliasingSamples != 0) ? antiAliasingSamples + "x" : "Deactivated");
     if (antiAliasingSamples == Settings.getInteger("antialiasing")) {
       cbxAntialiasing.setSelectedIndex(i);
     }
   }
   cbxVSync.setSelected(Settings.getBoolean("vsync"));
   cbxHardwareSkinning.setSelected(Settings.getBoolean("hardware_skinning"));
   sldShadowQuality.setValue(Settings.getInteger("shadow_quality"));
 }
Esempio n. 4
0
 @Inject
 PasswordHasher(Settings settings, Charset charset) throws NoSuchAlgorithmException {
   this.charset = charset;
   String salt = settings.getString(SETTINGS_KEY_PASSWORD_SALT, DEFAULT_SALT);
   String alg = settings.getString(SETTINGS_KEY_HASHING_ALGORITHM, DEFAULT_HASHING_ALGORITHM);
   if (settings.getBoolean("productionMode", false) && DEFAULT_SALT.equals(salt)) {
     throw new ConfigurationError(
         "Default password salt should not be used in "
             + "production mode.  Set property salt for namespace timetracker to "
             + "be something else");
   }
   saltBytes = salt.getBytes(charset);
   this.algorithm = alg;
   // fail early
   hash("abcd");
 }