Project

General

Profile

Download (2.47 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.SWT;
13
import org.eclipse.swt.events.SelectionListener;
14

    
15
import eu.etaxonomy.cdm.model.common.ReferencedEntityBase;
16
import eu.etaxonomy.cdm.model.reference.Reference;
17
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
18
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
19
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
20
import eu.etaxonomy.taxeditor.ui.element.ISelectableElement;
21
import eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator;
22
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
23
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement;
24
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
25

    
26
/**
27
 * @author n.hoffmann
28
 * @created Mar 25, 2010
29
 * @version 1.0
30
 */
31
public abstract class AbstractReferencedEntityElement<T extends ReferencedEntityBase>
32
		extends AbstractEntityCollectionElement<T> implements ISelectableElement {
33

    
34
	private SelectionArbitrator selectionArbitrator;
35

    
36
	protected EntitySelectionElement<Reference> selection_reference;
37
	protected TextWithLabelElement text_referenceDetail;
38

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

    
49
	/** {@inheritDoc} */
50
	@Override
51
	public void createControls(ICdmFormElement formElement, int style) {
52
		selection_reference = formFactory
53
				.createSelectionElement(Reference.class,//getConversationHolder(),
54
						 formElement, "Reference",
55
						null, EntitySelectionElement.ALL, style);
56
		text_referenceDetail = formFactory.createTextWithLabelElement(
57
				formElement, "Reference Detail", null, SWT.NULL);
58
	}
59

    
60
	@Override
61
	public void setEntity(T entity) {
62
		this.entity = entity;
63

    
64
		selection_reference.setEntity(entity.getCitation());
65
		text_referenceDetail.setText(entity.getCitationMicroReference());
66
	}
67

    
68
	@Override
69
    public SelectionArbitrator getSelectionArbitrator() {
70
		return selectionArbitrator;
71
	}
72

    
73
}
(2-2/19)