Project

General

Profile

Download (9.52 KB) Statistics
| Branch: | Tag: | Revision:
1
package eu.etaxonomy.taxeditor.view.userecords;
2

    
3
import org.eclipse.jface.viewers.ISelection;
4
import org.eclipse.jface.viewers.SelectionChangedEvent;
5
import org.eclipse.swt.SWT;
6
import org.eclipse.swt.widgets.Composite;
7
import org.eclipse.ui.forms.widgets.Section;
8

    
9
import eu.etaxonomy.cdm.model.description.DescriptionBase;
10
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
11
import eu.etaxonomy.cdm.model.reference.Reference;
12
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
13
import eu.etaxonomy.taxeditor.ui.element.RootElement;
14
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.DetailType;
15
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.EntityDetailType;
16
import eu.etaxonomy.taxeditor.ui.section.description.DescribedSpecimenSection;
17
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionDetailSection;
18
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementDetailSection;
19
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementMediaSection;
20
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementSourceSection;
21
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionSourceSection;
22
import eu.etaxonomy.taxeditor.ui.section.description.NaturalLanguageSection;
23
import eu.etaxonomy.taxeditor.ui.section.description.ScopeSection;
24
import eu.etaxonomy.taxeditor.ui.section.name.NameRelationshipDetailSection;
25
import eu.etaxonomy.taxeditor.ui.section.name.NomenclaturalStatusSection;
26
import eu.etaxonomy.taxeditor.ui.section.name.NonViralNameDetailSection;
27
import eu.etaxonomy.taxeditor.ui.section.name.ProtologueSection;
28
import eu.etaxonomy.taxeditor.ui.section.name.TypeDesignationSection;
29
import eu.etaxonomy.taxeditor.ui.section.reference.NomenclaturalReferenceDetailSection;
30
import eu.etaxonomy.taxeditor.ui.section.reference.ReferenceDetailSection;
31
import eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessagesSection;
32
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonBaseDetailSection;
33
import eu.etaxonomy.taxeditor.ui.section.userecords.UseRecordDetailSection;
34
import eu.etaxonomy.taxeditor.view.AbstractCdmDataViewer;
35
import eu.etaxonomy.taxeditor.view.AbstractCdmViewPart;
36

    
37

    
38

    
39

    
40

    
41
public class UseRecordsViewer extends AbstractCdmDataViewer {
42

    
43
	private ISelection selection;
44
	
45
	public UseRecordsViewer(Composite parent, AbstractCdmViewPart viewPart) {
46
		super(parent, viewPart);
47
	}
48
	@Override
49
	protected void showParts() {
50
		if (getInput() instanceof TaxonBase) {
51
			createTaxonSections(rootElement);
52

    
53
		} else if (getInput() instanceof DescriptionBase) {
54
			if (((DescriptionBase) getInput()).isImageGallery()) {
55
				createImageGallerySection(rootElement);
56

    
57
			} else {
58
				createUseSection(rootElement);
59

    
60
			}
61
		} else if (getInput() instanceof DescriptionElementBase) {
62
			createUseRecordSection(rootElement);
63

    
64
		} 
65
		
66
		/*if (getInput() instanceof TaxonBase) {
67
			if (currentViewPart != VIEW_PART.TAXON) {
68
				createTaxonSections(rootElement);
69
				currentViewPart = VIEW_PART.TAXON;
70
			}
71
		} else if (getInput() instanceof Reference) {
72
			if (currentViewPart != VIEW_PART.REFEERENCE) {
73
				createReferenceSections(rootElement);
74
				currentViewPart = VIEW_PART.REFEERENCE;
75
			}
76
		} else if (getInput() instanceof DescriptionBase) {
77
			if (((DescriptionBase) getInput()).isImageGallery()) {
78
				if (currentViewPart != VIEW_PART.IMAGE_GALLERY) {
79
					createImageGallerySection(rootElement);
80
					currentViewPart = VIEW_PART.IMAGE_GALLERY;
81
				}
82
			} else {
83
				if (currentViewPart != VIEW_PART.DESCRIPTION) {
84
					createDescriptionSection(rootElement);
85
					currentViewPart = VIEW_PART.DESCRIPTION;
86
				}
87
			}
88
		} else if (getInput() instanceof DescriptionElementBase) {
89
			if (currentViewPart != VIEW_PART.DESCRIPTION_ELEMENT) {
90
				createDescriptionElementSection(rootElement);
91
				currentViewPart = VIEW_PART.DESCRIPTION_ELEMENT;
92
			}
93
		} else {
94
			destroySections();
95
			currentViewPart = VIEW_PART.EMPTY;
96
		}
97
		layout();
98
		*/
99
	}
100
	private void createTaxonSections(RootElement parent) {
101
		destroySections();
102

    
103
		TaxonBaseDetailSection taxonBaseDetailSection = (TaxonBaseDetailSection) formFactory
104
				.createCdmDetailSection(DetailType.TAXONBASE,
105
						getConversationHolder(), parent, this, Section.TWISTIE);
106

    
107
		formFactory.createHorizontalSeparator(parent, SWT.BORDER);
108

    
109
		NonViralNameDetailSection nonViralNameSection = (NonViralNameDetailSection) formFactory
110
				.createCdmDetailSection(DetailType.NONVIRALNAME,
111
						getConversationHolder(), parent, this, Section.TWISTIE
112
								| Section.EXPANDED);
113

    
114
		formFactory.createHorizontalSeparator(parent, SWT.BORDER);
115

    
116
		NomenclaturalReferenceDetailSection referenceDetailSection = (NomenclaturalReferenceDetailSection) formFactory
117
				.createCdmDetailSection(DetailType.NOMENCLATURALREFERENCE,
118
						getConversationHolder(), parent, this, Section.TWISTIE);
119

    
120
		formFactory.createHorizontalSeparator(parent, SWT.BORDER);
121

    
122
		NomenclaturalStatusSection nomenclaturalStatusSection = (NomenclaturalStatusSection) formFactory
123
				.createEntityDetailSection(
124
						EntityDetailType.NOMENCLATURALSTATUS,
125
						getConversationHolder(), parent, Section.TWISTIE);
126

    
127
		formFactory.createHorizontalSeparator(parent, SWT.BORDER);
128

    
129
		ProtologueSection protologSection = (ProtologueSection) formFactory
130
				.createEntityDetailSection(EntityDetailType.PROTOLOG,
131
						getConversationHolder(), parent, Section.TWISTIE);
132

    
133
		formFactory.createHorizontalSeparator(parent, SWT.BORDER);
134

    
135
		TypeDesignationSection typeDesignationSection = (TypeDesignationSection) formFactory
136
				.createEntityDetailSection(EntityDetailType.TYPEDESIGNATION,
137
						getConversationHolder(), parent, Section.TWISTIE);
138

    
139
		formFactory.createHorizontalSeparator(parent, SWT.BORDER);
140

    
141
		NameRelationshipDetailSection nameRelationshipSection = (NameRelationshipDetailSection) formFactory
142
				.createEntityDetailSection(EntityDetailType.NAME_RELATIONSHIP,
143
						getConversationHolder(), parent, Section.TWISTIE);
144

    
145
		formFactory.createHorizontalSeparator(parent, SWT.BORDER);
146

    
147
		ParsingMessagesSection parsingMessagesSection = (ParsingMessagesSection) formFactory
148
				.createCdmDetailSection(DetailType.PARSINGMESSAGE,
149
						getConversationHolder(), parent, this, Section.EXPANDED);
150

    
151
		addPart(taxonBaseDetailSection);
152
		addPart(nonViralNameSection);
153
		addPart(nomenclaturalStatusSection);
154
		addPart(protologSection);
155
		addPart(referenceDetailSection);
156
		addPart(typeDesignationSection);
157
		addPart(nameRelationshipSection);
158
		addPart(parsingMessagesSection);
159
	}
160
	
161
	
162
	private void createUseRecordSection(RootElement parent) {
163
		destroySections();
164

    
165
		UseRecordDetailSection descriptionUseRecordSection = (UseRecordDetailSection) formFactory
166
				.createCdmDetailSection(DetailType.USE_RECORD,
167
						getConversationHolder(), parent, this, Section.TWISTIE
168
								| Section.EXPANDED);
169

    
170
		formFactory.createHorizontalSeparator(parent, SWT.BORDER);
171
		
172
		addPart(descriptionUseRecordSection);
173
		
174
		
175
	}
176
	
177
	private void createUseSection(RootElement parent) {
178
		destroySections();
179
		DescriptionDetailSection descriptionDetailSection = (DescriptionDetailSection) formFactory
180
				.createCdmDetailSection(DetailType.DESCRIPTION,
181
						getConversationHolder(), parent, this, Section.TWISTIE
182
								| Section.EXPANDED);
183

    
184
		formFactory.createHorizontalSeparator(parent, SWT.BORDER);
185

    
186
		/*NaturalLanguageSection naturalLanguageSection = (NaturalLanguageSection) formFactory
187
				.createCdmDetailSection(DetailType.NATURAL_LANGUAGE,
188
						getConversationHolder(), parent, this, Section.TWISTIE
189
								| Section.EXPANDED);
190

    
191
		formFactory.createHorizontalSeparator(parent, SWT.BORDER);
192

    
193
		DescribedSpecimenSection describedSpecimenSection = (DescribedSpecimenSection) formFactory
194
				.createEntityDetailSection(EntityDetailType.DESCRIBED_SPECIMEN,
195
						getConversationHolder(), parent, Section.TWISTIE);
196

    
197
		formFactory.createHorizontalSeparator(parent, SWT.BORDER);*/
198

    
199
		DescriptionSourceSection descriptionSourceSection = (DescriptionSourceSection) formFactory
200
				.createEntityDetailSection(EntityDetailType.DESCRIPTIONSOURCE,
201
						getConversationHolder(), parent, Section.TWISTIE);
202

    
203
		/*formFactory.createHorizontalSeparator(parent, SWT.BORDER);
204

    
205
		ScopeSection scopeSection = (ScopeSection) formFactory
206
				.createEntityDetailSection(EntityDetailType.SCOPE,
207
						getConversationHolder(), parent, Section.TWISTIE);
208

    
209
		formFactory.createHorizontalSeparator(parent, SWT.BORDER);*/
210

    
211
		addPart(descriptionDetailSection);
212
		addPart(descriptionSourceSection);
213
		
214
	}
215
	
216
	
217
	
218
	private void createImageGallerySection(RootElement parent) {
219
		destroySections();
220
		DescriptionDetailSection descriptionDetailSection = (DescriptionDetailSection) formFactory
221
				.createCdmDetailSection(DetailType.DESCRIPTION,
222
						getConversationHolder(), parent, this, Section.TWISTIE
223
								| Section.EXPANDED);
224

    
225
		addPart(descriptionDetailSection);
226
	}
227
	
228
	private void createReferenceSections(RootElement parent) {
229
		destroySections();
230

    
231
		ReferenceDetailSection referenceDetailSection = (ReferenceDetailSection) formFactory
232
				.createCdmDetailSection(DetailType.REFERENCEBASE,
233
						getConversationHolder(), parent, this, Section.TWISTIE
234
								| Section.EXPANDED);
235

    
236
		addPart(referenceDetailSection);
237
		
238
	}
239
	@Override
240
	public ISelection getSelection() {
241
		return selection;
242
	}
243
	@Override
244
	public void setSelection(ISelection selection, boolean reveal) {
245
		this.selection = selection;
246
		SelectionChangedEvent selectionChangedEvent = new SelectionChangedEvent(
247
				this, selection);
248
		fireSelectionChanged(selectionChangedEvent);
249
	}
250

    
251
}
(2-2/2)