aboutsummaryrefslogtreecommitdiffstats
path: root/server/src
diff options
context:
space:
mode:
Diffstat (limited to 'server/src')
-rw-r--r--server/src/main/java/com/vaadin/ui/AbstractListing.java6
-rw-r--r--server/src/main/java/com/vaadin/ui/ComboBox.java11
-rw-r--r--server/src/main/java/com/vaadin/ui/DeclarativeCaptionGenerator.java10
-rw-r--r--server/src/main/java/com/vaadin/ui/DeclarativeIconGenerator.java10
-rw-r--r--server/src/main/java/com/vaadin/ui/DeclarativeItemEnabledProvider.java2
5 files changed, 30 insertions, 9 deletions
diff --git a/server/src/main/java/com/vaadin/ui/AbstractListing.java b/server/src/main/java/com/vaadin/ui/AbstractListing.java
index 2f455fa27b..6f0463b822 100644
--- a/server/src/main/java/com/vaadin/ui/AbstractListing.java
+++ b/server/src/main/java/com/vaadin/ui/AbstractListing.java
@@ -324,8 +324,10 @@ public abstract class AbstractListing<T> extends AbstractComponent {
Boolean.class));
}
- setItemCaptionGenerator(new DeclarativeCaptionGenerator<>());
- setItemIconGenerator(new DeclarativeIconGenerator<>());
+ setItemCaptionGenerator(
+ new DeclarativeCaptionGenerator<>(getItemCaptionGenerator()));
+ setItemIconGenerator(
+ new DeclarativeIconGenerator<>(getItemIconGenerator()));
List<T> readItems = readItems(design, context);
if (!readItems.isEmpty() && this instanceof Listing) {
diff --git a/server/src/main/java/com/vaadin/ui/ComboBox.java b/server/src/main/java/com/vaadin/ui/ComboBox.java
index f0f90eab22..2b91236843 100644
--- a/server/src/main/java/com/vaadin/ui/ComboBox.java
+++ b/server/src/main/java/com/vaadin/ui/ComboBox.java
@@ -84,11 +84,18 @@ public class ComboBox<T> extends AbstractSingleSelect<T>
*/
protected static class DeclarativeStyleGenerator<T>
implements StyleGenerator<T> {
+
+ private StyleGenerator<T> fallback;
private Map<T, String> styles = new HashMap<>();
+ public DeclarativeStyleGenerator(StyleGenerator<T> fallback) {
+ this.fallback = fallback;
+ }
+
@Override
public String apply(T item) {
- return styles.get(item);
+ return styles.containsKey(item) ? styles.get(item)
+ : fallback.apply(item);
}
/**
@@ -581,7 +588,7 @@ public class ComboBox<T> extends AbstractSingleSelect<T>
@Override
protected List<T> readItems(Element design, DesignContext context) {
- setStyleGenerator(new DeclarativeStyleGenerator<>());
+ setStyleGenerator(new DeclarativeStyleGenerator<>(getStyleGenerator()));
return super.readItems(design, context);
}
diff --git a/server/src/main/java/com/vaadin/ui/DeclarativeCaptionGenerator.java b/server/src/main/java/com/vaadin/ui/DeclarativeCaptionGenerator.java
index 9aa6035d9d..617315459d 100644
--- a/server/src/main/java/com/vaadin/ui/DeclarativeCaptionGenerator.java
+++ b/server/src/main/java/com/vaadin/ui/DeclarativeCaptionGenerator.java
@@ -28,16 +28,22 @@ import java.util.Map;
*/
class DeclarativeCaptionGenerator<T> implements ItemCaptionGenerator<T> {
+ private ItemCaptionGenerator<T> fallback;
private Map<T, String> captions = new HashMap<>();
+ public DeclarativeCaptionGenerator(ItemCaptionGenerator<T> fallback) {
+ this.fallback = fallback;
+ }
+
@Override
public String apply(T item) {
- return captions.get(item);
+ return captions.containsKey(item) ? captions.get(item)
+ : fallback.apply(item);
}
/**
* Sets a {@code caption} for the {@code item}.
- *
+ *
* @param item
* a data item
* @param caption
diff --git a/server/src/main/java/com/vaadin/ui/DeclarativeIconGenerator.java b/server/src/main/java/com/vaadin/ui/DeclarativeIconGenerator.java
index 984ac4cf47..926de395b3 100644
--- a/server/src/main/java/com/vaadin/ui/DeclarativeIconGenerator.java
+++ b/server/src/main/java/com/vaadin/ui/DeclarativeIconGenerator.java
@@ -30,16 +30,22 @@ import com.vaadin.server.Resource;
*/
class DeclarativeIconGenerator<T> implements IconGenerator<T> {
+ private IconGenerator<T> fallback;
private Map<T, Resource> captions = new HashMap<>();
+ public DeclarativeIconGenerator(IconGenerator<T> fallback) {
+ this.fallback = fallback;
+ }
+
@Override
public Resource apply(T item) {
- return captions.get(item);
+ return captions.containsKey(item) ? captions.get(item)
+ : fallback.apply(item);
}
/**
* Sets an {@code icon} for the {@code item}.
- *
+ *
* @param item
* a data item
* @param icon
diff --git a/server/src/main/java/com/vaadin/ui/DeclarativeItemEnabledProvider.java b/server/src/main/java/com/vaadin/ui/DeclarativeItemEnabledProvider.java
index f16e54f1b2..adb2ade00f 100644
--- a/server/src/main/java/com/vaadin/ui/DeclarativeItemEnabledProvider.java
+++ b/server/src/main/java/com/vaadin/ui/DeclarativeItemEnabledProvider.java
@@ -39,7 +39,7 @@ class DeclarativeItemEnabledProvider<T> implements SerializablePredicate<T> {
/**
* Adds the {@code item} to disabled items list.
- *
+ *
* @param item
* a data item
* @param caption