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