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 if (super.setParent(parent
)) {
69 // If this has been moved to the misapplied names group, do nothing
70 if (parent
instanceof MisappliedGroupComposite
) {
74 // Has this been moved to a HomotypicalGroup?
75 if (parent
instanceof HomotypicalGroupComposite
) {
77 HomotypicalGroup homotypicalGroup
=
78 ((HomotypicalGroupComposite
)parent
).getGroup();
80 IUndoableOperation operation
= new ChangeConceptToSynonymOperation
81 ("change misapplication to synonym", editor
.getUndoContext(), taxon
, misappliedName
, homotypicalGroup
, editor
);
82 EditorUtil
.executeOperation(operation
);
90 public IPropertySource
getPropertySource() {
91 return new MisapplicationPropertySource(misappliedName
);
95 protected Font
getViewerFont() {
96 return MISAPPLIEDNAME_FONT
;
99 protected void calculateErrors() {
100 super.calculateErrors();
102 textViewer
.setShowSecError(misappliedName
);
106 protected TaxonNameBase
<?
, ?
> getName() {
107 return misappliedName
.getName();
110 public Object
getData () {
111 return getMisappliedName();