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
.ExpandableComposite
;
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
.DerivedUnit
;
19 import eu
.etaxonomy
.taxeditor
.model
.AbstractUtility
;
20 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
21 import eu
.etaxonomy
.taxeditor
.ui
.element
.ICdmFormElement
;
22 import eu
.etaxonomy
.taxeditor
.ui
.element
.LayoutConstants
;
23 import eu
.etaxonomy
.taxeditor
.ui
.section
.AbstractCdmDetailElement
;
24 import eu
.etaxonomy
.taxeditor
.ui
.section
.AbstractCdmDetailSection
;
27 * <p>DerivedUnitFacadeDetailElement class.</p>
30 * @created Jun 17, 2010
33 public class DerivedUnitFacadeDetailElement
extends AbstractCdmDetailElement
<DerivedUnit
> {
35 private DerivedUnitFacade facade
;
37 private final DerivedUnitFacadeConfigurator configurator
;
39 private GeneralDetailSection section_general
;
40 private GatheringEventDetailSection section_gatheringEvent
;
41 private DerivedUnitBaseDetailSection section_derivedUnitBase
;
42 private FieldObservationDetailSection section_fieldObservation
;
45 * <p>Constructor for DerivedUnitFacadeDetailElement.</p>
47 * @param formFactory a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object.
48 * @param formElement a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} object.
50 public DerivedUnitFacadeDetailElement(CdmFormFactory formFactory
,
51 ICdmFormElement formElement
) {
52 super(formFactory
, formElement
);
53 configurator
= DerivedUnitFacadeConfigurator
.NewInstance();
54 configurator
.setMoveDerivedUnitMediaToGallery(true);
55 configurator
.setMoveFieldObjectMediaToGallery(true);
60 public void setEntity(DerivedUnit entity
) {
61 super.setEntity(entity
);
63 facade
= DerivedUnitFacade
.NewInstance(entity
, configurator
);
65 section_general
.setEntity(facade
);
66 section_derivedUnitBase
.setEntity(facade
);
67 section_gatheringEvent
.setEntity(facade
);
68 section_fieldObservation
.setEntity(facade
);
70 } catch (DerivedUnitFacadeNotSupportedException e
) {
71 AbstractUtility
.errorDialog("Error", this, "SpecimenFacadeNotSupportedException while inititating SpecimenFacade", e
);
77 public void removeElements() {
78 super.removeElements();
79 if(section_general
!= null){
80 removeControl(section_general
);
81 section_general
.dispose();
82 section_general
= null;
84 if(section_derivedUnitBase
!= null){
85 removeControl(section_derivedUnitBase
);
86 section_derivedUnitBase
.dispose();
87 section_derivedUnitBase
= null;
89 if(section_gatheringEvent
!= null){
90 removeControl(section_gatheringEvent
);
91 section_gatheringEvent
.dispose();
92 section_gatheringEvent
= null;
94 if(section_fieldObservation
!= null){
95 removeControl(section_fieldObservation
);
96 section_fieldObservation
.dispose();
97 section_fieldObservation
= null;
103 public DerivedUnit
getEntity() {
104 throw new IllegalArgumentException("Should not be called");
108 * <p>Getter for the field <code>facade</code>.</p>
110 * @return a {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade} object.
112 public DerivedUnitFacade
getFacade(){
118 protected void createControls(ICdmFormElement formElement
,
119 DerivedUnit entity
, int style
) {
121 section_general
= formFactory
.createGeneralDetailSection(getConversationHolder(), formElement
, null, ExpandableComposite
.TWISTIE
| ExpandableComposite
.EXPANDED
);
122 section_general
.setLayoutData(LayoutConstants
.FILL_HORIZONTALLY(2, 1));
123 addControl(section_general
);
124 addElement(section_general
);
126 section_gatheringEvent
= formFactory
.createGatheringEventDetailSection(getConversationHolder(), formElement
, null, ExpandableComposite
.TWISTIE
);
127 section_gatheringEvent
.setLayoutData(LayoutConstants
.FILL_HORIZONTALLY(2, 1));
128 addControl(section_gatheringEvent
);
129 addElement(section_gatheringEvent
);
131 section_fieldObservation
= formFactory
.createFieldObservationDetailSection(getConversationHolder(), formElement
, null, ExpandableComposite
.TWISTIE
);
132 section_fieldObservation
.setLayoutData(LayoutConstants
.FILL_HORIZONTALLY(2, 1));
133 addControl(section_fieldObservation
);
134 addElement(section_fieldObservation
);
136 section_derivedUnitBase
= formFactory
.createDerivedUnitBaseDetailSection(getConversationHolder(), formElement
, null, ExpandableComposite
.TWISTIE
);
137 section_derivedUnitBase
.setLayoutData(LayoutConstants
.FILL_HORIZONTALLY(2, 1));
138 addControl(section_derivedUnitBase
);
139 addElement(section_derivedUnitBase
);
144 public void handleEvent(Object eventSource
) {
145 if(eventSource
== section_derivedUnitBase
|| eventSource
== section_gatheringEvent
|| eventSource
== section_fieldObservation
){
146 if(getParentElement() instanceof AbstractCdmDetailSection
) {
147 ((AbstractCdmDetailSection
) getParentElement()).updateTitle();