Project

General

Profile

Revision 98a2455f

ID98a2455f3da2841496b415bc1f402515a6e0b034
Parent f9c6b1eb
Child 1f016f08

Added by Andreas Kohlbecker almost 3 years ago

fix #7245 fixing validation of ToOneRelatedEntityCombobox and re-enabling TaxonNamePopupEditorMode.REQUIRE_NOMENCLATURALREFERENCE

View differences:

src/main/java/eu/etaxonomy/cdm/vaadin/ui/config/TaxonNamePopupEditorConfig.java
31 31
        popup.enableMode(TaxonNamePopupEditorMode.AUTOFILL_AUTHORSHIP_DATA);
32 32
        popup.enableMode(TaxonNamePopupEditorMode.NOMENCLATURALREFERENCE_SECTION_EDITING_ONLY);
33 33
        popup.enableMode(TaxonNamePopupEditorMode.VALIDATE_AGAINST_HIGHER_NAME_PART);
34
        // popup.enableMode(TaxonNamePopupEditorMode.REQUIRE_NOMENCLATURALREFERENCE);
34
        popup.enableMode(TaxonNamePopupEditorMode.REQUIRE_NOMENCLATURALREFERENCE);
35 35
    }
36 36

  
37 37
    /**
......
42 42
    public static void configure(TaxonNamePopupEditorView popup) {
43 43
        popup.enableMode(TaxonNamePopupEditorMode.AUTOFILL_AUTHORSHIP_DATA);
44 44
        popup.enableMode(TaxonNamePopupEditorMode.VALIDATE_AGAINST_HIGHER_NAME_PART);
45
        // popup.enableMode(TaxonNamePopupEditorMode.REQUIRE_NOMENCLATURALREFERENCE);
45
        popup.enableMode(TaxonNamePopupEditorMode.REQUIRE_NOMENCLATURALREFERENCE);
46 46
    }
47 47

  
48 48
}
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/TaxonNameEditorPresenter.java
250 250
            };
251 251

  
252 252
        }
253

  
253 254
        return taxonName;
254 255
    }
255 256

  
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/TaxonNamePopupEditor.java
320 320

  
321 321
        row++;
322 322
        nomReferenceCombobox = new ToOneRelatedEntityCombobox<Reference>("Nomenclatural reference", Reference.class);
323
        // nomReferenceCombobox.setImmediate(true);
323 324
        nomReferenceCombobox.addClickListenerAddEntity(e -> getViewEventBus().publish(
324 325
                this,
325 326
                new ReferenceEditorAction(EditorActionType.ADD, null, nomReferenceCombobox, this)
......
560 561
        if(isModeEnabled(TaxonNamePopupEditorMode.REQUIRE_NOMENCLATURALREFERENCE)) {
561 562
            if(combinationAuthorshipField.getValue() == null){
562 563
                nomReferenceCombobox.setRequired(true);
564
                nomReferenceCombobox.setImmediate(true);
563 565
            } else {
564 566
                combinationAuthorshipField.addValueChangeListener(e -> {
565 567
                    if(e.getProperty().getValue() == null){
566 568
                        nomReferenceCombobox.setRequired(true);
569
                        nomReferenceCombobox.setImmediate(true);
567 570
                    }
568 571
                });
569 572
            }
570 573
        }
571

  
572 574
    }
573 575

  
574 576
    /**
src/main/java/eu/etaxonomy/vaadin/component/ReloadableLazyComboBox.java
120 120
        }
121 121
    }
122 122

  
123

  
124 123
}
src/main/java/eu/etaxonomy/vaadin/component/ToOneRelatedEntityCombobox.java
12 12
import org.vaadin.viritin.fields.LazyComboBox.FilterablePagingProvider;
13 13

  
14 14
import com.vaadin.data.Property;
15
import com.vaadin.data.Validator.InvalidValueException;
15 16
import com.vaadin.data.fieldgroup.FieldGroup;
16 17
import com.vaadin.data.util.converter.Converter.ConversionException;
18
import com.vaadin.server.AbstractErrorMessage.ContentMode;
19
import com.vaadin.server.ErrorMessage;
20
import com.vaadin.server.ErrorMessage.ErrorLevel;
21
import com.vaadin.server.UserError;
17 22
import com.vaadin.ui.Button;
18 23
import com.vaadin.ui.Button.ClickListener;
19 24
import com.vaadin.ui.Component;
......
50 55
        this.type = type;
51 56
        setCaption(caption);
52 57
        lazySelect = new ReloadableLazyComboBox<V>(type);
58
        lazySelect.setValidationVisible(false); // validation is to be shown for the ToOneRelatedEntityCombobox
59
        lazySelect.setRequiredError("Must be given");
60
        setRequiredError("Must be given");
53 61
        addStyledComponents(lazySelect, addButton, editButton);
54 62
        addSizedComponents(lazySelect, container);
63
        // lazySelect.setImmediate(true); // should cause immediate validation, however,
64
        // it does not work here, therefore we validate in the commitSelect() method during the commit
55 65
        lazySelect.addValueChangeListener(e -> {
56 66
            // update the itemContainer immediately so that the edit button acts on the chosen item
57
            lazySelect.commit();
67
            commitSelect();
58 68
        });
59 69
    }
60 70

  
......
169 179
     */
