Project

General

Profile

« Previous | Next » 

Revision e8674a36

Added by Andreas Kohlbecker about 6 years ago

ref #7195 introducing the concept of EditorActionContext stacks to facilitate creating blocking relations

View differences:

src/main/java/eu/etaxonomy/vaadin/mvp/AbstractPopupEditor.java
9 9
package eu.etaxonomy.vaadin.mvp;
10 10

  
11 11
import java.util.Map;
12
import java.util.Stack;
12 13

  
13 14
import org.apache.log4j.Logger;
14 15
import org.vaadin.spring.events.EventScope;
......
47 48

  
48 49
import eu.etaxonomy.cdm.database.PermissionDeniedException;
49 50
import eu.etaxonomy.cdm.vaadin.component.TextFieldNFix;
51
import eu.etaxonomy.cdm.vaadin.event.AbstractEditorAction;
52
import eu.etaxonomy.cdm.vaadin.event.AbstractEditorAction.EditorActionContext;
50 53
import eu.etaxonomy.vaadin.component.NestedFieldGroup;
51 54
import eu.etaxonomy.vaadin.component.SwitchableTextField;
52 55
import eu.etaxonomy.vaadin.mvp.event.EditorDeleteEvent;
......
90 93

  
91 94
    private boolean isBeanLoaded;
92 95

  
96
    private Stack<EditorActionContext> context = new Stack<EditorActionContext>();
97

  
98
    private boolean isContextUpdated;
99

  
93 100
    public AbstractPopupEditor(Layout layout, Class<DTO> dtoType) {
94 101

  
95 102
        mainLayout = new VerticalLayout();
......
621 628
        return getPresenter();
622 629
    }
623 630

  
631
    /**
632
     * Returns the context of editor actions for this editor.
633
     * The context submitted with {@link #setParentContext(Stack)} will be updated
634
     * to represent the current context.
635
     *
636
     * @return the context
637
     */
638
    public Stack<EditorActionContext> getEditorActionContext() {
639
        if(!isContextUpdated){
640
            if(getBean() == null){
641
                throw new RuntimeException("getContext() is only possible after the bean is loaded");
642
            }
643
            context.push(new AbstractEditorAction.EditorActionContext(getBean(), this));
644
            isContextUpdated = true;
645
        }
646
        return context;
647
    }
648

  
649
    /**
650
     * Set the context of editor actions parent to this editor
651
     *
652
     * @param context the context to set
653
     */
654
    public void setParentEditorActionContext(Stack<EditorActionContext> context) {
655
        this.context.addAll(context);
656
    }
657

  
624 658
}

Also available in: Unified diff