1
|
/**
|
2
|
* Copyright (C) 2014 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
|
package eu.etaxonomy.taxeditor.ui.section.occurrence.dna;
|
10
|
|
11
|
import org.eclipse.swt.SWT;
|
12
|
import org.eclipse.swt.events.SelectionListener;
|
13
|
|
14
|
import eu.etaxonomy.cdm.model.molecular.Sequence;
|
15
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
16
|
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
|
17
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
18
|
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
|
19
|
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
|
20
|
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement;
|
21
|
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
|
22
|
|
23
|
/**
|
24
|
* @author pplitzner
|
25
|
* @date 07.01.2014
|
26
|
*/
|
27
|
public class SequenceReferenceCollectionDetailElement
|
28
|
extends AbstractEntityCollectionElement<Reference>{
|
29
|
|
30
|
protected EntitySelectionElement<Reference> selection_reference;
|
31
|
protected TextWithLabelElement text_referenceDetail;
|
32
|
|
33
|
public SequenceReferenceCollectionDetailElement(CdmFormFactory formFactory,
|
34
|
AbstractFormSection<?> section, Reference entity,
|
35
|
SelectionListener removeListener, int style) {
|
36
|
super(formFactory, section, entity, removeListener, null, style);
|
37
|
}
|
38
|
|
39
|
@Override
|
40
|
public void createControls(ICdmFormElement formElement, int style) {
|
41
|
selection_reference = formFactory
|
42
|
.createSelectionElement(Reference.class,
|
43
|
formElement, "Reference",
|
44
|
null, EntitySelectionElement.SELECTABLE|EntitySelectionElement.EDITABLE, style);
|
45
|
text_referenceDetail = formFactory.createTextWithLabelElement(
|
46
|
formElement, "Reference Detail", null, SWT.NULL);
|
47
|
if (entity != null){
|
48
|
setEntity(entity);
|
49
|
}
|
50
|
}
|
51
|
|
52
|
@Override
|
53
|
public void setEntity(Reference entity) {
|
54
|
this.entity = entity;
|
55
|
if(selection_reference != null){
|
56
|
selection_reference.setEntity(entity);
|
57
|
text_referenceDetail.setText(entity.getReferenceAbstract());
|
58
|
}
|
59
|
|
60
|
}
|
61
|
|
62
|
@Override
|
63
|
public void handleEvent(Object eventSource) {
|
64
|
if(eventSource==selection_reference){
|
65
|
if(getParentElement() instanceof SequenceReferenceCollectionDetailSection){
|
66
|
Sequence sequence = ((SequenceReferenceCollectionDetailSection) getParentElement()).getEntity();
|
67
|
sequence.removeCitation(entity);
|
68
|
Reference newCitation = selection_reference.getSelection();
|
69
|
sequence.addCitation(newCitation);
|
70
|
entity = newCitation;
|
71
|
|
72
|
text_referenceDetail.setEnabled(true);
|
73
|
}
|
74
|
} else if(eventSource==text_referenceDetail){
|
75
|
entity.setReferenceAbstract(text_referenceDetail.getText());
|
76
|
}
|
77
|
}
|
78
|
}
|