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.swt.SWT;
|
13
|
import org.eclipse.swt.events.SelectionListener;
|
14
|
import org.eclipse.swt.graphics.Color;
|
15
|
|
16
|
import eu.etaxonomy.cdm.model.name.NameRelationship;
|
17
|
import eu.etaxonomy.cdm.model.name.NameRelationshipType;
|
18
|
import eu.etaxonomy.taxeditor.model.MessagingUtils;
|
19
|
import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
|
20
|
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
|
21
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
22
|
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
|
23
|
import eu.etaxonomy.taxeditor.ui.element.LabelElement;
|
24
|
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
|
25
|
import eu.etaxonomy.taxeditor.ui.section.supplemental.AbstractReferencedEntityElement;
|
26
|
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
|
27
|
|
28
|
/**
|
29
|
* <p>NameRelationshipDetailElement class.</p>
|
30
|
*
|
31
|
* @author n.hoffmann
|
32
|
* @created Mar 18, 2010
|
33
|
* @version 1.0
|
34
|
*/
|
35
|
public class NameRelationshipDetailElement extends AbstractReferencedEntityElement<NameRelationship>{
|
36
|
|
37
|
private TextWithLabelElement text_ruleConsidered;
|
38
|
private EntitySelectionElement selection_toName;
|
39
|
private TermComboElement<NameRelationshipType> combo_relationshipType;
|
40
|
private LabelElement label;
|
41
|
|
42
|
/**
|
43
|
* <p>Constructor for NameRelationshipDetailElement.</p>
|
44
|
*
|
45
|
* @param cdmFormFactory a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object.
|
46
|
* @param formElement a {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection} object.
|
47
|
* @param entity a {@link eu.etaxonomy.cdm.model.name.NameRelationship} object.
|
48
|
* @param removeListener a {@link org.eclipse.swt.events.SelectionListener} object.
|
49
|
* @param style a int.
|
50
|
*/
|
51
|
public NameRelationshipDetailElement(CdmFormFactory cdmFormFactory,
|
52
|
AbstractFormSection formElement,
|
53
|
NameRelationship entity, SelectionListener removeListener, int style) {
|
54
|
super(cdmFormFactory, formElement, entity, removeListener, style);
|
55
|
}
|
56
|
|
57
|
/* (non-Javadoc)
|
58
|
* @see eu.etaxonomy.taxeditor.forms.entitysections.AbstractEntitySetElementComposite#createControls(org.eclipse.swt.widgets.Composite, int)
|
59
|
*/
|
60
|
/** {@inheritDoc} */
|
61
|
@Override
|
62
|
public void createControls(ICdmFormElement element, int style) {
|
63
|
label = formFactory.createLabel(element, null);
|
64
|
|
65
|
text_ruleConsidered = formFactory.createTextWithLabelElement(element, "Rule Considered", null, SWT.NULL);
|
66
|
|
67
|
super.createControls(element, style);
|
68
|
}
|
69
|
|
70
|
/** {@inheritDoc} */
|
71
|
@Override
|
72
|
public void setEntity(NameRelationship entity) {
|
73
|
String text = entity.getFromName().getTitleCache() + " is " + entity.getType().getLabel() + " " + entity.getToName().getTitleCache();
|
74
|
|
75
|
label.setText(text);
|
76
|
text_ruleConsidered.setText(entity.getRuleConsidered());
|
77
|
|
78
|
super.setEntity(entity);
|
79
|
}
|
80
|
|
81
|
/** {@inheritDoc} */
|
82
|
@Override
|
83
|
public void handleEvent(Object eventSource) {
|
84
|
if(eventSource == combo_relationshipType){
|
85
|
getEntity().setType(combo_relationshipType.getSelection());
|
86
|
}
|
87
|
else if(eventSource == selection_toName){
|
88
|
MessagingUtils.error(getClass(), "No API call available.", null);
|
89
|
}
|
90
|
else if(eventSource == text_ruleConsidered){
|
91
|
getEntity().setRuleConsidered(text_ruleConsidered.getText());
|
92
|
}
|
93
|
else if(eventSource == selection_reference){
|
94
|
getEntity().setCitation(selection_reference.getSelection());
|
95
|
}
|
96
|
else if(eventSource == text_referenceDetail){
|
97
|
getEntity().setCitationMicroReference(text_referenceDetail.getText());
|
98
|
}
|
99
|
}
|
100
|
|
101
|
/** {@inheritDoc} */
|
102
|
@Override
|
103
|
public void setBackground(Color color) {
|
104
|
if(label != null)
|
105
|
label.setBackground(color);
|
106
|
super.setBackground(color);
|
107
|
}
|
108
|
|
109
|
}
|