Project

General

Profile

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

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

    
13
import org.eclipse.swt.SWT;
14
import org.eclipse.swt.events.SelectionListener;
15

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

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

    
35
	private SelectionArbitrator selectionArbitrator;
36
	
37
	protected EntitySelectionElement<Reference> selection_reference;
38
	protected TextWithLabelElement text_referenceDetail;
39

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

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

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

    
65
		selection_reference.setEntity(entity.getCitation());
66
		text_referenceDetail.setText(entity.getCitationMicroReference());
67
	}
68
	
69
	@Override
70
    public SelectionArbitrator getSelectionArbitrator() {
71
		return selectionArbitrator;
72
	}
73

    
74
}
(2-2/19)