Merged refactoring from development branch.
[taxeditor.git] / taxeditor-store / src / main / java / eu / etaxonomy / taxeditor / ui / section / occurrence / CollectionDetailElement.java
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.occurrence;
12
13 import eu.etaxonomy.cdm.model.occurrence.Collection;
14 import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory;
15 import eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement;
16 import eu.etaxonomy.taxeditor.ui.forms.TextWithLabelElement;
17 import eu.etaxonomy.taxeditor.ui.forms.ToggleableTextElement;
18 import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.SelectionType;
19 import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
20 import eu.etaxonomy.taxeditor.ui.selection.CollectionSelectionElement;
21 import eu.etaxonomy.taxeditor.ui.selection.InstitutionSelectionElement;
22
23 /**
24 * <p>CollectionDetailElement class.</p>
25 *
26 * @author n.hoffmann
27 * @created Oct 13, 2010
28 * @version 1.0
29 */
30 public class CollectionDetailElement extends AbstractCdmDetailElement<Collection> {
31
32 private ToggleableTextElement text_titleCache;
33
34 private TextWithLabelElement text_code;
35
36 private TextWithLabelElement text_codeStandard;
37
38 private TextWithLabelElement text_name;
39
40 private TextWithLabelElement text_townOrLocation;
41
42 private InstitutionSelectionElement selection_institute;
43
44 private CollectionSelectionElement selection_superCollection;
45
46 /**
47 * <p>Constructor for CollectionDetailElement.</p>
48 *
49 * @param formFactory a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory} object.
50 * @param formElement a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement} object.
51 */
52 public CollectionDetailElement(CdmFormFactory formFactory,
53 ICdmFormElement formElement) {
54 super(formFactory, formElement);
55 }
56
57 /* (non-Javadoc)
58 * @see eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#createControls(eu.etaxonomy.taxeditor.forms.ICdmFormElement, eu.etaxonomy.cdm.model.common.IAnnotatableEntity, int)
59 */
60 /** {@inheritDoc} */
61 @Override
62 protected void createControls(ICdmFormElement formElement,
63 Collection entity, int style) {
64 text_titleCache = formFactory.createToggleableTextField(formElement, "Title Cache", entity.getTitleCache(), entity.isProtectedTitleCache(), style);
65
66 text_code = formFactory.createTextWithLabelElement(formElement, "Code", entity.getCode(), style);
67 text_codeStandard = formFactory.createTextWithLabelElement(formElement, "Code Standard", entity.getCodeStandard(), style);
68 text_name = formFactory.createTextWithLabelElement(formElement, "Name", entity.getName(), style);
69 text_townOrLocation = formFactory.createTextWithLabelElement(formElement, "Town Or Location", entity.getTownOrLocation(), style);
70 selection_institute = (InstitutionSelectionElement) formFactory.createSelectionElement(SelectionType.INSTITUTION, getConversationHolder(), formElement, "Institute", entity.getInstitute(), style);
71 selection_superCollection = (CollectionSelectionElement) formFactory.createSelectionElement(SelectionType.COLLECTION, getConversationHolder(), formElement, "Super Collection", entity.getSuperCollection(), style);
72 }
73
74 /* (non-Javadoc)
75 * @see eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#handleEvent(java.lang.Object)
76 */
77 /** {@inheritDoc} */
78 @Override
79 public void handleEvent(Object eventSource) {
80 if(eventSource == text_titleCache){
81 getEntity().setTitleCache(text_titleCache.getText(), text_titleCache.getState());
82 }
83 else if(eventSource == text_code){
84 getEntity().setCode(text_code.getText());
85 }
86 else if(eventSource == text_codeStandard){
87 getEntity().setCodeStandard(text_codeStandard.getText());
88 }
89 else if(eventSource == text_name){
90 getEntity().setName(text_name.getText());
91 }
92 else if(eventSource == text_townOrLocation){
93 getEntity().setTownOrLocation(text_townOrLocation.getText());
94 }
95 else if(eventSource == selection_institute){
96 getEntity().setInstitute(selection_institute.getSelection());
97 }
98 else if(eventSource == selection_superCollection){
99 getEntity().setSuperCollection(selection_superCollection.getSelection());
100 }
101 }
102
103 }