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