e5c8c9fb0b2719bf655f85a6771d2c639177aeac
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / section / key / PolytomousKeyDetailElement.java
1 /**
2 *
3 */
4 package eu.etaxonomy.taxeditor.ui.section.key;
5
6 import eu.etaxonomy.cdm.model.description.PolytomousKey;
7 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
8 import eu.etaxonomy.taxeditor.ui.element.CdmPropertyChangeEvent;
9 import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
10 import eu.etaxonomy.taxeditor.ui.element.NumberWithLabelElement;
11 import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
12 import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
13
14 /**
15 * @author n.hoffmann
16 *
17 */
18 public class PolytomousKeyDetailElement extends
19 AbstractCdmDetailElement<PolytomousKey> {
20
21 private TextWithLabelElement textLabel;
22 private NumberWithLabelElement numberStartNumber;
23
24 public PolytomousKeyDetailElement(CdmFormFactory formFactory,
25 ICdmFormElement formElement) {
26 super(formFactory, formElement);
27 }
28
29 @Override
30 protected void createControls(ICdmFormElement formElement,
31 PolytomousKey entity, int style) {
32 textLabel = formFactory.createTextWithLabelElement(formElement, "Title", entity.getTitleCache(), style);
33 numberStartNumber = formFactory.createNumberTextWithLabelElement(formElement, "Start Number", entity.getStartNumber(), style);
34 }
35
36 public String getText() {
37 return textLabel.getText();
38 }
39
40 /*
41 * (non-Javadoc)
42 *
43 * @see
44 * eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#handleEvent(java
45 * .lang.Object)
46 */
47 @Override
48 public void handleEvent(Object eventSource) {
49 if(eventSource==textLabel){
50 getEntity().setTitleCache(textLabel.getText(), true);
51 }
52 else if(eventSource==numberStartNumber){
53 getEntity().setStartNumber(numberStartNumber.getInteger());
54 }
55 firePropertyChangeEvent(new CdmPropertyChangeEvent(this, null));
56 }
57 }