Project

General

Profile

Download (3.42 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.preference.PreferencesUtil;
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
 */
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
	protected boolean isCommonNameReference = false;
40

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

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

    
62
	@Override
63
	public void createControls(ICdmFormElement formElement, int style) {
64
	    if (isCommonNameReference && PreferencesUtil.getFilterCommonNameReferences()){
65
	        selection_reference = formFactory
66
                    .createCommonNameReferenceSelectionElement(formElement, "Reference",
67
                            null, EntitySelectionElement.ALL, style);
68
	    }else{
69
	        selection_reference = formFactory
70
	                .createSelectionElement(Reference.class,//getConversationHolder(),
71
	                         formElement, "Reference",
72
	                        null, EntitySelectionElement.ALL, style);
73
	    }
74

    
75
		text_referenceDetail = formFactory.createTextWithLabelElement(
76
				formElement, "Reference Detail", null, SWT.NULL);
77
	}
78

    
79
	@Override
80
	public void setEntity(T entity) {
81
		this.entity = entity;
82

    
83
		selection_reference.setEntity(entity.getCitation());
84
		text_referenceDetail.setText(entity.getCitationMicroReference());
85
	}
86

    
87
	@Override
88
    public SelectionArbitrator getSelectionArbitrator() {
89
		return selectionArbitrator;
90
	}
91

    
92
}
(2-2/20)