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);
}
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);
}
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();
}
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());
}
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.");
}
Aggregations