Esempio n. 1
1
  private final void updateState() {

    // This used to be synchronized but now we do this instead
    if (!Platform.isFxApplicationThread()) {
      throw new IllegalThreadStateException("Must be on the Fx App Thread");
    }

    Map<String, Advisory> advisories = evaluateState();

    State newState = evaluateAdvisories(advisories);

    // Advisory processing
    if (newState != State.Normal) {

      Date now = new Date(System.currentTimeMillis());
      String time = timeFormat.format(now);

      warningTextBuilder.delete(0, warningTextBuilder.length());
      for (Advisory a : advisories.values()) {
        Advisory.toMessage(warningTextBuilder, a);
        warningTextBuilder.append("\r\n");
      }

      warningTextBuilder.append("at ").append(time);
      warningText.set(warningTextBuilder.toString());
    } else {
      warningText.set(getStatusOKMessage());
    }

    state.set(new StateChange(newState, advisories));
  }
Esempio n. 2
0
 public String commandString() {
   StringBuilder sb = new StringBuilder();
   for (StringProperty argProperty : this.commandArgs().getValue()) {
     sb.append(argProperty.getValue()).append(" ");
   }
   return sb.toString();
 }
Esempio n. 3
0
  @Override
  public void bridgeEstablished() {
    /* Only rebuild launchers if the updater is not waiting for the bridge to come back,
     * as the GUI will be restarted shortly */
    if (updateScene == null
        || (!updateScene.isAwaitingBridgeEstablish() && !updateScene.isAwaitingGUIRestart())) {

      log.info(String.format("Bridge established, rebuilding all launchers"));
      rebuildAllLaunchers();
      if (context.getBridge().isServiceUpdating()) {
        setMode(Mode.UPDATE);
      } else {
        final StringProperty prop = Configuration.getDefault().temporaryOnStartConnectionProperty();
        String tmp = prop.get();
        if (!StringUtils.isBlank(tmp)) {
          try {
            Connection c =
                context.getBridge().getConnectionService().getConnection(Long.parseLong(tmp));
            if (c == null) throw new Exception("No connection with id of " + tmp);
            log.info(
                String.format(
                    "Using temporary 'on start' connection %d (%s)", c.getId(), c.getHostname()));
            context.getBridge().connect(c);
          } catch (Exception e) {
            log.error("Failed to start temporary 'on start' connection.", e);
          }
          prop.set("");
        }
      }
    }
  }
Esempio n. 4
0
  @Override
  protected void activate() {
    currencyComboBox.setItems(model.getTradeCurrencies());
    currencyComboBox.getSelectionModel().select(model.getTradeCurrency());
    currencyComboBox.setVisibleRowCount(Math.min(currencyComboBox.getItems().size(), 25));
    currencyComboBox.setOnAction(
        e -> {
          model.onSetTradeCurrency(currencyComboBox.getSelectionModel().getSelectedItem());
          updateChartData();
        });

    model.getOfferBookListItems().addListener(changeListener);
    tradeCurrencySubscriber =
        EasyBind.subscribe(
            model.tradeCurrency,
            newValue -> {
              String code = newValue.getCode();
              areaChart.setTitle("Offer book for " + newValue.getName());
              priceColumnLabel.set("Price (" + code + "/BTC)");
              volumeColumnLabel.set("Volume (" + code + ")");
              xAxis.setLabel(priceColumnLabel.get());
              xAxis.setTickLabelFormatter(new NumberAxis.DefaultFormatter(xAxis, "", ""));
            });

    buyOfferTableView.setItems(model.getBuyOfferList());
    sellOfferTableView.setItems(model.getSellOfferList());

    updateChartData();
  }
  @Override
  public void initialize(URL url, ResourceBundle resourceBundle) {
    StringProperty appName = new SimpleStringProperty("ElsassBrowser");
    StringExpression appTitle = appName.concat(" - ");
    appTitle = appTitle.concat(this.presentationView.getEngine().titleProperty());

    ElsassBrowser.getCurrentStage().titleProperty().bind(appTitle);
  }
