Java 类javafx.beans.value.ObservableStringValue 实例源码

项目:speedment    文件:HasPackageNameProperty.java   
/**
 * 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());
    }
}
项目:LoliXL    文件:ThemesPresenter.java   
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(", "));
        }
    });
}
项目:LoliXL    文件:GameVersion.java   
@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;
        }
    };
}
项目:SmartModInserter    文件:Bindings.java   
/**
 * 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;
}
项目:assertj-javafx    文件:StringTest.java   
@Test
public void testObservableStringValue(){
    ObservableStringValue actual = new SimpleStringProperty("test");

    assertThat(actual).hasValue("test");

    assertThat(actual).hasSameValue(actual);
}
项目:assertj-javafx    文件:ObservableStringValueAssertions_contains_Test.java   
@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");
    }
}
项目:LoliXL    文件:McdirGameVersionProvider.java   
@Override
public ObservableStringValue getLocalizedName() {
    if (isCurrentMcdir()) {
        return I18N.localize("org.to2mbn.lolixl.mcdir.default.name");
    }
    return FxConstants.string(location.toString());
}
项目:LoliXL    文件:TileManagementPresenter.java   
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);
}
项目:qupath    文件:ProjectMetadataEditorCommand.java   
public ObservableStringValue getProperty(final String columnName) {
    return Bindings.createStringBinding(() -> {
        String value = metadataMap.get(columnName);
        if (value == null)
            return "";
        return
                value;
    });
}
项目:speedment    文件:AbstractTextItem.java   
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());
    }
}
项目:ISAAC    文件:ErrorMarkerUtils.java   
/**
 * @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);
}
项目:assertj-javafx    文件:ObservableStringValueAssertions_hasValue_Test.java   
@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");
    }
}
项目:assertj-javafx    文件:ObservableStringValueAssertions_hasValue_Test.java   
@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>");
    }
}
项目:assertj-javafx    文件:ObservableStringValueAssertions_hasValue_Test.java   
@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>");
    }
}
项目:assertj-javafx    文件:ObservableStringValueAssertions_contains_Test.java   
@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);
    }
}
项目:ReactFX    文件:StringBinding.java   
/**
 * @deprecated Use {@link Val#suspendable(javafx.beans.value.ObservableValue)}.
 */
@Deprecated
public static StringBinding wrap(ObservableStringValue source) {
    return new StringBinding() {
        { bind(source); }

        @Override
        protected String computeValue() { return source.get(); }
    };
}
项目:fx-animation-editor    文件:ChainedBindingFunctions.java   
public StringBinding selectString(Function<S, ? extends ObservableStringValue> childPropertyAccessor) {
    return selectString(childPropertyAccessor, "");
}
项目:fx-animation-editor    文件:ChainedBindingFunctions.java   
public StringBinding selectString(Function<S, ? extends ObservableStringValue> childPropertyAccessor, String defaultValue) {
    return new StringBindingAdapter(new ChainBinding<>(rootProperty, childPropertyAccessor), defaultValue);
}
项目:LoliXL    文件:I18N.java   
public static ObservableStringValue localize(String key, Object... arguments) {
    return new LocalizedStringValue(getLocalizationService(), key, arguments);
}
项目:LoliXL    文件:FxConstants.java   
public static ObservableStringValue string(String constant) {
    return new StringConstant(constant);
}
项目:LoliXL    文件:Theme.java   
default ObservableValue<ObservableStringValue[]> getAuthors() {
    return null;
}
项目:LoliXL    文件:Theme.java   
default ObservableStringValue getDescription() {
    return null;
}
项目:LoliXL    文件:TileManagementPresenter.java   
@Override
public ObservableStringValue getLocalizedName() {
    return I18N.localize("org.to2mbn.lolixl.ui.impl.tiles.management.title");
}
项目:LoliXL    文件:DownloadCenterPresenter.java   
@Override
public ObservableStringValue getLocalizedName() {
    return I18N.localize("org.to2mbn.lolixl.ui.download_center.title");
}
项目:LoliXL    文件:SettingsPresenter.java   
@Override
public ObservableStringValue getLocalizedName() {
    return I18N.localize("org.to2mbn.lolixl.ui.impl.settings.title");
}
项目:LoliXL    文件:DefaultBackground.java   
@Override
public ObservableStringValue getLocalizedName() {
    return I18N.localize("org.to2mbn.lolixl.ui.theme.background.default.name");
}
项目:LoliXL    文件:DefaultTheme.java   
@Override
public ObservableStringValue getLocalizedName() {
    return I18N.localize("org.to2mbn.lolixl.ui.theme.default.name");
}
项目:LoliXL    文件:DefaultTheme.java   
@Override
public ObservableValue<ObservableStringValue[]> getAuthors() {
    return FxConstants.object(new ObservableStringValue[] { I18N.localize("org.to2mbn.lolixl.ui.theme.default.author.lolixlgroup") });
}
项目:LoliXL    文件:DefaultTheme.java   
@Override
public ObservableStringValue getDescription() {
    return I18N.localize("org.to2mbn.lolixl.ui.theme.default.description");
}
项目:LoliXL    文件:VersionTag.java   
public VersionTag(String id, int ranking, List<String> cssClasses, ObservableStringValue displayName) {
    this.id = Objects.requireNonNull(id);
    this.ranking = ranking;
    this.cssClasses = Objects.requireNonNull(cssClasses);
    this.displayName = Objects.requireNonNull(displayName);
}
项目:LoliXL    文件:VersionTag.java   
public ObservableStringValue getDisplayName() {
    return displayName;
}
项目:LoliXL    文件:AuthenticationProfile.java   
default ObservableStringValue getEmail() {
    return null;
}
项目:LoliXL    文件:AuthenticationProfile.java   
@Override
default ObservableStringValue getLocalizedName() {
    return getUsername();
}
项目:LoliXL    文件:OfflineAuthenticationService.java   
@Override
public ObservableStringValue getLocalizedName() {
    return I18N.localize("org.to2mbn.lolixl.auth.offline.name");
}
项目:LoliXL    文件:OfflineAuthenticationProfile.java   
@Override
public ObservableStringValue getUsername() {
    return username;
}
项目:LoliXL    文件:YggdrasilAuthenticationProfile.java   
@Override
public ObservableStringValue getUsername() {
    return usernameView;
}
项目:LoliXL    文件:YggdrasilAuthenticationProfile.java   
@Override
public ObservableStringValue getEmail() {
    return emailProperty;
}
项目:qupath    文件:ProjectMetadataEditorCommand.java   
public ObservableStringValue getNameBinding() {
    return Bindings.createStringBinding(() -> entry.getImageName());
}
项目:ColorPuzzleFX    文件:SolverViewModel.java   
public ObservableStringValue speedLabel() {
    return speedLabel;
}
项目:ISAAC    文件:ErrorMarkerUtils.java   
/**
 * @deprecated Use {@link #setupErrorMarker(Control, StackPane, ValidBooleanBinding)} instead
 */
public static Node setupErrorMarker(Control initialControl, ObservableStringValue reasonWhyControlInvalid)
{
    return setupErrorMarker(initialControl, new StackPane(), reasonWhyControlInvalid);
}