Project

General

Profile

« Previous | Next » 

Revision 7b4a20a4

Added by Andreas Kohlbecker about 6 years ago

ref #7246 ReloadableLazyComboBox performance improvement

View differences:

src/main/java/eu/etaxonomy/vaadin/component/ReloadableLazyComboBox.java
17 17
import com.vaadin.ui.AbstractSelect;
18 18
import com.vaadin.ui.ComboBox;
19 19

  
20
public class ReloadableLazyComboBox<T> extends LazyComboBox<T> implements ReloadableSelect, EntitySupport<T>{
20
public class ReloadableLazyComboBox<T> extends LazyComboBox<T> implements ReloadableSelect, EntitySupport<T> {
21 21

  
22 22

  
23 23
    private static final long serialVersionUID = -4833661351090992884L;
24 24

  
25
//    boolean originalScrollToSelect;
26

  
25 27
    static Field lazySelectInternalValueField;
26 28
    static Field internalSelectField;
27 29
    static {
......
44 46
     */
45 47
    public ReloadableLazyComboBox(Class<T> itemType) {
46 48
        super(itemType);
47
        // in the LazyComboBox.initList() scrollToSelectedItem is set to false for better performance
48
        // but this breaks the refresh, so we need to set it true
49
        // (temporarily setting it true in reload() does not work)
50
        ((ComboBox)getSelect()).setScrollToSelectedItem(true);
51 49
    }
52 50

  
53 51
    /**
......
55 53
     */
56 54
    @Override
57 55
    public void reload() {
56
        // in the LazyComboBox.initList() scrollToSelectedItem is set to false for better performance
57
        // but this breaks the refresh, so we need to set it now so that it can
58
        // affect the next component repaint which is triggered in refresh()
59
        ComboBox comboBox = (ComboBox)getSelect();
60
        comboBox.setScrollToSelectedItem(true);
58 61
        refresh(); // reload from persistence
59
        discard(); // reload from data source
62
        discard(); // reload from property data source
60 63
    }
61 64

  
65

  
62 66
    /**
63 67
     * This method allows updating the value even if the equals check done
64 68
     * in {@link com.vaadin.ui.AbstractField#setValue(Object)} would return true.
......
118 122
        }
119 123
    }
120 124

  
125

  
121 126
}

Also available in: Unified diff