Esempio n. 6
0
 private void setListener() {
   @Nullable StringProperty fieldTextProperty = textProperty();
   if (fieldTextProperty == null) {
     throw new ZeusRuntimeException("NaturalField: textProperty is null");
   }
   @NotNull ChangeListener<String> fieldAddListener = prepareAddListener();
   fieldTextProperty.addListener(fieldAddListener);
 }
Esempio n. 7
0
  @Override
  public void initialize(URL location, ResourceBundle resources) {
    localeName.bind(ProgramProperty.localeName);
    localeName.addListener(
        (observ, old, value) -> setElementText(Controller.getResourceBundle(new Locale(value))));

    setElementText(
        Controller.getResourceBundle(
            new Locale(SingleObject.getProgramSettings().getLocaleName())));
  }
 @Override
 protected final void updateItem(LocalFile item, boolean empty) {
   super.updateItem(item, empty);
   icon.set(null);
   title.setValue("");
   if (!empty) {
     icon.set(item.getIcon());
     title.setValue(item.getFileName());
   }
 }
 @Override
 public String toString() {
   return "Admin [adminName="
       + adminName.getValue()
       + ", adminLevel="
       + adminLevel.getValue()
       + ", adminId="
       + adminId.getValue()
       + "]";
 }
    /**
     * Determines if a group is empty
     *
     * @param group The group to check
     * @return true if the group has no values, false if there is at least one value in the group
     */
    private boolean groupEmpty(Map<String, Set<StringProperty>> group) {
      for (Map.Entry<String, Set<StringProperty>> entry : group.entrySet()) {
        for (StringProperty property : entry.getValue()) {
          if (property != null && property.getValue() != null && !property.getValue().isEmpty()) {
            return false;
          }
        }
      }

      return true;
    }
Esempio n. 11
0
  public void bind(final StringProperty property, final String propertyName) {
    String value = props.getProperty(propertyName);
    if (value != null) {
      property.set(value);
    }

    property.addListener(
        o -> {
          props.setProperty(propertyName, property.getValue());
        });
  }
Esempio n. 12
0
  @Override
  public int hashCode() {
    int result = 17;
    result = 31 * result + id;
    result = 31 * result + (firstName.get() != null ? firstName.get().hashCode() : 0);
    result = 31 * result + (lastName.get() != null ? lastName.get().hashCode() : 0);
    result = 31 * result + age.get();
    result = 31 * result + salary.get();
    result = 31 * result + (hired.get() != null ? hired.get().hashCode() : 0);
    result = 31 * result + (dismissal.get() != null ? dismissal.get().hashCode() : 0);

    return result;
  }
Esempio n. 13
0
 @Override
 public String toString() {
   return "First name: "
       + firstName.get()
       + ", Last name: "
       + lastName.get()
       + ", Age: "
       + age.get()
       + ", Salary: "
       + salary.get()
       + ", Hired date: "
       + hired.get()
       + (dismissal.get() != null ? ", Dismissal date: " + dismissal.get() : "");
 }
