switched to cdmlib 2.0
[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.swt.graphics.Font;
13 import org.eclipse.swt.widgets.Composite;
14 import org.eclipse.ui.forms.IManagedForm;
15 import org.eclipse.ui.views.properties.IPropertySource;
16
17 import eu.etaxonomy.cdm.model.taxon.Taxon;
18 import eu.etaxonomy.taxeditor.actions.ui.ChangeTaxonToSynonymAction;
19 import eu.etaxonomy.taxeditor.actions.ui.MoveTaxonDialogAction;
20 import eu.etaxonomy.taxeditor.editor.ContextMenu;
21
22 /**
23 * @author p.ciardelli
24 * @created 13.01.2009
25 * @version 1.0
26 */
27 public class AcceptedNameComposite extends NameComposite {
28 @SuppressWarnings("unused")
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 contextMenu.addAction(new ChangeTaxonToSynonymAction(getTaxon()));
50 contextMenu.addAction(new MoveTaxonDialogAction(getTaxon()));
51
52 // TODO Make action "Create autonym and subspecies"
53 // contextMenu.addSeparator();
54 //
55 // contextMenu.addAction(new CreateAutonym(getTaxon()));
56 // contextMenu.addAction(new CreateSubspecies(getTaxon()));
57 }
58
59 @Override
60 public IPropertySource getPropertySource() {
61 if (getTaxon() == null) {
62 return null;
63 }
64 return getPropertySourceByName(getTaxon().getName());
65 }
66
67 @Override
68 protected Font getViewerFont() {
69 return ACCEPTED_FONT;
70 }
71 }