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
.propertysheet
.name
.SynonymPropertySource
;
23 import eu
.etaxonomy
.taxeditor
.store
.model
.NameUtil
;
24 import eu
.etaxonomy
.taxeditor
.store
.operations
.ChangeHomotypicGroupOperation
;
25 import eu
.etaxonomy
.taxeditor
.store
.operations
.ChangeSynonymToMisapplicationOperation
;
32 public class SynonymComposite
extends NameComposite
{
33 @SuppressWarnings("unused")
34 private static final Logger logger
= Logger
35 .getLogger(SynonymComposite
.class);
37 private Synonym synonym
;
39 public SynonymComposite(TaxonNameEditor editor
, Composite parent
, Synonym synonym
) {
40 super(editor
, parent
, null, synonym
);
42 this.taxon
= editor
.getTaxon();
43 this.synonym
= synonym
;
46 setFont(getViewerFont());
47 setIndent(SYNONYM_INDENT
);
50 if (NameUtil
.isNameGroupBasionym(synonym
.getName())) {
51 setIcon(HOMOTYPIC_SYNONYM_ORIGINAL_COMBINATION_ICON
);
53 setIcon(HOMOTYPIC_SYNONYM_ICON
);
56 if (NameUtil
.isNameGroupBasionym(synonym
.getName())) {
57 setIcon(HETEROTYPIC_SYNONYM_ORIGINAL_COMBINATION_ICON
);
59 setIcon(HETEROTYPIC_SYNONYM_ICON
);
63 initTextViewer(synonym
);
66 private boolean isHomotypic() {
67 HomotypicalGroup group
= synonym
.getHomotypicGroup();
68 return group
.equals(taxon
.getHomotypicGroup());
71 public Synonym
getSynonym() {
75 public boolean setParent(Composite parent
) {
77 if (super.setParent(parent
)) {
79 // Has this been moved to the misapplied names group?
80 if (parent
instanceof MisappliedGroupComposite
) {
81 IUndoableOperation operation
= new ChangeSynonymToMisapplicationOperation
82 ("change to misapplication", editor
.getUndoContext(), taxon
, synonym
, editor
); //$NON-NLS-1$
84 EditorUtil
.executeOperation(operation
);
87 // Has this been moved to a HomotypicalGroup?
88 if (parent
instanceof HomotypicalGroupComposite
) {
90 HomotypicalGroup homotypicalGroup
=
91 ((HomotypicalGroupComposite
)parent
).getGroup();
93 // Make sure we are not dropping synonym on its own group
94 if (homotypicalGroup
.equals(synonym
.getHomotypicGroup())) {
98 IUndoableOperation operation
= new ChangeHomotypicGroupOperation
99 ("change type", editor
.getUndoContext(), taxon
, synonym
, homotypicalGroup
, editor
); //$NON-NLS-1$
101 EditorUtil
.executeOperation(operation
);
109 public IPropertySource
getPropertySource() {
110 if (NameUtil
.isNameGroupBasionym(synonym
.getName())) {
111 return new BasionymSynonymPropertySource(synonym
);
113 return new SynonymPropertySource(synonym
);
117 protected Font
getViewerFont() {
122 protected TaxonNameBase
getName() {
123 return synonym
.getName();
126 public Object
getData () {