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
.description
;
12 import org
.apache
.log4j
.Logger
;
13 import org
.eclipse
.core
.commands
.operations
.IUndoableOperation
;
14 import org
.eclipse
.jface
.action
.Action
;
15 import org
.eclipse
.jface
.resource
.ImageDescriptor
;
16 import org
.eclipse
.swt
.graphics
.Font
;
17 import org
.eclipse
.swt
.graphics
.Image
;
18 import org
.eclipse
.swt
.widgets
.Composite
;
19 import org
.eclipse
.ui
.views
.properties
.IPropertySource
;
21 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionElementBase
;
22 import eu
.etaxonomy
.taxeditor
.editor
.ContextMenu
;
23 import eu
.etaxonomy
.taxeditor
.editor
.EditorUtil
;
24 import eu
.etaxonomy
.taxeditor
.editor
.GroupedComposite
;
25 import eu
.etaxonomy
.taxeditor
.propertysheet
.description
.DescriptionElementPropertySource
;
26 import eu
.etaxonomy
.taxeditor
.store
.model
.DescriptionUtil
;
27 import eu
.etaxonomy
.taxeditor
.store
.model
.ImageResources
;
28 import eu
.etaxonomy
.taxeditor
.store
.model
.Resources
;
29 import eu
.etaxonomy
.taxeditor
.store
.operations
.DeleteDescriptionElementOperation
;
36 public class DescriptionElementComposite
extends GroupedComposite
{
37 private static final Logger logger
= Logger
.getLogger(DescriptionElementComposite
.class);
40 * ************ COMPOSITE TYPES ************
42 public static final String TEXT_DATA
= "text_data";
43 public static final String COMMON_TAXON_NAME
= "common_taxon_name";
44 public static final String DISTRIBUTION
= "distribution";
47 * ************ FONTS ************
49 public static final Font ELEMENT_FONT
= Resources
50 .getFont(Resources
.SYNONYM_FONT
);
53 * ************ ICONS ************
55 public static final Image BLACK_SQUARE_ICON
= ImageResources
56 .getImage(ImageResources
.BLACK_SQUARE_ICON
);
58 protected DescriptionElementBase element
;
60 private static final String EMPTY_NAME_PROMPT
= "Click to add descriptive element text";
62 public DescriptionElementComposite(TaxonDescriptionEditor editor
, Composite parent
, DescriptionElementBase element
) {
63 super(editor
, parent
);
65 this.element
= element
;
69 createBorderSupport();
70 createLineWrapSupport();
73 createEmptyViewerPrompt(EMPTY_NAME_PROMPT
);
75 setIsDraggable(false);
76 setIcon(BLACK_SQUARE_ICON
);
77 setFont(getViewerFont());
80 this.setMenu(editor
.getMenu());
85 protected void initTextViewer() {
89 text
= DescriptionUtil
.getCache(element
);
91 if (text
.length() == 0) {
94 textViewer
.getTextWidget().setText(text
);
98 public DescriptionElementBase
getElement() {
102 protected void parse(String text
) {
104 DescriptionUtil
.setCache(getElement(), text
);
106 // Manually refresh the property sheet to reflect changes
112 public IPropertySource
getPropertySource() {
113 return new DescriptionElementPropertySource(getElement());
117 protected Font
getViewerFont() {
121 public Object
getData () {