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
);
34 initializeComposite();
39 * @see eu.etaxonomy.taxeditor.editor.name.NameComposite#initializeComposite()
42 protected void initializeComposite() {
44 setIcon(MISAPPLIEDNAME_ICON
);
45 setFont(getViewerFont());
46 setIndent(MISAPPLIEDNAME_INDENT
);
50 initTextViewer(getMisappliedName());
53 private void showSec() {
54 if (getMisappliedName() == null) {
58 if (getMisappliedName().getSec() == null) {
59 setNonEditableInfo("sec. ???");
61 setNonEditableInfo("sec. " + getMisappliedName().getSec().getTitleCache());
65 public Taxon
getMisappliedName() {
66 return getTaxonBase();
69 public boolean setParent(Composite parent
) {
71 boolean doSetParent
= false;
73 // Has this been moved to a HomotypicalGroup?
74 if (parent
instanceof HomotypicalGroupComposite
) {
76 HomotypicalGroup homotypicalGroup
=
77 ((HomotypicalGroupComposite
)parent
).getGroup();
79 IUndoableOperation operation
= new ChangeConceptToSynonymOperation
80 ("change misapplication to synonym", editor
.getUndoContext(), taxon
, getMisappliedName(), homotypicalGroup
, editor
);
81 EditorUtil
.executeOperation(operation
);
88 public IPropertySource
getPropertySource() {
89 return new MisapplicationPropertySource(getMisappliedName());
93 protected Font
getViewerFont() {
94 return MISAPPLIEDNAME_FONT
;
97 protected void calculateErrors() {
98 super.calculateErrors();
100 textViewer
.setShowSecError(getMisappliedName());
104 protected TaxonNameBase
<?
, ?
> getName() {
105 return getMisappliedName().getName();
108 public Object
getData () {
109 return getMisappliedName();