3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
11 package eu
.etaxonomy
.taxeditor
.ui
.section
.occurrence
;
13 import org
.eclipse
.ui
.forms
.widgets
.Section
;
15 import eu
.etaxonomy
.cdm
.api
.facade
.DerivedUnitFacade
;
16 import eu
.etaxonomy
.cdm
.api
.facade
.DerivedUnitFacadeConfigurator
;
17 import eu
.etaxonomy
.cdm
.api
.facade
.DerivedUnitFacadeNotSupportedException
;
18 import eu
.etaxonomy
.cdm
.model
.occurrence
.DerivedUnitBase
;
19 import eu
.etaxonomy
.taxeditor
.store
.StoreUtil
;
20 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
21 import eu
.etaxonomy
.taxeditor
.ui
.element
.ICdmFormElement
;
22 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
.DetailType
;
23 import eu
.etaxonomy
.taxeditor
.ui
.element
.LayoutConstants
;
24 import eu
.etaxonomy
.taxeditor
.ui
.section
.AbstractCdmDetailElement
;
25 import eu
.etaxonomy
.taxeditor
.ui
.section
.AbstractCdmDetailSection
;
28 * <p>DerivedUnitFacadeDetailElement class.</p>
31 * @created Jun 17, 2010
34 public class DerivedUnitFacadeDetailElement
extends AbstractCdmDetailElement
<DerivedUnitBase
> {
36 private DerivedUnitFacade facade
;
38 private DerivedUnitFacadeConfigurator configurator
;
40 private GeneralDetailSection section_general
;
41 private GatheringEventDetailSection section_gatheringEvent
;
42 private DerivedUnitBaseDetailSection section_derivedUnitBase
;
43 private FieldObservationDetailSection section_fieldObservation
;
46 * <p>Constructor for DerivedUnitFacadeDetailElement.</p>
48 * @param formFactory a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object.
49 * @param formElement a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} object.
51 public DerivedUnitFacadeDetailElement(CdmFormFactory formFactory
,
52 ICdmFormElement formElement
) {
53 super(formFactory
, formElement
);
54 configurator
= DerivedUnitFacadeConfigurator
.NewInstance();
55 configurator
.setMoveDerivedUnitMediaToGallery(true);
56 configurator
.setMoveFieldObjectMediaToGallery(true);
61 public void setEntity(DerivedUnitBase entity
) {
62 super.setEntity(entity
);
64 facade
= DerivedUnitFacade
.NewInstance(entity
, configurator
);
66 section_general
.setEntity(facade
);
67 section_derivedUnitBase
.setEntity(facade
);
68 section_gatheringEvent
.setEntity(facade
);
69 section_fieldObservation
.setEntity(facade
);
71 } catch (DerivedUnitFacadeNotSupportedException e
) {
72 StoreUtil
.errorDialog("Error", this, "SpecimenFacadeNotSupportedException while inititating SpecimenFacade", e
);
78 public void removeElements() {
79 super.removeElements();
80 if(section_general
!= null){
81 removeControl(section_general
);
82 section_general
.dispose();
83 section_general
= null;
85 if(section_derivedUnitBase
!= null){
86 removeControl(section_derivedUnitBase
);
87 section_derivedUnitBase
.dispose();
88 section_derivedUnitBase
= null;
90 if(section_gatheringEvent
!= null){
91 removeControl(section_gatheringEvent
);
92 section_gatheringEvent
.dispose();
93 section_gatheringEvent
= null;
95 if(section_fieldObservation
!= null){
96 removeControl(section_fieldObservation
);
97 section_fieldObservation
.dispose();
98 section_fieldObservation
= null;
104 public DerivedUnitBase
getEntity() {
105 throw new IllegalArgumentException("Should not be called");
109 * <p>Getter for the field <code>facade</code>.</p>
111 * @return a {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade} object.
113 public DerivedUnitFacade
getFacade(){
119 protected void createControls(ICdmFormElement formElement
,
120 DerivedUnitBase entity
, int style
) {
122 section_general
= (GeneralDetailSection
) formFactory
.createCdmDetailSection(DetailType
.DERIVED_UNIT_GENERAL
, getConversationHolder(), formElement
, null, Section
.TWISTIE
| Section
.EXPANDED
);
123 section_general
.setLayoutData(LayoutConstants
.FILL_HORIZONTALLY(2, 1));
124 addControl(section_general
);
125 addElement(section_general
);
127 section_gatheringEvent
= (GatheringEventDetailSection
) formFactory
.createCdmDetailSection(DetailType
.GATHERING_EVENT
, getConversationHolder(), formElement
, null, Section
.TWISTIE
);
128 section_gatheringEvent
.setLayoutData(LayoutConstants
.FILL_HORIZONTALLY(2, 1));
129 addControl(section_gatheringEvent
);
130 addElement(section_gatheringEvent
);
132 section_fieldObservation
= (FieldObservationDetailSection
) formFactory
.createCdmDetailSection(DetailType
.FIELD_OBSERVATION
, getConversationHolder(), formElement
, null, Section
.TWISTIE
);
133 section_fieldObservation
.setLayoutData(LayoutConstants
.FILL_HORIZONTALLY(2, 1));
134 addControl(section_fieldObservation
);
135 addElement(section_fieldObservation
);
137 section_derivedUnitBase
= (DerivedUnitBaseDetailSection
) formFactory
.createCdmDetailSection(DetailType
.DERIVED_UNIT
, getConversationHolder(), formElement
, null, Section
.TWISTIE
);
138 section_derivedUnitBase
.setLayoutData(LayoutConstants
.FILL_HORIZONTALLY(2, 1));
139 addControl(section_derivedUnitBase
);
140 addElement(section_derivedUnitBase
);
145 public void handleEvent(Object eventSource
) {
146 if(eventSource
== section_derivedUnitBase
|| eventSource
== section_gatheringEvent
|| eventSource
== section_fieldObservation
){
147 if(getParentElement() instanceof AbstractCdmDetailSection
) {
148 ((AbstractCdmDetailSection
) getParentElement()).updateTitle();