Example #1
0
  public void initialize() {
    txtAPIKey
        .textProperty()
        .addListener(
            (obs, ov, nv) -> {
              ObservableList<String> styleClass = txtAPIKey.getStyleClass();
              if (!APIKey.isValid(nv)) {
                styleClass.removeAll("field-ok");
                if (!styleClass.contains("field-error")) styleClass.add("field-error");
              } else {
                styleClass.removeAll("field-error");
                if (!styleClass.contains("field-ok")) styleClass.add("field-ok");
              }
            });

    String apiKey = GW2Tools.inst().getAppSettings().apiKey.getValue();
    if (apiKey != null && apiKey.length() > 0) {
      txtAPIKey.setText(apiKey);
      chkbxRememberKey.setSelected(true);
    }

    GW2Tools.inst().getAssets().updateGW2Assets(this);
  }
Example #2
0
  @FXML
  void onApply(ActionEvent event) {
    APIKey apiKey;
    try {
      apiKey = APIKey.of(txtAPIKey.getText());
    } catch (GW2APIException e) {
      // TODO feedback
      return;
    }

    GW2Tools.inst().getAppSettings().apiKey.setValue(apiKey.getKey());
    if (!chkbxRememberKey.isSelected()) {
      GW2Tools.inst().getAppSettings().apiKey.setValue(null);
    }
    GW2Tools.inst()
        .getSettingsManager()
        .saveFXSettingsSheet(
            GW2Tools.inst().getAppSettings(), Arrays.asList("apiKey")); // TODO hacked saved fix!
    GW2Tools.inst().getAppSettings().apiKey.setValue(apiKey.getKey());
    GW2Tools.inst().setAccount(GW2API.inst().getAccount(apiKey));
    showApplication();
  }
Example #3
0
 private void showApplication() {
   GW2Tools.inst().getApplicationPane().setCenter(GW2Tools.inst().getApp().getRootPane());
 }