3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
11 package eu
.etaxonomy
.taxeditor
.ui
.section
.name
;
13 import java
.util
.Arrays
;
15 import org
.eclipse
.ui
.forms
.widgets
.ExpandableComposite
;
17 import eu
.etaxonomy
.cdm
.model
.name
.NomenclaturalCode
;
18 import eu
.etaxonomy
.cdm
.model
.name
.NonViralName
;
19 import eu
.etaxonomy
.taxeditor
.ui
.campanula
.compatibility
.ICdmFormElement
;
20 import eu
.etaxonomy
.taxeditor
.ui
.combo
.EnumComboElement
;
21 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
22 import eu
.etaxonomy
.taxeditor
.ui
.element
.LayoutConstants
;
23 import eu
.etaxonomy
.taxeditor
.ui
.section
.AbstractCdmDetailSection
;
24 import eu
.etaxonomy
.taxeditor
.ui
.section
.AbstractIdentifiableEntityDetailElement
;
28 * NonViralNameDetailElement class.
32 * @created May 20, 2010
35 public class NonViralNameDetailElement
extends
36 AbstractIdentifiableEntityDetailElement
<NonViralName
> {
38 private NameDetailSection section_name
;
39 private AuthorshipDetailSection section_author
;
40 private EnumComboElement
<NomenclaturalCode
> combo_nomenclaturalCode
;
41 private HybridDetailSection section_hybrid
;
45 * Constructor for NonViralNameDetailElement.
49 * a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
52 * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
55 public NonViralNameDetailElement(CdmFormFactory formFactory
,
56 ICdmFormElement formElement
) {
57 super(formFactory
, formElement
);
64 * eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#createControls
65 * (eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement,
66 * eu.etaxonomy.cdm.model.common.AnnotatableEntity, int)
70 protected void createControls(ICdmFormElement formElement
, final NonViralName entity
, int style
) {
72 toggleable_cache
= formFactory
.createToggleableTextField(formElement
, "Cache", entity
.getTitleCache(), entity
.isProtectedTitleCache() || entity
.isProtectedFullTitleCache(), style
);
74 combo_nomenclaturalCode
= formFactory
.createEnumComboElement(NomenclaturalCode
.class, formElement
, style
);
75 combo_nomenclaturalCode
.setSelection(entity
.getNomenclaturalCode());
77 section_name
= formFactory
.createNameDetailSection(getConversationHolder(), formElement
, null, ExpandableComposite
.TWISTIE
| ExpandableComposite
.EXPANDED
);
78 section_name
.setLayoutData(LayoutConstants
.FILL_HORIZONTALLY(2, 1));
79 addControl(section_name
);
80 addElement(section_name
);
81 section_author
= formFactory
.createAuthorshipDetailSection(getConversationHolder(), formElement
, null, ExpandableComposite
.TWISTIE
| ExpandableComposite
.EXPANDED
);
82 section_author
.setLayoutData(LayoutConstants
.FILL_HORIZONTALLY(2, 1));
83 addControl(section_author
);
84 addElement(section_author
);
86 section_hybrid
= formFactory
.createHybridDetailSection(getConversationHolder(), formElement
, null, ExpandableComposite
.TWISTIE
);
87 section_hybrid
.setLayoutData(LayoutConstants
.FILL_HORIZONTALLY(2, 1));
88 addControl(section_hybrid
);
89 addElement(section_hybrid
);
94 protected void updateContent() {
95 super.updateContent();
97 // disable nomenclatural code, because changing of nom.code is not
98 // implemented on library side
99 combo_nomenclaturalCode
.setEnabled(false);
101 setIrrelevant(toggleable_cache
.getState(),
102 Arrays
.asList(new Object
[] { toggleable_cache
}));
107 public void setEntity(NonViralName entity
) {
108 super.setEntity(entity
);
109 section_name
.setEntity(entity
);
110 section_author
.setEntity(entity
);
111 section_hybrid
.setEntity(entity
);
116 public void removeElements() {
117 super.removeElements();
118 if (section_name
!= null) {
119 section_name
.removeElements();
120 removeControl(section_name
);
121 section_name
.dispose();
124 if (section_author
!= null) {
125 section_author
.removeElements();
126 removeControl(section_author
);
127 section_author
.dispose();
128 section_author
= null;
136 * eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#handleEvent(java
141 public void handleEvent(Object eventSource
) {
142 if (eventSource
== toggleable_cache
) {
143 handleToggleableCacheField();
144 // we never want the fullTitleCache to be protected since we only
146 // initiating the free text name editor
147 getEntity().setProtectedFullTitleCache(false);
148 } else if (eventSource
== section_name
|| eventSource
== section_author
) {
149 if (getParentElement() instanceof AbstractCdmDetailSection
) {
150 ((AbstractCdmDetailSection
) getParentElement()).updateTitle();
152 if (!toggleable_cache
.getState()) {
153 toggleable_cache
.setText(getEntity().getTitleCache());
156 if (eventSource
== section_name
) {
157 section_name
.setEntity(getEntity());
158 getLayoutComposite().layout();