- split off "Preparation/Preservation section" from dna sample general
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / section / occurrence / dna / DnaSampleGeneralDetailElement.java
1 // $Id$
2 /**
3 * Copyright (C) 2013 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 package eu.etaxonomy.taxeditor.ui.section.occurrence.dna;
11
12 import eu.etaxonomy.cdm.model.molecular.DnaSample;
13 import eu.etaxonomy.cdm.model.occurrence.Collection;
14 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
15 import eu.etaxonomy.taxeditor.ui.element.CheckboxElement;
16 import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
17 import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
18 import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
19 import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
20
21 /**
22 * @author pplitzner
23 * @date 16.12.2013
24 *
25 */
26 public class DnaSampleGeneralDetailElement extends AbstractCdmDetailElement<DnaSample> {
27
28
29 private EntitySelectionElement<Collection> selection_collection;
30 private TextWithLabelElement textBarcode;
31 private CheckboxElement checkIsPublish;
32
33 public DnaSampleGeneralDetailElement(CdmFormFactory formFactory, ICdmFormElement formElement) {
34 super(formFactory, formElement);
35 }
36
37 @Override
38 protected void createControls(ICdmFormElement formElement, DnaSample entity, int style) {
39 selection_collection = formFactory
40 .createSelectionElement(Collection.class,
41 getConversationHolder(), formElement, "Collection",
42 entity.getCollection(),
43 EntitySelectionElement.ALL, style);
44 textBarcode = formFactory.createTextWithLabelElement(formElement, "Barcode", entity.getBarcode(), style);
45 checkIsPublish = formFactory.createCheckbox(formElement, "Publish", entity.isPublish(), style);
46
47 }
48
49 @Override
50 public void handleEvent(Object eventSource) {
51 if(eventSource==textBarcode){
52 getEntity().setBarcode(textBarcode.getText());
53 }
54 else if(eventSource==checkIsPublish){
55 getEntity().setPublish(checkIsPublish.getSelection());
56 } else if (eventSource == selection_collection) {
57 getEntity().setCollection(selection_collection.getSelection());
58 }
59 }
60
61 }