3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
11 package eu
.etaxonomy
.taxeditor
.section
.description
;
13 import org
.apache
.log4j
.Logger
;
14 import org
.eclipse
.jface
.action
.Action
;
15 import org
.eclipse
.jface
.action
.ToolBarManager
;
16 import org
.eclipse
.jface
.viewers
.ISelectionProvider
;
17 import org
.eclipse
.swt
.SWT
;
18 import org
.eclipse
.swt
.widgets
.Control
;
20 import eu
.etaxonomy
.cdm
.api
.conversation
.ConversationHolder
;
21 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionElementBase
;
22 import eu
.etaxonomy
.cdm
.model
.description
.TextData
;
23 import eu
.etaxonomy
.taxeditor
.editor
.EditorUtil
;
24 import eu
.etaxonomy
.taxeditor
.forms
.CdmFormFactory
;
25 import eu
.etaxonomy
.taxeditor
.forms
.CdmFormFactory
.DetailType
;
26 import eu
.etaxonomy
.taxeditor
.forms
.ICdmFormElement
;
27 import eu
.etaxonomy
.taxeditor
.operations
.ChangeDescriptionElementType
;
28 import eu
.etaxonomy
.taxeditor
.section
.AbstractCdmDetailSection
;
29 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
32 * <p>DescriptionElementDetailSection class.</p>
35 * @created Mar 5, 2010
38 public class DescriptionElementDetailSection
extends
39 AbstractCdmDetailSection
<DescriptionElementBase
> {
41 private static final Logger logger
= Logger
42 .getLogger(DescriptionElementDetailSection
.class);
45 * <p>Constructor for DescriptionElementDetailSection.</p>
47 * @param cdmFormFactory a {@link eu.etaxonomy.taxeditor.forms.CdmFormFactory} object.
48 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
49 * @param parentElement a {@link eu.etaxonomy.taxeditor.forms.ICdmFormElement} object.
50 * @param selectionProvider a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
53 public DescriptionElementDetailSection(CdmFormFactory cdmFormFactory
, ConversationHolder conversation
,
54 ICdmFormElement parentElement
, ISelectionProvider selectionProvider
, int style
) {
55 super(cdmFormFactory
, conversation
, parentElement
, selectionProvider
, style
);
59 private Control
createToolbar() {
60 if(! hasSpecificElement()){
64 ToolBarManager toolBarManager
= new ToolBarManager(SWT
.FLAT
);
66 final String destinationString
= (getEntity() instanceof TextData
) ?
"the specific element" : "free text";
68 final String label
= "Change to " + destinationString
;
70 Action addAction
= new Action("Change Type", Action
.AS_PUSH_BUTTON
) {
72 * @see org.eclipse.jface.action.Action#run()
76 boolean confirmed
= EditorUtil
.confirmDialog("Confirmation", "Do you really want to change to "
77 + destinationString
+ "? Current data will be lost.");
79 ChangeDescriptionElementType operation
= new ChangeDescriptionElementType(label
,
80 getEntity(), EditorUtil
.getDetailsView(), EditorUtil
.getActiveMultiPageTaxonEditor().getUndoContext());
81 EditorUtil
.executeOperation(operation
);
85 // TODO enable this once a proper icon has been found
86 // addAction.setImageDescriptor(new ImageDescriptor() {
89 // public ImageData getImageData() {
90 // return ImageResources.getImage(ImageResources.ADD_ICON).getImageData();
93 addAction
.setToolTipText(label
);
95 toolBarManager
.add(addAction
);
97 ICdmFormElement parentElement
= this.getParentElement();
100 return toolBarManager
.createControl(this);
105 public String
getHeading() {
106 return "Description Element";
111 protected DetailType
getDetailType() {
112 return DetailType
.DESCRIPTIONELEMENT
;
117 protected void setSectionTitle() {
118 this.setText(getHeading() + ": " + getEntity().getFeature().getLabel(CdmStore
.getDefaultLanguage()));
119 setTextClient(createToolbar());
122 private boolean hasSpecificElement(){
123 return getEntity().getFeature().isSupportsCategoricalData()
124 || getEntity().getFeature().isSupportsCommonTaxonName()
125 || getEntity().getFeature().isSupportsDistribution()
126 || getEntity().getFeature().isSupportsIndividualAssociation()
127 || getEntity().getFeature().isSupportsQuantitativeData()
128 || getEntity().getFeature().isSupportsTaxonInteraction();