Project

General

Profile

« Previous | Next » 

Revision fadb1f53

Added by Andreas Kohlbecker about 5 years ago

ref #7548 relaoding of the workingset only when a 'root' popupeditor has been closed

View differences:

src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorkingsetPresenter.java
22 22
import java.util.Stack;
23 23
import java.util.UUID;
24 24

  
25
import org.apache.log4j.Level;
25 26
import org.apache.log4j.Logger;
26 27
import org.springframework.beans.factory.annotation.Autowired;
27 28
import org.vaadin.spring.events.EventScope;
......
170 171
     *
171 172
     */
172 173
    protected void refreshView(boolean doReload) {
174
        logger.setLevel(Level.DEBUG);
173 175
        if(workingset == null){
174 176
            return; // nothing to do
175 177
        }
176 178
        if(doReload){
179
            if(logger.isDebugEnabled()){
180
                logger.debug("refreshView() - workingset:\n" + workingset.toString());
181
            }
177 182
            List<RegistrationDTO> unpersisted = new ArrayList<>();
178 183
            for(RegistrationDTO regDto : workingset.getRegistrationDTOs()){
179 184
                if(!regDto.registration().isPersited()){
......
191 196
                    }
192 197
                }
193 198
            }
199
            if(logger.isDebugEnabled()){
200
                logger.debug("refreshView() - workingset reloaded:\n" + workingset.toString());
201
            }
194 202
        }
195 203
        applyWorkingset();
196 204
    }
......
332 340
        popup.loadInEditor(event.getEntityUuid());
333 341
    }
334 342

  
335
    @EventBusListenerMethod
336
    public void onDoneWithReferencePopupEditor(DoneWithPopupEvent event) throws RegistrationValidationException{
337
        if(event.getPopup() instanceof ReferencePopupEditor){
338
            if(event.getReason().equals(Reason.SAVE)){
339
                refreshView(true);
340
            }
341
        }
342
    }
343

  
344 343
    @EventBusListenerMethod(filter = EditorActionTypeFilter.Edit.class)
345 344
    public void onRegistrationEditorAction(RegistrationEditorAction event) {
346 345

  
......
418 417
    public void onDoneWithTaxonnameEditor(DoneWithPopupEvent event) {
419 418
        if(event.getPopup() instanceof TaxonNamePopupEditor){
420 419
            Registration registration = null;
421
            boolean doRefreshView = false;
422 420
            if(newNameForRegistrationPopupEditor != null && event.getPopup().equals(newNameForRegistrationPopupEditor)){
423 421
                if(event.getReason().equals(Reason.SAVE)){
424 422
                    try {
......
427 425
                        loadWorkingSet(workingset.getCitationUuid());
428 426
                    } finally {
429 427
                        clearSession();
430
                        doRefreshView = true;
431 428
                        getView().getAddNewNameRegistrationButton().setEnabled(true);
432 429
                    }
433 430
                }
......
454 451
            for(TaxonName name : namesToCheck){
455 452
                if(name != null){
456 453
                    clearSession();
457
                    doRefreshView |= registrationWorkflowService.addBlockingRegistration(name.getUuid(), registration) != null;
454
                    registrationWorkflowService.addBlockingRegistration(name.getUuid(), registration);
458 455
                }
459 456
            }
460 457

  
461
            refreshView(doRefreshView);
458
            // always reload if the first editor is closed as the data might have been changed through any other sub-popupeditor
459
            refreshView(isAtContextRoot(event.getPopup()));
462 460
        }
463 461
    }
464 462

  
......
610 608
            if(event.getReason().equals(Reason.SAVE)){
611 609
                // NOTE: adding the SpecimenTypeDesignations to the registration is done in the
612 610
                // SpecimenTypeDesignationWorkingSetServiceImpl.save(SpecimenTypeDesignationWorkingSetDTO dto) method
613
                refreshView(true);
614
            } else if(event.getReason().equals(Reason.CANCEL)){
615
                // noting to do
616 611
            }
612
            // always reload if the first editor is closed as the data might have been changed through any other sub-popupeditor
613
            refreshView(isAtContextRoot(event.getPopup()));
617 614
        } else if(event.getPopup() instanceof NameTypeDesignationPopupEditor){
618 615
            if(event.getReason().equals(Reason.SAVE)){
619 616

  
620 617
                Registration registration = null;
621
                boolean doRefreshView = false;
622 618

  
623 619
                UUID typeDesignationUuid = ((NameTypeDesignationPopupEditor)event.getPopup()).getBean().getUuid();
624 620

  
......
630 626
                    nameTypeDesignationPopupEditorRegistrationUUIDMap.remove(event.getPopup());
631 627
                } finally {
632 628
                    clearSession();
633
                    doRefreshView = true;
634 629
                }
635 630

  
636 631
                if(registration == null){
......
646 641

  
647 642
                for(TaxonName name : namesToCheck){
648 643
                    if(name != null){
649
                        doRefreshView |= registrationWorkflowService.addBlockingRegistration(name.getUuid(), registration) != null;
644
                        registrationWorkflowService.addBlockingRegistration(name.getUuid(), registration);
650 645
                    }
651 646

  
652 647
                }
653 648

  
654
                refreshView(doRefreshView);
655

  
656 649
            } else if(event.getReason().equals(Reason.CANCEL)){
657 650
                // noting to do
658 651
            }
652
            // always reload if the first editor is closed as the data might have been changed through any other sub-popupeditor
653
            refreshView(isAtContextRoot(event.getPopup()));
659 654

  
660 655
        }
661 656
        // ignore other editors
......
739 734
            if(workingset.getRegistrationDTOs().stream().anyMatch(reg ->
740 735
                reg.getTypifiedNameRef() != null
741 736
                && reg.getTypifiedNameRef().getUuid().equals(event.getEntityUuid()))){
742
                    refreshView(true);
737
                    //refreshView(true);
743 738
            }
744 739
        } else
745 740
        if(TypeDesignationBase.class.isAssignableFrom(event.getEntityType())){
......
749 744
                            )
750 745
                        )
751 746
                    ){
752
                refreshView(true);
747
                //refreshView(true);
753 748
            }
754 749
        }
755 750
    }
756 751

  
752
    public boolean isAtContextRoot(PopupView popupView) {
753
        AbstractPopupEditor popupEditor = ((AbstractPopupEditor)popupView);
754
        if(popupEditor.getEditorActionContext().size() > 1){
755
            EditorActionContext topContext = (EditorActionContext) popupEditor.getEditorActionContext().get(popupEditor.getEditorActionContext().size() - 2);
756
            return getView().equals(topContext.getParentView());
757
        } else {
758
            logger.error("Invalid EditorActionContext size. A popupeditor should at leaset have the workingset as root");
759
            return false;
760
        }
761
    }
762

  
763
    public EditorActionContext editorActionContextRoot(PopupView popupView) {
764
        Stack<EditorActionContext>context = ((AbstractPopupEditor)popupView).getEditorActionContext();
765
        return context.get(0);
766
    }
767

  
757 768
    public Registration findRegistrationInContext(PopupView popupView) {
758 769
        Stack<EditorActionContext>context = ((AbstractPopupEditor)popupView).getEditorActionContext();
759 770
        return findRegistrationInContext(context);

Also available in: Unified diff