use of javafx.util.StringConverter 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.util.StringConverter in project Gargoyle by callakrsos.
the class IExcelScreenHandler method valueMapper.
/**
* 테이블컬럼의 row에 해당하는 데이터가 무엇인지 정의한 값에 따라 엑셀에 표현됨.
*
* StringConverter를 이용한 TableCell인경우 정의된 StringConvert를 이용한 데이터를 Excel의
* Cell에 쓰고, StringConverter를 이용하지않는 UI의 TableCell의 경우 데이터셋에 바인드된 값을 사용하게됨.
*
* 작성된 API내에서 적절한 값이 아니라고 판단되는경우 Ovrride해서 재정의하도록한다.
*
* @작성자 : KYJ
* @작성일 : 2016. 9. 9.
* @param table
* 사용자 화면에 정의된 tableView
* @param column
* 사용자 화면에 정의된 tableColumn
* @param columnIndex
* 사용자 화면에 정의된 tableColumn의 인덱스
* @param rowIndex
* 사용자 화면에 정의된 tableCell의 인덱스
* @return Object 테이블셀에 정의된 데이터를 리턴할 값으로, 리턴해주는 값이 엑셀에 write된다.
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
public default default <T> Object valueMapper(TableView<?> table, TableColumn<?, ?> column, int columnIndex, int rowIndex) {
Callback cellFactory = column.getCellFactory();
if (cellFactory != null) {
TableCell cell = (TableCell) cellFactory.call(column);
if (cell != null) {
StringConverter converter = null;
if (cell instanceof TextFieldTableCell) {
TextFieldTableCell txtCell = (TextFieldTableCell) cell;
converter = txtCell.getConverter();
} else // }
if (cell instanceof ComboBoxTableCell) {
ComboBoxTableCell txtCell = (ComboBoxTableCell) cell;
converter = txtCell.getConverter();
} else // else if (cell instanceof HyperlinkTableCell) {
// HyperlinkTableCell txtCell = (HyperlinkTableCell) cell;
// converter = txtCell.getConverter();
// }
/* else 기본값. */
{
try {
Method m = cell.getClass().getMethod("converterProperty");
if (m != null) {
Object object = m.invoke(cell);
if (object != null && object instanceof ObjectProperty) {
ObjectProperty<StringConverter> convert = (ObjectProperty<StringConverter>) object;
converter = convert.get();
}
}
} catch (Exception e) {
// Nothing...
}
}
if (converter != null) {
Object cellData = column.getCellData(rowIndex);
return converter.toString(cellData);
}
}
}
return column.getCellData(rowIndex);
}
use of javafx.util.StringConverter in project bitsquare by bitsquare.
the class GUIUtil method getCurrencyListItemConverter.
public static StringConverter<CurrencyListItem> getCurrencyListItemConverter(String postFix, Preferences preferences) {
return new StringConverter<CurrencyListItem>() {
@Override
public String toString(CurrencyListItem item) {
TradeCurrency tradeCurrency = item.tradeCurrency;
String code = tradeCurrency.getCode();
if (code.equals(GUIUtil.SHOW_ALL_FLAG))
return "▶ Show all";
else if (code.equals(GUIUtil.EDIT_FLAG))
return "▼ Edit currency list";
else {
String displayString = CurrencyUtil.getNameByCode(code) + " (" + code + ")";
if (preferences.getSortMarketCurrenciesNumerically())
displayString += " - " + item.numTrades + " " + postFix;
return tradeCurrency.getDisplayPrefix() + displayString;
}
}
@Override
public CurrencyListItem fromString(String s) {
return null;
}
};
}
use of javafx.util.StringConverter in project POL-POM-5 by PhoenicisOrg.
the class ChooseRepositoryTypePanel method populate.
/**
* Populates the content of this component
*/
private void populate() {
choiceBox = new ComboBox<>(repositoryChoices);
choiceBox.setPromptText(tr("Please select the repository type you want to add"));
choiceBox.setConverter(new StringConverter<RepositoryType>() {
@Override
public String toString(RepositoryType repositoryType) {
return repositoryType.getLabel();
}
@Override
public RepositoryType fromString(String string) {
return Arrays.stream(RepositoryType.values()).filter(type -> type.getLabel().equals(string)).findAny().orElse(null);
}
});
choiceBox.setOnAction(event -> onRepositoryTypeSelection.accept(choiceBox.getSelectionModel().getSelectedItem()));
Label choiceBoxLabel = new Label(tr("Repository type:"));
choiceBoxLabel.setLabelFor(choiceBox);
HBox content = new HBox(choiceBoxLabel, choiceBox);
content.setId("repositoryTypeSelection");
HBox.setHgrow(choiceBox, Priority.ALWAYS);
this.setCenter(content);
}
use of javafx.util.StringConverter in project bisq-desktop by bisq-network.
the class FiatAccountsView method addNewAccount.
// Add new account form
private void addNewAccount() {
paymentAccountsListView.getSelectionModel().clearSelection();
removeAccountRows();
addAccountButton.setDisable(true);
accountTitledGroupBg = addTitledGroupBg(root, ++gridRow, 1, Res.get("shared.createNewAccount"), Layout.GROUP_DISTANCE);
// noinspection unchecked
paymentMethodComboBox = addLabelComboBox(root, gridRow, Res.getWithCol("shared.paymentMethod"), Layout.FIRST_ROW_AND_GROUP_DISTANCE).second;
paymentMethodComboBox.setPromptText(Res.get("shared.selectPaymentMethod"));
paymentMethodComboBox.setVisibleRowCount(11);
paymentMethodComboBox.setPrefWidth(250);
List<PaymentMethod> list = PaymentMethod.getAllValues().stream().filter(paymentMethod -> !paymentMethod.getId().equals(PaymentMethod.BLOCK_CHAINS_ID)).collect(Collectors.toList());
paymentMethodComboBox.setItems(FXCollections.observableArrayList(list));
paymentMethodComboBox.setConverter(new StringConverter<PaymentMethod>() {
@Override
public String toString(PaymentMethod paymentMethod) {
return paymentMethod != null ? Res.get(paymentMethod.getId()) : "";
}
@Override
public PaymentMethod fromString(String s) {
return null;
}
});
paymentMethodComboBox.setOnAction(e -> {
if (paymentMethodForm != null) {
FormBuilder.removeRowsFromGridPane(root, 3, paymentMethodForm.getGridRow() + 1);
GridPane.setRowSpan(accountTitledGroupBg, paymentMethodForm.getRowSpan() + 1);
}
gridRow = 2;
paymentMethodForm = getPaymentMethodForm(paymentMethodComboBox.getSelectionModel().getSelectedItem());
if (paymentMethodForm != null) {
paymentMethodForm.addFormForAddAccount();
gridRow = paymentMethodForm.getGridRow();
Tuple2<Button, Button> tuple2 = add2ButtonsAfterGroup(root, ++gridRow, Res.get("shared.saveNewAccount"), Res.get("shared.cancel"));
saveNewAccountButton = tuple2.first;
saveNewAccountButton.setOnAction(event -> onSaveNewAccount(paymentMethodForm.getPaymentAccount()));
saveNewAccountButton.disableProperty().bind(paymentMethodForm.allInputsValidProperty().not());
Button cancelButton = tuple2.second;
cancelButton.setOnAction(event -> onCancelNewAccount());
GridPane.setRowSpan(accountTitledGroupBg, paymentMethodForm.getRowSpan() + 1);
}
});
}
Aggregations