Search in sources :

Example 6 with StringConverter

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);
        }
    });
}
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)

Example 7 with StringConverter

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);
}
Also used : ObjectProperty(javafx.beans.property.ObjectProperty) Callback(javafx.util.Callback) TextFieldTableCell(javafx.scene.control.cell.TextFieldTableCell) TableCell(javafx.scene.control.TableCell) ComboBoxTableCell(javafx.scene.control.cell.ComboBoxTableCell) TextFieldTableCell(javafx.scene.control.cell.TextFieldTableCell) Method(java.lang.reflect.Method) StringConverter(javafx.util.StringConverter) ComboBoxTableCell(javafx.scene.control.cell.ComboBoxTableCell)

Example 8 with StringConverter

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;
        }
    };
}
Also used : TradeCurrency(io.bitsquare.locale.TradeCurrency) StringConverter(javafx.util.StringConverter)

Example 9 with StringConverter

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);
}
Also used : Consumer(java.util.function.Consumer) HBox(javafx.scene.layout.HBox) Priority(javafx.scene.layout.Priority) Arrays(java.util.Arrays) Label(javafx.scene.control.Label) ComboBox(javafx.scene.control.ComboBox) FXCollections(javafx.collections.FXCollections) Localisation.tr(org.phoenicis.configuration.localisation.Localisation.tr) ObservableList(javafx.collections.ObservableList) BorderPane(javafx.scene.layout.BorderPane) StringConverter(javafx.util.StringConverter) HBox(javafx.scene.layout.HBox) Label(javafx.scene.control.Label)

