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
.eclipse
.swt
.graphics
.Font
;
13 import org
.eclipse
.swt
.graphics
.Image
;
14 import org
.eclipse
.swt
.widgets
.Composite
;
15 import org
.eclipse
.ui
.views
.properties
.IPropertySource
;
17 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionElementBase
;
18 import eu
.etaxonomy
.taxeditor
.editor
.GroupedComposite
;
19 import eu
.etaxonomy
.taxeditor
.propertysheet
.description
.DescriptionElementPropertySource
;
20 import eu
.etaxonomy
.taxeditor
.store
.model
.DescriptionUtil
;
21 import eu
.etaxonomy
.taxeditor
.store
.model
.ImageResources
;
22 import eu
.etaxonomy
.taxeditor
.store
.model
.Resources
;
29 public class DescriptionElementComposite
extends GroupedComposite
{
32 * ************ COMPOSITE TYPES ************
34 public static final String TEXT_DATA
= "text_data";
35 public static final String COMMON_TAXON_NAME
= "common_taxon_name";
36 public static final String DISTRIBUTION
= "distribution";
39 * ************ FONTS ************
41 public static final Font ELEMENT_FONT
= Resources
42 .getFont(Resources
.SYNONYM_FONT
);
45 * ************ ICONS ************
47 public static final Image BLACK_SQUARE_ICON
= ImageResources
48 .getImage(ImageResources
.BLACK_SQUARE_ICON
);
50 protected DescriptionElementBase element
;
52 private static final String EMPTY_NAME_PROMPT
= "Click to add descriptive element text";
54 public DescriptionElementComposite(TaxonDescriptionEditor editor
, Composite parent
, DescriptionElementBase element
) {
55 super(editor
, parent
);
57 this.element
= element
;
61 createBorderSupport();
62 createLineWrapSupport();
65 createEmptyViewerPrompt(EMPTY_NAME_PROMPT
);
67 setIsDraggable(false);
68 setIcon(BLACK_SQUARE_ICON
);
69 setFont(getViewerFont());
72 this.setMenu(editor
.getMenu());
77 protected void initTextViewer() {
81 text
= DescriptionUtil
.getCache(element
);
83 if (text
.length() == 0) {
86 textViewer
.getTextWidget().setText(text
);
90 public DescriptionElementBase
getElement() {
94 protected void parse(String text
) {
96 DescriptionUtil
.setCache(getElement(), text
);
98 // Manually refresh the property sheet to reflect changes
104 public IPropertySource
getPropertySource() {
105 return new DescriptionElementPropertySource(getElement());
109 protected Font
getViewerFont() {
113 public Object
getData () {