Search in sources :

Example 1 with StringConverter

use of javafx.util.StringConverter in project POL-POM-5 by PlayOnLinux.

the class WinePrefixContainerInformationTab method populate.

private void populate() {
    final VBox informationPane = new VBox();
    final Text title = new TextWithStyle(tr("Information"), TITLE_CSS_CLASS);
    informationPane.getStyleClass().add(CONFIGURATION_PANE_CSS_CLASS);
    informationPane.getChildren().add(title);
    final GridPane informationContentPane = new GridPane();
    informationContentPane.getStyleClass().add("grid");
    informationContentPane.add(new TextWithStyle(tr("Name:"), CAPTION_TITLE_CSS_CLASS), 0, 0);
    Label name = new Label(container.getName());
    name.setWrapText(true);
    informationContentPane.add(name, 1, 0);
    informationContentPane.add(new TextWithStyle(tr("Path:"), CAPTION_TITLE_CSS_CLASS), 0, 1);
    Label path = new Label(container.getPath());
    path.setWrapText(true);
    informationContentPane.add(path, 1, 1);
    informationContentPane.add(new TextWithStyle(tr("Wine version:"), CAPTION_TITLE_CSS_CLASS), 0, 2);
    Label version = new Label(container.getVersion());
    version.setWrapText(true);
    informationContentPane.add(version, 1, 2);
    informationContentPane.add(new TextWithStyle(tr("Wine architecture:"), CAPTION_TITLE_CSS_CLASS), 0, 3);
    Label architecture = new Label(container.getArchitecture());
    architecture.setWrapText(true);
    informationContentPane.add(architecture, 1, 3);
    informationContentPane.add(new TextWithStyle(tr("Wine distribution:"), CAPTION_TITLE_CSS_CLASS), 0, 4);
    Label distribution = new Label(container.getDistribution());
    distribution.setWrapText(true);
    informationContentPane.add(distribution, 1, 4);
    Region spacer = new Region();
    spacer.setPrefHeight(20);
    VBox.setVgrow(spacer, Priority.NEVER);
    ComboBox<EngineVersionDTO> changeEngineComboBox = new ComboBox<EngineVersionDTO>(FXCollections.observableList(engineVersions));
    changeEngineComboBox.setConverter(new StringConverter<EngineVersionDTO>() {

        @Override
        public String toString(EngineVersionDTO object) {
            return object.getVersion();
        }

        @Override
        public EngineVersionDTO fromString(String string) {
            return engineVersions.stream().filter(engineVersion -> engineVersion.getVersion().equals(string)).findFirst().get();
        }
    });
    changeEngineComboBox.getSelectionModel().select(engineVersions.stream().filter(engineVersion -> engineVersion.getVersion().equals(container.getVersion())).findFirst().get());
    Button deleteButton = new Button(tr("Delete container"));
    deleteButton.setOnMouseClicked(event -> this.onDeletePrefix.accept(container));
    informationPane.getChildren().addAll(informationContentPane, spacer, changeEngineComboBox, deleteButton);
    this.setContent(informationPane);
}
Also used : Button(javafx.scene.control.Button) Label(javafx.scene.control.Label) TextWithStyle(org.phoenicis.javafx.views.common.TextWithStyle) FXCollections(javafx.collections.FXCollections) Localisation.tr(org.phoenicis.configuration.localisation.Localisation.tr) StringConverter(javafx.util.StringConverter) VBox(javafx.scene.layout.VBox) EngineVersionDTO(org.phoenicis.engines.dto.EngineVersionDTO) Text(javafx.scene.text.Text) Consumer(java.util.function.Consumer) Priority(javafx.scene.layout.Priority) List(java.util.List) Region(javafx.scene.layout.Region) ComboBox(javafx.scene.control.ComboBox) Tab(javafx.scene.control.Tab) WinePrefixContainerDTO(org.phoenicis.containers.dto.WinePrefixContainerDTO) GridPane(javafx.scene.layout.GridPane) TextWithStyle(org.phoenicis.javafx.views.common.TextWithStyle) GridPane(javafx.scene.layout.GridPane) ComboBox(javafx.scene.control.ComboBox) Label(javafx.scene.control.Label) Text(javafx.scene.text.Text) EngineVersionDTO(org.phoenicis.engines.dto.EngineVersionDTO) Button(javafx.scene.control.Button) Region(javafx.scene.layout.Region) VBox(javafx.scene.layout.VBox)