Example 10 with StringConverter

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);
        }
    });
}
Also used : Button(javafx.scene.control.Button) PopmoneyValidator(bisq.desktop.util.validation.PopmoneyValidator) Coin(org.bitcoinj.core.Coin) ListCell(javafx.scene.control.ListCell) Layout(bisq.desktop.util.Layout) BSFormatter(bisq.desktop.util.BSFormatter) PaymentAccountFactory(bisq.core.payment.PaymentAccountFactory) WesternUnionAccount(bisq.core.payment.WesternUnionAccount) ComboBox(javafx.scene.control.ComboBox) Res(bisq.core.locale.Res) MoneyBeamValidator(bisq.desktop.util.validation.MoneyBeamValidator) BICValidator(bisq.desktop.util.validation.BICValidator) AliPayForm(bisq.desktop.components.paymentmethods.AliPayForm) PopmoneyForm(bisq.desktop.components.paymentmethods.PopmoneyForm) SwishForm(bisq.desktop.components.paymentmethods.SwishForm) VenmoForm(bisq.desktop.components.paymentmethods.VenmoForm) AliPayValidator(bisq.desktop.util.validation.AliPayValidator) SepaInstantForm(bisq.desktop.components.paymentmethods.SepaInstantForm) Popup(bisq.desktop.main.overlays.popups.Popup) ChaseQuickPayValidator(bisq.desktop.util.validation.ChaseQuickPayValidator) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) FormBuilder(bisq.desktop.util.FormBuilder) ClearXchangeValidator(bisq.desktop.util.validation.ClearXchangeValidator) PaymentMethod(bisq.core.payment.payload.PaymentMethod) Collectors(java.util.stream.Collectors) AccountAgeWitnessService(bisq.core.payment.AccountAgeWitnessService) OKPayForm(bisq.desktop.components.paymentmethods.OKPayForm) OKPayValidator(bisq.desktop.util.validation.OKPayValidator) VenmoValidator(bisq.desktop.util.validation.VenmoValidator) PaymentAccount(bisq.core.payment.PaymentAccount) List(java.util.List) CashDepositForm(bisq.desktop.components.paymentmethods.CashDepositForm) RevolutValidator(bisq.desktop.util.validation.RevolutValidator) AnchorPane(javafx.scene.layout.AnchorPane) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) UpholdForm(bisq.desktop.components.paymentmethods.UpholdForm) UserThread(bisq.common.UserThread) SpecificBankForm(bisq.desktop.components.paymentmethods.SpecificBankForm) IBANValidator(bisq.desktop.util.validation.IBANValidator) FasterPaymentsForm(bisq.desktop.components.paymentmethods.FasterPaymentsForm) MoneyBeamForm(bisq.desktop.components.paymentmethods.MoneyBeamForm) SwishValidator(bisq.desktop.util.validation.SwishValidator) ClearXchangeForm(bisq.desktop.components.paymentmethods.ClearXchangeForm) ListView(javafx.scene.control.ListView) FXCollections(javafx.collections.FXCollections) FxmlView(bisq.desktop.common.view.FxmlView) Inject(javax.inject.Inject) ClearXchangeAccount(bisq.core.payment.ClearXchangeAccount) Tuple2(bisq.common.util.Tuple2) USPostalMoneyOrderValidator(bisq.desktop.util.validation.USPostalMoneyOrderValidator) Tuple3(bisq.common.util.Tuple3) VPos(javafx.geometry.VPos) UpholdValidator(bisq.desktop.util.validation.UpholdValidator) TextAlignment(javafx.scene.text.TextAlignment) Callback(javafx.util.Callback) RevolutForm(bisq.desktop.components.paymentmethods.RevolutForm) TitledGroupBg(bisq.desktop.components.TitledGroupBg) GridPane(javafx.scene.layout.GridPane) NationalBankForm(bisq.desktop.components.paymentmethods.NationalBankForm) SameBankForm(bisq.desktop.components.paymentmethods.SameBankForm) WesternUnionForm(bisq.desktop.components.paymentmethods.WesternUnionForm) Label(javafx.scene.control.Label) InteracETransferValidator(bisq.desktop.util.validation.InteracETransferValidator) PerfectMoneyForm(bisq.desktop.components.paymentmethods.PerfectMoneyForm) BisqEnvironment(bisq.core.app.BisqEnvironment) StringConverter(javafx.util.StringConverter) CashAppValidator(bisq.desktop.util.validation.CashAppValidator) USPostalMoneyOrderForm(bisq.desktop.components.paymentmethods.USPostalMoneyOrderForm) TimeUnit(java.util.concurrent.TimeUnit) PaymentMethodForm(bisq.desktop.components.paymentmethods.PaymentMethodForm) InputValidator(bisq.core.util.validation.InputValidator) ChaseQuickPayForm(bisq.desktop.components.paymentmethods.ChaseQuickPayForm) ImageUtil(bisq.desktop.util.ImageUtil) SepaForm(bisq.desktop.components.paymentmethods.SepaForm) ImageView(javafx.scene.image.ImageView) CashAppForm(bisq.desktop.components.paymentmethods.CashAppForm) InteracETransferForm(bisq.desktop.components.paymentmethods.InteracETransferForm) PerfectMoneyValidator(bisq.desktop.util.validation.PerfectMoneyValidator) ActivatableViewAndModel(bisq.desktop.common.view.ActivatableViewAndModel) ChangeListener(javafx.beans.value.ChangeListener) Button(javafx.scene.control.Button) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) PaymentMethod(bisq.core.payment.payload.PaymentMethod)

Aggregations

StringConverter (javafx.util.StringConverter)33 Label (javafx.scene.control.Label)14 Callback (javafx.util.Callback)14 FXCollections (javafx.collections.FXCollections)12 Insets (javafx.geometry.Insets)12 Button (javafx.scene.control.Button)11 ImageView (javafx.scene.image.ImageView)11 Inject (javax.inject.Inject)11 ChangeListener (javafx.beans.value.ChangeListener)10 ObservableList (javafx.collections.ObservableList)10 ComboBox (javafx.scene.control.ComboBox)10 Priority (javafx.scene.layout.Priority)9 Arrays (java.util.Arrays)8 List (java.util.List)8 ListChangeListener (javafx.collections.ListChangeListener)8 GridPane (javafx.scene.layout.GridPane)8 HBox (javafx.scene.layout.HBox)8 Consumer (java.util.function.Consumer)7 Res (bisq.core.locale.Res)6 VPos (javafx.geometry.VPos)6