Project

General

Profile

Revision 8d14e2c1

ID8d14e2c1ebe0af6f928365926d3e2295aa65c023
Parent db767472
Child 9da64e4a

Added by Andreas Kohlbecker almost 4 years ago

executing list filter while typing

View differences:

src/main/java/eu/etaxonomy/cdm/vaadin/event/UpdateResultsEvent.java
8 8
*/
9 9
package eu.etaxonomy.cdm.vaadin.event;
10 10

  
11
import com.vaadin.ui.TextField;
12

  
11 13
import eu.etaxonomy.vaadin.mvp.AbstractView;
12 14

  
13 15
/**
......
18 20
public class UpdateResultsEvent {
19 21

  
20 22
    private AbstractView sourceView = null;
23
    TextField field;
24
    String newText;
21 25

  
22 26

  
23 27
    /**
24 28
     * @param sourceView
25 29
     */
26
    public UpdateResultsEvent(AbstractView sourceView) {
30
    public UpdateResultsEvent(TextField field, String newText, AbstractView sourceView) {
27 31
        super();
28 32
        this.sourceView = sourceView;
33
        this.field = field;
34
        this.newText = newText;
29 35
    }
30 36

  
31 37
    /**
......
42 48
        this.sourceView = sourceView;
43 49
    }
44 50

  
51
    /**
52
     * @return the field
53
     */
54
    public TextField getField() {
55
        return field;
56
    }
57

  
58
    /**
59
     * @return the newText
60
     */
61
    public String getNewText() {
62
        return newText;
63
    }
64

  
45 65

  
46 66

  
47 67
}
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/TaxonNamePopupEditor.java
13 13

  
14 14
import org.springframework.security.core.GrantedAuthority;
15 15

  
16
import com.vaadin.shared.ui.label.ContentMode;
16 17
import com.vaadin.ui.Alignment;
17 18
import com.vaadin.ui.CheckBox;
18 19
import com.vaadin.ui.GridLayout;
20
import com.vaadin.ui.Label;
19 21
import com.vaadin.ui.ListSelect;
20 22
import com.vaadin.ui.TextField;
21 23

  
......
232 234
        combinationAuthorshipField = new TeamOrPersonField("combination author(s)");
233 235
        combinationAuthorshipField.setWidth(100,  Unit.PERCENTAGE);
234 236
        addField(combinationAuthorshipField, "combinationAuthorship", 0, row, GRID_COLS-1, row);
235
        row++;
236
        exCombinationAuthorshipField = new TeamOrPersonField("Ex-combination author(s)");
237
        exCombinationAuthorshipField.setWidth(100,  Unit.PERCENTAGE);
238
        addField(exCombinationAuthorshipField, "exCombinationAuthorship", 0, row, GRID_COLS-1, row);
239 237

  
238
        row++;
239
        grid.addComponent(new Label("Hint: <i>Nomenclatural authors can be edited in the nomenclatural reference.</i>", ContentMode.HTML), 0, row, 3, row);
240 240
        // nomenclaturalReference
241 241
        row++;
242 242
        nomReferenceCombobox = new ToOneRelatedEntityCombobox<Reference>("Nomenclatural reference", Reference.class);
......
260 260
        nomenclaturalReferenceDetail = addTextField("Reference detail", "nomenclaturalMicroReference", 3, row, 3, row);
261 261
        nomenclaturalReferenceDetail.setWidth(100, Unit.PIXELS);
262 262

  
263
        row++;
264
        exCombinationAuthorshipField = new TeamOrPersonField("Ex-combination author(s)");
265
        exCombinationAuthorshipField.setWidth(100,  Unit.PERCENTAGE);
266
        addField(exCombinationAuthorshipField, "exCombinationAuthorship", 0, row, GRID_COLS-1, row);
263 267

  
264 268
        // Basionym
265 269
        row++;
......
313 317
     * @return
314 318
     */
315 319
    private void enableBasionymFields(boolean enable) {
320

  
321

  
316 322
        basionymAuthorshipField.setVisible(enable);
317 323
        exBasionymAuthorshipField.setVisible(enable);
318 324
        basionymsComboboxSelect.setVisible(enable);
319
        if(modesActive.contains(TaxonNamePopupEditorMode.suppressReplacementAuthorshipData)){
320
            TaxonName taxonName = getBean();
321
            basionymAuthorshipField.setVisible(taxonName.getBasionymAuthorship() != null);
325
        TaxonName taxonName = getBean();
326

  
327
        if(taxonName != null){
328
            if(modesActive.contains(TaxonNamePopupEditorMode.suppressReplacementAuthorshipData)){
329
                basionymAuthorshipField.setVisible(taxonName.getBasionymAuthorship() != null);
330
            }
331
            updateFieldVisibility(taxonName.getRank());
322 332
        }
323 333
    }
324 334

  
......
333 343
        specificEpithetField.setVisible(isSpeciesOrBelow);
334 344
        infraGenericEpithetField.setVisible(rank.isInfraGenericButNotSpeciesGroup());
335 345
        genusOrUninomialField.setCaption(isSpeciesOrBelow ? "Genus" : "Uninomial");
346
        exCombinationAuthorshipField.setVisible(isSpeciesOrBelow);
336 347
    }
