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 eu.etaxonomy.cdm.model.agent.Team;
|
12
|
import eu.etaxonomy.taxeditor.store.StoreUtil;
|
13
|
import eu.etaxonomy.taxeditor.ui.element.CacheRelevance;
|
14
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
15
|
import eu.etaxonomy.taxeditor.ui.element.CdmPropertyChangeEvent;
|
16
|
import eu.etaxonomy.taxeditor.ui.element.CheckboxElement;
|
17
|
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
|
18
|
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
|
19
|
import eu.etaxonomy.taxeditor.ui.element.ToggleableTextElement;
|
20
|
import eu.etaxonomy.taxeditor.ui.section.AbstractIdentifiableEntityDetailElement;
|
21
|
|
22
|
/**
|
23
|
* TeamDetailElement class.
|
24
|
*
|
25
|
* @author n.hoffmann
|
26
|
* @created Apr 26, 2010
|
27
|
*/
|
28
|
public class TeamDetailElement
|
29
|
extends AbstractIdentifiableEntityDetailElement<Team> {
|
30
|
|
31
|
private ToggleableTextElement toggleable_nomenclaturalTitleCache;
|
32
|
private ToggleableTextElement toggleable_collectorTitleCache;
|
33
|
private CheckboxElement hasAdditionalMembers;
|
34
|
|
35
|
private TeamMemberSection section_teamMembers;
|
36
|
private boolean isNomenclaturalTeam;
|
37
|
|
38
|
/**
|
39
|
* Constructor for TeamDetailElement.
|
40
|
*/
|
41
|
public TeamDetailElement(CdmFormFactory cdmFormFactory,
|
42
|
ICdmFormElement formElement, int style, boolean isNomenclatural) {
|
43
|
super(cdmFormFactory, formElement);
|
44
|
this.isNomenclaturalTeam = isNomenclatural;
|
45
|
}
|
46
|
|
47
|
@Override
|
48
|
protected void createControls(ICdmFormElement formElement, Team entity, int style) {
|
49
|
|
50
|
setWarnForReferencingObjects(formElement);
|
51
|
toggleable_cache = formFactory.createToggleableTextField(formElement, "Title Cache",
|
52
|
entity.getTitleCache(), entity.isProtectedTitleCache(), style);
|
53
|
toggleable_nomenclaturalTitleCache = formFactory.createToggleableTextField(formElement,
|
54
|
"Abbrev. Title", entity.getNomenclaturalTitleCache(), entity.isProtectedNomenclaturalTitleCache(),
|
55
|
CacheRelevance.CACHE2, style);
|
56
|
toggleable_collectorTitleCache = formFactory.createToggleableTextField(formElement,
|
57
|
"Collector Title", entity.getCollectorTitleCache(), entity.isProtectedCollectorTitleCache(),
|
58
|
CacheRelevance.CACHE2, style);
|
59
|
hasAdditionalMembers = formFactory.createCheckbox(formElement, "Additional Members", entity.isHasMoreMembers(), style);
|
60
|
section_teamMembers = formFactory.createTeamMemberSection(getConversationHolder(), formElement, StoreUtil.getSectionStyle(TeamMemberSection.class, entity.getClass().getCanonicalName(), true), isNomenclaturalTeam);
|
61
|
section_teamMembers.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
|
62
|
|
63
|
//cache relevance
|
64
|
//TODO
|
65
|
// registerCacheRelevance(toggleable_nomenclaturalTitleCache);
|
66
|
registerCacheRelevance(hasAdditionalMembers, toggleable_cache, toggleable_nomenclaturalTitleCache);
|
67
|
registerCacheRelevance(section_teamMembers, toggleable_cache, toggleable_nomenclaturalTitleCache);
|
68
|
}
|
69
|
|
70
|
@Override
|
71
|
protected void updateContent() {
|
72
|
super.updateContent();
|
73
|
if (toggleable_cache != null){
|
74
|
toggleable_cache.setCacheEnabled(getEntity().isProtectedTitleCache());
|
75
|
}
|
76
|
if (toggleable_nomenclaturalTitleCache != null){
|
77
|
toggleable_nomenclaturalTitleCache.setCacheEnabled(getEntity()
|
78
|
.isProtectedNomenclaturalTitleCache());
|
79
|
}
|
80
|
if (toggleable_collectorTitleCache != null){
|
81
|
toggleable_collectorTitleCache.setCacheEnabled(getEntity()
|
82
|
.isProtectedCollectorTitleCache());
|
83
|
}
|
84
|
section_teamMembers.setEntity(getEntity());
|
85
|
|
86
|
updateCacheRelevance();
|
87
|
}
|
88
|
|
89
|
@Override
|
90
|
public void handleEvent(Object eventSource) {
|
91
|
if (eventSource == toggleable_cache) {
|
92
|
handleToggleableCacheField();
|
93
|
|
94
|
} else if (eventSource == toggleable_nomenclaturalTitleCache) {
|
95
|
updateToggleable_nomanclaturalTitleCacheField();
|
96
|
updateCacheRelevance();
|
97
|
} else if (eventSource == toggleable_collectorTitleCache) {
|
98
|
updateToggleable_collectorTitleCacheField();
|
99
|
updateCacheRelevance();
|
100
|
} else if (eventSource == section_teamMembers) {
|
101
|
toggleable_cache.setText(getEntity().getTitleCache());
|
102
|
toggleable_nomenclaturalTitleCache.setText(getEntity()
|
103
|
.getNomenclaturalTitleCache());
|
104
|
toggleable_collectorTitleCache.setText(getEntity()
|
105
|
.getCollectorTitleCache());
|
106
|
} else if (eventSource == hasAdditionalMembers){
|
107
|
getEntity().setHasMoreMembers(hasAdditionalMembers.getSelection());
|
108
|
updateToggleableCacheField();
|
109
|
toggleable_nomenclaturalTitleCache.setText(getEntity()
|
110
|
.getNomenclaturalTitleCache());
|
111
|
}
|
112
|
|
113
|
firePropertyChangeEvent(new CdmPropertyChangeEvent(this, null));
|
114
|
}
|
115
|
|
116
|
public void updateToggleable_nomanclaturalTitleCacheField() {
|
117
|
boolean pushedState = toggleable_nomenclaturalTitleCache.getState();
|
118
|
|
119
|
getEntity().setNomenclaturalTitleCache(toggleable_nomenclaturalTitleCache.getText(), pushedState);
|
120
|
updateCacheRelevance();
|
121
|
|
122
|
if (!getEntity().isProtectedNomenclaturalTitleCache()) {
|
123
|
toggleable_nomenclaturalTitleCache.setText(getEntity().getNomenclaturalTitleCache());
|
124
|
}
|
125
|
}
|
126
|
|
127
|
public void updateToggleable_collectorTitleCacheField() {
|
128
|
boolean pushedState = toggleable_collectorTitleCache.getState();
|
129
|
|
130
|
getEntity().setCollectorTitleCache(toggleable_collectorTitleCache.getText(), pushedState);
|
131
|
updateCacheRelevance();
|
132
|
|
133
|
if (!getEntity().isProtectedCollectorTitleCache()) {
|
134
|
toggleable_collectorTitleCache.setText(getEntity().getCollectorTitleCache());
|
135
|
}
|
136
|
}
|
137
|
|
138
|
public boolean isNomenclaturalTeam() {
|
139
|
return isNomenclaturalTeam;
|
140
|
}
|
141
|
public void setNomenclaturalTeam(boolean isNomenclaturalTeam) {
|
142
|
this.isNomenclaturalTeam = isNomenclaturalTeam;
|
143
|
}
|
144
|
}
|