本文整理汇总了Java中javafx.beans.value.ObservableStringValue类的典型用法代码示例。如果您正苦于以下问题:Java ObservableStringValue类的具体用法?Java ObservableStringValue怎么用?Java ObservableStringValue使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ObservableStringValue类属于javafx.beans.value包,在下文中一共展示了ObservableStringValue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: defaultPackageNameProperty
import javafx.beans.value.ObservableStringValue; //导入依赖的package包/类
/**
* Returns the default value for the package name
*
* @param injector the injector, in case an implementing class needs it
* @return the default package name
*/
default ObservableStringValue defaultPackageNameProperty(Injector injector) {
final TranslatorSupport<?> support = new TranslatorSupport<>(injector, this);
if (this instanceof ProjectProperty) {
final ProjectProperty project = (ProjectProperty) this;
return createStringBinding(
support::defaultPackageName,
project.nameProperty(),
project.companyNameProperty()
);
} else if (this instanceof HasAliasProperty) {
final HasAliasProperty alias = (HasAliasProperty) this;
return createStringBinding(support::defaultPackageName, alias.aliasProperty());
} else {
return createStringBinding(support::defaultPackageName, nameProperty());
}
}
示例2: updateInfoPane
import javafx.beans.value.ObservableStringValue; //导入依赖的package包/类
private void updateInfoPane(Theme selectedTheme) {
view.themeNameLabel.textProperty().bind(selectedTheme.getLocalizedName());
view.themeDescriptionLabel.textProperty().bind(selectedTheme.getDescription());
view.themeAuthorsLabel.textProperty().bind(new StringBinding() {
ObservableValue<ObservableStringValue[]> authorsBinding = selectedTheme.getAuthors();
{
bind(authorsBinding);
}
@Override
protected String computeValue() {
return Stream
.of(authorsBinding.getValue())
.map(ObservableStringValue::get)
.collect(joining(", "));
}
});
}
示例3: getLocalizedName
import javafx.beans.value.ObservableStringValue; //导入依赖的package包/类
@Override
default ObservableStringValue getLocalizedName() {
return new StringBinding() {
StringProperty aliasProperty = aliasProperty();
{
bind(aliasProperty);
}
@Override
protected String computeValue() {
String alias = aliasProperty.get();
if (alias == null) {
return getVersionNumber();
}
return alias;
}
};
}
示例4: decision
import javafx.beans.value.ObservableStringValue; //导入依赖的package包/类
/**
* Returns a new observable string which contains either the contents of ifTrue, or ifFalse, depending on the condition
* @param condition
* @param ifTrue
* @param ifFalse
* @return
*/
public static ObservableStringValue decision(ObservableBooleanValue condition,
ObservableStringValue ifTrue,
ObservableStringValue ifFalse) {
StringProperty ret = new SimpleStringProperty();
condition.addListener((obs, ov, nv) -> {
ret.set(nv ? ifTrue.get() : ifFalse.get());
});
ifTrue.addListener((obs, ov, nv) -> {
if (condition.get()) {
ret.set(nv);
}
});
ifFalse.addListener((obs, ov, nv) -> {
if (!condition.get()) {
ret.set(nv);
}
});
ret.set(condition.get() ? ifTrue.get() : ifFalse.get());
return ret;
}
示例5: testObservableStringValue
import javafx.beans.value.ObservableStringValue; //导入依赖的package包/类
@Test
public void testObservableStringValue(){
ObservableStringValue actual = new SimpleStringProperty("test");
assertThat(actual).hasValue("test");
assertThat(actual).hasSameValue(actual);
}
示例6: should_fail_if_expected_value_is_null
import javafx.beans.value.ObservableStringValue; //导入依赖的package包/类
@Test
public void should_fail_if_expected_value_is_null(){
try{
ObservableStringValue actual = new SimpleStringProperty("test123");
new ObservableStringValueAssertions(actual).contains(null);
fail("Should throw an AssertionError");
}catch(AssertionError error){
assertThat(error).hasMessageContaining("expected value may not be null");
}
}
示例7: getLocalizedName
import javafx.beans.value.ObservableStringValue; //导入依赖的package包/类
@Override
public ObservableStringValue getLocalizedName() {
if (isCurrentMcdir()) {
return I18N.localize("org.to2mbn.lolixl.mcdir.default.name");
}
return FxConstants.string(location.toString());
}
示例8: bindManagementTile
import javafx.beans.value.ObservableStringValue; //导入依赖的package包/类
private void bindManagementTile() {
Tile tile = new ItemTile(new DisplayableItem() {
@Override
public ObservableStringValue getLocalizedName() {
return FxConstants.string("...");
}
});
Panel panel = panelDisplayService.newPanel();
panel.bindButton(tile);
panel.bindItem(this);
panel.contentProperty().set(view.rootContainer);
homeContentPresenter.setManagementTile(tile);
}
示例9: getProperty
import javafx.beans.value.ObservableStringValue; //导入依赖的package包/类
public ObservableStringValue getProperty(final String columnName) {
return Bindings.createStringBinding(() -> {
String value = metadataMap.get(columnName);
if (value == null)
return "";
return
value;
});
}
示例10: setTextFieldBehaviour
import javafx.beans.value.ObservableStringValue; //导入依赖的package包/类
private static void setTextFieldBehaviour(TextInputControl text, boolean useDefaultValue, ObservableStringValue defaultValue, StringProperty customValue) {
if (useDefaultValue) {
customValue.unbind();
text.textProperty().bind(defaultValue);
} else {
text.textProperty().unbind();
text.setText(customValue.get());
customValue.bind(text.textProperty());
}
}
示例11: setupErrorMarker
import javafx.beans.value.ObservableStringValue; //导入依赖的package包/类
/**
* @deprecated Use {@link #setupErrorMarker(Control, StackPane, ValidBooleanBinding)} instead
*/
public static Node setupErrorMarker(Control initialControl, StackPane stackPane, ObservableStringValue reasonWhyControlInvalid)
{
ValidBooleanBinding binding = new ValidBooleanBinding()
{
{
bind(reasonWhyControlInvalid);
}
@Override
protected boolean computeValue()
{
if (StringUtils.isNotBlank(reasonWhyControlInvalid.get()))
{
setInvalidReason(reasonWhyControlInvalid.get());
return false;
}
else
{
clearInvalidReason();
return true;
}
}
};
return setupErrorMarker(initialControl, stackPane, binding);
}
示例12: should_fail_if_expected_value_is_null
import javafx.beans.value.ObservableStringValue; //导入依赖的package包/类
@Test
public void should_fail_if_expected_value_is_null(){
try{
ObservableStringValue actual = new SimpleStringProperty("test");
new ObservableStringValueAssertions(actual).hasValue(null);
fail("Should throw an AssertionError");
}catch(AssertionError error){
assertThat(error).hasMessageContaining("expected value may not be null");
}
}
示例13: should_fail_if_actual_has_wrong_value
import javafx.beans.value.ObservableStringValue; //导入依赖的package包/类
@Test
public void should_fail_if_actual_has_wrong_value(){
try{
ObservableStringValue actual = new SimpleStringProperty("test");
new ObservableStringValueAssertions(actual).hasValue("testest");
fail("Should throw an AssertionError");
}catch(AssertionError error){
assertThat(error).hasMessageContaining("<testest> but was <test>");
}
}
示例14: should_fail_if_actual_has_value_of_null
import javafx.beans.value.ObservableStringValue; //导入依赖的package包/类
@Test
public void should_fail_if_actual_has_value_of_null(){
try{
ObservableStringValue actual = new SimpleStringProperty();
new ObservableStringValueAssertions(actual).hasValue("test");
fail("Should throw an AssertionError");
}catch(AssertionError error){
assertThat(error).hasMessageContaining("<test> but was <null>");
}
}
示例15: should_fail_if_actual_does_not_contain_expected_text
import javafx.beans.value.ObservableStringValue; //导入依赖的package包/类
@Test
public void should_fail_if_actual_does_not_contain_expected_text(){
try{
ObservableStringValue actual = new SimpleStringProperty("test123");
new ObservableStringValueAssertions(actual).contains("st21");
fail("Should throw an AssertionError");
}catch(AssertionError error){
assertThat(error);
}
}