Project

General

Profile

Revision 64bf3ea5

ID64bf3ea5a36b3931b134b1c84d99a0bed3fe5181
Parent 5ff2ddc5
Child ea92bdaa

Added by Andreas Kohlbecker over 1 year ago

ref #7910 ToManyRelatedEntitiesListSelect: no longer setting readlony on nested fields

View differences:

src/main/java/eu/etaxonomy/vaadin/component/ToManyRelatedEntitiesListSelect.java
440 440

  
441 441
    private void updateButtonStates(){
442 442

  
443
        boolean isWritable = !getState().readOnly;
443 444
        int fieldsCount = getNestedFields().size();
445

  
444 446
        for(int row = 0; row < fieldsCount; row++){
445 447

  
446 448
            boolean isFirst = row == 0;
......
455 457
                // edit
456 458
                Button editCreateButton = ((Button)buttonGroup.getComponent(0));
457 459
                editCreateButton.setDescription(field.getValue() == null ? "New" : "Edit");
458
                editCreateButton.setEnabled(!getState().readOnly && (field.getValue() == null
460
                editCreateButton.setEnabled(isWritable && (field.getValue() == null
459 461
                        || field.getValue() != null && testEditButtonPermission(field.getValue())));
460 462
            }
461 463
            // add
462
            buttonGroup.getComponent(addButtonIndex).setEnabled(!getState().readOnly && (isLast || isOrderedCollection));
464
            buttonGroup.getComponent(addButtonIndex).setEnabled(isWritable && (isLast || isOrderedCollection));
463 465
            // remove
464 466
            // can be always true, removing the last entry causes an new empty entry to be added.
465
            buttonGroup.getComponent(addButtonIndex + 1).setEnabled(!getState().readOnly);
467
            buttonGroup.getComponent(addButtonIndex + 1).setEnabled(isWritable);
466 468
            // up
467 469
            if(isOrderedCollection && buttonGroup.getComponentCount() >  addButtonIndex + 2){
468
                buttonGroup.getComponent(addButtonIndex + 2).setEnabled(!getState().readOnly && !isFirst);
470
                buttonGroup.getComponent(addButtonIndex + 2).setEnabled(isWritable && !isFirst);
469 471
                // down
470
                buttonGroup.getComponent(addButtonIndex + 3).setEnabled(!getState().readOnly  && !isLast);
472
                buttonGroup.getComponent(addButtonIndex + 3).setEnabled(isWritable && !isLast);
471 473
            }
472 474
        }
473 475
    }
......
681 683
    @Override
682 684
    public void setReadOnly(boolean readOnly) {
683 685
        super.setReadOnly(readOnly);
684
        setDeepReadOnly(readOnly, getContent(), null);
685 686
        updateButtonStates();
686 687
    }
687 688

  

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)