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
|
|
63
|
|
64
|
/** {@inheritDoc} */
|
65
|
@Override
|
66
|
public void createControls(ICdmFormElement formElement, int style) {
|
67
|
if (isCommonNameReference && PreferencesUtil.getFilterCommonNameReferences()){
|
68
|
selection_reference = formFactory
|
69
|
.createCommonNameReferenceSelectionElement(formElement, "Reference",
|
70
|
null, EntitySelectionElement.ALL, style);
|
71
|
}else{
|
72
|
selection_reference = formFactory
|
73
|
.createSelectionElement(Reference.class,//getConversationHolder(),
|
74
|
formElement, "Reference",
|
75
|
null, EntitySelectionElement.ALL, style);
|
76
|
}
|
77
|
|
78
|
text_referenceDetail = formFactory.createTextWithLabelElement(
|
79
|
formElement, "Reference Detail", null, SWT.NULL);
|
80
|
}
|
81
|
|
82
|
@Override
|
83
|
public void setEntity(T entity) {
|
84
|
this.entity = entity;
|
85
|
|
86
|
selection_reference.setEntity(entity.getCitation());
|
87
|
text_referenceDetail.setText(entity.getCitationMicroReference());
|
88
|
}
|
89
|
|
90
|
@Override
|
91
|
public SelectionArbitrator getSelectionArbitrator() {
|
92
|
return selectionArbitrator;
|
93
|
}
|
94
|
|
95
|
}
|