Project

General

Profile

« Previous | Next » 

Revision 66af3161

Added by Andreas Kohlbecker over 4 years ago

fix #8377 disabling delete buttons in editors for new type designations and fixing bug in button state handling

View differences:

src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorkingsetPresenter.java
608 608
                    typifiedNameUuid
609 609
                    );
610 610
            popup.grantToCurrentUser(EnumSet.of(CRUD.UPDATE, CRUD.DELETE));
611
            popup.withDeleteButton(false);
611 612
            popup.loadInEditor(identifierSet);
612
            popup.withDeleteButton(true);
613 613
            if(event.hasSource()){
614 614
                // propagate readonly state from source component to popup
615 615
                popup.setReadOnly(event.getSource().isReadOnly());
......
617 617
        } else {
618 618
            NameTypeDesignationPopupEditor popup = openPopupEditor(NameTypeDesignationPopupEditor.class, event);
619 619
            popup.setParentEditorActionContext(event.getContext(), event.getTarget());
620
            popup.withDeleteButton(true);
621 620
            popup.grantToCurrentUser(EnumSet.of(CRUD.UPDATE, CRUD.DELETE));
622 621
            RegistrationDTO regDto = workingset.getRegistrationDTO(event.getRegistrationUuid()).get();
623 622
            Reference citation = regDto.getCitation();
......
634 633
                    return nameTypeDesignation;
635 634
                }
636 635
            });
636
            popup.withDeleteButton(false);
637 637
            popup.loadInEditor(null);
638 638
            popup.getCitationCombobox().setEnabled(false);
639 639
            popup.getTypifiedNamesComboboxSelect().setEnabled(false);
src/main/java/eu/etaxonomy/vaadin/mvp/AbstractPopupEditor.java
135 135

  
136 136
    private EditorFormConfigurator<? extends AbstractPopupEditor<DTO, P>> editorComponentsConfigurator;
137 137

  
138
    private boolean withDeleteButton;
139

  
138 140
    public AbstractPopupEditor(Layout layout, Class<DTO> dtoType) {
139 141

  
140 142
        mainLayout = new VerticalLayout();
......
246 248
        }
247 249
        statusMessageLabel.setVisible(readOnly);
248 250
        save.setVisible(!readOnly);
249
        delete.setVisible(!readOnly);
251
        updateDeleteButtonState();
250 252
        cancel.setCaption(readOnly ? "Close" : "Cancel");
251 253
        recursiveReadonly(readOnly, (AbstractComponentContainer)getFieldLayout());
252 254
    }
......
755 757

  
756 758
    public void withDeleteButton(boolean withDelete){
757 759

  
758
        if(withDelete){
760
        this.withDeleteButton = withDelete;
761
        if(withDeleteButton){
759 762
            buttonLayout.setExpandRatio(save, 0);
760 763
            buttonLayout.setExpandRatio(delete, 1);
761 764
        } else {
762 765
            buttonLayout.setExpandRatio(save, 1);
763 766
            buttonLayout.setExpandRatio(delete, 0);
764 767
        }
765
        delete.setVisible(withDelete);
768
        updateDeleteButtonState();
769
    }
770

  
771
    /**
772
     * @param withDelete
773
     */
774
    private void updateDeleteButtonState() {
775
        delete.setVisible(withDeleteButton && !isReadOnly());
766 776
    }
767 777

  
768 778
    public boolean addStatusMessage(String message){

Also available in: Unified diff