1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2007 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
|
|
11
|
package eu.etaxonomy.taxeditor.ui.section.description;
|
12
|
|
13
|
import org.eclipse.swt.events.SelectionListener;
|
14
|
|
15
|
import eu.etaxonomy.cdm.model.common.DefinedTerm;
|
16
|
import eu.etaxonomy.cdm.model.common.TermType;
|
17
|
import eu.etaxonomy.cdm.model.description.TaxonDescription;
|
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.ICdmFormElement;
|
22
|
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement;
|
23
|
|
24
|
/**
|
25
|
* <p>ScopeElement class.</p>
|
26
|
*
|
27
|
* @author n.hoffmann
|
28
|
* @created Mar 18, 2010
|
29
|
* @version 1.0
|
30
|
*/
|
31
|
public class ScopeElement extends AbstractEntityCollectionElement<DefinedTerm> {
|
32
|
|
33
|
private TermComboElement<DefinedTerm> combo_scope;
|
34
|
|
35
|
/**
|
36
|
* <p>Constructor for ScopeElement.</p>
|
37
|
*
|
38
|
* @param cdmFormFactory a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object.
|
39
|
* @param section a {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection} object.
|
40
|
* @param element a {@link eu.etaxonomy.cdm.model.description.Scope} object.
|
41
|
* @param removeListener a {@link org.eclipse.swt.events.SelectionListener} object.
|
42
|
* @param style a int.
|
43
|
*/
|
44
|
public ScopeElement(CdmFormFactory cdmFormFactory,
|
45
|
AbstractFormSection section, DefinedTerm element,
|
46
|
SelectionListener removeListener, int style) {
|
47
|
super(cdmFormFactory, section, element, removeListener, null, style);
|
48
|
}
|
49
|
|
50
|
/** {@inheritDoc} */
|
51
|
@Override
|
52
|
public void setEntity(DefinedTerm entity) {
|
53
|
this.entity = entity;
|
54
|
if(!entity.getLabel().isEmpty()){
|
55
|
combo_scope.setSelection(entity);
|
56
|
}
|
57
|
}
|
58
|
|
59
|
/** {@inheritDoc} */
|
60
|
@Override
|
61
|
public void createControls(ICdmFormElement element, int style) {
|
62
|
combo_scope = formFactory.createDefinedTermComboElement(TermType.Scope, element, "Scope", null, style);
|
63
|
}
|
64
|
|
65
|
/** {@inheritDoc} */
|
66
|
@Override
|
67
|
public void handleEvent(Object eventSource) {
|
68
|
DefinedTerm scopeTerm = combo_scope.getSelection();
|
69
|
if(eventSource==combo_scope && scopeTerm!=null){
|
70
|
if(getParentElement() instanceof ScopeSection){
|
71
|
TaxonDescription taxonDescription = ((ScopeSection)getParentElement()).getEntity();
|
72
|
taxonDescription.removeScope(entity);
|
73
|
taxonDescription.addScope(scopeTerm);
|
74
|
entity = scopeTerm;
|
75
|
}
|
76
|
}
|
77
|
}
|
78
|
|
79
|
}
|