Search in sources :

Example 1 with YoutubeQuality

use of com.github.axet.vget.vhs.YouTubeInfo.YoutubeQuality in project Gargoyle by callakrsos.

the class UtubeDownloaderComposite method initialize.

@FXML
public void initialize() {
    btnDownload.setDisable(true);
    this.txtDownloadLocation.setText(System.getProperty("user.home"));
    this.txtDownloadLocation.setPromptText("Downlaod Location");
    // this.lvDownlaodCont.setCellFactory(new Callback<ListView<UtubeItemDVO>, ListCell<UtubeItemDVO>>() {
    //
    // @Override
    // public ListCell<UtubeItemDVO> call(ListView<UtubeItemDVO> param) {
    // return new UtubeListCell();
    // }
    // });
    // this.lvDownlaodCont.setOnDragDetected(ev -> {
    // ev.setDragDetect(true);
    // });
    txtUtubeURL.setOnDragOver(ev -> {
        if (ev.getDragboard().hasUrl()) {
            ev.acceptTransferModes(TransferMode.LINK);
            ev.consume();
        }
    });
    txtUtubeURL.setOnDragDropped(ev -> {
        Dragboard dragboard = ev.getDragboard();
        String url = dragboard.getUrl();
        txtUtubeURL.setText(url);
    });
    txtUtubeURL.textProperty().addListener((oba, o, n) -> {
        btnDownload.setDisable(n.trim().isEmpty());
    });
    // 초기값
    this.cbQuality.getItems().addAll(YoutubeQuality.values());
    // 디폴트
    this.cbQuality.getSelectionModel().select(YoutubeQuality.p480);
    this.cbQuality.setCellFactory(new Callback<ListView<YoutubeQuality>, ListCell<YoutubeQuality>>() {

        @Override
        public ListCell<YoutubeQuality> call(ListView<YoutubeQuality> param) {
            return new TextFieldListCell<>(new StringConverter<YoutubeQuality>() {

                @Override
                public String toString(YoutubeQuality object) {
                    return object.name();
                }

                @Override
                public YoutubeQuality fromString(String string) {
                    return YoutubeQuality.valueOf(string);
                }
            });
        }
    });
    this.wasDownloading.addListener((oba, o, n) -> {
        if (n != null)
            this.btnDownload.setDisable(n.booleanValue());
    });
    this.downloadedFile.addListener((oba, o, n) -> {
        if (n != null && n.exists()) {
            //				btnOpen.setDisable(false);
            this.txtFileName.setText(n.getName());
        } else {
        //				btnOpen.setDisable(true);
        }
    });
}
Also used : ListView(javafx.scene.control.ListView) YoutubeQuality(com.github.axet.vget.vhs.YouTubeInfo.YoutubeQuality) ListCell(javafx.scene.control.ListCell) TextFieldListCell(javafx.scene.control.cell.TextFieldListCell) StringConverter(javafx.util.StringConverter) Dragboard(javafx.scene.input.Dragboard) FXML(javafx.fxml.FXML)

Aggregations

YoutubeQuality (com.github.axet.vget.vhs.YouTubeInfo.YoutubeQuality)1 FXML (javafx.fxml.FXML)1 ListCell (javafx.scene.control.ListCell)1 ListView (javafx.scene.control.ListView)1 TextFieldListCell (javafx.scene.control.cell.TextFieldListCell)1 Dragboard (javafx.scene.input.Dragboard)1 StringConverter (javafx.util.StringConverter)1