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.section.agent;
|
12
|
|
13
|
import java.util.Arrays;
|
14
|
import java.util.Collection;
|
15
|
|
16
|
import org.apache.log4j.Logger;
|
17
|
import org.eclipse.swt.SWT;
|
18
|
|
19
|
import eu.etaxonomy.cdm.model.agent.Person;
|
20
|
import eu.etaxonomy.taxeditor.forms.CdmFormFactory;
|
21
|
import eu.etaxonomy.taxeditor.forms.ICdmFormElement;
|
22
|
import eu.etaxonomy.taxeditor.forms.TextWithLabelElement;
|
23
|
import eu.etaxonomy.taxeditor.forms.ToggleableTextElement;
|
24
|
import eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement;
|
25
|
|
26
|
/**
|
27
|
* <p>PersonDetailElement class.</p>
|
28
|
*
|
29
|
* @author n.hoffmann
|
30
|
* @created Mar 8, 2010
|
31
|
* @version 1.0
|
32
|
*/
|
33
|
public class PersonDetailElement extends AbstractCdmDetailElement<Person> {
|
34
|
|
35
|
|
36
|
|
37
|
private static final Logger logger = Logger
|
38
|
.getLogger(PersonDetailElement.class);
|
39
|
private ToggleableTextElement toggleable_cache;
|
40
|
private TextWithLabelElement text_nomenclaturalTitle;
|
41
|
private TextWithLabelElement text_firstname;
|
42
|
private TextWithLabelElement text_lastname;
|
43
|
private TextWithLabelElement text_prefix;
|
44
|
private TextWithLabelElement text_suffix;
|
45
|
|
46
|
private Collection<Object> excludeFromIrrelevantToggleableObjects;
|
47
|
|
48
|
/**
|
49
|
* <p>Constructor for PersonDetailElement.</p>
|
50
|
*
|
51
|
* @param cdmFormFactory a {@link eu.etaxonomy.taxeditor.forms.CdmFormFactory} object.
|
52
|
* @param formElement a {@link eu.etaxonomy.taxeditor.forms.ICdmFormElement} object.
|
53
|
* @param style a int.
|
54
|
*/
|
55
|
public PersonDetailElement(CdmFormFactory cdmFormFactory, ICdmFormElement formElement,
|
56
|
int style) {
|
57
|
super(cdmFormFactory, formElement);
|
58
|
}
|
59
|
|
60
|
/** {@inheritDoc} */
|
61
|
@Override
|
62
|
protected void createControls(ICdmFormElement formElement, Person entity, int style) {
|
63
|
getLayoutComposite().setLayoutData(CdmFormFactory.LAYOUT(2, false));
|
64
|
|
65
|
toggleable_cache = formFactory.createToggleableTextField(formElement, "Title Cache", entity.getTitleCache(), entity.isProtectedTitleCache(), SWT.NULL);
|
66
|
|
67
|
text_nomenclaturalTitle = formFactory.createTextWithLabelElement(formElement, "Nom. Title", entity.getNomenclaturalTitle(), SWT.NULL);
|
68
|
|
69
|
|
70
|
text_firstname = formFactory.createTextWithLabelElement(formElement, "Firstname", entity.getFirstname(), SWT.NULL);
|
71
|
text_lastname = formFactory.createTextWithLabelElement(formElement, "Lastname", entity.getLastname(), SWT.NULL);
|
72
|
|
73
|
text_prefix = formFactory.createTextWithLabelElement(formElement, "Prefix", entity.getPrefix(), SWT.NULL);
|
74
|
text_suffix = formFactory.createTextWithLabelElement(formElement, "Suffix", entity.getSuffix(), SWT.NULL);
|
75
|
}
|
76
|
|
77
|
/** {@inheritDoc} */
|
78
|
@Override
|
79
|
protected void updateContent() {
|
80
|
super.updateContent();
|
81
|
|
82
|
excludeFromIrrelevantToggleableObjects = Arrays.asList(new Object[]{toggleable_cache, text_nomenclaturalTitle});
|
83
|
|
84
|
toggleable_cache.setEnabled(getEntity().isProtectedTitleCache());
|
85
|
setIrrelevant(toggleable_cache.getState(), excludeFromIrrelevantToggleableObjects);
|
86
|
}
|
87
|
|
88
|
|
89
|
/** {@inheritDoc} */
|
90
|
@Override
|
91
|
public void handleEvent(Object eventSource) {
|
92
|
if(eventSource == toggleable_cache){
|
93
|
getEntity().setTitleCache(toggleable_cache.getText(), toggleable_cache.getState());
|
94
|
setIrrelevant(toggleable_cache.getState(), excludeFromIrrelevantToggleableObjects);
|
95
|
}
|
96
|
else if(eventSource == text_nomenclaturalTitle){
|
97
|
getEntity().setNomenclaturalTitle(text_nomenclaturalTitle.getText());
|
98
|
}
|
99
|
else if(eventSource == text_firstname){
|
100
|
getEntity().setFirstname(text_firstname.getText());
|
101
|
}
|
102
|
else if(eventSource == text_lastname){
|
103
|
getEntity().setLastname(text_lastname.getText());
|
104
|
}
|
105
|
else if(eventSource == text_prefix){
|
106
|
getEntity().setPrefix(text_prefix.getText());
|
107
|
}
|
108
|
else if(eventSource == text_suffix){
|
109
|
getEntity().setSuffix(text_suffix.getText());
|
110
|
}
|
111
|
|
112
|
if(eventSource != toggleable_cache){
|
113
|
toggleable_cache.setText(getEntity().getTitleCache());
|
114
|
}
|
115
|
}
|
116
|
}
|