3 * Copyright (C) 2014 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.taxeditor
.ui
.section
.name
;
12 import org
.eclipse
.swt
.events
.SelectionListener
;
13 import org
.eclipse
.swt
.graphics
.Color
;
15 import eu
.etaxonomy
.cdm
.model
.taxon
.SynonymRelationship
;
16 import eu
.etaxonomy
.cdm
.model
.taxon
.SynonymRelationshipType
;
17 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
18 import eu
.etaxonomy
.taxeditor
.ui
.combo
.TermComboElement
;
19 import eu
.etaxonomy
.taxeditor
.ui
.element
.AbstractFormSection
;
20 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
21 import eu
.etaxonomy
.taxeditor
.ui
.element
.CheckboxElement
;
22 import eu
.etaxonomy
.taxeditor
.ui
.element
.ICdmFormElement
;
23 import eu
.etaxonomy
.taxeditor
.ui
.element
.LabelElement
;
24 import eu
.etaxonomy
.taxeditor
.ui
.element
.TextWithLabelElement
;
25 import eu
.etaxonomy
.taxeditor
.ui
.section
.supplemental
.AbstractReferencedEntityElement
;
26 import eu
.etaxonomy
.taxeditor
.ui
.selection
.EntitySelectionElement
;
33 public class SynonymRelationshipDetailElement
extends AbstractReferencedEntityElement
<SynonymRelationship
>{
35 private TextWithLabelElement text_ruleConsidered
;
36 private LabelElement label
;
37 private EntitySelectionElement selection_toName
;
38 private TermComboElement
<SynonymRelationshipType
> combo_relationshipType
;
39 private CheckboxElement checkProParte
;
40 private CheckboxElement checkPartial
;
43 * <p>Constructor for NameRelationshipDetailElement.</p>
45 * @param cdmFormFactory a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object.
46 * @param formElement a {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection} object.
47 * @param entity a {@link eu.etaxonomy.cdm.model.name.NameRelationship} object.
48 * @param removeListener a {@link org.eclipse.swt.events.SelectionListener} object.
51 public SynonymRelationshipDetailElement(CdmFormFactory cdmFormFactory
,
52 AbstractFormSection formElement
,
53 SynonymRelationship entity
, SelectionListener removeListener
, int style
) {
54 super(cdmFormFactory
, formElement
, entity
, removeListener
, style
);
58 * @see eu.etaxonomy.taxeditor.forms.entitysections.AbstractEntitySetElementComposite#createControls(org.eclipse.swt.widgets.Composite, int)
62 public void createControls(ICdmFormElement element
, int style
) {
63 label
= formFactory
.createLabel(element
, null);
64 checkProParte
= formFactory
.createCheckbox(element
, "Pro Parte Synonym", null, style
);
65 checkPartial
= formFactory
.createCheckbox(element
, "Partial Synonym", null, style
);
66 super.createControls(element
, style
);
71 public void setEntity(SynonymRelationship entity
) {
72 String text
= entity
.getSynonym().getTitleCache() + " is " + entity
.getType().getLabel() + " " + entity
.getAcceptedTaxon().getTitleCache();
76 checkPartial
.setSelection(entity
.isPartial());
77 checkProParte
.setSelection(entity
.isProParte());
79 super.setEntity(entity
);
84 public void handleEvent(Object eventSource
) {
85 if(eventSource
== combo_relationshipType
){
86 getEntity().setType(combo_relationshipType
.getSelection());
88 else if(eventSource
== selection_toName
){
89 MessagingUtils
.error(getClass(), "No API call available.", null);
91 else if(eventSource
== checkPartial
){
92 getEntity().setPartial(checkPartial
.getSelection());
94 else if(eventSource
== checkProParte
){
95 getEntity().setProParte(checkProParte
.getSelection());
97 else if(eventSource
== selection_reference
){
98 getEntity().setCitation(selection_reference
.getSelection());
100 else if(eventSource
== text_referenceDetail
){
101 getEntity().setCitationMicroReference(text_referenceDetail
.getText());
107 public void setBackground(Color color
) {
109 label
.setBackground(color
);
111 super.setBackground(color
);