4 package eu
.etaxonomy
.taxeditor
.ui
.section
.supplemental
;
6 import org
.eclipse
.swt
.events
.SelectionListener
;
7 import org
.eclipse
.swt
.widgets
.Composite
;
8 import org
.eclipse
.swt
.widgets
.Control
;
10 import eu
.etaxonomy
.cdm
.model
.common
.IdentifiableSource
;
11 import eu
.etaxonomy
.cdm
.model
.metadata
.PreferencePredicate
;
12 import eu
.etaxonomy
.taxeditor
.preference
.PreferencesUtil
;
13 import eu
.etaxonomy
.taxeditor
.store
.StoreUtil
;
14 import eu
.etaxonomy
.taxeditor
.ui
.element
.AbstractFormSection
;
15 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
16 import eu
.etaxonomy
.taxeditor
.ui
.element
.ICdmFormElement
;
17 import eu
.etaxonomy
.taxeditor
.ui
.element
.LayoutConstants
;
18 import eu
.etaxonomy
.taxeditor
.ui
.section
.common
.ExternalLinksSection
;
22 * @created Nov 16, 2009
24 public class IdentifiableSourceElement
extends AbstractOriginalSourceElement
<IdentifiableSource
>{
26 boolean isEnabled
= true;
28 public IdentifiableSourceElement(CdmFormFactory cdmFormFactory
, AbstractFormSection formElement
, IdentifiableSource element
,
29 SelectionListener removeListener
, int style
, boolean isEnabled
) {
30 super(cdmFormFactory
, formElement
, element
, removeListener
, style
);
31 this.isEnabled
= isEnabled
;
32 for (Control control
: this.getControls()){
33 control
.setEnabled(isEnabled
);
34 if (control
instanceof Composite
){
35 for (Control co
: ((Composite
)control
).getChildren()){
36 co
.setEnabled(isEnabled
);
44 public IdentifiableSourceElement(CdmFormFactory cdmFormFactory
, AbstractFormSection formElement
, IdentifiableSource element
,
45 SelectionListener removeListener
, int style
) {
46 super(cdmFormFactory
, formElement
, element
, removeListener
, style
);
52 public void createControls(ICdmFormElement formElement
, int style
) {
53 super.createControls(formElement
, style
);
54 externalLinks
= formFactory
.createExternalLinksSection(getConversationHolder(), formElement
, StoreUtil
.getSectionStyle(ExternalLinksSection
.class, IdentifiableSource
.class.getCanonicalName()));
55 externalLinks
.setLayoutData(LayoutConstants
.FILL_HORIZONTALLY(2, 1));
60 public void setEntity(IdentifiableSource entity
) {
61 super.setEntity(entity
);
62 if (PreferencesUtil
.getBooleanValue(PreferencePredicate
.ShowIdInSource
.getKey())){
63 text_idInSource
.setText(entity
.getIdInSource());
65 if (PreferencesUtil
.getBooleanValue(PreferencePredicate
.ShowNamespaceInSource
.getKey())){
66 text_idNamespace
.setText(entity
.getIdNamespace());
69 selection_reference
.setEntity(entity
.getCitation());
70 text_referenceDetail
.setText(entity
.getCitationMicroReference());
71 combo_origsourcetype
.setSelection(entity
.getType());
72 text_originaleNameString
.setText(entity
.getOriginalNameString());
80 public void handleEvent(Object eventSource
) {
81 if(eventSource
== text_idInSource
){
82 getEntity().setIdInSource(text_idInSource
.getText());
84 else if(eventSource
== text_idNamespace
){
85 getEntity().setIdNamespace(text_idNamespace
.getText());
87 if(eventSource
== selection_reference
){
88 getEntity().setCitation(selection_reference
.getSelection());
90 else if(eventSource
== text_referenceDetail
){
91 getEntity().setCitationMicroReference(text_referenceDetail
.getText());
93 else if(eventSource
== text_originaleNameString
){
94 getEntity().setOriginalNameString(text_originaleNameString
.getText());
95 } else if(eventSource
== combo_origsourcetype
){
96 getEntity().setType(combo_origsourcetype
.getSelection());