Project

General

Profile

Download (4.46 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.jface.util.IPropertyChangeListener;
13
import org.eclipse.jface.util.PropertyChangeEvent;
14
import org.eclipse.swt.SWT;
15
import org.eclipse.swt.widgets.Composite;
16

    
17
import eu.etaxonomy.cdm.model.common.TermType;
18
import eu.etaxonomy.cdm.model.taxon.Synonym;
19
import eu.etaxonomy.cdm.model.taxon.SynonymRelationship;
20
import eu.etaxonomy.cdm.model.taxon.SynonymRelationshipType;
21
import eu.etaxonomy.cdm.model.taxon.Taxon;
22
import eu.etaxonomy.taxeditor.ui.AbstractEntityCollectionElementWizardPage;
23
import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
24
import eu.etaxonomy.taxeditor.ui.element.CheckboxElement;
25
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
26

    
27
/**
28
 * @author pplitzner
29
 * @date 27.01.2014
30
 *
31
 */
32
public class SynonymRelationshipWizardPage extends AbstractEntityCollectionElementWizardPage implements IPropertyChangeListener {
33

    
34

    
35
    private EntitySelectionElement<Taxon> selection_relatedTo;
36

    
37
    private TermComboElement<SynonymRelationshipType> combo_relationshipType;
38

    
39
    private CheckboxElement checkboxProParte;
40

    
41
    private boolean isProParte;
42

    
43
    private CheckboxElement checkboxPartial;
44

    
45
    private boolean isPartial;
46

    
47
    private final Synonym entity;
48

    
49
    private SynonymRelationshipType type;
50

    
51
    private Taxon taxon;
52

    
53

    
54
    /**
55
     * <p>
56
     * Constructor for NameRelationshipWizardPage.
57
     * </p>
58
     *
59
     * @param callingSection
60
     *            a
61
     *            {@link eu.etaxonomy.taxeditor.ui.section.name.NameRelationshipDetailSection}
62
     *            object.
63
     */
64
    protected SynonymRelationshipWizardPage(
65
            SynonymRelationshipDetailSection callingSection) {
66
        super("SynonymRelationshipWizardPage");
67
        setTitle("New Synonym Relationship");
68
        setDescription(callingSection.getEntity().getTitleCache());
69
        this.entity = callingSection.getEntity();
70
        this.formFactory = callingSection.getFormFactory();
71

    
72
        formFactory.addPropertyChangeListener(this);
73
    }
74

    
75
    /*
76
     * (non-Javadoc)
77
     *
78
     * @see
79
     * org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets
80
     * .Composite)
81
     */
82
    /** {@inheritDoc} */
83
    @Override
84
    public void createControl(Composite parent) {
85
        super.createControl(parent);
86

    
87
        combo_relationshipType = formFactory.createDefinedTermComboElement(TermType.SynonymRelationshipType,
88
                rootElement, "Synonym Relationship Type", null, SWT.NULL);
89

    
90
        selection_relatedTo = formFactory
91
                .createSelectionElement(Taxon.class,
92
                        ((SynonymRelationshipWizard) getWizard())
93
                        .getConversationHolder(), rootElement,
94
                        "Related to", null, EntitySelectionElement.ALL,
95
                        SWT.NULL);
96

    
97
        checkboxProParte = formFactory.createCheckbox(rootElement, "Pro Parte Synonym", null, SWT.NULL);
98

    
99
        checkboxPartial = formFactory.createCheckbox(rootElement, "Partial Synonym", null, SWT.NULL);
100

    
101
    }
102

    
103
    /**
104
     * <p>
105
     * getNameRelationship
106
     * </p>
107
     *
108
     * @return a {@link eu.etaxonomy.cdm.model.name.NameRelationship} object.
109
     */
110
    public SynonymRelationship getSynonymRelationship() {
111
        SynonymRelationship synonymRelationship = taxon.addSynonym(entity, combo_relationshipType.getSelection());
112
        synonymRelationship.setPartial(isPartial);
113
        synonymRelationship.setProParte(isProParte);
114
        return synonymRelationship;
115
    }
116

    
117
    /** {@inheritDoc} */
118
    @Override
119
    public void propertyChange(PropertyChangeEvent event) {
120
        if (event == null) {
121
            return;
122
        }
123
        Object eventSource = event.getSource();
124
        if (eventSource == combo_relationshipType) {
125
            type = combo_relationshipType.getSelection();
126
        } else if (eventSource == selection_relatedTo) {
127
            taxon = selection_relatedTo.getEntity();
128
        } else if (eventSource == checkboxProParte) {
129
            isProParte = checkboxProParte.getSelection();
130
        } else if (eventSource == checkboxPartial) {
131
            isPartial = checkboxPartial.getSelection();
132
        }
133

    
134
        boolean complete = type != null && taxon != null;
135
        setPageComplete(complete);
136
    }
137

    
138
}
(24-24/25)