Project

General

Profile

Revision af0633ea

IDaf0633ea30b3c4e985bd4020c0e6a60eb8ea93ae
Parent 98db0610
Child eb8d2f54

Added by Andreas Kohlbecker over 1 year ago

ref #8176 WeaklyRelatedEntityCombobox solving minor performance on setValue

View differences:

src/main/java/eu/etaxonomy/cdm/service/TaxonNameStringFilterablePagingProvider.java
13 13
import java.util.HashMap;
14 14
import java.util.List;
15 15
import java.util.Map;
16
import java.util.Objects;
16 17
import java.util.UUID;
17 18

  
18 19
import org.apache.log4j.Logger;
......
233 234
    @Override
234 235
    public UUID idFor(String stringRepresentation) {
235 236
        if(lastPagedEntityUUIDs == null){
236
            findEntities(0, stringRepresentation);
237
            int pages = Math.max(1, size(stringRepresentation));
238
            for(int i = 0; i < pages; i++){
239
                findEntities(i, stringRepresentation);
240
            }
237 241
        }
238 242
        return lastPagedEntityUUIDs.get(stringRepresentation);
239 243
    }
src/main/java/eu/etaxonomy/vaadin/component/WeaklyRelatedEntityCombobox.java
8 8
*/
9 9
package eu.etaxonomy.vaadin.component;
10 10

  
11
import java.util.Objects;
11 12
import java.util.Optional;
12 13
import java.util.UUID;
13 14

  
......
196 197
     */
197 198
    @Override
198 199
    public void setValue(String newFieldValue) throws com.vaadin.data.Property.ReadOnlyException, ConversionException {
199
        lazySelect.refresh();
200
        if(lazySelect.getOptions().contains(newFieldValue)){
201
            lazySelect.setValue(newFieldValue);
200
        if(!Objects.equals(newFieldValue, lazySelect.getValue())){
201
            lazySelect.refresh();
202
            if(contains(newFieldValue)){
203
                lazySelect.setValue(newFieldValue);
204
            }
205
            lazySelect.markAsDirty();
202 206
        }
203
        lazySelect.markAsDirty();
204 207
    }
205 208

  
209
    /**
210
     * @param newFieldValue
211
     * @return
212
     */
213
    private boolean contains(String newFieldValue) {
214
        UUID id = filterablePagingProvider.idFor(newFieldValue);
215
        return id != null;
216
    }
217

  
218

  
206 219
    @Override
207 220
    public boolean isValueInOptions(){
208 221
        return lazySelect.getOptions().contains(lazySelect.getValue());

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)