|
15 | 15 | */
|
16 | 16 | package com.vaadin.flow.component;
|
17 | 17 |
|
18 |
| -import java.util.Locale; |
19 | 18 | import java.util.Objects;
|
20 |
| -import java.util.stream.Stream; |
21 | 19 |
|
22 | 20 | import com.vaadin.flow.function.SerializableBiConsumer;
|
23 |
| -import com.vaadin.flow.internal.LocaleUtil; |
24 | 21 | import com.vaadin.flow.server.ErrorEvent;
|
25 | 22 | import com.vaadin.flow.shared.Registration;
|
26 | 23 | import com.vaadin.signals.Signal;
|
|
35 | 32 | * {@link Signal#effect(Runnable)}, that is automatically enabled when a
|
36 | 33 | * component is attached and disabled when the component is detached.
|
37 | 34 | * Additionally it provides methods to bind signals to component according to a
|
38 |
| - * given value setting function and format strings based on signal values. |
| 35 | + * given value setting function. |
39 | 36 | *
|
40 | 37 | * @since 24.8
|
41 | 38 | */
|
@@ -137,97 +134,6 @@ public static <C extends Component, T> Registration bind(C owner,
|
137 | 134 | });
|
138 | 135 | }
|
139 | 136 |
|
140 |
| - /** |
141 |
| - * Formats a string using the values of the provided signals and the given |
142 |
| - * locale, sets the formatted string on the owner component using the |
143 |
| - * provided setter function. |
144 |
| - * <p> |
145 |
| - * Binds a formatted string using the values of the provided signals to a |
146 |
| - * given owner component in a way defined in <code>setter</code> function |
147 |
| - * and creates a Signal effect function executing the setter whenever the |
148 |
| - * signal value changes. |
149 |
| - * <p> |
150 |
| - * Example of usage: |
151 |
| - * |
152 |
| - * <pre> |
153 |
| - * ComponentEffect.format(mySpan, Span::setText, Locale.US, |
154 |
| - * "The price of %s is %.2f", nameSignal, priceSignal); |
155 |
| - * </pre> |
156 |
| - * |
157 |
| - * @see Signal#effect(Runnable) |
158 |
| - * @param owner |
159 |
| - * the owner component for which the effect is applied, must not |
160 |
| - * be <code>null</code> |
161 |
| - * @param setter |
162 |
| - * the setter function that defines how the formatted string is |
163 |
| - * applied to the component, must not be <code>null</code> |
164 |
| - * @param locale |
165 |
| - * the locale to be used for formatting the string, if |
166 |
| - * <code>null</code>, then no localization is applied |
167 |
| - * @param format |
168 |
| - * the format string to be used for formatting the signal values, |
169 |
| - * must not be <code>null</code> |
170 |
| - * @param signals |
171 |
| - * the signals whose values are to be used for formatting the |
172 |
| - * string, must not be <code>null</code> |
173 |
| - * @return a {@link Registration} that can be used to remove the effect |
174 |
| - * function |
175 |
| - * @param <C> |
176 |
| - * the type of the component |
177 |
| - */ |
178 |
| - public static <C extends Component> Registration format(C owner, |
179 |
| - SerializableBiConsumer<C, String> setter, Locale locale, |
180 |
| - String format, Signal<?>... signals) { |
181 |
| - return effect(owner, () -> { |
182 |
| - Object[] values = Stream.of(signals).map(Signal::value).toArray(); |
183 |
| - setter.accept(owner, String.format(locale, format, values)); |
184 |
| - }); |
185 |
| - } |
186 |
| - |
187 |
| - /** |
188 |
| - * Formats a string using the values of the provided signals and sets it on |
189 |
| - * the owner component using the provided setter function. |
190 |
| - * <p> |
191 |
| - * Binds a formatted string using the values of the provided signals to a |
192 |
| - * given owner component in a way defined in <code>setter</code> function |
193 |
| - * and creates a Signal effect function executing the setter whenever the |
194 |
| - * signal value changes. |
195 |
| - * <p> |
196 |
| - * Formats using locale from the current UI, I18NProvider or default locale |
197 |
| - * depending on what is available. |
198 |
| - * <p> |
199 |
| - * Example of usage: |
200 |
| - * |
201 |
| - * <pre> |
202 |
| - * ComponentEffect.format(mySpan, Span::setText, "The price of %s is %.2f", |
203 |
| - * nameSignal, priceSignal); |
204 |
| - * </pre> |
205 |
| - * |
206 |
| - * @see Signal#effect(Runnable) |
207 |
| - * @param owner |
208 |
| - * the owner component for which the effect is applied, must not |
209 |
| - * be <code>null</code> |
210 |
| - * @param setter |
211 |
| - * the setter function that defines how the formatted string is |
212 |
| - * applied to the component, must not be <code>null</code> |
213 |
| - * @param format |
214 |
| - * the format string to be used for formatting the signal values, |
215 |
| - * must not be <code>null</code> |
216 |
| - * @param signals |
217 |
| - * the signals whose values are to be used for formatting the |
218 |
| - * string, must not be <code>null</code> |
219 |
| - * @return a {@link Registration} that can be used to remove the effect |
220 |
| - * function |
221 |
| - * @param <C> |
222 |
| - * the type of the component |
223 |
| - */ |
224 |
| - public static <C extends Component> Registration format(C owner, |
225 |
| - SerializableBiConsumer<C, String> setter, String format, |
226 |
| - Signal<?>... signals) { |
227 |
| - Locale locale = LocaleUtil.getLocale(); |
228 |
| - return format(owner, setter, locale, format, signals); |
229 |
| - } |
230 |
| - |
231 | 137 | private void enableEffect(Component owner) {
|
232 | 138 | if (closed) {
|
233 | 139 | return;
|
|
0 commit comments