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
.editor
.name
;
12 import org
.apache
.log4j
.Logger
;
13 import org
.eclipse
.core
.commands
.operations
.IUndoableOperation
;
14 import org
.eclipse
.swt
.graphics
.Font
;
15 import org
.eclipse
.swt
.widgets
.Composite
;
16 import org
.eclipse
.ui
.views
.properties
.IPropertySource
;
18 import eu
.etaxonomy
.cdm
.model
.name
.HomotypicalGroup
;
19 import eu
.etaxonomy
.cdm
.model
.name
.TaxonNameBase
;
20 import eu
.etaxonomy
.cdm
.model
.taxon
.Synonym
;
21 import eu
.etaxonomy
.taxeditor
.editor
.EditorUtil
;
22 import eu
.etaxonomy
.taxeditor
.model
.NameHelper
;
23 import eu
.etaxonomy
.taxeditor
.operations
.ChangeHomotypicGroupOperation
;
24 import eu
.etaxonomy
.taxeditor
.operations
.ChangeSynonymToMisapplicationOperation
;
25 import eu
.etaxonomy
.taxeditor
.propertysheet
.name
.SynonymPropertySource
;
32 public class SynonymComposite
extends NameComposite
<Synonym
> {
33 @SuppressWarnings("unused")
34 private static final Logger logger
= Logger
35 .getLogger(SynonymComposite
.class);
37 public SynonymComposite(TaxonNameEditor editor
, Composite parent
, Synonym synonym
) {
38 super(editor
, parent
, synonym
);
40 initializeComposite();
44 * @see eu.etaxonomy.taxeditor.editor.name.NameComposite#initializeComposite()
47 protected void initializeComposite() {
49 setFont(getViewerFont());
50 setIndent(SYNONYM_INDENT
);
53 if (NameHelper
.isNameGroupBasionym(getSynonym().getName())) {
54 setIcon(HOMOTYPIC_SYNONYM_ORIGINAL_COMBINATION_ICON
);
56 setIcon(HOMOTYPIC_SYNONYM_ICON
);
59 if (NameHelper
.isNameGroupBasionym(getSynonym().getName())) {
60 setIcon(HETEROTYPIC_SYNONYM_ORIGINAL_COMBINATION_ICON
);
62 setIcon(HETEROTYPIC_SYNONYM_ICON
);
66 initTextViewer(getSynonym());
69 private boolean isHomotypic() {
70 HomotypicalGroup group
= getSynonym().getHomotypicGroup();
71 return group
.equals(taxon
.getHomotypicGroup());
74 public Synonym
getSynonym() {
75 return getTaxonBase();
78 public boolean setParent(Composite parent
) {
80 boolean doSetParent
= false;
82 // Has this been moved to the misapplied names group?
83 if (parent
instanceof MisappliedGroupComposite
) {
84 IUndoableOperation operation
= new ChangeSynonymToMisapplicationOperation
85 ("change to misapplication", editor
.getUndoContext(), taxon
, getSynonym(), editor
); //$NON-NLS-1$
86 EditorUtil
.executeOperation(operation
);
91 // Has this been moved to a HomotypicalGroup?
92 if (parent
instanceof HomotypicalGroupComposite
) {
94 HomotypicalGroup homotypicalGroup
=
95 ((HomotypicalGroupComposite
)parent
).getGroup();
97 // Make sure we are not dropping synonym on its own group
98 if (!homotypicalGroup
.equals(getSynonym().getHomotypicGroup())) {
99 IUndoableOperation operation
= new ChangeHomotypicGroupOperation
100 ("change type", editor
.getUndoContext(), taxon
, getSynonym(), homotypicalGroup
, editor
); //$NON-NLS-1$
101 EditorUtil
.executeOperation(operation
);
109 public IPropertySource
getPropertySource() {
110 if (NameHelper
.isNameGroupBasionym(getSynonym().getName())) {
111 return new BasionymSynonymPropertySource(getSynonym());
113 return new SynonymPropertySource(getSynonym());
117 protected Font
getViewerFont() {
122 protected TaxonNameBase
<?
, ?
> getName() {
123 return getSynonym().getName();
126 public Object
getData () {