Esempio n. 14
0
  static {
    preferences = Preferences.userNodeForPackage(ThemeManager.class);

    final StringProperty _baseColorProperty = new SimpleStringProperty();

    // restore the old value
    fontScaleProperty.set(preferences.getDouble(FONT_SIZE, 1));

    // Save the value when it changes
    fontScaleProperty.addListener(
        (observable, oldValue, newValue) -> {
          if (newValue != null) {
            preferences.putDouble(FONT_SIZE, newValue.doubleValue());
          }
        });

    baseColorProperty.setValue(Color.web(preferences.get(BASE_COLOR, DEFAULT_MODENA_BASE_COLOR)));

    // restore the old base color value
    switch (preferences.get(LAST, Application.STYLESHEET_MODENA)) {
      case Application.STYLESHEET_CASPIAN:
        baseColorProperty.setValue(
            Color.web(preferences.get(BASE_COLOR, DEFAULT_CASPIAN_BASE_COLOR)));
        break;
      case Application.STYLESHEET_MODENA:
        baseColorProperty.setValue(
            Color.web(preferences.get(BASE_COLOR, DEFAULT_MODENA_BASE_COLOR)));
        break;
      default:
        baseColorProperty.setValue(
            Color.web(preferences.get(BASE_COLOR, DEFAULT_MODENA_BASE_COLOR)));
    }

    _baseColorProperty.setValue(colorToHex(baseColorProperty.getValue()));

    // Save the value when it changes
    baseColorProperty.addListener(
        (observable, oldValue, newValue) -> {
          if (newValue != null) {
            preferences.put(BASE_COLOR, colorToHex(newValue));
            _baseColorProperty.setValue(colorToHex(newValue));
          }
        });

    // Create the binding format for the style / font size
    styleProperty =
        Bindings.format(
            "-fx-font-size: %1$.6fem; -fx-base:%2$s", fontScaleProperty, _baseColorProperty);
  }
 @Override
 public String toString() {
   StringBuilder builder = new StringBuilder();
   builder.append(_Visibility.getValue()).append(" ");
   if (_IsFinal.getValue()) builder.append("final").append(" ");
   if (_IsStatic.getValue()) builder.append("static ");
   builder.append(_Type.getValue()).append(" ");
   builder.append(_Name.getValue()).append(" ");
   builder.append(" = ").append(_DefaultValue.getValue());
   builder.append("\n");
   builder.append("annotations:\n");
   for (StringProperty str : _Annotations) builder.append(str).append("\n");
   builder.append("\n");
   return builder.toString();
 }
Esempio n. 16
0
 public final void setCharacter(final Character CHARACTER) {
   if (null == character) {
     _character = String.valueOf(CHARACTER);
   } else {
     character.set(String.valueOf(CHARACTER));
   }
 }
Esempio n. 17
0
 public final void setCharacter(final String CHARACTER) {
   if (null == character) {
     _character = CHARACTER;
   } else {
     character.set(CHARACTER);
   }
 }
Esempio n. 18
0
  @Override
  public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;

    Task task = (Task) o;

    if (!shortName.get().equals(task.shortName.get())) return false;
    if (description.get() != null
        ? !description.get().equals(task.description.get())
        : task.description.get() != null) return false;
    if (estimate.get() != (task.estimate.get())) return false;
    return !(status.get() != null
        ? !status.get().equals(task.status.get())
        : task.status.get() != null);
  }
  @Override
  public void doDeactivate() {
    txId.unbind();

    dataModel.getSellerProcessState().removeListener(sellerStateListener);
    dataModel.getBuyerProcessState().removeListener(buyerStateListener);
  }
Esempio n. 20
0
  private void createChart() {
    xAxis = new NumberAxis();
    xAxis.setForceZeroInRange(false);
    xAxis.setAutoRanging(true);
    xAxis.setLabel(priceColumnLabel.get());

    yAxis = new NumberAxis();
    yAxis.setForceZeroInRange(false);
    yAxis.setAutoRanging(true);
    yAxis.setLabel("Amount in BTC");
    yAxis.setTickLabelFormatter(new NumberAxis.DefaultFormatter(yAxis, "", ""));

    seriesBuy = new XYChart.Series();
    seriesBuy.setName("Offers for  buy bitcoin  ");

    seriesSell = new XYChart.Series();
    seriesSell.setName("Offers for sell bitcoin");

    areaChart = new AreaChart<>(xAxis, yAxis);
    areaChart.setAnimated(false);
    areaChart.setId("charts");
    areaChart.setMinHeight(300);
    areaChart.setPadding(new Insets(0, 30, 10, 0));
    areaChart.getData().addAll(seriesBuy, seriesSell);
  }
 @Override
 protected Task<Void> createTask() {
   SynchronizePlaylistTask task = new SynchronizePlaylistTask(drive, playlist);
   task.setDelete(delete);
   srvProgress.bind(progressProperty());
   progressString.bind(task.progressStringProperty());
   return task;
 }
 @Override
 public String toString() {
   return "LuceneSearchTypeFilter [searchParameter="
       + searchParameter.get()
       + ", isValid="
       + isValid.get()
       + "]";
 }
