1
|
/**
|
2
|
* Copyright (C) 2007 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
|
10
|
package eu.etaxonomy.taxeditor.ui.section.name;
|
11
|
|
12
|
import org.eclipse.jface.util.PropertyChangeEvent;
|
13
|
|
14
|
import eu.etaxonomy.cdm.model.name.INonViralName;
|
15
|
import eu.etaxonomy.cdm.model.name.Rank;
|
16
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
17
|
import eu.etaxonomy.taxeditor.ui.element.CheckboxElement;
|
18
|
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
|
19
|
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
|
20
|
|
21
|
/**
|
22
|
* @author n.hoffmann
|
23
|
* @created Jan 5, 2011
|
24
|
*/
|
25
|
public class HybridDetailElement extends AbstractCdmDetailElement<INonViralName> {
|
26
|
|
27
|
private CheckboxElement checkboxMonomHybrid;
|
28
|
private CheckboxElement checkboxBinomHybrid;
|
29
|
private CheckboxElement checkboxTrinomHybrid;
|
30
|
private CheckboxElement checkboxHybridFormula;
|
31
|
|
32
|
/**
|
33
|
* @param formFactory
|
34
|
* @param formElement
|
35
|
*/
|
36
|
public HybridDetailElement(CdmFormFactory formFactory,
|
37
|
ICdmFormElement formElement) {
|
38
|
super(formFactory, formElement);
|
39
|
}
|
40
|
|
41
|
@Override
|
42
|
protected void createControls(ICdmFormElement formElement, INonViralName entity,
|
43
|
int style) {
|
44
|
boolean enableBinom = false;
|
45
|
boolean enableTrinom = false;
|
46
|
if (entity.getRank() != null){
|
47
|
if (entity.getRank().isLower(Rank.GENUS())){
|
48
|
enableBinom = true;
|
49
|
}
|
50
|
|
51
|
if (entity.getRank().isLower(Rank.SPECIES())){
|
52
|
enableTrinom = true;
|
53
|
}
|
54
|
}
|
55
|
checkboxMonomHybrid = formFactory.createCheckbox(formElement, "Monom hybrid", entity.isMonomHybrid(), style);
|
56
|
checkboxBinomHybrid = formFactory.createCheckbox(formElement, "Binom hybrid", entity.isBinomHybrid(), style);
|
57
|
checkboxBinomHybrid.setEnabled(enableBinom);
|
58
|
checkboxTrinomHybrid = formFactory.createCheckbox(formElement, "Trinom hybrid", entity.isTrinomHybrid(), style);
|
59
|
checkboxTrinomHybrid.setEnabled(enableTrinom);
|
60
|
checkboxHybridFormula = formFactory.createCheckbox(formElement, "Hybrid formula", entity.isHybridFormula(), style);
|
61
|
checkboxHybridFormula.setEnabled(false);//read-only
|
62
|
}
|
63
|
|
64
|
@Override
|
65
|
public void handleEvent(Object eventSource) {
|
66
|
if(eventSource == checkboxMonomHybrid){
|
67
|
getEntity().setMonomHybrid(checkboxMonomHybrid.getSelection());
|
68
|
}
|
69
|
else if(eventSource == checkboxBinomHybrid){
|
70
|
getEntity().setBinomHybrid(checkboxBinomHybrid.getSelection());
|
71
|
}
|
72
|
else if(eventSource == checkboxTrinomHybrid){
|
73
|
getEntity().setTrinomHybrid(checkboxTrinomHybrid.getSelection());
|
74
|
}
|
75
|
|
76
|
}
|
77
|
|
78
|
|
79
|
|
80
|
|
81
|
@Override
|
82
|
public void propertyChange(PropertyChangeEvent event) {
|
83
|
if (event == null) {
|
84
|
return;
|
85
|
}
|
86
|
|
87
|
Object obj = event.getSource();
|
88
|
handleEvent(obj);
|
89
|
if (obj instanceof NameDetailElement){
|
90
|
if (getEntity().getRank() != null){
|
91
|
checkboxBinomHybrid.setEnabled(getEntity().getRank().isLower(Rank.GENUS()));
|
92
|
checkboxTrinomHybrid.setEnabled(getEntity().getRank().isLower(Rank.SPECIES()));
|
93
|
}
|
94
|
}
|
95
|
|
96
|
}
|
97
|
|
98
|
|
99
|
|
100
|
}
|