Project

General

Profile

« Previous | Next » 

Revision b9e727eb

Added by Andreas Kohlbecker almost 6 years ago

ref #7361 fixing update problem of editOrCreate button

View differences:

src/main/java/eu/etaxonomy/vaadin/component/ToManyRelatedEntitiesListSelect.java
79 79
     */
80 80
    private static final int GRID_X_FIELD = 0;
81 81

  
82
    private static final int GRID_X_BUTTON_GROUP = 1;
83

  
82 84
    private int GRID_COLS = 2;
83 85

  
84 86
    private GridLayout grid = new GridLayout(GRID_COLS, 1);
......
269 271
            }
270 272
            if(newRowNeeded){
271 273
                addNewRow(row, data.get(row));
274
            } else {
275
                // update the editOrCreate buttons
276
                ButtonGroup bg = (ToManyRelatedEntitiesListSelect<V, F>.ButtonGroup) grid.getComponent(GRID_X_BUTTON_GROUP, row);
277
                updateEditOrCreateButton(bg, data.get(row));
272 278
            }
273 279
        }
274 280
        creatingFields = false;
......
331 337
                grid.setRows(grid.getRows() + 1);
332 338
            }
333 339
            grid.addComponent(field, GRID_X_FIELD, row);
334
            grid.addComponent(buttonGroup, 1, row);
340
            grid.addComponent(buttonGroup, GRID_X_BUTTON_GROUP, row);
335 341
            updateButtonStates();
336 342
            nestFieldGroup(field);
337 343
            row++;
......
351 357
     */
352 358
    public void updateEditOrCreateButton(ButtonGroup buttonGroup, Object value) {
353 359

  
354
        if(buttonGroup == null || buttonGroup.getEditOrCreateButton() == null){
360
        if(!withEditButton || buttonGroup == null || buttonGroup.getEditOrCreateButton() == null){
355 361
            return;
356 362
        }
357 363

  
......
631 637
     */
632 638
    public void withEditButton(boolean withEditButton){
633 639
        this.withEditButton = withEditButton;
640
        if(getPropertyDataSource() != null) {
641
            throw new RuntimeException("withEditButton must not be changed after the datasource is set.");
642
        }
634 643
    }
635 644

  
636 645
    /**

Also available in: Unified diff