Пример #1
0
  @Override
  public void initialize(URL location, ResourceBundle resources) {
    controller = GitController.sharedController();
    commandListView.setItems(controller.commands);

    dropPane.addEventHandler(
        DragEvent.DRAG_OVER,
        (DragEvent event) -> {
          Dragboard db = event.getDragboard();
          if (db.hasFiles()) {
            event.acceptTransferModes(TransferMode.ANY);
          }
          event.consume();
        });

    dropPane.addEventHandler(
        DragEvent.DRAG_DROPPED,
        (DragEvent event) -> {
          Dragboard db = event.getDragboard();
          db.getFiles()
              .stream()
              .findFirst()
              .ifPresent(
                  (File file) -> {
                    File dir = file.isDirectory() ? file : file.getParentFile();
                    File repository = controller.findRepository(dir);
                    if (repository == null) {
                      controller.init(dir);
                    }
                    controller.add(file);

                    this.textField.setText(controller.getCurrentRepository().getParent() + "/");
                  });
          event.setDropCompleted(true);
        });
  }
Пример #2
0
 @FXML
 private void commitButtonDidPush() {
   controller.commit();
 }