Project

General

Profile

Download (4.37 KB) Statistics
| Branch: | Tag: | Revision:
1
// $Id$
2
/**
3
* Copyright (C) 2014 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
package eu.etaxonomy.taxeditor.ui.section.name;
11

    
12
import org.eclipse.swt.events.SelectionListener;
13
import org.eclipse.swt.graphics.Color;
14

    
15
import eu.etaxonomy.cdm.model.taxon.SynonymRelationship;
16
import eu.etaxonomy.cdm.model.taxon.SynonymRelationshipType;
17
import eu.etaxonomy.taxeditor.model.MessagingUtils;
18
import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
19
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
20
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
21
import eu.etaxonomy.taxeditor.ui.element.CheckboxElement;
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
 * @author pplitzner
30
 * @date 28.01.2014
31
 *
32
 */
33
public class SynonymRelationshipDetailElement extends AbstractReferencedEntityElement<SynonymRelationship>{
34

    
35
    private TextWithLabelElement text_ruleConsidered;
36
    private LabelElement label;
37
    private EntitySelectionElement selection_toName;
38
    private TermComboElement<SynonymRelationshipType> combo_relationshipType;
39
    private CheckboxElement checkProParte;
40
    private CheckboxElement checkPartial;
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 SynonymRelationshipDetailElement(CdmFormFactory cdmFormFactory,
52
            AbstractFormSection formElement,
53
            SynonymRelationship 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
        checkProParte = formFactory.createCheckbox(element, "Pro Parte Synonym", null, style);
65
        checkPartial= formFactory.createCheckbox(element, "Partial Synonym", null, style);
66
        super.createControls(element, style);
67
    }
68

    
69
    /** {@inheritDoc} */
70
    @Override
71
    public void setEntity(SynonymRelationship entity) {
72
        String text = entity.getSynonym().getTitleCache() + " is " + entity.getType().getLabel() + " " + entity.getAcceptedTaxon().getTitleCache();
73

    
74
        label.setText(text);
75

    
76
        checkPartial.setSelection(entity.isPartial());
77
        checkProParte.setSelection(entity.isProParte());
78

    
79
        super.setEntity(entity);
80
    }
81

    
82
    /** {@inheritDoc} */
83
    @Override
84
    public void handleEvent(Object eventSource) {
85
        if(eventSource == combo_relationshipType){
86
            getEntity().setType(combo_relationshipType.getSelection());
87
        }
88
        else if(eventSource == selection_toName){
89
            MessagingUtils.error(getClass(), "No API call available.", null);
90
        }
91
        else if(eventSource == checkPartial){
92
            getEntity().setPartial(checkPartial.getSelection());
93
        }
94
        else if(eventSource == checkProParte){
95
            getEntity().setProParte(checkProParte.getSelection());
96
        }
97
        else if(eventSource == selection_reference){
98
            getEntity().setCitation(selection_reference.getSelection());
99
        }
100
        else if(eventSource == text_referenceDetail){
101
            getEntity().setCitationMicroReference(text_referenceDetail.getText());
102
        }
103
    }
104

    
105
    /** {@inheritDoc} */
106
    @Override
107
    public void setBackground(Color color) {
108
        if(label != null) {
109
            label.setBackground(color);
110
        }
111
        super.setBackground(color);
112
    }
113

    
114
}
(21-21/25)