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
|
package eu.etaxonomy.taxeditor.ui.section.description;
|
10
|
|
11
|
import org.eclipse.swt.SWT;
|
12
|
import org.eclipse.swt.events.SelectionListener;
|
13
|
|
14
|
import eu.etaxonomy.cdm.model.description.DescriptionElementSource;
|
15
|
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
|
16
|
import eu.etaxonomy.cdm.model.name.TaxonName;
|
17
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
18
|
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
|
19
|
import eu.etaxonomy.taxeditor.store.StoreUtil;
|
20
|
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
|
21
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
22
|
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
|
23
|
import eu.etaxonomy.taxeditor.ui.element.IEntityElement;
|
24
|
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
|
25
|
import eu.etaxonomy.taxeditor.ui.section.common.ExternalLinksSection;
|
26
|
import eu.etaxonomy.taxeditor.ui.section.supplemental.AbstractOriginalSourceElement;
|
27
|
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
|
28
|
|
29
|
/**
|
30
|
* @author n.hoffmann
|
31
|
* @created Nov 16, 2009
|
32
|
*/
|
33
|
public class DescriptionElementSourceElement extends
|
34
|
AbstractOriginalSourceElement<DescriptionElementSource> implements
|
35
|
IEntityElement<DescriptionElementSource>{//, IEnableableFormElement {
|
36
|
private EntitySelectionElement<Reference> selection_descriptionElementSource;
|
37
|
private EntitySelectionElement<TaxonName> selection_name;
|
38
|
boolean isEnabled = true;
|
39
|
|
40
|
public DescriptionElementSourceElement(CdmFormFactory cdmFormFactory,
|
41
|
AbstractFormSection<?> formElement, DescriptionElementSource element,
|
42
|
SelectionListener removeListener, int style, boolean isCommonNameReference) {
|
43
|
super(cdmFormFactory, formElement, element, removeListener, style, isCommonNameReference);
|
44
|
cdmFormFactory.createSelectionArbitrator(this);
|
45
|
}
|
46
|
|
47
|
@Override
|
48
|
public void createControls(ICdmFormElement formElement, int style) {
|
49
|
super.createControls(formElement, style);
|
50
|
selection_name = formFactory
|
51
|
.createSelectionElement(TaxonName.class,//getConversationHolder(),
|
52
|
formElement, "Name in Source",
|
53
|
null, EntitySelectionElement.ALL, SWT.NULL);
|
54
|
|
55
|
externalLinks = formFactory.createExternalLinksSection(getConversationHolder(), formElement, StoreUtil.getSectionStyle(ExternalLinksSection.class, DescriptionElementSource.class.getCanonicalName()));
|
56
|
externalLinks.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
|
57
|
if (getEntity() != null){
|
58
|
setEntity(entity);
|
59
|
}
|
60
|
}
|
61
|
|
62
|
@Override
|
63
|
public void setEntity(DescriptionElementSource entity) {
|
64
|
super.setEntity(entity);
|
65
|
if (selection_reference != null){
|
66
|
if (PreferencesUtil.getBooleanValue(PreferencePredicate.ShowIdInSource.getKey())){
|
67
|
text_idInSource.setText(entity.getIdInSource());
|
68
|
}
|
69
|
if (PreferencesUtil.getBooleanValue(PreferencePredicate.ShowNamespaceInSource.getKey())){
|
70
|
text_idNamespace.setText(entity.getIdNamespace());
|
71
|
}
|
72
|
|
73
|
selection_reference.setEntity(entity.getCitation());
|
74
|
text_referenceDetail.setText(entity.getCitationMicroReference());
|
75
|
text_originaleNameString.setText(entity.getOriginalNameString());
|
76
|
selection_name.setEntity(entity.getNameUsedInSource());
|
77
|
combo_origsourcetype.setSelection(entity.getType());
|
78
|
externalLinks.setEntity(entity);
|
79
|
}
|
80
|
}
|
81
|
|
82
|
@Override
|
83
|
public void setSelected(boolean selected) {}
|
84
|
|
85
|
@Override
|
86
|
public void handleEvent(Object eventSource) {
|
87
|
if (eventSource == text_idInSource) {
|
88
|
getEntity().setIdInSource(text_idInSource.getText());
|
89
|
} else if (eventSource == text_idNamespace) {
|
90
|
getEntity().setIdNamespace(text_idNamespace.getText());
|
91
|
} else if (eventSource == selection_reference) {
|
92
|
getEntity().setCitation(selection_reference.getSelection());
|
93
|
} else if (eventSource == text_referenceDetail) {
|
94
|
getEntity().setCitationMicroReference(
|
95
|
text_referenceDetail.getText());
|
96
|
} else if (eventSource == text_originaleNameString) {
|
97
|
getEntity().setOriginalNameString(
|
98
|
text_originaleNameString.getText());
|
99
|
} else if (eventSource == selection_name) {
|
100
|
getEntity().setNameUsedInSource(selection_name.getSelection());
|
101
|
}
|
102
|
else if(eventSource == combo_origsourcetype){
|
103
|
getEntity().setType(combo_origsourcetype.getSelection());
|
104
|
}
|
105
|
}
|
106
|
|
107
|
@Override
|
108
|
public void setEnabled(boolean enabled) {
|
109
|
super.setEnabled(enabled);
|
110
|
externalLinks.setEnabled(isEnabled);
|
111
|
}
|
112
|
}
|