Project

General

Profile

« Previous | Next » 

Revision bdd1bcf5

Added by Andreas Müller over 7 years ago

ref #5974 Remove synonym relationships (rename synRelType to synRel and others)

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/SynonymRelationshipWizardPage.java
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
}
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.SynonymRelationshipType;
20
//import eu.etaxonomy.cdm.model.taxon.Taxon;
21
//import eu.etaxonomy.taxeditor.ui.AbstractEntityCollectionElementWizardPage;
22
//import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
23
//import eu.etaxonomy.taxeditor.ui.element.CheckboxElement;
24
//import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
25
//
26
///**
27
// * @author pplitzner
28
// * @date 27.01.2014
29
// *
30
// */
31
//public class SynonymRelationshipWizardPage extends AbstractEntityCollectionElementWizardPage implements IPropertyChangeListener {
32
//
33
//
34
//    private EntitySelectionElement<Taxon> selection_relatedTo;
35
//
36
//    private TermComboElement<SynonymRelationshipType> combo_relationshipType;
37
//
38
//    private CheckboxElement checkboxProParte;
39
//
40
//    private boolean isProParte;
41
//
42
//    private CheckboxElement checkboxPartial;
43
//
44
//    private boolean isPartial;
45
//
46
//    private final Synonym entity;
47
//
48
//    private SynonymRelationshipType type;
49
//
50
//    private Taxon taxon;
51
//
52
//
53
//    /**
54
//     * <p>
55
//     * Constructor for NameRelationshipWizardPage.
56
//     * </p>
57
//     *
58
//     * @param callingSection
59
//     *            a
60
//     *            {@link eu.etaxonomy.taxeditor.ui.section.name.NameRelationshipDetailSection}
61
//     *            object.
62
//     */
63
//    protected SynonymRelationshipWizardPage(
64
//            SynonymRelationshipDetailSection callingSection) {
65
//        super("SynonymRelationshipWizardPage");
66
//        setTitle("New Synonym Relationship");
67
//        setDescription(callingSection.getEntity().getTitleCache());
68
//        this.entity = callingSection.getEntity();
69
//        this.formFactory = callingSection.getFormFactory();
70
//
71
//        formFactory.addPropertyChangeListener(this);
72
//    }
73
//
74
//    /*
75
//     * (non-Javadoc)
76
//     *
77
//     * @see
78
//     * org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets
79
//     * .Composite)
80
//     */
81
//    /** {@inheritDoc} */
82
//    @Override
83
//    public void createControl(Composite parent) {
84
//        super.createControl(parent);
85
//
86
//        combo_relationshipType = formFactory.createDefinedTermComboElement(TermType.SynonymRelationshipType,
87
//                rootElement, "Synonym Relationship Type", null, SWT.NULL);
88
//
89
//        selection_relatedTo = formFactory
90
//                .createSelectionElement(Taxon.class,
91
//                        ((SynonymRelationshipWizard) getWizard())
92
//                        .getConversationHolder(), rootElement,
93
//                        "Related to", null, EntitySelectionElement.ALL,
94
//                        SWT.NULL);
95
//
96
//        checkboxProParte = formFactory.createCheckbox(rootElement, "Pro Parte Synonym", null, SWT.NULL);
97
//
98
//        checkboxPartial = formFactory.createCheckbox(rootElement, "Partial Synonym", null, SWT.NULL);
99
//
100
//    }
101
//
102
//    /**
103
//     * <p>
104
//     * getNameRelationship
105
//     * </p>
106
//     *
107
//     * @return a {@link eu.etaxonomy.cdm.model.name.NameRelationship} object.
108
//     */
109
//    public SynonymRelationship getSynonymRelationship() {
110
//        SynonymRelationship synonymRelationship = taxon.addSynonym(entity, combo_relationshipType.getSelection());
111
//        synonymRelationship.setPartial(isPartial);
112
//        synonymRelationship.setProParte(isProParte);
113
//        return synonymRelationship;
114
//    }
115
//
116
//    /** {@inheritDoc} */
117
//    @Override
118
//    public void propertyChange(PropertyChangeEvent event) {
119
//        if (event == null) {
120
//            return;
121
//        }
122
//        Object eventSource = event.getSource();
123
//        if (eventSource == combo_relationshipType) {
124
//            type = combo_relationshipType.getSelection();
125
//        } else if (eventSource == selection_relatedTo) {
126
//            taxon = selection_relatedTo.getEntity();
127
//        } else if (eventSource == checkboxProParte) {
128
//            isProParte = checkboxProParte.getSelection();
129
//        } else if (eventSource == checkboxPartial) {
130
//            isPartial = checkboxPartial.getSelection();
131
//        }
132
//
133
//        boolean complete = type != null && taxon != null;
134
//        setPageComplete(complete);
135
//    }
136
//
137
//}

Also available in: Unified diff