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
.ContextMenu
;
22 import eu
.etaxonomy
.taxeditor
.editor
.EditorUtil
;
23 import eu
.etaxonomy
.taxeditor
.propertysheet
.name
.SynonymPropertySource
;
24 import eu
.etaxonomy
.taxeditor
.store
.model
.NameUtil
;
25 import eu
.etaxonomy
.taxeditor
.store
.operations
.ChangeHomotypicGroupOperation
;
26 import eu
.etaxonomy
.taxeditor
.store
.operations
.ChangeSynonymToMisapplicationOperation
;
33 public class SynonymComposite
extends NameComposite
{
34 @SuppressWarnings("unused")
35 private static final Logger logger
= Logger
36 .getLogger(SynonymComposite
.class);
38 private Synonym synonym
;
40 public SynonymComposite(TaxonNameEditor editor
, Composite parent
, Synonym synonym
) {
41 super(editor
, parent
, null, synonym
);
43 this.taxon
= editor
.getTaxon();
44 this.synonym
= synonym
;
47 setFont(getViewerFont());
48 setIndent(SYNONYM_INDENT
);
51 if (NameUtil
.isNameGroupBasionym(synonym
.getName())) {
52 setIcon(HOMOTYPIC_SYNONYM_ORIGINAL_COMBINATION_ICON
);
54 setIcon(HOMOTYPIC_SYNONYM_ICON
);
57 if (NameUtil
.isNameGroupBasionym(synonym
.getName())) {
58 setIcon(HETEROTYPIC_SYNONYM_ORIGINAL_COMBINATION_ICON
);
60 setIcon(HETEROTYPIC_SYNONYM_ICON
);
64 initTextViewer(synonym
);
67 private boolean isHomotypic() {
68 HomotypicalGroup group
= synonym
.getHomotypicGroup();
69 return group
.equals(taxon
.getHomotypicGroup());
72 public Synonym
getSynonym() {
76 public boolean setParent(Composite parent
) {
78 if (super.setParent(parent
)) {
80 // Has this been moved to the misapplied names group?
81 if (parent
instanceof MisappliedGroupComposite
) {
82 IUndoableOperation operation
= new ChangeSynonymToMisapplicationOperation
83 ("change to misapplication", editor
.getUndoContext(), taxon
, synonym
, editor
); //$NON-NLS-1$
85 EditorUtil
.executeOperation(operation
);
88 // Has this been moved to a HomotypicalGroup?
89 if (parent
instanceof HomotypicalGroupComposite
) {
91 HomotypicalGroup homotypicalGroup
=
92 ((HomotypicalGroupComposite
)parent
).getGroup();
94 // Make sure we are not dropping synonym on its own group
95 if (homotypicalGroup
.equals(synonym
.getHomotypicGroup())) {
99 IUndoableOperation operation
= new ChangeHomotypicGroupOperation
100 ("change type", editor
.getUndoContext(), taxon
, synonym
, homotypicalGroup
, editor
); //$NON-NLS-1$
102 EditorUtil
.executeOperation(operation
);
110 public IPropertySource
getPropertySource() {
111 if (NameUtil
.isNameGroupBasionym(synonym
.getName())) {
112 return new BasionymSynonymPropertySource(synonym
);
114 return new SynonymPropertySource(synonym
);
118 protected Font
getViewerFont() {
123 protected TaxonNameBase
getName() {
124 return synonym
.getName();
127 public Object
getData () {