Updated version in pom / project files to taxeditor version : 5.34.0 and cdmlib versi...
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / section / occurrence / AbstractEventDetailElement.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 package eu.etaxonomy.taxeditor.ui.section.occurrence;
10
11 import org.eclipse.swt.events.SelectionListener;
12
13 import eu.etaxonomy.cdm.model.agent.AgentBase;
14 import eu.etaxonomy.cdm.model.common.EventBase;
15 import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
16 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
17 import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
18 import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
19 import eu.etaxonomy.taxeditor.ui.element.TimePeriodElement;
20 import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement;
21 import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
22
23 /**
24 * <p>
25 * Abstract AbstractEventDetailElement class.
26 * </p>
27 *
28 * @author n.hoffmann
29 * @created Oct 14, 2010
30 */
31 public abstract class AbstractEventDetailElement<T extends EventBase> extends
32 AbstractEntityCollectionElement<T> {
33
34 protected EntitySelectionElement<AgentBase> selection_agent;
35 protected TextWithLabelElement text_description;
36 protected TimePeriodElement element_timePeriod;
37
38 /**
39 * <p>
40 * Constructor for AbstractEventDetailElement.
41 * </p>
42 *
43 * @param formFactory
44 * a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
45 * object.
46 * @param section
47 * a {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection}
48 * object.
49 * @param entity
50 * a T object.
51 * @param removeListener
52 * a {@link org.eclipse.swt.events.SelectionListener} object.
53 * @param style
54 * a int.
55 * @param <T>
56 * a T object.
57 */
58 public AbstractEventDetailElement(CdmFormFactory formFactory,
59 AbstractFormSection section, T entity,
60 SelectionListener removeListener, int style) {
61 super(formFactory, section, entity, removeListener, null, style);
62 }
63
64
65 /** {@inheritDoc} */
66 @Override
67 public void setEntity(T entity) {
68 if (selection_agent != null){
69 selection_agent.setEntity(entity.getActor());
70 text_description.setText(entity.getDescription());
71 element_timePeriod.setEntity(entity.getTimeperiod());
72 }
73 }
74
75
76 /** {@inheritDoc} */
77 @Override
78 public void createControls(ICdmFormElement element, int style) {
79 selection_agent = formFactory
80 .createSelectionElement(AgentBase.class,//getConversationHolder(),
81 element, "Actor", null,
82 EntitySelectionElement.ALL, style);
83 element_timePeriod = formFactory.createTimePeriodElement(element,
84 "Time Period", null, style);
85 text_description = formFactory.createTextWithLabelElement(element,
86 "Description", null, style);
87 if (entity != null){
88 selection_agent.setEntity(entity.getActor());
89 text_description.setText(entity.getDescription());
90 element_timePeriod.setEntity(entity.getTimeperiod());
91 }
92 }
93
94 }