Project

General

Profile

« Previous | Next » 

Revision cca5f235

Added by Andreas Kohlbecker almost 5 years ago

ref #8220 editing exististing names for new regitration: citation detail enabled, section only restriction disabled

View differences:

src/main/java/eu/etaxonomy/cdm/vaadin/view/name/TaxonNameEditorPresenter.java
336 336
        return getRepo().getNameService();
337 337
    }
338 338

  
339
    /**
340
     * @param referenceEditorPopup
341
     */
342
    private void configureReferencePopupEditor(ReferencePopupEditor referenceEditorPopup, UUID referenceUUID) {
343
        boolean nomRefSectionEditingOnly = getView().isModeEnabled(TaxonNamePopupEditorMode.NOMENCLATURALREFERENCE_SECTION_EDITING_ONLY);
344
        if(nomRefSectionEditingOnly){
345
            referenceEditorPopup.setBeanInstantiator(newReferenceInstantiator);
346
        }
347

  
348
        // TODO this should be configurable per UI - RegistrationUiReferenceEditorFormConfigurator as spring bean, different spring profiles
349
        referenceEditorPopup.setEditorComponentsConfigurator(new RegistrationUiReferenceEditorFormConfigurator(nomRefSectionEditingOnly && newReferenceInstantiator != null));
350

  
351
        referenceEditorPopup.loadInEditor(referenceUUID);
352
        if(!nomRefSectionEditingOnly){
353
            referenceEditorPopup.getTypeSelect().setValue(ReferenceType.Article);
354
        }
355
    }
356

  
339 357
    @EventBusListenerMethod(filter = EditorActionTypeFilter.Add.class)
340 358
    public void onReferenceEditorActionAdd(ReferenceEditorAction event) {
341 359

  
......
347 365

  
348 366
        referenceEditorPopup.grantToCurrentUser(EnumSet.of(CRUD.UPDATE, CRUD.DELETE));
349 367
        referenceEditorPopup.withDeleteButton(true);
350
        referenceEditorPopup.setBeanInstantiator(newReferenceInstantiator);
351
        // TODO this should be configurable per UI - RegistrationUiReferenceEditorFormConfigurator as spring bean, different spring profiles
352
        referenceEditorPopup.setEditorComponentsConfigurator(new RegistrationUiReferenceEditorFormConfigurator(newReferenceInstantiator != null));
353
        referenceEditorPopup.loadInEditor(null);
354
//        if(newReferenceInstantiator != null){
355
//            // this is a bit clumsy, we actually need to inject something like a view configurer
356
//            // which can enable, disable fields
357
//            referenceEditorPopup.getInReferenceCombobox().setEnabled(false);
358
//            referenceEditorPopup.getTypeSelect().setEnabled(false);
359
//        }
368
        configureReferencePopupEditor(referenceEditorPopup, null);
360 369
    }
361 370

  
371

  
362 372
    @EventBusListenerMethod(filter = EditorActionTypeFilter.Edit.class)
363 373
    public void onReferenceEditorActionEdit(ReferenceEditorAction event) {
364 374

  
......
369 379
        ReferencePopupEditor referenceEditorPopup = openPopupEditor(ReferencePopupEditor.class, event);
370 380

  
371 381
        referenceEditorPopup.withDeleteButton(true);
372
        referenceEditorPopup.setBeanInstantiator(newReferenceInstantiator);
373
        // TODO this should be configurable per UI - RegistrationUiReferenceEditorFormConfigurator as spring bean, different spring profiles
374
        referenceEditorPopup.setEditorComponentsConfigurator(new RegistrationUiReferenceEditorFormConfigurator(newReferenceInstantiator != null));
375
        referenceEditorPopup.loadInEditor(event.getEntityUuid());
376
//        if(newReferenceInstantiator != null){
377
//            // this is a bit clumsy, we actually need to inject something like a view configurator
378
//            // which can enable, disable fields
379
//            referenceEditorPopup.getInReferenceCombobox().setEnabled(false);
380
//            referenceEditorPopup.getInReferenceCombobox().setEditButtonEnabled(false); // <-------
381
//            referenceEditorPopup.getTypeSelect().setEnabled(false);
382
//        }
382
        configureReferencePopupEditor(referenceEditorPopup, event.getEntityUuid());
383 383
    }
384 384

  
385 385
    @EventBusListenerMethod
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/TaxonNamePopupEditor.java
873 873
        return nomReferenceCombobox;
874 874
    }
875 875

  
876

  
877
    /**
878
     * {@inheritDoc}
879
     */
880
    @Override
881
    public TextField getNomenclaturalReferenceDetail() {
882
        return nomenclaturalReferenceDetail;
883
    }
884

  
876 885
    /**
877 886
     * {@inheritDoc}
878 887
     */
......
950 959
    @Override
951 960
    public void enableMode(TaxonNamePopupEditorMode mode){
952 961
            modesActive.add(mode);
962
            updateFormOnModeChange();
953 963
    }
954 964

  
955 965
    @Override
......
960 970
    @Override
961 971
    public void disableMode(TaxonNamePopupEditorMode mode){
962 972
        modesActive.remove(mode);
973
        updateFormOnModeChange();
974
    }
975

  
976
    /**
977
     * updates UI in turn of mode changes if needed, that is when the bean has been set
978
     * already.
979
     */
980
    private void updateFormOnModeChange() {
981
        if(getBean() != null){
982
            // need to update the ui
983
            afterItemDataSourceSet();
984
            if(!isModeEnabled(TaxonNamePopupEditorMode.AUTOFILL_AUTHORSHIP_DATA)){
985
                updateFieldVisibility();
986
            }
987
        }
963 988
    }
964 989

  
965 990
    @Override
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/TaxonNamePopupEditorView.java
13 13
import com.vaadin.ui.AbstractField;
14 14
import com.vaadin.ui.CheckBox;
15 15
import com.vaadin.ui.NativeSelect;
16
import com.vaadin.ui.TextField;
16 17

  
17 18
import eu.etaxonomy.cdm.model.name.TaxonName;
18 19
import eu.etaxonomy.cdm.model.reference.Reference;
......
120 121

  
121 122
    CheckBox getOrthographicVariantToggle();
122 123

  
124
    /**
125
     * @return
126
     */
127
    TextField getNomenclaturalReferenceDetail();
128

  
123 129

  
124 130
}
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorkingsetPresenter.java
380 380
                // editing need to be done another way.
381 381
                // Otherwise we would need to be prepared for creating blocking registrations
382 382
                // in turn of creation, modification of related taxon names.
383
                popup.disableMode(TaxonNamePopupEditorMode.NOMENCLATURALREFERENCE_SECTION_EDITING_ONLY);
383 384
                popup.getNomReferenceCombobox().setReadOnly(false);
385
                popup.getNomenclaturalReferenceDetail().setReadOnly(false);
384 386
                popup.addStatusMessage("The chosen name needs to be completed before it can be used. "
385 387
                        + "Please add the nomenclatural reference and click on \"Save\" to proceed "
386 388
                        + "with entering the typifications for this name.");

Also available in: Unified diff