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.campanula.compatibility.ICdmFormElement;
|
19
|
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
|
20
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
21
|
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
|
22
|
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement;
|
23
|
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
|
24
|
|
25
|
/**
|
26
|
* <p>
|
27
|
* Abstract AbstractReferencedEntityElement class.
|
28
|
* </p>
|
29
|
*
|
30
|
* @author n.hoffmann
|
31
|
* @created Mar 25, 2010
|
32
|
* @version 1.0
|
33
|
*/
|
34
|
public abstract class AbstractReferencedEntityElement<T extends ReferencedEntityBase>
|
35
|
extends AbstractEntityCollectionElement<T> {
|
36
|
|
37
|
protected EntitySelectionElement<Reference> selection_reference;
|
38
|
protected TextWithLabelElement text_referenceDetail;
|
39
|
|
40
|
protected TextWithLabelElement text_originaleNameString;
|
41
|
|
42
|
private boolean hasOriginalNameString = false;
|
43
|
|
44
|
/**
|
45
|
* <p>
|
46
|
* Constructor for AbstractReferencedEntityElement.
|
47
|
* </p>
|
48
|
*
|
49
|
* @param formFactory
|
50
|
* a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
|
51
|
* object.
|
52
|
* @param section
|
53
|
* a {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection}
|
54
|
* object.
|
55
|
* @param entity
|
56
|
* a T object.
|
57
|
* @param removeListener
|
58
|
* a {@link org.eclipse.swt.events.SelectionListener} object.
|
59
|
* @param style
|
60
|
* a int.
|
61
|
* @param <T>
|
62
|
* a T object.
|
63
|
*/
|
64
|
public AbstractReferencedEntityElement(CdmFormFactory formFactory,
|
65
|
AbstractFormSection section, T entity,
|
66
|
SelectionListener removeListener, int style) {
|
67
|
super(formFactory, section, entity, removeListener, null, style);
|
68
|
}
|
69
|
|
70
|
/*
|
71
|
* (non-Javadoc)
|
72
|
*
|
73
|
* @see
|
74
|
* eu.etaxonomy.taxeditor.forms.section.AbstractEntityCollectionElement#
|
75
|
* createControls(eu.etaxonomy.taxeditor.forms.ICdmFormElement, int)
|
76
|
*/
|
77
|
/** {@inheritDoc} */
|
78
|
@Override
|
79
|
public void createControls(ICdmFormElement formElement, int style) {
|
80
|
selection_reference = formFactory
|
81
|
.createSelectionElement(Reference.class,
|
82
|
getConversationHolder(), formElement, "Reference",
|
83
|
null, EntitySelectionElement.ALL, style);
|
84
|
text_referenceDetail = formFactory.createTextWithLabelElement(
|
85
|
formElement, "Reference Detail", null, SWT.NULL);
|
86
|
if (hasOriginalNameString)
|
87
|
text_originaleNameString = formFactory.createTextWithLabelElement(
|
88
|
formElement, "Original Name", null, SWT.NULL);
|
89
|
}
|
90
|
|
91
|
/**
|
92
|
* <p>
|
93
|
* setEntity
|
94
|
* </p>
|
95
|
*
|
96
|
* @param entity
|
97
|
* a T object.
|
98
|
*/
|
99
|
@Override
|
100
|
public void setEntity(T entity) {
|
101
|
this.entity = entity;
|
102
|
|
103
|
selection_reference.setEntity(entity.getCitation());
|
104
|
text_referenceDetail.setText(entity.getCitationMicroReference());
|
105
|
if (hasOriginalNameString)
|
106
|
text_originaleNameString.setText(entity.getOriginalNameString());
|
107
|
// // remove old listeners
|
108
|
// clearEditButtonSelectionListener();
|
109
|
//
|
110
|
// addEditButtonSelectionListener(new
|
111
|
// BulkEditorOpeningSelectionListener(entity.getCitation()));
|
112
|
//
|
113
|
};
|
114
|
|
115
|
//
|
116
|
// public void addEditButtonSelectionListener(SelectionListener listener){
|
117
|
// selection_reference.addEditButtonSelectionListener(listener);
|
118
|
// }
|
119
|
//
|
120
|
// public void removeEditButtonSelectionListener(SelectionListener
|
121
|
// listener){
|
122
|
// selection_reference.removeEditorButtonSelectionListener(listener);
|
123
|
// }
|
124
|
//
|
125
|
// public void clearEditButtonSelectionListener(){
|
126
|
// selection_reference.clearEditButtonSelectionListener();
|
127
|
// }
|
128
|
|
129
|
/**
|
130
|
* <p>
|
131
|
* Setter for the field <code>hasOriginalNameString</code>.
|
132
|
* </p>
|
133
|
*
|
134
|
* @param hasOriginalNameString
|
135
|
* a boolean.
|
136
|
*/
|
137
|
public void setHasOriginalNameString(boolean hasOriginalNameString) {
|
138
|
this.hasOriginalNameString = hasOriginalNameString;
|
139
|
}
|
140
|
|
141
|
/**
|
142
|
* <p>
|
143
|
* hasOriginalNameString
|
144
|
* </p>
|
145
|
*
|
146
|
* @return a boolean.
|
147
|
*/
|
148
|
public boolean hasOriginalNameString() {
|
149
|
return hasOriginalNameString;
|
150
|
}
|
151
|
}
|