2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
9 package eu
.etaxonomy
.taxeditor
.ui
.section
.agent
;
11 import org
.eclipse
.swt
.SWT
;
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
;
24 * PersonDetailElement class.
27 * @created Mar 8, 2010
29 public class PersonDetailElement
extends AbstractIdentifiableEntityDetailElement
<Person
> {
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
;
42 public PersonDetailElement(CdmFormFactory cdmFormFactory
,
43 ICdmFormElement formElement
, int style
) {
44 super(cdmFormFactory
, formElement
);
48 protected void createControls(ICdmFormElement formElement
, Person entity
,
50 setWarnForReferencingObjects(formElement
);
51 toggleable_cache
= formFactory
.createToggleableTextField(formElement
,
52 "Title Cache", entity
.getTitleCache(),
53 entity
.isProtectedTitleCache(), SWT
.NULL
);
55 text_nomenclaturalTitle
= formFactory
.createTextWithLabelElement(
56 formElement
, "Abbrev. Title", entity
.getNomenclaturalTitle(),
58 text_collectorTitle
= formFactory
.createTextWithLabelElement(
59 formElement
, "Collector Title", entity
.getCollectorTitle(),
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();
75 registerCacheRelevance(text_firstname
);
76 registerCacheRelevance(text_lastname
);
77 registerCacheRelevance(text_prefix
);
78 registerCacheRelevance(text_suffix
);
79 registerCacheRelevance(text_initials
);
83 protected void updateContent() {
84 super.updateContent();
85 toggleable_cache
.setEnabled(getEntity().isProtectedTitleCache());
86 updateCacheRelevance();
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());
115 //if (eventSource != toggleable_cache) {
116 if (!getEntity().isProtectedTitleCache()){
117 toggleable_cache
.setText(getEntity().generateTitle());
120 firePropertyChangeEvent(new CdmPropertyChangeEvent(this, null));
124 protected void handleToggleableCacheField() {
125 boolean pushedState
= toggleable_cache
.getState();
126 getEntity().setProtectedTitleCache(pushedState
);
127 getEntity().getTitleCache();
129 getEntity().setTitleCache(toggleable_cache
.getText(), pushedState
);
131 updateCacheRelevance();
132 updateToggleableCacheField();