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
.NameUtil
;
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
{
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 boolean doSetParent
= false;
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$
83 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())) {
96 IUndoableOperation operation
= new ChangeHomotypicGroupOperation
97 ("change type", editor
.getUndoContext(), taxon
, synonym
, homotypicalGroup
, editor
); //$NON-NLS-1$
98 EditorUtil
.executeOperation(operation
);
106 public IPropertySource
getPropertySource() {
107 if (NameUtil
.isNameGroupBasionym(synonym
.getName())) {
108 return new BasionymSynonymPropertySource(synonym
);
110 return new SynonymPropertySource(synonym
);
114 protected Font
getViewerFont() {
119 protected TaxonNameBase
<?
, ?
> getName() {
120 return synonym
.getName();
123 public Object
getData () {