mirror of
https://gitee.com/jmix/cuba.git
synced 2024-11-30 10:17:43 +08:00
Java 8 Functional interfaces #363
This commit is contained in:
parent
e5c3e7c1fb
commit
1c03eac407
@ -25,5 +25,11 @@ public interface ButtonsPanel extends BoxLayout {
|
||||
|
||||
@Deprecated
|
||||
interface Provider extends Supplier<Collection<Component>> {
|
||||
@Override
|
||||
default Collection<Component> get() {
|
||||
return getButtons();
|
||||
}
|
||||
|
||||
Collection<Component> getButtons();
|
||||
}
|
||||
}
|
@ -260,5 +260,11 @@ public interface FileUploadField extends UploadField, Field<FileDescriptor>, Com
|
||||
|
||||
@Deprecated
|
||||
interface FileContentProvider extends Supplier<InputStream> {
|
||||
@Override
|
||||
default InputStream get() {
|
||||
return provide();
|
||||
}
|
||||
|
||||
InputStream provide();
|
||||
}
|
||||
}
|
@ -46,5 +46,18 @@ public interface ListComponent<E extends Entity> extends Component, Component.Be
|
||||
*/
|
||||
@Deprecated
|
||||
interface IconProvider<E extends Entity> extends Function<E, String> {
|
||||
@Override
|
||||
default String apply(E entity) {
|
||||
return getItemIcon(entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by {@link Table} to get an icon to be shown for a row.
|
||||
*
|
||||
* @param entity an entity instance represented by the current row
|
||||
* @return icon name or null to show no icon
|
||||
*/
|
||||
@Nullable
|
||||
String getItemIcon(E entity);
|
||||
}
|
||||
}
|
@ -145,6 +145,16 @@ public interface LookupField<V> extends OptionsField<V, V>, HasInputPrompt, Buff
|
||||
*/
|
||||
@Deprecated
|
||||
interface NewOptionHandler extends Consumer<String> {
|
||||
@Override
|
||||
default void accept(String caption) {
|
||||
addNewOption(caption);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when user enters a value which is not in the options list, and presses Enter.
|
||||
* @param caption value entered by user
|
||||
*/
|
||||
void addNewOption(String caption);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -152,5 +162,17 @@ public interface LookupField<V> extends OptionsField<V, V>, HasInputPrompt, Buff
|
||||
*/
|
||||
@Deprecated
|
||||
interface OptionIconProvider<T> extends Function<T, String> {
|
||||
@Override
|
||||
default String apply(T item) {
|
||||
return getItemIcon(item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when component paints its content.
|
||||
*
|
||||
* @param item item from options list, options map or enum options
|
||||
* @return icon name or null to show no icon
|
||||
*/
|
||||
String getItemIcon(T item);
|
||||
}
|
||||
}
|
@ -139,6 +139,12 @@ public interface TokenList<V> extends Field<V>, Component.BelongToFrame, Compone
|
||||
|
||||
@Deprecated
|
||||
interface TokenStyleGenerator extends Function<Object, String> {
|
||||
@Override
|
||||
default String apply(Object itemId) {
|
||||
return getStyle(itemId);
|
||||
}
|
||||
|
||||
String getStyle(Object itemId);
|
||||
}
|
||||
|
||||
interface ItemChangeHandler {
|
||||
|
@ -88,6 +88,20 @@ public interface Tree<E extends Entity> extends ListComponent<E>, Component.Edit
|
||||
*/
|
||||
@Deprecated
|
||||
interface StyleProvider<E extends Entity> extends Function<E, String> {
|
||||
@Override
|
||||
default String apply(E entity) {
|
||||
return getStyleName(entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by {@link Tree} to get a style for item. <br>
|
||||
* All unhandled exceptions from StyleProvider in Web components by default are logged with ERROR level
|
||||
* and not shown to users.
|
||||
*
|
||||
* @param entity an entity instance represented by the current item
|
||||
* @return style name or null to apply the default
|
||||
*/
|
||||
String getStyleName(E entity);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user