Example 2 with StringConverter

use of javafx.util.StringConverter in project Gargoyle by callakrsos.

the class FxTableViewUtil method getValue.

/**
	 * 테이블컬럼의 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 static Object getValue(TableView<?> table, TableColumn<?, ?> column, 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 기본값. */
            {
                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 3 with StringConverter

use of javafx.util.StringConverter in project Gargoyle by callakrsos.

the class DaoWizardViewController method initialize.

@FXML
public void initialize() {
    tbParams.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    // this.colProgramTypeLock.setCellValueFactory(v ->
    // v.getValue().lockYnProperty());
    // this.colProgramTypeLock.setCellFactory(v ->{
    // return
    // });
    tbmSysDaoDVOProperty = new SimpleObjectProperty<>(new TbmSysDaoDVO());
    colParamTestValue.setCellFactory(TextFieldTableCell.forTableColumn());
    methodDesc.setCellFactory(TextFieldTableCell.forTableColumn());
    methodName.setCellFactory(TextFieldTableCell.forTableColumn());
    // [시작] 넘버링 컬럼
    colMethodNo.setCellValueFactory(new NumberingCellValueFactory<>(tbMethods.getItems()));
    /*
		 * 2015-11-02 기존에 사용하던 NumberingCellValueFactory을 적용할 수 없음.
		 * colParamNo컬럼같은경우는 method에 따라 데이터의 주소값이 바뀌는 타입이라 주소값이 바뀌는 상태에선 적절한 넘버링
		 * 데이터가 화면에 보여주지않음. 하여 주소값을 계속 유지시킬 수 있도록 tbMethods에서 선택된 메소드정보에서 값을
		 * 참조하여 넘버링을 시킴.
		 *
		 * 2016-04-19 파람의 아이템을 삭제하고 다시 호출했을때 인덱스 순서가 맞지않던 버그 fix
		 */
    colParamNo.setCellValueFactory(param -> {
        return new ReadOnlyObjectWrapper<Integer>(tbParams.getItems().indexOf(param.getValue()) + 1);
    });
    // [끝] 넘버링 컬럼
    colParamTypes.setCellFactory(ChoiceBoxTableCell.forTableColumn("Nomal", "Arrays"));
    // 텍스트의 내용이 변경되면 메모리에 적재시키기 위한 이벤트 함수.
    // 2015.11.17 키 이벤트가 눌릴때 처리되지않게함, 타이밍 문제가 있어, 저장시에 문제가 있음.
    // txtSql.getCodeArea().setOnKeyPressed();
    txtSql.getCodeArea().setOnKeyReleased(event -> {
        if (!event.isShortcutDown()) {
            TbpSysDaoMethodsDVO selectedMethodItem = getSelectedMethodItem();
            if (selectedMethodItem != null)
                selectedMethodItem.setSqlBody(txtSql.getText());
        }
    });
    StringConverter<String> classConverter = new StringConverter<String>() {

        @Override
        public String toString(String clazz) {
            if (clazz == null || clazz.isEmpty())
                return "";
            String result = clazz;
            int lastIndexOf = clazz.lastIndexOf('.');
            if (lastIndexOf >= 0) {
                result = clazz.substring(lastIndexOf + 1);
            }
            return result;
        }

        @Override
        public String fromString(String clazz) {
            return clazz;
        }
    };
    // 메소드 컬럼에서 Result Vo Class를 더블클릭한경우 VO참조를 걸 수 있도록 팝업창을 뜨는 로직 포함되있음.
    colResultVoClass.setCellFactory(param -> {
        TextFieldTableCell<TbpSysDaoMethodsDVO, String> textFieldTableCell = new TextFieldTableCell<>();
        textFieldTableCell.setOnMouseClicked(event -> {
            if (event.getClickCount() == 2) {
                String clazz = textFieldTableCell.getItem();
                try {
                    BaseOpenClassResourceView view = null;
                    if (ValueUtil.isNotEmpty(clazz)) {
                        view = new MeerketAbstractVoOpenClassResourceView(clazz);
                    } else {
                        view = new MeerketAbstractVoOpenClassResourceView();
                    }
                    view.setConsumer(str -> {
                        if (str == null || str.isEmpty())
                            return;
                        try {
                            int selectedItem = tbMethods.getSelectionModel().getSelectedIndex();
                            tbMethods.getItems().get(selectedItem).setResultVoClass(str);
                        } catch (Exception e) {
                            DialogUtil.showExceptionDailog(e, "로드할 수 없는 클래스 유형입니다.");
                            return;
                        }
                    });
                    ResultDialog<String> show = view.show();
                    show.consume();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
        textFieldTableCell.setConverter(classConverter);
        return textFieldTableCell;
    });
    colResultVoClass.setCellValueFactory(param -> param.getValue().resultVoClassProperty());
    // SQL 에디터 마우스 클릭이벤트, 선택한 메소드 항목이 없다면 Editable을 활성화 시키지않는다.
    txtSql.getCodeArea().setOnMouseClicked(event -> {
        if (!event.isShortcutDown()) {
            int selectedMethodIndex = getSelectedMethodIndex();
            if (selectedMethodIndex == -1) {
                txtSql.getCodeArea().setEditable(false);
            } else {
                txtSql.getCodeArea().setEditable(true);
            }
        }
    });
    // 2016-08-27 custom 항목 추가. 이 항목추가시 typeMapping.properties 파일의 항목도 추가야함.
    ObservableList<String> collect = DatabaseTypeMappingResourceLoader.getInstance().getEntry().stream().map(v -> v.getValue().toString()).distinct().collect(FxCollectors.toObservableList());
    collect.addAll(Arrays.asList("Integer", "Long", "Double"));
    colProgramType.setCellFactory(ChoiceBoxTableCell.forTableColumn(collect));
    lblMessage.setText(MSG_NO_WARNNING);
    // 메뉴등록작업
    applyContextMenu();
}
Also used : TbmSysDaoDVO(kyj.Fx.dao.wizard.core.model.vo.TbmSysDaoDVO) StringConverter(javafx.util.StringConverter) MeerketAbstractVoOpenClassResourceView(com.kyj.fx.voeditor.visual.component.popup.MeerketAbstractVoOpenClassResourceView) IOException(java.io.IOException) TbpSysDaoMethodsDVO(kyj.Fx.dao.wizard.core.model.vo.TbpSysDaoMethodsDVO) BaseOpenClassResourceView(com.kyj.fx.voeditor.visual.component.popup.BaseOpenClassResourceView) TextFieldTableCell(javafx.scene.control.cell.TextFieldTableCell) ReadOnlyObjectWrapper(javafx.beans.property.ReadOnlyObjectWrapper) FXML(javafx.fxml.FXML)

Example 4 with StringConverter

use of javafx.util.StringConverter in project bitsquare by bitsquare.

the class ArbitratorSelectionView method addLanguageGroup.

///////////////////////////////////////////////////////////////////////////////////////////
// UI builder
///////////////////////////////////////////////////////////////////////////////////////////
private void addLanguageGroup() {
    addTitledGroupBg(root, gridRow, 1, "Which languages do you speak?");
    Tuple2<Label, ListView> tuple = addLabelListView(root, gridRow, "Your languages:", Layout.FIRST_ROW_DISTANCE);
    GridPane.setValignment(tuple.first, VPos.TOP);
    languagesListView = tuple.second;
    languagesListView.setMinHeight(3 * Layout.LIST_ROW_HEIGHT + 2);
    languagesListView.setMaxHeight(6 * Layout.LIST_ROW_HEIGHT + 2);
    languagesListView.setCellFactory(new Callback<ListView<String>, ListCell<String>>() {

        @Override
        public ListCell<String> call(ListView<String> list) {
            return new ListCell<String>() {

                final Label label = new Label();

                final ImageView icon = ImageUtil.getImageViewById(ImageUtil.REMOVE_ICON);

                final Button removeButton = new Button("", icon);

                final AnchorPane pane = new AnchorPane(label, removeButton);

                {
                    label.setLayoutY(5);
                    removeButton.setId("icon-button");
                    AnchorPane.setRightAnchor(removeButton, 0d);
                }

                @Override
                public void updateItem(final String item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null && !empty) {
                        label.setText(LanguageUtil.getDisplayName(item));
                        removeButton.setOnAction(e -> onRemoveLanguage(item));
                        setGraphic(pane);
                    } else {
                        setGraphic(null);
                    }
                }
            };
        }
    });
    languageComboBox = addLabelComboBox(root, ++gridRow, "", 15).second;
    languageComboBox.setPromptText("Add language");
    languageComboBox.setConverter(new StringConverter<String>() {

        @Override
        public String toString(String code) {
            return LanguageUtil.getDisplayName(code);
        }

        @Override
        public String fromString(String s) {
            return null;
        }
    });
    languageComboBox.setOnAction(e -> onAddLanguage());
}
Also used : HPos(javafx.geometry.HPos) Popup(io.bitsquare.gui.main.overlays.popups.Popup) javafx.scene.control(javafx.scene.control) TableGroupHeadline(io.bitsquare.gui.components.TableGroupHeadline) UserThread(io.bitsquare.common.UserThread) ImageUtil(io.bitsquare.gui.util.ImageUtil) Tuple2(io.bitsquare.common.util.Tuple2) StringConverter(javafx.util.StringConverter) ActivatableViewAndModel(io.bitsquare.gui.common.view.ActivatableViewAndModel) LanguageUtil(io.bitsquare.locale.LanguageUtil) Inject(javax.inject.Inject) BooleanProperty(javafx.beans.property.BooleanProperty) FormBuilder(io.bitsquare.gui.util.FormBuilder) Insets(javafx.geometry.Insets) ReadOnlyObjectWrapper(javafx.beans.property.ReadOnlyObjectWrapper) ListChangeListener(javafx.collections.ListChangeListener) Layout(io.bitsquare.gui.util.Layout) VPos(javafx.geometry.VPos) AnchorPane(javafx.scene.layout.AnchorPane) ImageView(javafx.scene.image.ImageView) FxmlView(io.bitsquare.gui.common.view.FxmlView) ChangeListener(javafx.beans.value.ChangeListener) Callback(javafx.util.Callback) GridPane(javafx.scene.layout.GridPane) ImageView(javafx.scene.image.ImageView) AnchorPane(javafx.scene.layout.AnchorPane)

Example 5 with StringConverter

use of javafx.util.StringConverter in project bitsquare by bitsquare.

the class ArbitratorRegistrationView method buildUI.

private void buildUI() {
    GridPane gridPane = new GridPane();
    gridPane.setPadding(new Insets(30, 25, -1, 25));
    gridPane.setHgap(5);
    gridPane.setVgap(5);
    ColumnConstraints columnConstraints1 = new ColumnConstraints();
    columnConstraints1.setHalignment(HPos.RIGHT);
    columnConstraints1.setHgrow(Priority.SOMETIMES);
    columnConstraints1.setMinWidth(200);
    ColumnConstraints columnConstraints2 = new ColumnConstraints();
    columnConstraints2.setHgrow(Priority.ALWAYS);
    gridPane.getColumnConstraints().addAll(columnConstraints1, columnConstraints2);
    root.getChildren().add(gridPane);
    addTitledGroupBg(gridPane, gridRow, 3, "Arbitrator registration");
    pubKeyTextField = FormBuilder.addLabelTextField(gridPane, gridRow, "Public key:", model.registrationPubKeyAsHex.get(), Layout.FIRST_ROW_DISTANCE).second;
    pubKeyTextField.textProperty().bind(model.registrationPubKeyAsHex);
    Tuple2<Label, ListView> tuple = addLabelListView(gridPane, ++gridRow, "Your languages:");
    GridPane.setValignment(tuple.first, VPos.TOP);
    languagesListView = tuple.second;
    languagesListView.disableProperty().bind(model.registrationEditDisabled);
    languagesListView.setMinHeight(3 * Layout.LIST_ROW_HEIGHT + 2);
    languagesListView.setMaxHeight(6 * Layout.LIST_ROW_HEIGHT + 2);
    languagesListView.setCellFactory(new Callback<ListView<String>, ListCell<String>>() {

        @Override
        public ListCell<String> call(ListView<String> list) {
            return new ListCell<String>() {

                final Label label = new Label();

                final ImageView icon = ImageUtil.getImageViewById(ImageUtil.REMOVE_ICON);

                final Button removeButton = new Button("", icon);

                final AnchorPane pane = new AnchorPane(label, removeButton);

                {
                    label.setLayoutY(5);
                    removeButton.setId("icon-button");
                    AnchorPane.setRightAnchor(removeButton, 0d);
                }

                @Override
                public void updateItem(final String item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null && !empty) {
                        label.setText(LanguageUtil.getDisplayName(item));
                        removeButton.setOnAction(e -> onRemoveLanguage(item));
                        setGraphic(pane);
                    } else {
                        setGraphic(null);
                    }
                }
            };
        }
    });
    languageComboBox = addLabelComboBox(gridPane, ++gridRow).second;
    languageComboBox.disableProperty().bind(model.registrationEditDisabled);
    languageComboBox.setPromptText("Add language");
    languageComboBox.setConverter(new StringConverter<String>() {

        @Override
        public String toString(String code) {
            return LanguageUtil.getDisplayName(code);
        }

        @Override
        public String fromString(String s) {
            return null;
        }
    });
    languageComboBox.setOnAction(e -> onAddLanguage());
    registerButton = addButtonAfterGroup(gridPane, ++gridRow, "Register arbitrator");
    registerButton.disableProperty().bind(model.registrationEditDisabled);
    registerButton.setOnAction(e -> onRegister());
    revokeButton = addButton(gridPane, ++gridRow, "Revoke registration");
    revokeButton.setDefaultButton(false);
    revokeButton.disableProperty().bind(model.revokeButtonDisabled);
    revokeButton.setOnAction(e -> onRevoke());
    addTitledGroupBg(gridPane, ++gridRow, 2, "Information", Layout.GROUP_DISTANCE);
    Label infoLabel = addMultilineLabel(gridPane, gridRow);
    GridPane.setMargin(infoLabel, new Insets(Layout.FIRST_ROW_AND_GROUP_DISTANCE, 0, 0, 0));
    infoLabel.setText("Please note that you need to stay  available for 15 days after revoking as there might be trades which are using you as " + "arbitrator. The max. allowed trade period is 8 days and the dispute process might take up to 7 days.");
}
Also used : HPos(javafx.geometry.HPos) Popup(io.bitsquare.gui.main.overlays.popups.Popup) javafx.scene.layout(javafx.scene.layout) Arbitrator(io.bitsquare.arbitration.Arbitrator) javafx.scene.control(javafx.scene.control) UserThread(io.bitsquare.common.UserThread) ImageUtil(io.bitsquare.gui.util.ImageUtil) Tuple2(io.bitsquare.common.util.Tuple2) StringConverter(javafx.util.StringConverter) ActivatableViewAndModel(io.bitsquare.gui.common.view.ActivatableViewAndModel) LanguageUtil(io.bitsquare.locale.LanguageUtil) EnterPrivKeyWindow(io.bitsquare.gui.main.overlays.windows.EnterPrivKeyWindow) Inject(javax.inject.Inject) FormBuilder(io.bitsquare.gui.util.FormBuilder) Insets(javafx.geometry.Insets) ListChangeListener(javafx.collections.ListChangeListener) Layout(io.bitsquare.gui.util.Layout) VPos(javafx.geometry.VPos) ImageView(javafx.scene.image.ImageView) FxmlView(io.bitsquare.gui.common.view.FxmlView) ChangeListener(javafx.beans.value.ChangeListener) Callback(javafx.util.Callback) Insets(javafx.geometry.Insets) ImageView(javafx.scene.image.ImageView)

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