2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.taxeditor
.ui
.section
.supplemental
;
12 import org
.eclipse
.swt
.SWT
;
13 import org
.eclipse
.swt
.events
.SelectionListener
;
15 import eu
.etaxonomy
.cdm
.model
.common
.ReferencedEntityBase
;
16 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
17 import eu
.etaxonomy
.taxeditor
.preference
.PreferencesUtil
;
18 import eu
.etaxonomy
.taxeditor
.ui
.element
.AbstractFormSection
;
19 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
20 import eu
.etaxonomy
.taxeditor
.ui
.element
.ICdmFormElement
;
21 import eu
.etaxonomy
.taxeditor
.ui
.element
.ISelectableElement
;
22 import eu
.etaxonomy
.taxeditor
.ui
.element
.SelectionArbitrator
;
23 import eu
.etaxonomy
.taxeditor
.ui
.element
.TextWithLabelElement
;
24 import eu
.etaxonomy
.taxeditor
.ui
.section
.AbstractEntityCollectionElement
;
25 import eu
.etaxonomy
.taxeditor
.ui
.selection
.EntitySelectionElement
;
29 * @created Mar 25, 2010
31 public abstract class AbstractReferencedEntityElement
<T
extends ReferencedEntityBase
>
32 extends AbstractEntityCollectionElement
<T
> implements ISelectableElement
{
34 private SelectionArbitrator selectionArbitrator
;
36 protected EntitySelectionElement
<Reference
> selection_reference
;
37 protected TextWithLabelElement text_referenceDetail
;
39 protected boolean isCommonNameReference
= false;
41 public AbstractReferencedEntityElement(CdmFormFactory formFactory
,
42 AbstractFormSection section
, T entity
,
43 SelectionListener removeListener
, int style
, boolean isCommonNameReference
) {
44 super(formFactory
, section
, entity
, removeListener
, null, style
);
45 // make this element selectable
46 if(formFactory
.getSelectionProvider() != null){
47 selectionArbitrator
= formFactory
.createSelectionArbitrator(this);
49 this.isCommonNameReference
= isCommonNameReference
;
52 public AbstractReferencedEntityElement(CdmFormFactory formFactory
,
53 AbstractFormSection section
, T entity
,
54 SelectionListener removeListener
, int style
) {
55 super(formFactory
, section
, entity
, removeListener
, null, style
);
56 // make this element selectable
57 if(formFactory
.getSelectionProvider() != null){
58 selectionArbitrator
= formFactory
.createSelectionArbitrator(this);
63 public void createControls(ICdmFormElement formElement
, int style
) {
64 if (isCommonNameReference
&& PreferencesUtil
.getFilterCommonNameReferences()){
65 selection_reference
= formFactory
66 .createCommonNameReferenceSelectionElement(formElement
, "Reference",
67 null, EntitySelectionElement
.ALL
, style
);
69 selection_reference
= formFactory
70 .createSelectionElement(Reference
.class,//getConversationHolder(),
71 formElement
, "Reference",
72 null, EntitySelectionElement
.ALL
, style
);
75 text_referenceDetail
= formFactory
.createTextWithLabelElement(
76 formElement
, "Reference Detail", null, SWT
.NULL
);
80 public void setEntity(T entity
) {
83 selection_reference
.setEntity(entity
.getCitation());
84 text_referenceDetail
.setText(entity
.getCitationMicroReference());
88 public SelectionArbitrator
getSelectionArbitrator() {
89 return selectionArbitrator
;