Merge branch 'develop' into LibrAlign
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / section / occurrence / dna / SampleDesignationTextDetailElement.java
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
10 package eu.etaxonomy.taxeditor.ui.section.occurrence.dna;
11
12 import org.eclipse.swt.events.SelectionListener;
13 import org.eclipse.swt.graphics.Color;
14
15 import eu.etaxonomy.cdm.model.common.Identifier;
16 import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
17 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
18 import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
19 import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
20 import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement;
21
22 /**
23 *
24 * @author pplitzner
25 * @date Oct 16, 2014
26 *
27 * @param <T>
28 */
29 public class SampleDesignationTextDetailElement extends
30 AbstractEntityCollectionElement<Identifier> {
31
32 protected TextWithLabelElement text_description;
33
34 /**
35 * @param formFactory
36 * @param section
37 * @param entity
38 * @param removeListener
39 * @param backgroundColor
40 * @param style
41 */
42 public SampleDesignationTextDetailElement(CdmFormFactory formFactory, AbstractFormSection<?> section,
43 Identifier entity, SelectionListener removeListener, Color backgroundColor, int style) {
44 super(formFactory, section, entity, removeListener, backgroundColor, style);
45 }
46
47 /*
48 * (non-Javadoc)
49 *
50 * @see
51 * eu.etaxonomy.taxeditor.section.AbstractEntityCollectionElement#createControls
52 * (eu.etaxonomy.taxeditor.forms.ICdmFormElement, int)
53 */
54 /** {@inheritDoc} */
55 @Override
56 public void createControls(ICdmFormElement element, int style) {
57 text_description = formFactory.createTextWithLabelElement(element,
58 "Sample Designation", null, style);
59 }
60
61 /* (non-Javadoc)
62 * @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement#handleEvent(java.lang.Object)
63 */
64 @Override
65 public void handleEvent(Object eventSource) {
66 if(eventSource==text_description){
67 String identifier = null;
68 if(!text_description.getText().isEmpty()){
69 identifier = text_description.getText();
70 }
71 this.entity.setIdentifier(identifier);
72 }
73 }
74
75 /* (non-Javadoc)
76 * @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement#setEntity(java.lang.Object)
77 */
78 @Override
79 public void setEntity(Identifier entity) {
80 this.entity = entity;
81 text_description.setText(entity.getIdentifier());
82 }
83
84 }