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 java.util.Arrays;
|
12
|
import java.util.Collection;
|
13
|
|
14
|
import org.eclipse.swt.SWT;
|
15
|
|
16
|
import eu.etaxonomy.cdm.model.agent.Person;
|
17
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
18
|
import eu.etaxonomy.taxeditor.ui.element.CdmPropertyChangeEvent;
|
19
|
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
|
20
|
import eu.etaxonomy.taxeditor.ui.element.LsidWithExceptionLabelElement;
|
21
|
import eu.etaxonomy.taxeditor.ui.element.OrcidWithLabelElement;
|
22
|
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
|
23
|
import eu.etaxonomy.taxeditor.ui.element.TimePeriodElement;
|
24
|
import eu.etaxonomy.taxeditor.ui.section.AbstractIdentifiableEntityDetailElement;
|
25
|
|
26
|
/**
|
27
|
* PersonDetailElement class.
|
28
|
*
|
29
|
* @author n.hoffmann
|
30
|
* @created Mar 8, 2010
|
31
|
*/
|
32
|
public class PersonDetailElement extends AbstractIdentifiableEntityDetailElement<Person> {
|
33
|
|
34
|
private TextWithLabelElement text_nomenclaturalTitle;
|
35
|
private TextWithLabelElement text_firstname;
|
36
|
private TextWithLabelElement text_lastname;
|
37
|
private TextWithLabelElement text_prefix;
|
38
|
private TextWithLabelElement text_suffix;
|
39
|
private TextWithLabelElement text_initials;
|
40
|
private TimePeriodElement time_lifespan;
|
41
|
private OrcidWithLabelElement text_orcid;
|
42
|
private LsidWithExceptionLabelElement text_lsid;
|
43
|
private Collection<Object> excludeFromIrrelevantToggleableObjects;
|
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
|
text_nomenclaturalTitle = formFactory.createTextWithLabelElement(
|
59
|
formElement, "Abbrev. Title", entity.getNomenclaturalTitle(),
|
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
|
|
75
|
@Override
|
76
|
protected void updateContent() {
|
77
|
super.updateContent();
|
78
|
|
79
|
excludeFromIrrelevantToggleableObjects = Arrays.asList(new Object[] {
|
80
|
toggleable_cache, text_nomenclaturalTitle });
|
81
|
|
82
|
toggleable_cache.setEnabled(getEntity().isProtectedTitleCache());
|
83
|
setIrrelevant(toggleable_cache.getState(),
|
84
|
excludeFromIrrelevantToggleableObjects);
|
85
|
}
|
86
|
|
87
|
@Override
|
88
|
public void handleEvent(Object eventSource) {
|
89
|
if (eventSource == toggleable_cache) {
|
90
|
handleToggleableCacheField();
|
91
|
} else if (eventSource == text_nomenclaturalTitle) {
|
92
|
getEntity().setNomenclaturalTitle(text_nomenclaturalTitle.getText());
|
93
|
} else if (eventSource == text_firstname) {
|
94
|
getEntity().setGivenName(text_firstname.getText());
|
95
|
}else if (eventSource == text_initials) {
|
96
|
getEntity().setInitials(text_initials.getText());
|
97
|
}else if (eventSource == text_lastname) {
|
98
|
getEntity().setFamilyName(text_lastname.getText());
|
99
|
} else if (eventSource == text_prefix) {
|
100
|
getEntity().setPrefix(text_prefix.getText());
|
101
|
} else if (eventSource == text_suffix) {
|
102
|
getEntity().setSuffix(text_suffix.getText());
|
103
|
}else if (eventSource == text_orcid) {
|
104
|
getEntity().setOrcid(text_orcid.parseText());
|
105
|
}else if (eventSource == text_lsid) {
|
106
|
getEntity().setLsid(text_lsid.parseText());
|
107
|
}else if (eventSource == time_lifespan) {
|
108
|
getEntity().setLifespan(time_lifespan.getTimePeriod());
|
109
|
}
|
110
|
|
111
|
//if (eventSource != toggleable_cache) {
|
112
|
if (!getEntity().isProtectedTitleCache()){
|
113
|
toggleable_cache.setText(getEntity().generateTitle());
|
114
|
}
|
115
|
|
116
|
firePropertyChangeEvent(new CdmPropertyChangeEvent(this, null));
|
117
|
}
|
118
|
|
119
|
@Override
|
120
|
protected void handleToggleableCacheField() {
|
121
|
boolean pushedState = toggleable_cache.getState();
|
122
|
getEntity().setProtectedTitleCache(pushedState);
|
123
|
getEntity().getTitleCache();
|
124
|
if (pushedState){
|
125
|
getEntity().setTitleCache(toggleable_cache.getText(), pushedState);
|
126
|
}
|
127
|
setIrrelevant(pushedState, Arrays.asList(new Object[] { toggleable_cache, text_nomenclaturalTitle }));
|
128
|
updateToggleableCacheField();
|
129
|
}
|
130
|
}
|