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
.occurrence
;
11 import eu
.etaxonomy
.cdm
.model
.agent
.Institution
;
12 import eu
.etaxonomy
.cdm
.model
.occurrence
.Collection
;
13 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
14 import eu
.etaxonomy
.taxeditor
.ui
.element
.ICdmFormElement
;
15 import eu
.etaxonomy
.taxeditor
.ui
.element
.TextWithLabelElement
;
16 import eu
.etaxonomy
.taxeditor
.ui
.element
.ToggleableTextElement
;
17 import eu
.etaxonomy
.taxeditor
.ui
.section
.AbstractCdmDetailElement
;
18 import eu
.etaxonomy
.taxeditor
.ui
.selection
.EntitySelectionElement
;
22 * @created Oct 13, 2010
24 public class CollectionDetailElement
extends
25 AbstractCdmDetailElement
<Collection
> {
27 private ToggleableTextElement text_titleCache
;
29 private TextWithLabelElement text_code
;
31 private TextWithLabelElement text_codeStandard
;
33 private TextWithLabelElement text_name
;
35 private TextWithLabelElement text_townOrLocation
;
37 private EntitySelectionElement
<Institution
> selection_institute
;
39 private EntitySelectionElement
<Collection
> selection_superCollection
;
42 * Constructor for CollectionDetailElement.
44 public CollectionDetailElement(CdmFormFactory formFactory
,
45 ICdmFormElement formElement
) {
46 super(formFactory
, formElement
);
50 protected void createControls(ICdmFormElement formElement
,
51 Collection entity
, int style
) {
52 text_titleCache
= formFactory
.createToggleableTextField(formElement
,
53 "Title Cache", entity
.getTitleCache(),
54 entity
.isProtectedTitleCache(), style
);
56 text_code
= formFactory
.createTextWithLabelElement(formElement
, "Code",
57 entity
.getCode(), style
);
58 text_codeStandard
= formFactory
.createTextWithLabelElement(formElement
,
59 "Code Standard", entity
.getCodeStandard(), style
);
60 text_name
= formFactory
.createTextWithLabelElement(formElement
, "Name",
61 entity
.getName(), style
);
62 text_townOrLocation
= formFactory
.createTextWithLabelElement(
63 formElement
, "Town Or Location", entity
.getTownOrLocation(),
65 selection_institute
= formFactory
66 .createSelectionElement(Institution
.class,
67 formElement
, "Institute",
68 entity
.getInstitute(),
69 EntitySelectionElement
.ALL
, style
);
70 selection_superCollection
= formFactory
71 .createSelectionElement(Collection
.class,
73 "Super Collection", entity
.getSuperCollection(),
74 EntitySelectionElement
.ALL
, style
);
78 public void handleEvent(Object eventSource
) {
79 if (eventSource
== text_titleCache
) {
80 getEntity().setTitleCache(text_titleCache
.getText(),
81 text_titleCache
.getState());
82 } else if (eventSource
== text_code
) {
83 getEntity().setCode(text_code
.getText());
84 } else if (eventSource
== text_codeStandard
) {
85 getEntity().setCodeStandard(text_codeStandard
.getText());
86 } else if (eventSource
== text_name
) {
87 getEntity().setName(text_name
.getText());
88 } else if (eventSource
== text_townOrLocation
) {
89 getEntity().setTownOrLocation(text_townOrLocation
.getText());
90 } else if (eventSource
== selection_institute
) {
91 getEntity().setInstitute(selection_institute
.getSelection());
92 } else if (eventSource
== selection_superCollection
) {
93 getEntity().setSuperCollection(
94 selection_superCollection
.getSelection());
96 if (eventSource
!= text_titleCache
) {
97 text_titleCache
.setText(getEntity().getTitleCache());