1 |
729887cf
|
n.hoffmann
|
/**
|
2 |
|
|
* Copyright (C) 2007 EDIT
|
3 |
ccc7ac6f
|
Patric Plitzner
|
* European Distributed Institute of Taxonomy
|
4 |
729887cf
|
n.hoffmann
|
* http://www.e-taxonomy.eu
|
5 |
ccc7ac6f
|
Patric Plitzner
|
*
|
6 |
729887cf
|
n.hoffmann
|
* 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 |
f211dd28
|
n.hoffmann
|
package eu.etaxonomy.taxeditor.ui.section.description;
|
11 |
729887cf
|
n.hoffmann
|
|
12 |
|
|
import org.eclipse.swt.events.SelectionListener;
|
13 |
|
|
|
14 |
49a64920
|
Cherian Mathew
|
import eu.etaxonomy.cdm.model.common.DefinedTerm;
|
15 |
ccc7ac6f
|
Patric Plitzner
|
import eu.etaxonomy.cdm.model.common.TermType;
|
16 |
65434a68
|
Patrick Plitzner
|
import eu.etaxonomy.cdm.model.description.PolytomousKey;
|
17 |
9dfd3706
|
Patrick Plitzner
|
import eu.etaxonomy.cdm.model.description.TaxonDescription;
|
18 |
b9a0d300
|
l.morris
|
import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
|
19 |
78222507
|
n.hoffmann
|
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
|
20 |
|
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
21 |
dacb59c9
|
Patric Plitzner
|
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
|
22 |
f211dd28
|
n.hoffmann
|
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement;
|
23 |
65434a68
|
Patrick Plitzner
|
import eu.etaxonomy.taxeditor.ui.section.key.ScopeRestrictionSection;
|
24 |
729887cf
|
n.hoffmann
|
|
25 |
|
|
/**
|
26 |
3be6ef3e
|
n.hoffmann
|
* <p>ScopeElement class.</p>
|
27 |
|
|
*
|
28 |
729887cf
|
n.hoffmann
|
* @author n.hoffmann
|
29 |
|
|
* @created Mar 18, 2010
|
30 |
|
|
* @version 1.0
|
31 |
|
|
*/
|
32 |
49a64920
|
Cherian Mathew
|
public class ScopeElement extends AbstractEntityCollectionElement<DefinedTerm> {
|
33 |
ccc7ac6f
|
Patric Plitzner
|
|
34 |
49a64920
|
Cherian Mathew
|
private TermComboElement<DefinedTerm> combo_scope;
|
35 |
729887cf
|
n.hoffmann
|
|
36 |
3be6ef3e
|
n.hoffmann
|
/**
|
37 |
|
|
* <p>Constructor for ScopeElement.</p>
|
38 |
|
|
*
|
39 |
78222507
|
n.hoffmann
|
* @param cdmFormFactory a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object.
|
40 |
|
|
* @param section a {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection} object.
|
41 |
3be6ef3e
|
n.hoffmann
|
* @param element a {@link eu.etaxonomy.cdm.model.description.Scope} object.
|
42 |
|
|
* @param removeListener a {@link org.eclipse.swt.events.SelectionListener} object.
|
43 |
|
|
* @param style a int.
|
44 |
|
|
*/
|
45 |
729887cf
|
n.hoffmann
|
public ScopeElement(CdmFormFactory cdmFormFactory,
|
46 |
49a64920
|
Cherian Mathew
|
AbstractFormSection section, DefinedTerm element,
|
47 |
729887cf
|
n.hoffmann
|
SelectionListener removeListener, int style) {
|
48 |
|
|
super(cdmFormFactory, section, element, removeListener, null, style);
|
49 |
|
|
}
|
50 |
|
|
|
51 |
3be6ef3e
|
n.hoffmann
|
/** {@inheritDoc} */
|
52 |
729887cf
|
n.hoffmann
|
@Override
|
53 |
49a64920
|
Cherian Mathew
|
public void setEntity(DefinedTerm entity) {
|
54 |
cfcb0ce6
|
n.hoffmann
|
this.entity = entity;
|
55 |
9dfd3706
|
Patrick Plitzner
|
if(entity!=null && entity.getId()!=0){
|
56 |
d0e36b21
|
Patric Plitzner
|
combo_scope.setSelection(entity);
|
57 |
231d61a4
|
Patrick Plitzner
|
combo_scope.removeEmptyElement();
|
58 |
d0e36b21
|
Patric Plitzner
|
}
|
59 |
729887cf
|
n.hoffmann
|
}
|
60 |
|
|
|
61 |
3be6ef3e
|
n.hoffmann
|
/** {@inheritDoc} */
|
62 |
729887cf
|
n.hoffmann
|
@Override
|
63 |
cfcb0ce6
|
n.hoffmann
|
public void createControls(ICdmFormElement element, int style) {
|
64 |
ccc7ac6f
|
Patric Plitzner
|
combo_scope = formFactory.createDefinedTermComboElement(TermType.Scope, element, "Scope", null, style);
|
65 |
729887cf
|
n.hoffmann
|
}
|
66 |
|
|
|
67 |
3be6ef3e
|
n.hoffmann
|
/** {@inheritDoc} */
|
68 |
729887cf
|
n.hoffmann
|
@Override
|
69 |
|
|
public void handleEvent(Object eventSource) {
|
70 |
d0e36b21
|
Patric Plitzner
|
DefinedTerm scopeTerm = combo_scope.getSelection();
|
71 |
|
|
if(eventSource==combo_scope && scopeTerm!=null){
|
72 |
65434a68
|
Patrick Plitzner
|
if(getParentElement() instanceof ScopeRestrictionSection){
|
73 |
|
|
PolytomousKey key = ((ScopeRestrictionSection)getParentElement()).getEntity();
|
74 |
|
|
key.removeScopeRestriction(entity);
|
75 |
|
|
key.addScopeRestriction(scopeTerm);
|
76 |
d0e36b21
|
Patric Plitzner
|
entity = scopeTerm;
|
77 |
|
|
}
|
78 |
9dfd3706
|
Patrick Plitzner
|
else if(getParentElement() instanceof ScopeSection){
|
79 |
|
|
TaxonDescription description = ((ScopeSection)getParentElement()).getEntity();
|
80 |
|
|
description.removeScope(entity);
|
81 |
|
|
description.addScope(scopeTerm);
|
82 |
|
|
entity = scopeTerm;
|
83 |
|
|
|
84 |
|
|
}
|
85 |
d0e36b21
|
Patric Plitzner
|
}
|
86 |
729887cf
|
n.hoffmann
|
}
|
87 |
cfcb0ce6
|
n.hoffmann
|
|
88 |
729887cf
|
n.hoffmann
|
}
|