1
|
/**
|
2
|
* Copyright (C) 2007 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* 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
|
package eu.etaxonomy.taxeditor.ui.section.supplemental.identifier;
|
11
|
|
12
|
import org.eclipse.swt.events.SelectionListener;
|
13
|
|
14
|
import eu.etaxonomy.cdm.model.term.DefinedTerm;
|
15
|
import eu.etaxonomy.cdm.model.common.Identifier;
|
16
|
import eu.etaxonomy.cdm.model.term.TermType;
|
17
|
import eu.etaxonomy.taxeditor.ui.combo.term.TermComboElement;
|
18
|
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
|
19
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
20
|
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
|
21
|
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
|
22
|
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement;
|
23
|
|
24
|
/**
|
25
|
*
|
26
|
* @author pplitzner
|
27
|
*
|
28
|
*/
|
29
|
public class IdentifierElement extends AbstractEntityCollectionElement<Identifier> {
|
30
|
|
31
|
private TextWithLabelElement textIdentifier;
|
32
|
|
33
|
private TermComboElement<DefinedTerm> comboIdentifierType;
|
34
|
|
35
|
public IdentifierElement(CdmFormFactory formFactory,
|
36
|
AbstractFormSection section, Identifier entity,
|
37
|
SelectionListener removeListener, int style) {
|
38
|
super(formFactory, section, entity, removeListener, null, style);
|
39
|
}
|
40
|
|
41
|
/** {@inheritDoc} */
|
42
|
@Override
|
43
|
public void setEntity(Identifier entity) {
|
44
|
this.entity = entity;
|
45
|
if (textIdentifier != null){
|
46
|
textIdentifier.setText(entity.getIdentifier());
|
47
|
comboIdentifierType.setSelection(entity.getType());
|
48
|
}
|
49
|
}
|
50
|
|
51
|
|
52
|
/** {@inheritDoc} */
|
53
|
@Override
|
54
|
public void createControls(ICdmFormElement formElement, int style) {
|
55
|
comboIdentifierType = formFactory.createDefinedTermComboElement(TermType.IdentifierType, formElement, "Type", null, style);
|
56
|
textIdentifier = formFactory.createTextWithLabelElement(formElement, "Identifier", null, style);
|
57
|
if (entity != null){
|
58
|
setEntity(entity);
|
59
|
}
|
60
|
}
|
61
|
|
62
|
@Override
|
63
|
public void handleEvent(Object eventSource) {
|
64
|
if (eventSource == textIdentifier) {
|
65
|
getEntity().setIdentifier(textIdentifier.getText());
|
66
|
} else if (eventSource == comboIdentifierType) {
|
67
|
getEntity().setType(comboIdentifierType.getSelection());
|
68
|
}
|
69
|
}
|
70
|
|
71
|
}
|