1
|
/**
|
2
|
* Copyright (C) 2021 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.supplemental;
|
10
|
|
11
|
import org.eclipse.swt.events.SelectionListener;
|
12
|
import org.eclipse.swt.widgets.Composite;
|
13
|
import org.eclipse.swt.widgets.Control;
|
14
|
|
15
|
import eu.etaxonomy.cdm.model.common.IdentifiableSource;
|
16
|
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
|
17
|
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
|
18
|
import eu.etaxonomy.taxeditor.store.StoreUtil;
|
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.LayoutConstants;
|
23
|
import eu.etaxonomy.taxeditor.ui.section.common.ExternalLinksSection;
|
24
|
|
25
|
/**
|
26
|
* @author n.hoffmann
|
27
|
* @created Nov 16, 2009
|
28
|
*/
|
29
|
public class IdentifiableSourceElement extends AbstractOriginalSourceElement<IdentifiableSource>{
|
30
|
|
31
|
boolean isEnabled = true;
|
32
|
|
33
|
public IdentifiableSourceElement(CdmFormFactory cdmFormFactory, AbstractFormSection formElement, IdentifiableSource element,
|
34
|
SelectionListener removeListener, int style, boolean isEnabled) {
|
35
|
super(cdmFormFactory, formElement, element, removeListener, style);
|
36
|
this.isEnabled = isEnabled;
|
37
|
for (Control control: this.getControls()){
|
38
|
control.setEnabled(isEnabled);
|
39
|
if (control instanceof Composite){
|
40
|
for (Control co: ((Composite)control).getChildren()){
|
41
|
co.setEnabled(isEnabled);
|
42
|
}
|
43
|
}
|
44
|
}
|
45
|
}
|
46
|
|
47
|
public IdentifiableSourceElement(CdmFormFactory cdmFormFactory, AbstractFormSection formElement, IdentifiableSource element,
|
48
|
SelectionListener removeListener, int style) {
|
49
|
super(cdmFormFactory, formElement, element, removeListener, style);
|
50
|
}
|
51
|
|
52
|
@Override
|
53
|
public void createControls(ICdmFormElement formElement, int style) {
|
54
|
super.createControls(formElement, style);
|
55
|
externalLinks = formFactory.createExternalLinksSection(formElement, StoreUtil.getSectionStyle(ExternalLinksSection.class, IdentifiableSource.class.getCanonicalName()));
|
56
|
externalLinks.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
|
57
|
if (entity != null){
|
58
|
setEntity(this.entity);
|
59
|
}
|
60
|
}
|
61
|
|
62
|
@Override
|
63
|
public void setEntity(IdentifiableSource 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
|
combo_origsourcetype.setSelection(entity.getType());
|
76
|
text_originalInfo.setText(entity.getOriginalInfo());
|
77
|
}
|
78
|
}
|
79
|
|
80
|
@Override
|
81
|
public void handleEvent(Object eventSource) {
|
82
|
super.handleEvent(eventSource);
|
83
|
}
|
84
|
}
|