コード例 #1
0
 @Test
 public void ensureSelectionModelUpdatesWhenValueChangesToNull() {
   box.getItems().addAll("Apple", "Orange", "Banana");
   box.setValue("pineapple");
   assertEquals("pineapple", box.getSelectionModel().getSelectedItem());
   assertEquals("pineapple", box.getValue());
   box.setValue(null);
   assertEquals(null, box.getSelectionModel().getSelectedItem());
   assertEquals(-1, box.getSelectionModel().getSelectedIndex());
   assertEquals(null, box.getValue());
 }
コード例 #2
0
 @Test
 public void ensureSelectionModelUpdatesWhenValueChanges() {
   box.getItems().addAll("Apple", "Orange", "Banana");
   assertNull(box.getSelectionModel().getSelectedItem());
   box.setValue("Orange");
   assertEquals("Orange", box.getSelectionModel().getSelectedItem());
 }
コード例 #3
0
  void generateBackupPaths() {
    ObservableList restorePaths = FXCollections.observableArrayList();
    restorePaths.clear();
    vBarBDirs.getChildren().clear();
    //        cbRestoreDirectory.getItems().clear();
    String[] backupArr = constants.getValue("s_dumpDir").split(";");
    for (final String dir : backupArr) {
      restorePaths.add(dir);
      HBox hbox = new HBox();
      Label lbl = new Label(dir);
      Button btn = new Button("Delete");
      btn.setOnAction(
          new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent event) {
              String nString = constants.getValue("s_dumpDir");
              nString = nString.replaceAll(";" + dir, "");
              nString = nString.replaceAll(dir, "");
              constants.addValue("s_dumpDir", nString);
              System.out.println(constants.getValue("s_dumpDir"));
              txtDir.setText(nString);
              generateBackupPaths();
            }
          });
      hbox.getChildren().add(lbl);
      hbox.getChildren().add(btn);
      vBarBDirs.getChildren().add(hbox);
    }

    try {

      cbRestoreDirectory.setItems(restorePaths);
      cbRestoreDirectory.setValue(restorePaths.get(0));
      generateRestore(restorePaths.get(0).toString());
    } catch (Exception e) {
      e.printStackTrace();
    }
    cbRestoreDirectory
        .valueProperty()
        .addListener(
            new ChangeListener<String>() {
              @Override
              public void changed(ObservableValue ov, String t, String t1) {
                //                System.out.println(ov);
                //                System.out.println(t);
                //                System.out.println(t1);
                generateRestore(t1);
              }
            });
  }