Project

General

Profile

« Previous | Next » 

Revision b0ce5b17

Added by Patrick Plitzner over 10 years ago

merged trunk into branch

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/DerivedUnitFacadeDetailElement.java
1 1
// $Id$
2 2
/**
3 3
* Copyright (C) 2007 EDIT
4
* European Distributed Institute of Taxonomy 
4
* European Distributed Institute of Taxonomy
5 5
* http://www.e-taxonomy.eu
6
* 
6
*
7 7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8 8
* See LICENSE.TXT at the top of this package for the full license terms.
9 9
*/
10 10

  
11 11
package eu.etaxonomy.taxeditor.ui.section.occurrence;
12 12

  
13
import org.eclipse.ui.forms.widgets.Section;
13
import org.eclipse.ui.forms.widgets.ExpandableComposite;
14 14

  
15 15
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
16 16
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacadeConfigurator;
17 17
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacadeNotSupportedException;
18 18
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
19
import eu.etaxonomy.taxeditor.store.StoreUtil;
19
import eu.etaxonomy.taxeditor.model.AbstractUtility;
20 20
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
21 21
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
22
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.DetailType;
23 22
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
24 23
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
25 24
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection;
......
32 31
 * @version 1.0
33 32
 */
34 33
public class DerivedUnitFacadeDetailElement extends AbstractCdmDetailElement<DerivedUnit> {
35
	
34

  
36 35
	private DerivedUnitFacade facade;
37 36

  
38
	private DerivedUnitFacadeConfigurator configurator;
37
	private final DerivedUnitFacadeConfigurator configurator;
39 38

  
40 39
	private GeneralDetailSection section_general;
41 40
	private GatheringEventDetailSection section_gatheringEvent;
......
55 54
		configurator.setMoveDerivedUnitMediaToGallery(true);
56 55
		configurator.setMoveFieldObjectMediaToGallery(true);
57 56
	}
58
	
57

  
59 58
	/** {@inheritDoc} */
60 59
	@Override
61 60
	public void setEntity(DerivedUnit entity) {
62 61
		super.setEntity(entity);
63 62
		try {
64 63
			facade = DerivedUnitFacade.NewInstance(entity, configurator);
65
			
64

  
66 65
			section_general.setEntity(facade);
67 66
			section_derivedUnitBase.setEntity(facade);
68 67
			section_gatheringEvent.setEntity(facade);
69 68
			section_fieldObservation.setEntity(facade);
70
			
69

  
71 70
		} catch (DerivedUnitFacadeNotSupportedException e) {
72
			StoreUtil.errorDialog("Error", this, "SpecimenFacadeNotSupportedException while inititating SpecimenFacade", e);
71
			AbstractUtility.errorDialog("Error", this, "SpecimenFacadeNotSupportedException while inititating SpecimenFacade", e);
73 72
		}
74 73
	}
75
	
74

  
76 75
	/** {@inheritDoc} */
77 76
	@Override
78 77
	public void removeElements() {
......
98 97
			section_fieldObservation = null;
99 98
		}
100 99
	}
101
	
100

  
102 101
	/** {@inheritDoc} */
103 102
	@Override
104 103
	public DerivedUnit getEntity() {
105 104
		throw new IllegalArgumentException("Should not be called");
106 105
	}
107
	
106

  
108 107
	/**
109 108
	 * <p>Getter for the field <code>facade</code>.</p>
110 109
	 *
......
113 112
	public DerivedUnitFacade getFacade(){
114 113
		return facade;
115 114
	}
116
	
115

  
117 116
	/** {@inheritDoc} */
118 117
	@Override
119 118
	protected void createControls(ICdmFormElement formElement,
120 119
			DerivedUnit entity, int style) {
121
		
122
		section_general = (GeneralDetailSection) formFactory.createCdmDetailSection(DetailType.DERIVED_UNIT_GENERAL, getConversationHolder(), formElement, null, Section.TWISTIE | Section.EXPANDED);
120

  
121
		section_general = formFactory.createGeneralDetailSection(getConversationHolder(), formElement, null, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
123 122
		section_general.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
124 123
		addControl(section_general);
125 124
		addElement(section_general);
126
		
127
		section_gatheringEvent = (GatheringEventDetailSection) formFactory.createCdmDetailSection(DetailType.GATHERING_EVENT, getConversationHolder(), formElement, null, Section.TWISTIE);
125

  
126
		section_gatheringEvent = formFactory.createGatheringEventDetailSection(getConversationHolder(), formElement, null, ExpandableComposite.TWISTIE);
128 127
		section_gatheringEvent.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
129 128
		addControl(section_gatheringEvent);
130 129
		addElement(section_gatheringEvent);
131
		
132
		section_fieldObservation = (FieldObservationDetailSection) formFactory.createCdmDetailSection(DetailType.FIELD_OBSERVATION, getConversationHolder(), formElement, null, Section.TWISTIE);
130

  
131
		section_fieldObservation = formFactory.createFieldObservationDetailSection(getConversationHolder(), formElement, null, ExpandableComposite.TWISTIE);
133 132
		section_fieldObservation.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
134 133
		addControl(section_fieldObservation);
135 134
		addElement(section_fieldObservation);
136
		
137
		section_derivedUnitBase = (DerivedUnitBaseDetailSection) formFactory.createCdmDetailSection(DetailType.DERIVED_UNIT, getConversationHolder(), formElement, null, Section.TWISTIE);
135

  
136
		section_derivedUnitBase = formFactory.createDerivedUnitBaseDetailSection(getConversationHolder(), formElement, null, ExpandableComposite.TWISTIE);
138 137
		section_derivedUnitBase.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
139 138
		addControl(section_derivedUnitBase);
140 139
		addElement(section_derivedUnitBase);
......
144 143
	@Override
145 144
	public void handleEvent(Object eventSource) {
146 145
		if(eventSource == section_derivedUnitBase || eventSource == section_gatheringEvent || eventSource == section_fieldObservation){
147
			if(getParentElement() instanceof AbstractCdmDetailSection)
148
				((AbstractCdmDetailSection) getParentElement()).updateTitle();
146
			if(getParentElement() instanceof AbstractCdmDetailSection) {
147
                ((AbstractCdmDetailSection) getParentElement()).updateTitle();
148
            }
149 149
		}
150 150
	}
151 151
}

Also available in: Unified diff