Esempio n. 23
0
  private void handleAlert(WebEvent<String> event) {
    numberOfAlerts.setValue(Integer.toString(Integer.valueOf(numberOfAlerts.getValue()) + 1));
    String message = event.getData();

    /*
     * Handle all the external onAlert event handlers first.
     */
    for (EventHandler<WebEvent<String>> handler : alertListeners) handler.handle(event);

    /*
     * Finally display an alert box if the operator demands it.
     */
    if (showAlerts.getValue()) {
      dialog.title("JavaScript Alert").message(message).showInformation();
      resetParents();
    }
  }
Esempio n. 24
0
 @Override
 public String toString() {
   return "Pessoa{"
       + "id="
       + id.get()
       + ",\nnome="
       + nome.get()
       + ", \ndataNasc="
       + dataNasc.get()
       + ", \napelido="
       + apelido.get()
       + ", \nendereco="
       + endereco.get()
       + ", \nimg="
       + img.get()
       + '}';
 }
Esempio n. 25
0
 @Override
 public void setValue(String edit) throws VariableWrongTypeException {
   if (Regex.getInstance().getType(edit) == GeneralType.CONSTANT) {
     View.getInstance()
         .showDialog(
             "The edited value looks like a variable, but since this is a String variable, the edit will be interpreted as a string. Use the command line to change types.");
   }
   myProperty.set(edit);
 }
Esempio n. 26
0
    //		Validator getValidator() { return validator; }
    void setValidator(Validator v) {
      if (valuePropertyListener != null) {
        valueProperty.removeListener(valuePropertyListener);
      }
      validator = v;

      if (validator != null) {
        valueProperty.addListener(
            new ChangeListener<String>() {
              @Override
              public void changed(
                  ObservableValue<? extends String> observable, String oldValue, String newValue) {
                statusProperty.set(validator.isValid());
              }
            });
        statusProperty.set(validator.isValid());
      }
    }
Esempio n. 27
0
  @Override
  public void start(Stage primaryStage) {
    primaryStage.setTitle("JavaFX TextField example");

    VBox mainLayout = new VBox();

    HBox fieldLayout = new HBox();

    TextField textField = new TextField();
    Button button = new Button("X");
    button.setDisable(true);
    textField
        .textProperty()
        .addListener(
            (obj, oldVal, newVal) -> {
              if (newVal.trim().isEmpty()) {
                button.setDisable(true);
              } else {
                button.setDisable(false);
              }
            });

    textField.textProperty().bindBidirectional(obs);

    fieldLayout.getChildren().addAll(textField, button);

    HBox buttons = new HBox();
    Button clear = new Button("Clear");
    clear.setOnAction(e -> obs.set(""));
    Button setVal = new Button("Set value");
    setVal.setOnAction(e -> obs.set("Hello"));
    Button dump = new Button("Dump");
    dump.setOnAction(e -> System.err.println("Current: " + obs.get()));
    buttons.getChildren().addAll(clear, setVal, dump);

    mainLayout.getChildren().addAll(fieldLayout, buttons);

    // show the generated scene graph
    Scene scene = new Scene(mainLayout);
    primaryStage.setScene(scene);
    primaryStage.show();
  }
  @Override
  public void doActivate() {
    txId.bind(dataModel.getTxId());

    dataModel.getSellerProcessState().addListener(sellerStateListener);
    dataModel.getBuyerProcessState().addListener(buyerStateListener);

    if (dataModel.getTrade() != null) {
      applySellerState();
      applyBuyerState();
    }
  }
 @Override
 public void refresh() {
   rawAmount.set("");
   App.apiProxy.getCharges(
       new RunLaterCallback<List<Charge>>() {
         @Override
         public void laterSuccess(List<Charge> charges) {
           charges.sort((o1, o2) -> o1.getWeight() - o2.getWeight());
           lvCharges.setItems(FXCollections.observableList(charges));
         }
       });
 }
Esempio n. 30
-1
 @Override
 public int hashCode() {
   int result = shortName.hashCode();
   result = 31 * result + (description != null ? description.hashCode() : 0);
   result = 31 * result + estimate.hashCode();
   result = 31 * result + (status != null ? status.hashCode() : 0);
   return result;
 }