9eecdde69ee9c71d0cd59215dc1f4b0b1dce5c4b
[taxeditor.git] / eclipseprojects / eu.etaxonomy.taxeditor / src / eu / etaxonomy / taxeditor / editor / name / AcceptedNameComposite.java
1 /**
2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
5 *
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.
8 */
9 package eu.etaxonomy.taxeditor.editor.name;
10
11 import org.apache.log4j.Logger;
12 import org.eclipse.jface.action.Action;
13 import org.eclipse.swt.graphics.Font;
14 import org.eclipse.swt.widgets.Composite;
15 import org.eclipse.ui.forms.IManagedForm;
16 import org.eclipse.ui.views.properties.IPropertySource;
17
18 import eu.etaxonomy.cdm.model.taxon.Taxon;
19 import eu.etaxonomy.taxeditor.actions.ui.ChangeTaxonToSynonymAction;
20 import eu.etaxonomy.taxeditor.actions.ui.MoveTaxonDialogAction;
21 import eu.etaxonomy.taxeditor.editor.ContextMenu;
22
23 /**
24 * @author p.ciardelli
25 * @created 13.01.2009
26 * @version 1.0
27 */
28 public class AcceptedNameComposite extends NameComposite {
29 private static final Logger logger = Logger
30 .getLogger(AcceptedNameComposite.class);
31
32 public AcceptedNameComposite(Composite groupComposite, IManagedForm form,
33 Taxon taxon) {
34 super(groupComposite, form, NameComposite.ACCEPTED_TAXON, taxon);
35
36 setDraggable(false);
37 setIcon(ACCEPTED_ICON);
38 setFont(getViewerFont());
39 setIndent(ACCEPTED_INDENT);
40
41 createMenu();
42
43 initNameViewer(taxon);
44 }
45
46 private void createMenu() {
47 ContextMenu contextMenu = createContextMenu();
48
49 // TODO Make action "Create autonym and subspecies"
50
51 Action changeTaxonAction = new ChangeTaxonToSynonymAction(getTaxon());
52 contextMenu.addAction(changeTaxonAction);
53
54 Action moveTaxonAction = new MoveTaxonDialogAction(getTaxon());
55 contextMenu.addAction(moveTaxonAction);
56 }
57
58 @Override
59 public IPropertySource getPropertySource() {
60 if (getTaxon() == null) {
61 return null;
62 }
63 return getPropertySourceByName(getTaxon().getName());
64 }
65
66 @Override
67 protected Font getViewerFont() {
68 return ACCEPTED_FONT;
69 }
70 }