170 180
    @Override
171 181
    public V getValue() {
172
        lazySelect.commit();
182
        commitSelect();
173 183
        return lazySelect.getValue();
174 184
    }
175 185

  
176 186

  
187

  
188

  
189
    /**
190
     *
191
     */
192
    public void commitSelect() {
193
        try {
194
            setComponentError(null);
195
            lazySelect.commit();
196
        } catch (InvalidValueException ex){
197
            UserError componentError = new UserError(ex.getHtmlMessage(), ContentMode.HTML, ErrorLevel.ERROR);
198
            setComponentError(componentError);
199
        }
200
    }
201

  
202

  
177 203
    /**
178 204
     * {@inheritDoc}
179 205
     */
......
222 248
    }
223 249

  
224 250

  
251
    @Override
252
    public void validate() throws InvalidValueException {
253
        super.validate();
254
        lazySelect.validate();
255
    }
256

  
257

  
258
    @Override
259
    public ErrorMessage getErrorMessage() {
260
        ErrorMessage errorMessage = lazySelect.getErrorMessage();
261
        return errorMessage;
262
    }
263

  
264

  
265
    @Override
266
    public boolean isValid() {
267
        return lazySelect.isValid();
268
    }
269

  
270
    @Override
271
    public void setRequired(boolean required) {
272
        super.setRequired(required);
273
        lazySelect.setRequired(required);
274
    }
275

  
276

  
277
    @Override
278
    public boolean isRequired() {
279
        return lazySelect.isRequired();
280
    }
281

  
282
    @Override
283
    public void setImmediate(boolean immediate) {
284
        super.setImmediate(immediate);
285
        lazySelect.setImmediate(immediate);
286
    }
287

  
288

  
289
    @Override
290
    public void commit() throws SourceException, InvalidValueException {
291
        lazySelect.commit(); // we must not use the commitSelect() here to allow InvalidValueException to be handled by the caller
292
        super.commit();
293
    }
294

  
295

  
296
    @Override
297
    public void setComponentError(ErrorMessage componentError) {
298
        lazySelect.setComponentError(componentError);
299
        super.setComponentError(componentError);
300
    }
301

  
302

  
303

  
225 304
}
src/main/webapp/VAADIN/themes/edit-valo/custom-fields.scss
164 164
        .v-filterselect-button {
165 165
            right: $v-unit-size * 2 + 1px;
166 166
        }
167
        .v-component-group {
168
          .v-required-field-indicator {
169
              // no not show the indicator of the nested select
170
              display: none;
171
          }
172
          .v-errorindicator {
173
             // no not show the indicator of the nested select
174
              display: none;
175
          }
176
        }
167 177
    }
168 178
    
169 179
    // ------------ minMaxTextField ------------ //

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)