337 348

  
338 349
    @Override
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/ListPresenter.java
17 17

  
18 18
import com.vaadin.spring.annotation.SpringComponent;
19 19
import com.vaadin.spring.annotation.ViewScope;
20
import com.vaadin.ui.TextField;
20 21

  
21 22
import eu.etaxonomy.cdm.api.service.pager.Pager;
22 23
import eu.etaxonomy.cdm.model.common.User;
......
74 75
            getView().getSubmitterFilter().setItemCaptionPropertyId("username");
75 76
        }
76 77

  
77
        getView().populate(pageRegistrations());
78
        getView().populate(pageRegistrations(null, null));
78 79
    }
79 80

  
80 81
    /**
......
82 83
     *
83 84
     * @return
84 85
     */
85
    private Pager<RegistrationDTO> pageRegistrations() {
86
    private Pager<RegistrationDTO> pageRegistrations(TextField textFieldOverride, String alternativeText) {
86 87

  
87 88
        // list all if the authenticated user is having the role CURATION of if it is an admin
88 89
        Authentication authentication = currentSecurityContext().getAuthentication();
89 90

  
90 91
        // prepare the filters
91
        String identifierFilter = getView().getIdentifierFilter().getValue();
92
        String nameFilter = getView().getTaxonNameFilter().getValue();
92
        String identifierFilter;
93
        if(textFieldOverride != null && textFieldOverride == getView().getIdentifierFilter()){
94
            identifierFilter = alternativeText;
95
        } else {
96
            identifierFilter = getView().getIdentifierFilter().getValue();
97
        }
98
        String nameFilter;
99
        if(textFieldOverride != null && textFieldOverride == getView().getTaxonNameFilter()){
100
            nameFilter = alternativeText;
101
        } else {
102
            nameFilter = getView().getTaxonNameFilter().getValue();
103
        }
93 104
        User submitter = null;
94 105
        if(getView().getSubmitterFilter() != null){
95 106
            Object o = getView().getSubmitterFilter().getValue();
......
137 148

  
138 149
    @EventListener
139 150
    public void onUpdateResultsEvent(UpdateResultsEvent event){
140
        getView().populate(pageRegistrations());
151
        getView().populate(pageRegistrations(event.getField(), event.getNewText()));
141 152
    }
142 153

  
143 154
}
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/ListViewBean.java
86 86

  
87 87
            submitterFilter = new ListSelect("Submitter");
88 88
            submitterFilter.setRows(1);
89
            submitterFilter.addValueChangeListener(e -> updateResults());
89
            submitterFilter.addValueChangeListener(e -> updateResults(null, null));
90 90
            toolBar.addComponent(submitterFilter);
91 91
        }
92 92

  
......
94 94
            statusFilter = new ListSelect("Status", Arrays.asList(RegistrationStatus.values()));
95 95
            statusFilter.setNullSelectionAllowed(true);
96 96
            statusFilter.setRows(1);
97
            statusFilter.addValueChangeListener(e -> updateResults());
97
            statusFilter.addValueChangeListener(e -> updateResults(null, null));
98 98
            toolBar.addComponent(statusFilter);
99 99
        }
100 100

  
101 101
        toolBar.addComponents(identifierFilter, taxonNameFilter);
102
        identifierFilter.addValueChangeListener(e -> updateResults());
103
        taxonNameFilter.addValueChangeListener(e -> updateResults());
102
        int textChangeTimeOut = 200;
103
        identifierFilter.addTextChangeListener(e -> updateResults(identifierFilter, e.getText()));
104
        identifierFilter.setTextChangeTimeout(textChangeTimeOut);
105
        taxonNameFilter.addTextChangeListener(e -> updateResults(taxonNameFilter, e.getText()));
106
        identifierFilter.setTextChangeTimeout(textChangeTimeOut);
104 107

  
105 108
        toolBar.setSpacing(true);
106 109
        addContentComponent(toolBar, null);
......
115 118
    /**
116 119
     * @return
117 120
     */
118
    private void updateResults() {
119
        eventBus.publishEvent(new UpdateResultsEvent(this));
121
    private void updateResults(TextField field, String newText) {
122
        eventBus.publishEvent(new UpdateResultsEvent(field, newText, this));
120 123
    }
121 124

  
122 125
    @Override

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)