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.identifier;
|
12
|
|
13
|
import org.eclipse.swt.events.SelectionListener;
|
14
|
|
15
|
import eu.etaxonomy.cdm.model.common.DefinedTerm;
|
16
|
import eu.etaxonomy.cdm.model.common.Identifier;
|
17
|
import eu.etaxonomy.cdm.model.common.TermType;
|
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.element.TextWithLabelElement;
|
23
|
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement;
|
24
|
|
25
|
/**
|
26
|
*
|
27
|
* @author pplitzner
|
28
|
*
|
29
|
*/
|
30
|
public class IdentifierDetailElement extends AbstractEntityCollectionElement<Identifier> {
|
31
|
|
32
|
private TextWithLabelElement textIdentifier;
|
33
|
|
34
|
private TermComboElement<DefinedTerm> comboIdentifierType;
|
35
|
|
36
|
public IdentifierDetailElement(CdmFormFactory formFactory,
|
37
|
AbstractFormSection section, Identifier entity,
|
38
|
SelectionListener removeListener, int style) {
|
39
|
super(formFactory, section, entity, removeListener, null, style);
|
40
|
}
|
41
|
|
42
|
/** {@inheritDoc} */
|
43
|
@Override
|
44
|
public void setEntity(Identifier entity) {
|
45
|
this.entity = entity;
|
46
|
textIdentifier.setText(entity.getIdentifier());
|
47
|
comboIdentifierType.setSelection(entity.getType());
|
48
|
}
|
49
|
|
50
|
/** {@inheritDoc} */
|
51
|
@Override
|
52
|
public void createControls(ICdmFormElement formElement, int style) {
|
53
|
textIdentifier = formFactory.createTextWithLabelElement(formElement, "Identifier", null, style);
|
54
|
comboIdentifierType = formFactory.createDefinedTermComboElement(TermType.IdentifierType, formElement, "Type", null, style);
|
55
|
}
|
56
|
|
57
|
@Override
|
58
|
public void handleEvent(Object eventSource) {
|
59
|
if (eventSource == textIdentifier) {
|
60
|
getEntity().setIdentifier(textIdentifier.getText());
|
61
|
} else if (eventSource == comboIdentifierType) {
|
62
|
getEntity().setType(comboIdentifierType.getSelection());
|
63
|
}
|
64
|
}
|
65
|
|
66
|
}
|