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
<Taxon
> {
31 public MisappliedNameComposite(TaxonNameEditor editor
, Composite parent
, Taxon misappliedName
) {
32 super(editor
, parent
, misappliedName
);
38 * @see eu.etaxonomy.taxeditor.editor.name.NameComposite#initializeComposite()
41 protected void initializeComposite() {
43 setIcon(MISAPPLIEDNAME_ICON
);
44 setFont(getViewerFont());
45 setIndent(MISAPPLIEDNAME_INDENT
);
49 initTextViewer(getMisappliedName());
52 private void showSec() {
53 if (getMisappliedName() == null) {
57 if (getMisappliedName().getSec() == null) {
58 setNonEditableInfo("sec. ???");
60 setNonEditableInfo("sec. " + getMisappliedName().getSec().getTitleCache());
64 public Taxon
getMisappliedName() {
65 return getTaxonBase();
68 public boolean setParent(Composite parent
) {
70 boolean doSetParent
= false;
72 // Has this been moved to a HomotypicalGroup?
73 if (parent
instanceof HomotypicalGroupComposite
) {
75 HomotypicalGroup homotypicalGroup
=
76 ((HomotypicalGroupComposite
)parent
).getGroup();
78 IUndoableOperation operation
= new ChangeConceptToSynonymOperation
79 ("change misapplication to synonym", editor
.getUndoContext(), taxon
, getMisappliedName(), homotypicalGroup
, editor
);
80 EditorUtil
.executeOperation(operation
);
87 public IPropertySource
getPropertySource() {
88 return new MisapplicationPropertySource(getMisappliedName());
92 protected Font
getViewerFont() {
93 return MISAPPLIEDNAME_FONT
;
96 protected void calculateErrors() {
97 super.calculateErrors();
99 textViewer
.setShowSecError(getMisappliedName());
103 protected TaxonNameBase
<?
, ?
> getName() {
104 return getMisappliedName().getName();
107 public Object
getData () {
108 return getMisappliedName();