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
.eclipse
.core
.commands
.operations
.IUndoableOperation
;
13 import org
.eclipse
.swt
.graphics
.Font
;
14 import org
.eclipse
.swt
.widgets
.Composite
;
15 import org
.eclipse
.ui
.views
.properties
.IPropertySource
;
17 import eu
.etaxonomy
.cdm
.model
.name
.HomotypicalGroup
;
18 import eu
.etaxonomy
.cdm
.model
.name
.TaxonNameBase
;
19 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
20 import eu
.etaxonomy
.taxeditor
.editor
.EditorUtil
;
21 import eu
.etaxonomy
.taxeditor
.operations
.ChangeConceptToSynonymOperation
;
22 import eu
.etaxonomy
.taxeditor
.propertysheet
.name
.MisapplicationPropertySource
;
29 public class MisappliedNameComposite
extends NameComposite
{
31 private Taxon misappliedName
;
33 public MisappliedNameComposite(TaxonNameEditor editor
, Composite parent
, Taxon misappliedName
) {
34 super(editor
, parent
, NameComposite
.MISAPPLIED_NAME
, misappliedName
);
36 this.taxon
= editor
.getTaxon();
37 this.misappliedName
= misappliedName
;
40 setIcon(MISAPPLIEDNAME_ICON
);
41 setFont(getViewerFont());
42 setIndent(MISAPPLIEDNAME_INDENT
);
46 initTextViewer(misappliedName
);
49 private void showSec() {
50 if (misappliedName
== null) {
54 if (misappliedName
.getSec() == null) {
55 setNonEditableInfo("sec. ???");
57 setNonEditableInfo("sec. " + misappliedName
.getSec().getTitleCache());
61 public Taxon
getMisappliedName() {
62 return misappliedName
;
65 public boolean setParent(Composite parent
) {
67 boolean doSetParent
= false;
69 // Has this been moved to a HomotypicalGroup?
70 if (parent
instanceof HomotypicalGroupComposite
) {
72 HomotypicalGroup homotypicalGroup
=
73 ((HomotypicalGroupComposite
)parent
).getGroup();
75 IUndoableOperation operation
= new ChangeConceptToSynonymOperation
76 ("change misapplication to synonym", editor
.getUndoContext(), taxon
, misappliedName
, homotypicalGroup
, editor
);
77 EditorUtil
.executeOperation(operation
);
84 public IPropertySource
getPropertySource() {
85 return new MisapplicationPropertySource(misappliedName
);
89 protected Font
getViewerFont() {
90 return MISAPPLIEDNAME_FONT
;
93 protected void calculateErrors() {
94 super.calculateErrors();
96 textViewer
.setShowSecError(misappliedName
);
100 protected TaxonNameBase
<?
, ?
> getName() {
101 return misappliedName
.getName();
104 public Object
getData () {
105 return getMisappliedName();