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
.images
;
12 import org
.apache
.log4j
.Logger
;
13 import org
.eclipse
.swt
.graphics
.Font
;
14 import org
.eclipse
.swt
.graphics
.Image
;
15 import org
.eclipse
.swt
.widgets
.Composite
;
16 import org
.eclipse
.ui
.views
.properties
.IPropertySource
;
18 import eu
.etaxonomy
.cdm
.model
.description
.TaxonDescription
;
19 import eu
.etaxonomy
.taxeditor
.editor
.AbstractTaxonEditor
;
20 import eu
.etaxonomy
.taxeditor
.editor
.GroupedComposite
;
21 import eu
.etaxonomy
.taxeditor
.model
.ImageResources
;
22 import eu
.etaxonomy
.taxeditor
.model
.Resources
;
23 import eu
.etaxonomy
.taxeditor
.propertysheet
.description
.TaxonDescriptionPropertySource
;
26 * Composite for editing a description's label / Title Cache information.
33 public class GalleryLabelComposite
extends GroupedComposite
{
34 private static final Logger logger
= Logger
35 .getLogger(GalleryLabelComposite
.class);
38 * ************ FONTS ************
40 public static final Font DESCRIPTION_LABEL_FONT
= Resources
41 .getFont(Resources
.ACCEPTED_TAXON_FONT
);
44 * ************ ICONS ************
46 public static final Image DESCRIPTION_LABEL_ICON
= ImageResources
47 .getImage(ImageResources
.BLACK_SQUARE_ICON
);
49 private static final String EMPTY_NAME_PROMPT
= "Click to add label for image gallery";
51 private TaxonDescription description
;
53 public GalleryLabelComposite(AbstractTaxonEditor editor
, Composite parent
, TaxonDescription description
) {
54 super(editor
, parent
);
56 this.description
= description
;
60 createBorderSupport();
61 createLineWrapSupport();
64 createEmptyViewerPrompt(EMPTY_NAME_PROMPT
);
66 setIsDraggable(false);
67 setFont(DESCRIPTION_LABEL_FONT
);
68 setIcon(DESCRIPTION_LABEL_ICON
);
70 this.setMenu(editor
.getMenu());
75 private void initTextViewer() {
76 if (textViewer
!= null) {
77 String text
= getDescription().getTitleCache();
79 if (text
.length() == 0) {
82 textViewer
.getTextWidget().setText(text
);
85 logger
.warn("TextViewer is null.");
89 public TaxonDescription
getDescription() {
94 // * FIXME migrate menu to plugin.xml configuration
96 // private void createMenu() {
98 // MenuManager featuresMenu = new MenuManager("Add description element");
99 // featuresMenu.setRemoveAllWhenShown(true);
100 // featuresMenu.addMenuListener(new IMenuListener() {
101 // public void menuAboutToShow(IMenuManager manager) {
102 // for (final Feature feature : PreferencesUtil.getPreferredFeatures()) {
104 // String text = feature.getLabel();
105 // manager.add(new Action(text){
107 // public void run() {
108 // IUndoableOperation operation = new CreateDescriptionElementOperation
109 // (this.getText(), editor.getUndoContext(), taxon, description, feature, editor);
110 // EditorUtil.executeOperation(operation);
117 // // Important: add an empty action. Otherwise, when the main menu sees that
118 // // there are no actions in the submenu, it will not be shown
120 // featuresMenu.add(new Action() {});
122 // ContextMenu contextMenu = createContextMenu();
123 // contextMenu.addSubmenu(featuresMenu);
126 protected void parse(String text
) {
127 getDescription().setTitleCache(text
);
129 // Manually refresh the property sheet to reflect changes
135 public IPropertySource
getPropertySource() {
136 return new TaxonDescriptionPropertySource(getDescription());
140 protected Font
getViewerFont() {
141 return DESCRIPTION_LABEL_FONT
;
144 public Object
getData () {
145 return getDescription();