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.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
|
textIdentifier.setText(entity.getIdentifier());
|
46
|
comboIdentifierType.setSelection(entity.getType());
|
47
|
}
|
48
|
|
49
|
/** {@inheritDoc} */
|
50
|
@Override
|
51
|
public void createControls(ICdmFormElement formElement, int style) {
|
52
|
comboIdentifierType = formFactory.createDefinedTermComboElement(TermType.IdentifierType, formElement, "Type", null, style);
|
53
|
textIdentifier = formFactory.createTextWithLabelElement(formElement, "Identifier", null, style);
|
54
|
}
|
55
|
|
56
|
@Override
|
57
|
public void handleEvent(Object eventSource) {
|
58
|
if (eventSource == textIdentifier) {
|
59
|
getEntity().setIdentifier(textIdentifier.getText());
|
60
|
} else if (eventSource == comboIdentifierType) {
|
61
|
getEntity().setType(comboIdentifierType.getSelection());
|
62
|
}
|
63
|
}
|
64
|
|
65
|
}
|