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
|
package eu.etaxonomy.taxeditor.ui.section.agent;
|
10
|
|
11
|
import org.apache.commons.lang.StringUtils;
|
12
|
import org.eclipse.swt.SWT;
|
13
|
|
14
|
import eu.etaxonomy.cdm.model.agent.Person;
|
15
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
16
|
import eu.etaxonomy.taxeditor.ui.element.CdmPropertyChangeEvent;
|
17
|
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
|
18
|
import eu.etaxonomy.taxeditor.ui.element.LsidWithExceptionLabelElement;
|
19
|
import eu.etaxonomy.taxeditor.ui.element.OrcidWithLabelElement;
|
20
|
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
|
21
|
import eu.etaxonomy.taxeditor.ui.element.TimePeriodElement;
|
22
|
import eu.etaxonomy.taxeditor.ui.section.AbstractIdentifiableEntityDetailElement;
|
23
|
|
24
|
/**
|
25
|
* PersonDetailElement class.
|
26
|
*
|
27
|
* @author n.hoffmann
|
28
|
* @created Mar 8, 2010
|
29
|
*/
|
30
|
public class PersonDetailElement extends AbstractIdentifiableEntityDetailElement<Person> {
|
31
|
|
32
|
private TextWithLabelElement text_nomenclaturalTitle;
|
33
|
// private TextWithLabelElement text_nomenclaturalTitleCache;
|
34
|
private TextWithLabelElement text_collectorTitle;
|
35
|
// private TextWithLabelElement text_collectorTitleCache;
|
36
|
private TextWithLabelElement text_firstname;
|
37
|
private TextWithLabelElement text_lastname;
|
38
|
private TextWithLabelElement text_prefix;
|
39
|
private TextWithLabelElement text_suffix;
|
40
|
private TextWithLabelElement text_initials;
|
41
|
private TimePeriodElement time_lifespan;
|
42
|
private OrcidWithLabelElement text_orcid;
|
43
|
private LsidWithExceptionLabelElement text_lsid;
|
44
|
|
45
|
public PersonDetailElement(CdmFormFactory cdmFormFactory,
|
46
|
ICdmFormElement formElement, int style) {
|
47
|
super(cdmFormFactory, formElement);
|
48
|
}
|
49
|
|
50
|
@Override
|
51
|
protected void createControls(ICdmFormElement formElement, Person entity,
|
52
|
int style) {
|
53
|
setWarnForReferencingObjects(formElement);
|
54
|
toggleable_cache = formFactory.createToggleableTextField(formElement,
|
55
|
"Title Cache", entity.getTitleCache(),
|
56
|
entity.isProtectedTitleCache(), SWT.NULL);
|
57
|
|
58
|
|
59
|
|
60
|
text_nomenclaturalTitle = formFactory.createTextWithLabelElement(
|
61
|
formElement, "Abbrev. Title", entity.getNomenclaturalTitle(),
|
62
|
SWT.SEARCH);
|
63
|
|
64
|
text_nomenclaturalTitle.setMessage(entity.getNomenclaturalTitleCache());
|
65
|
|
66
|
|
67
|
text_collectorTitle = formFactory.createTextWithLabelElement(
|
68
|
formElement, "Collector Title", entity.getCollectorTitle(),
|
69
|
SWT.SEARCH);
|
70
|
|
71
|
text_collectorTitle.setMessage(entity.getCollectorTitleCache());
|
72
|
|
73
|
text_lastname = formFactory.createTextWithLabelElement(formElement,
|
74
|
"Familiy Name", entity.getFamilyName(), SWT.NULL);
|
75
|
text_firstname = formFactory.createTextWithLabelElement(formElement,
|
76
|
"Other/Given Names", entity.getGivenName(), SWT.NULL);
|
77
|
text_initials = formFactory.createTextWithLabelElement(formElement,
|
78
|
"Initials", entity.getInitials(), SWT.NULL);
|
79
|
text_prefix = formFactory.createTextWithLabelElement(formElement,
|
80
|
"Prefix", entity.getPrefix(), SWT.NULL);
|
81
|
time_lifespan = formFactory.createTimePeriodElement(formElement, "Lifespan", entity.getLifespan(), SWT.NULL);
|
82
|
text_orcid = formFactory.createOrcidWithLabelElement(formElement, "ORCID", entity.getOrcid(), SWT.NULL);
|
83
|
text_lsid = formFactory.createLsidWithExceptionLabelElement(formElement, "LSID", entity.getLsid(), SWT.NULL);
|
84
|
|
85
|
getLayoutComposite().layout();
|
86
|
|
87
|
//cache relevance
|
88
|
registerCacheRelevance(text_firstname);
|
89
|
registerCacheRelevance(text_lastname);
|
90
|
registerCacheRelevance(text_prefix);
|
91
|
registerCacheRelevance(text_suffix);
|
92
|
registerCacheRelevance(text_initials);
|
93
|
|
94
|
|
95
|
|
96
|
}
|
97
|
|
98
|
@Override
|
99
|
protected void updateContent() {
|
100
|
super.updateContent();
|
101
|
toggleable_cache.setEnabled(getEntity().isProtectedTitleCache());
|
102
|
updateCacheRelevance();
|
103
|
}
|
104
|
|
105
|
@Override
|
106
|
public void handleEvent(Object eventSource) {
|
107
|
if (eventSource == toggleable_cache) {
|
108
|
handleToggleableCacheField();
|
109
|
} else if (eventSource == text_nomenclaturalTitle) {
|
110
|
if (StringUtils.isBlank(text_nomenclaturalTitle.getText()) && getEntity().getNomenclaturalTitle() != null){
|
111
|
getEntity().setNomenclaturalTitle(null);
|
112
|
|
113
|
}else if (StringUtils.isNotBlank(text_nomenclaturalTitle.getText()) ){
|
114
|
getEntity().setNomenclaturalTitle(text_nomenclaturalTitle.getText());
|
115
|
|
116
|
}
|
117
|
} else if (eventSource == text_collectorTitle) {
|
118
|
if (StringUtils.isBlank(text_collectorTitle.getText()) && getEntity().getCollectorTitle() != null){
|
119
|
getEntity().setCollectorTitle(null);
|
120
|
|
121
|
}else if (StringUtils.isNotBlank(text_collectorTitle.getText()) ){
|
122
|
getEntity().setCollectorTitle(text_collectorTitle.getText());
|
123
|
|
124
|
}
|
125
|
}else if (eventSource == text_firstname) {
|
126
|
getEntity().setGivenName(text_firstname.getText());
|
127
|
}else if (eventSource == text_initials) {
|
128
|
getEntity().setInitials(text_initials.getText());
|
129
|
}else if (eventSource == text_lastname) {
|
130
|
getEntity().setFamilyName(text_lastname.getText());
|
131
|
} else if (eventSource == text_prefix) {
|
132
|
getEntity().setPrefix(text_prefix.getText());
|
133
|
} else if (eventSource == text_suffix) {
|
134
|
getEntity().setSuffix(text_suffix.getText());
|
135
|
}else if (eventSource == text_orcid) {
|
136
|
getEntity().setOrcid(text_orcid.parseText());
|
137
|
}else if (eventSource == text_lsid) {
|
138
|
getEntity().setLsid(text_lsid.parseText());
|
139
|
}else if (eventSource == time_lifespan) {
|
140
|
getEntity().setLifespan(time_lifespan.getTimePeriod());
|
141
|
}
|
142
|
text_nomenclaturalTitle.setMessage(getEntity().getNomenclaturalTitleCache());
|
143
|
text_collectorTitle.setMessage(getEntity().getCollectorTitleCache());
|
144
|
|
145
|
if (!getEntity().isProtectedTitleCache()){
|
146
|
toggleable_cache.setText(getEntity().generateTitle());
|
147
|
}
|
148
|
|
149
|
firePropertyChangeEvent(new CdmPropertyChangeEvent(this, null));
|
150
|
|
151
|
}
|
152
|
|
153
|
@Override
|
154
|
protected void handleToggleableCacheField() {
|
155
|
boolean pushedState = toggleable_cache.getState();
|
156
|
getEntity().setProtectedTitleCache(pushedState);
|
157
|
getEntity().getTitleCache();
|
158
|
if (pushedState){
|
159
|
getEntity().setTitleCache(toggleable_cache.getText(), pushedState);
|
160
|
}
|
161
|
updateCacheRelevance();
|
162
|
updateToggleableCacheField();
|
163
|
}
|
164
|
}
|