use of javafx.scene.control.cell.TextFieldListCell 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);
}
});
}
use of javafx.scene.control.cell.TextFieldListCell in project Gargoyle by callakrsos.
the class ArticleExtractorComposite method initialize.
@FXML
public void initialize() {
cbAlgorisms.getItems().addAll(ValueUtil.HTML.getAvaliablesExtractorBase());
cbAlgorisms.getSelectionModel().select(ArticleExtractor.class);
cbAlgorisms.setCellFactory(new Callback<ListView<Class<? extends ExtractorBase>>, ListCell<Class<? extends ExtractorBase>>>() {
@Override
public ListCell<Class<? extends ExtractorBase>> call(ListView<Class<? extends ExtractorBase>> param) {
return new TextFieldListCell<>(new StringConverter<Class<? extends ExtractorBase>>() {
@Override
public String toString(Class<? extends ExtractorBase> object) {
return object.getSimpleName();
}
@Override
public Class<? extends ExtractorBase> fromString(String string) {
// TODO Auto-generated method stub
return null;
}
});
}
});
cbAlgorisms.setConverter(new StringConverter<Class<? extends ExtractorBase>>() {
@Override
public String toString(Class<? extends ExtractorBase> object) {
return object.getSimpleName();
}
@Override
public Class<? extends ExtractorBase> fromString(String string) {
// TODO Auto-generated method stub
return null;
}
});
cbAlgorisms.valueProperty().addListener((oba, o, n) -> {
Class<? extends ExtractorBase> algorism = n;
// webPreview.getEngine().getDocument().getBaseURI();
String baseURI = txtUrl.getText();
if (ValueUtil.isEmpty(baseURI))
return;
RealtimeSearchItemVO vo = new RealtimeSearchItemVO();
vo.setLink(baseURI);
try {
URLModel htmlContent = getHTMLContent(vo);
if (!htmlContent.isEmpty()) {
String boilderPipe = boilderPipe(algorism, htmlContent.getContent());
txtResult.setText(boilderPipe);
}
} catch (Exception e) {
e.printStackTrace();
}
});
cbSmmy.valueProperty().addListener((oba, o, n) -> {
txtSummary.setText(n.getUrl());
txtSummary.nextWord();
txtSummary.appendText(n.getContent());
});
StringConverter<URLModel> converter = new StringConverter<URLModel>() {
@Override
public String toString(URLModel object) {
return String.format("[%s] - %s", object.getTitle(), object.getUrl());
}
@Override
public URLModel fromString(String string) {
return null;
}
};
cbSmmy.setCellFactory(param -> {
TextFieldListCell<URLModel> textFieldListCell = new TextFieldListCell<>(converter);
textFieldListCell.setMaxWidth(600d);
textFieldListCell.setPrefWidth(600d);
return textFieldListCell;
});
/** Size the combo-box drop down list. */
cbSmmy.setConverter(converter);
Platform.runLater(() -> {
request(userData);
// Platform.runLater(() -> {
// WebEngine engine = webPreview.getEngine();
// engine.getLoadWorker().stateProperty().addListener((ChangeListener<State>)
// (ov, oldState, newState) -> {
// LOGGER.debug("{} - {}", newState.name(), engine.getLocation());
//
// if (newState == Worker.State.RUNNING) {
// String location = engine.getLocation();
// if (ValueUtil.isNotEmpty(location)) {
//
// Class<? extends ExtractorBase> algorism = cbAlgorisms.getValue();
// RealtimeSearchItemVO vo = new RealtimeSearchItemVO();
// vo.setLink(location);
// try {
// updateMainContent(algorism, getHTMLContent(vo));
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
//
// }
// });
// txtUrl.textProperty().addListener((oba, o, n) -> {
//
// if (ValueUtil.isNotEmpty(n)) {
// RealtimeSearchItemVO realtimeSearchItemVO = new
// RealtimeSearchItemVO();
// realtimeSearchItemVO.setLink(n);
// request(userData);
// }
//
// });
});
// engine.load(url);
// engine.getLoadWorker().messageProperty().addListener((oba, o, n) -> {
// LOGGER.debug("Browser Message : {}", n);
// });
// engine.setJavaScriptEnabled(true);
// HTML 코드를 engine에서 얻기위한 처리가 필요함.
// org.w3c.dom.Document doc = engine.getDocument();
// try {
// Transformer transformer =
// TransformerFactory.newInstance().newTransformer();
// transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no");
// transformer.setOutputProperty(OutputKeys.METHOD, "xml");
// transformer.setOutputProperty(OutputKeys.INDENT, "yes");
// transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
// transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount",
// "4");
//
// try (ByteArrayOutputStream outputStream = new
// ByteArrayOutputStream()) {
//
// try (OutputStreamWriter writer = new OutputStreamWriter(outputStream,
// "UTF-8")) {
// transformer.transform(new DOMSource(doc), new StreamResult(writer));
// Class<? extends ExtractorBase> algorism = cbAlgorisms.getValue();
// String boilderPipe = boilderPipe(algorism,
// outputStream.toString("UTF-8"));
// txtResult.setText(boilderPipe);
// }
// }
//
// } catch (Exception ex) {
// txtResult.setText(
// String.format("[%s] Something Problems Occured. \n\nStackTrace : {}",
// newState.name(), ValueUtil.toString(ex)));
// }
// } else {
// txtResult.setText("Waitings.... " + newState.name());
// }
// });
}
Aggregations