]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.browsing.ui/src/org/simantics/browsing/ui/content/CompositeImageDecorator.java
Do not compute replaceable type for non ReplaceableDefinedComponentTypes
[simantics/platform.git] / bundles / org.simantics.browsing.ui / src / org / simantics / browsing / ui / content / CompositeImageDecorator.java
1 package org.simantics.browsing.ui.content;
2
3 import java.util.Collection;
4
5 public class CompositeImageDecorator implements ImageDecorator {
6
7     Collection<ImageDecorator> decorators;
8
9     public static final ImageDecorator ID = new ImageDecorator() {
10         @Override
11         public <Image> Image decorateImage(Image image, String column, int itemIndex) {
12             return image;
13         }
14     };
15
16     private CompositeImageDecorator(Collection<ImageDecorator> decorators) {
17         this.decorators = decorators;
18     }
19
20     public static ImageDecorator create(Collection<ImageDecorator> decorators) {
21         if(decorators.isEmpty())
22             return ID;
23         else if(decorators.size() == 1)
24             return decorators.iterator().next();
25         else
26             return new CompositeImageDecorator(decorators);
27     }
28
29     @Override
30     public <Image> Image decorateImage(Image image, String column, int itemIndex) {
31         for(ImageDecorator decorator : decorators)
32             image = decorator.decorateImage(image, column, itemIndex);
33         return image;
34     }
35
36 }