Project

General

Profile

Download (1.6 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2018 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.cdm.vaadin.event;
10

    
11
import com.vaadin.ui.Field;
12

    
13
import eu.etaxonomy.vaadin.mvp.AbstractPopupEditor;
14
import eu.etaxonomy.vaadin.mvp.AbstractView;
15
import eu.etaxonomy.vaadin.util.PropertyIdPath;
16

    
17
public class EditorActionContext {
18

    
19
    Object parentEntity;
20

    
21
    AbstractView parentView;
22

    
23
    /**
24
     * The field in the parent view to which the child view is related to.
25
     */
26
    Field<?> targetField;
27

    
28
    /**
29
     * @param parentEntity
30
     * @param parentView
31
     */
32
    public EditorActionContext(Object parentEntity, AbstractView parentView) {
33
        super();
34
        this.parentEntity = parentEntity;
35
        this.parentView = parentView;
36
    }
37

    
38
    /**
39
     * TODO rename to getParentBean()
40
     *
41
     * @return the parentEntity
42
     */
43
    public Object getParentEntity() {
44
        return parentEntity;
45
    }
46

    
47
    public AbstractView getParentView() {
48
        return parentView;
49
    }
50

    
51
    public void setTargetField(Field<?> targetField) {
52
        this.targetField = targetField;
53
    }
54

    
55
    public Field<?> getTargetField() {
56
        return targetField;
57
    }
58

    
59
    public PropertyIdPath getTargetPropertyIdPath(){
60
        if(parentView instanceof AbstractPopupEditor && targetField != null){
61
            return ((AbstractPopupEditor)getParentView()).boundPropertyIdPath(targetField);
62
        } else {
63
            return null;
64
        }
65
    }
66

    
67

    
68

    
69
}
(8-8/28)