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