Project

General

Profile

« Previous | Next » 

Revision f561b00c

Added by Niels Hoffmann about 13 years ago

Refactoring selection elements so they can be configured

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/SpecimenTypeDesignationElement.java
1 1
// $Id$
2 2
/**
3
* Copyright (C) 2007 EDIT
4
* European Distributed Institute of Taxonomy 
5
* http://www.e-taxonomy.eu
6
* 
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.
9
*/
3
 * Copyright (C) 2007 EDIT
4
 * European Distributed Institute of Taxonomy 
5
 * http://www.e-taxonomy.eu
6
 * 
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.
9
 */
10 10

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

  
......
18 18
import eu.etaxonomy.cdm.model.occurrence.Specimen;
19 19
import eu.etaxonomy.taxeditor.ui.forms.AbstractFormSection;
20 20
import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory;
21
import eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement;
22
import eu.etaxonomy.taxeditor.ui.forms.TextWithLabelElement;
23 21
import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.SelectionType;
24 22
import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.TermComboType;
23
import eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement;
24
import eu.etaxonomy.taxeditor.ui.forms.TextWithLabelElement;
25 25
import eu.etaxonomy.taxeditor.ui.selection.DerivedUnitBaseSelectionElement;
26 26
import eu.etaxonomy.taxeditor.ui.term.SpecimenTypeDesignationStatusComboElement;
27 27

  
28 28
/**
29
 * <p>SpecimenTypeDesignationElement class.</p>
30
 *
29
 * <p>
30
 * SpecimenTypeDesignationElement class.
31
 * </p>
32
 * 
31 33
 * @author n.hoffmann
32 34
 * @created May 17, 2010
33 35
 * @version 1.0
......
38 40
	private SpecimenTypeDesignationStatusComboElement combo_typeStatus;
39 41
	private DerivedUnitBaseSelectionElement selection_typeSpecimen;
40 42
	private TextWithLabelElement text_specimenTypeText;
41
	
43

  
42 44
	/**
43
	 * <p>Constructor for SpecimenTypeDesignationElement.</p>
44
	 *
45
	 * @param formFactory a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory} object.
46
	 * @param section a {@link eu.etaxonomy.taxeditor.ui.forms.AbstractFormSection} object.
47
	 * @param entity a {@link eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation} object.
48
	 * @param removeListener a {@link org.eclipse.swt.events.SelectionListener} object.
49
	 * @param style a int.
45
	 * <p>
46
	 * Constructor for SpecimenTypeDesignationElement.
47
	 * </p>
48
	 * 
49
	 * @param formFactory
50
	 *            a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory}
51
	 *            object.
52
	 * @param section
53
	 *            a {@link eu.etaxonomy.taxeditor.ui.forms.AbstractFormSection}
54
	 *            object.
55
	 * @param entity
56
	 *            a {@link eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation}
57
	 *            object.
58
	 * @param removeListener
59
	 *            a {@link org.eclipse.swt.events.SelectionListener} object.
60
	 * @param style
61
	 *            a int.
50 62
	 */
51 63
	public SpecimenTypeDesignationElement(CdmFormFactory formFactory,
52 64
			AbstractFormSection section, SpecimenTypeDesignation entity,
53 65
			SelectionListener removeListener, int style) {
54 66
		super(formFactory, section, entity, removeListener, style);
55 67
	}
56
	
68

  
57 69
	/** {@inheritDoc} */
58 70
	@Override
