use of javafx.util.converter.IntegerStringConverter in project dwoss by gg-net.
the class CompanyUpdateController method initialize.
/**
* Initializes the controller class.
*
* @param url
* @param rb
*/
@Override
public void initialize(URL url, ResourceBundle rb) {
// button behavior
delAddressButton.disableProperty().bind(addressListView.getSelectionModel().selectedIndexProperty().lessThan(0));
delComButton.disableProperty().bind(communicationTableView.getSelectionModel().selectedIndexProperty().lessThan(0));
delContactButton.disableProperty().bind(contactListView.getSelectionModel().selectedIndexProperty().lessThan(0));
// get overwriten in accept()
companyNameTextField.setText("");
addressListView.setItems(addressList);
// enable the save and "saveAndClose" button only on filled TextFields
saveButton.disableProperty().bind(Bindings.createBooleanBinding(() -> companyNameTextField.getText().trim().isEmpty(), companyNameTextField.textProperty()).or(addressListView.getSelectionModel().selectedIndexProperty().lessThan(0)));
saveAndCloseButton.disableProperty().bind(Bindings.createBooleanBinding(() -> companyNameTextField.getText().trim().isEmpty(), companyNameTextField.textProperty()).or(addressListView.getSelectionModel().selectedIndexProperty().lessThan(0)));
// Address HORIZONTAL CellFactory
addressListView.setCellFactory((ListView<Address> p) -> {
ListCell<Address> cell = new ListCell<Address>() {
@Override
protected void updateItem(Address item, boolean empty) {
super.updateItem(item, empty);
if (item == null || empty) {
setGraphic(null);
setText("");
} else {
VBox anschriftbox = new VBox();
Label street = new Label(item.getStreet());
Label zipCode = new Label(item.getZipCode());
Label city = new Label(item.getCity());
HBox postBox = new HBox();
postBox.getChildren().addAll(zipCode, city);
postBox.setSpacing(2.0);
Label country = new Label(new Locale("", item.getIsoCountry()).getDisplayCountry());
anschriftbox.getChildren().addAll(street, postBox, country);
anschriftbox.setSpacing(2.0);
setText(null);
setGraphic(anschriftbox);
}
}
};
return cell;
});
addressListView.setOrientation(Orientation.HORIZONTAL);
// adding a CellFactory for every Colum
typeColumn.setCellValueFactory(new PropertyValueFactory<>("type"));
typeColumn.setCellFactory(column -> {
return new TableCell<Communication, Type>() {
@Override
protected void updateItem(Type item, boolean empty) {
super.updateItem(item, empty);
if (item == null || empty) {
setText(null);
} else {
setText(item.name());
setStyle("-fx-font-weight: bold");
}
}
};
});
idColumn.setCellValueFactory(new PropertyValueFactory<>("identifier"));
idColumn.setCellFactory(column -> {
return new TableCell<Communication, String>() {
@Override
protected void updateItem(String item, boolean empty) {
super.updateItem(item, empty);
if (item == null || empty) {
setText(null);
} else {
setText(item);
setStyle("");
}
}
};
});
prefColumn.setCellValueFactory(new PropertyValueFactory<>("prefered"));
prefColumn.setCellFactory(column -> {
return new TableCell<Communication, Boolean>() {
@Override
protected void updateItem(Boolean item, boolean empty) {
super.updateItem(item, empty);
if (item == null || empty) {
setText(null);
setGraphic(null);
} else {
HBox checkHBox = new HBox();
RadioButton prefRadioButton = new RadioButton();
prefRadioButton.setSelected(item);
prefRadioButton.setToggleGroup(prefGroup);
checkHBox.getChildren().add(prefRadioButton);
checkHBox.setAlignment(Pos.CENTER);
setText("");
setGraphic(checkHBox);
}
}
};
});
// Contact CellFactory
contactListView.setCellFactory((ListView<Contact> p) -> {
ListCell<Contact> cell = new ListCell<Contact>() {
@Override
protected void updateItem(Contact item, boolean empty) {
super.updateItem(item, empty);
if (item == null || empty) {
setGraphic(null);
setText("");
} else {
String anrede = "";
if (item.getSex() == Sex.FEMALE) {
anrede = "Frau ";
}
if (item.getSex() == Sex.MALE) {
anrede = "Herr ";
}
setText(anrede + item.toFullName());
}
}
};
return cell;
});
// force the ledger field to be numeric only, becuase the ledger get saved as an int
ledgerTextField.textFormatterProperty().set(new TextFormatter<>(new IntegerStringConverter(), 0, change -> {
String newText = change.getControlNewText();
if (Pattern.compile("-?((\\d*))").matcher(newText).matches()) {
return change;
} else {
return null;
}
}));
}
use of javafx.util.converter.IntegerStringConverter in project certmgr by hdecarne.
the class CertOptionsController method setupStage.
@Override
protected void setupStage(Stage stage) {
stage.getIcons().addAll(PlatformHelper.stageIcons(Images.NEWCERT32, Images.NEWCERT16));
stage.setTitle(CertOptionsI18N.formatSTR_STAGE_TITLE());
this.ctlAliasInput.textProperty().addListener((p, o, n) -> onAliasChanged(o, n));
this.ctlKeyAlgOption.valueProperty().addListener((p, o, n) -> onKeyAlgChanged(n));
this.ctlKeySizeOption.setConverter(new IntegerStringConverter());
this.ctlGeneratorOption.valueProperty().addListener((p, o, n) -> onGeneratorChanged(n));
this.ctlIssuerInput.valueProperty().addListener((p, o, n) -> onIssuerChanged(n));
this.cmdAddBasicConstraints.disableProperty().bind(this.basicConstraintsExtension.isNotNull());
this.cmdAddKeyUsage.disableProperty().bind(this.keyUsageExtension.isNotNull());
this.cmdAddExtendedKeyUsage.disableProperty().bind(this.extendedKeyUsageExtension.isNotNull());
this.cmdAddSubjectAlternativeName.disableProperty().bind(this.subjectAlternativeExtension.isNotNull());
this.cmdAddCRLDistributionPoints.disableProperty().bind(this.crlDistributionPointsExtension.isNotNull());
this.cmdEditExtension.disableProperty().bind(this.ctlExtensionData.getSelectionModel().selectedItemProperty().isNull());
this.cmdDeleteExtension.disableProperty().bind(this.ctlExtensionData.getSelectionModel().selectedItemProperty().isNull());
this.ctlExtensionDataCritical.setCellFactory(CheckBoxTableCell.forTableColumn(this.ctlExtensionDataCritical));
this.ctlExtensionDataCritical.setCellValueFactory(new PropertyValueFactory<>("critical"));
this.ctlExtensionDataName.setCellValueFactory(new PropertyValueFactory<>("name"));
this.ctlExtensionDataValue.setCellValueFactory(new PropertyValueFactory<>("value"));
}
use of javafx.util.converter.IntegerStringConverter in project certmgr by hdecarne.
the class StorePreferencesController method setupDialog.
@Override
protected void setupDialog(Dialog<UserCertStore> dialog) {
dialog.setTitle(StorePreferencesI18N.formatSTR_STAGE_TITLE());
this.ctlDefKeyAlgOption.valueProperty().addListener((p, o, n) -> onDefKeyAlgChanged(n));
this.ctlDefKeySizeOption.setConverter(new IntegerStringConverter());
addButtonEventFilter(ButtonType.APPLY, this::onApply);
}
Aggregations