Project

General

Profile

Download (3.37 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2017 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.vaadin.component;
10

    
11
import org.vaadin.viritin.fields.CaptionGenerator;
12
import org.vaadin.viritin.fields.LazyComboBox;
13
import org.vaadin.viritin.fields.LazyComboBox.FilterableCountProvider;
14
import org.vaadin.viritin.fields.LazyComboBox.FilterablePagingProvider;
15

    
16
import com.vaadin.ui.Button.ClickListener;
17

    
18
/**
19
 * @author a.kohlbecker
20
 * @since Jun 7, 2017
21
 *
22
 */
23
public class ToManyRelatedEntitiesComboboxSelect<V extends Object> extends ToManyRelatedEntitiesListSelect<V, LazyComboBox<V>> {
24

    
25
    private static final long serialVersionUID = -4496067980953939548L;
26

    
27
    private FilterablePagingProvider<V> filterablePagingProvider = null;
28
    private FilterableCountProvider filterableCountProvider = null;
29
    private Integer pageLength = null;
30

    
31
    private CaptionGenerator<V> captionGenerator;
32

    
33
    /**
34
     * @param itemType
35
     * @param fieldType
36
     * @param caption
37
     */
38
    public ToManyRelatedEntitiesComboboxSelect(Class<V> itemType, String caption) {
39
        super(itemType, null, caption);
40
        // TODO this.fieldTyp = LazyComboBox.class does not work
41
        LazyComboBox<V> field = new LazyComboBox<V>(itemType);
42
        this.fieldType = (Class<LazyComboBox<V>>) field.getClass();
43

    
44

    
45
    }
46

    
47
    /**
48
     * {@inheritDoc}
49
     */
50
    @Override
51
    protected LazyComboBox<V> newFieldInstance(V val) throws InstantiationException, IllegalAccessException {
52
        LazyComboBox<V> field = new LazyComboBox<V>(itemType);
53

    
54
        if(filterablePagingProvider == null || filterableCountProvider == null ||  pageLength == null) {
55
            throw new RuntimeException("The filterablePagingProvider, filterableCountProvider and pageLength must be set, use setPagingProviders().");
56
        }
57
        field.loadFrom(filterablePagingProvider, filterableCountProvider, pageLength);
58
        if(captionGenerator != null){
59
            field.setCaptionGenerator(captionGenerator);
60
        }
61
        return field;
62
    }
63

    
64
    public void setPagingProviders(FilterablePagingProvider<V> filterablePagingProvider, FilterableCountProvider filterableCountProvider, int pageLength){
65
        this.filterablePagingProvider = filterablePagingProvider;
66
        this.filterableCountProvider = filterableCountProvider;
67
        this.pageLength = pageLength;
68
    }
69

    
70
    /**
71
     * @param cdmTitleCacheCaptionGenerator
72
     */
73
    public void setCaptionGenerator(CaptionGenerator<V> captionGenerator) {
74
        this.captionGenerator = captionGenerator;
75
    }
76

    
77
    /**
78
     * {@inheritDoc}
79
     */
80
    @Override
81
    protected ClickListener newEditButtonClicklistener(LazyComboBox<V> field) {
82
        // TODO Auto-generated method stub
83
        return super.newEditButtonClicklistener(field);
84
    }
85

    
86
    /**
87
     * {@inheritDoc}
88
     */
89
    @Override
90
    protected ClickListener newAddButtonClicklistener(LazyComboBox<V> field) {
91
        // TODO Auto-generated method stub
92
        return super.newAddButtonClicklistener(field);
93
    }
94

    
95
    /**
96
     * {@inheritDoc}
97
     */
98
    @Override
99
    protected ClickListener newRemoveButtonClicklistener(LazyComboBox<V> field) {
100
        // TODO Auto-generated method stub
101
        return super.newRemoveButtonClicklistener(field);
102
    }
103

    
104

    
105

    
106
}
(6-6/10)