59 71
	public void createControls(ICdmFormElement formElement, int style) {
60
		selection_typeSpecimen = (DerivedUnitBaseSelectionElement) formFactory.createSelectionElement(SelectionType.DERIVED_UNIT, getConversationHolder(), formElement, "Unit", null, style);
61
		combo_typeStatus = (SpecimenTypeDesignationStatusComboElement) formFactory.createTermComboElement(TermComboType.SPECIMENTYPEDESIGNATIONSTATUS, formElement, "Designation Status", null, style);
62
		
72
		selection_typeSpecimen = (DerivedUnitBaseSelectionElement) formFactory
73
				.createSelectionElement(SelectionType.DERIVED_UNIT,
74
						getConversationHolder(), formElement, "Unit", null,
75
						DerivedUnitBaseSelectionElement.DEFAULT, style);
76
		combo_typeStatus = (SpecimenTypeDesignationStatusComboElement) formFactory
77
				.createTermComboElement(
78
						TermComboType.SPECIMENTYPEDESIGNATIONSTATUS,
79
						formElement, "Designation Status", null, style);
80

  
63 81
		super.createControls(formElement, style);
64 82
	}
65
	
83

  
66 84
	/** {@inheritDoc} */
67 85
	@Override
68 86
	public void setEntity(SpecimenTypeDesignation entity) {
69 87
		super.setEntity(entity);
70 88
		selection_typeSpecimen.setEntity(entity.getTypeSpecimen());
71
		
72
		SpecimenTypeDesignationStatus typeStatus = (SpecimenTypeDesignationStatus) HibernateProxyHelper.deproxy(entity.getTypeStatus());
89

  
90
		SpecimenTypeDesignationStatus typeStatus = (SpecimenTypeDesignationStatus) HibernateProxyHelper
91
				.deproxy(entity.getTypeStatus());
73 92
		combo_typeStatus.setSelection(typeStatus);
74 93
		checkbox_notDesignated.setSelection(entity.isNotDesignated());
75 94
	}
......
77 96
	/** {@inheritDoc} */
78 97
	@Override
79 98
	public void handleEvent(Object eventSource) {
80
		if(eventSource == combo_typeStatus){
99
		if (eventSource == combo_typeStatus) {
81 100
			getEntity().setTypeStatus(combo_typeStatus.getSelection());
82 101
		}
83 102
		// TODO remove this once specimens are correctly implemented
84
		else if(eventSource == text_specimenTypeText){
85
			// TODO this is a simple workaround to enter type specimen as text strings
86
			if(getEntity().getTypeSpecimen() == null){
103
		else if (eventSource == text_specimenTypeText) {
104
			// TODO this is a simple workaround to enter type specimen as text
105
			// strings
106
			if (getEntity().getTypeSpecimen() == null) {
87 107
				Specimen typeSpecimen = Specimen.NewInstance();
88 108
				getEntity().setTypeSpecimen(typeSpecimen);
89 109
			}
90
			getEntity().getTypeSpecimen().setTitleCache(text_specimenTypeText.getText());
91
		}	
92
		else if(eventSource == selection_typeSpecimen){
110
			getEntity().getTypeSpecimen().setTitleCache(
111
					text_specimenTypeText.getText());
112
		} else if (eventSource == selection_typeSpecimen) {
93 113
			getEntity().setTypeSpecimen(selection_typeSpecimen.getSelection());
94
		}
95
		else if(eventSource == checkbox_notDesignated){
114
		} else if (eventSource == checkbox_notDesignated) {
96 115
			getEntity().setNotDesignated(checkbox_notDesignated.getSelection());
97
		}
98
		else if(eventSource == selection_reference){
116
		} else if (eventSource == selection_reference) {
99 117
			getEntity().setCitation(selection_reference.getSelection());
100
		}
101
		else if(eventSource == text_referenceDetail){
102
			getEntity().setCitationMicroReference(text_referenceDetail.getText());
103
		}
104
		else if(eventSource == text_originaleNameString){
105
			getEntity().setOriginalNameString(text_originaleNameString.getText());
118
		} else if (eventSource == text_referenceDetail) {
119
			getEntity().setCitationMicroReference(
120
					text_referenceDetail.getText());
121
		} else if (eventSource == text_originaleNameString) {
122
			getEntity().setOriginalNameString(
123
					text_originaleNameString.getText());
106 124
		}
107 125
	}
108 126
}

Also available in: Unified diff