Project

General

Profile

Download (3.16 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
 * Copyright (C) 2007 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

    
10
package eu.etaxonomy.taxeditor.ui.section.supplemental;
11

    
12
import org.eclipse.swt.events.SelectionListener;
13

    
14
import eu.etaxonomy.cdm.model.common.SingleSourcedEntityBase;
15
import eu.etaxonomy.cdm.model.description.DescriptionElementSource;
16
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
17
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
18
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
19
import eu.etaxonomy.taxeditor.ui.element.ISelectableElement;
20
import eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator;
21
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement;
22
import eu.etaxonomy.taxeditor.ui.section.reference.OriginalSourceElement;
23

    
24
/**
25
 * @author n.hoffmann
26
 * @created Mar 25, 2010
27
 */
28
public abstract class AbstractSourcedEntityElement<T extends SingleSourcedEntityBase>
29
		extends AbstractEntityCollectionElement<T> implements ISelectableElement {
30

    
31
	private SelectionArbitrator selectionArbitrator;
32
	private OriginalSourceElement sourceElement;
33
//	protected EntitySelectionElement<Reference> selection_reference;
34
//	protected TextWithLabelElement text_referenceDetail;
35

    
36
	protected boolean isCommonNameReference = false;
37

    
38
	public AbstractSourcedEntityElement(CdmFormFactory formFactory,
39
			AbstractFormSection section, T entity,
40
			SelectionListener removeListener, int style, boolean isCommonNameReference) {
41
		super(formFactory, section, entity, removeListener, null, style);
42
		// make this element selectable
43
		if(formFactory.getSelectionProvider() != null){
44
			selectionArbitrator = formFactory.createSelectionArbitrator(this);
45
		}
46
		this.isCommonNameReference = isCommonNameReference;
47
	}
48

    
49
    public AbstractSourcedEntityElement(CdmFormFactory formFactory,
50
            AbstractFormSection section, T entity,
51
            SelectionListener removeListener, int style) {
52
        super(formFactory, section, entity, removeListener, null, style);
53
        // make this element selectable
54
        if(formFactory.getSelectionProvider() != null){
55
            selectionArbitrator = formFactory.createSelectionArbitrator(this);
56
        }
57
    }
58

    
59
	@Override
60
	public void createControls(ICdmFormElement formElement, int style) {
61

    
62
	    sourceElement = formFactory.createOriginalSourceElement(formElement, entity);
63
        if (entity.getSource() == null){
64
            DescriptionElementSource source = DescriptionElementSource.NewPrimarySourceInstance(null, null);
65
            entity.setSource(source);
66
            sourceElement.setEntity(source);
67
        }else{
68
            sourceElement.setEntity(entity.getSource());
69

    
70
        }
71
//	    sourceElement = formFactory.createOriginalSourceElement(formElement, entity);
72
	}
73

    
74
	@Override
75
	public void setEntity(T entity) {
76
		this.entity = entity;
77

    
78
//		selection_reference.setEntity(entity.getCitation());
79
//		text_referenceDetail.setText(entity.getCitationMicroReference());
80
	}
81

    
82
	@Override
83
    public SelectionArbitrator getSelectionArbitrator() {
84
		return selectionArbitrator;
85
	}
86

    
87
}
(5-5/22)