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
.ui
.section
.description
;
13 import org
.eclipse
.jface
.action
.Action
;
14 import org
.eclipse
.jface
.action
.ToolBarManager
;
15 import org
.eclipse
.jface
.viewers
.ISelectionProvider
;
16 import org
.eclipse
.swt
.SWT
;
17 import org
.eclipse
.swt
.widgets
.Control
;
19 import eu
.etaxonomy
.cdm
.api
.conversation
.ConversationHolder
;
20 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionElementBase
;
21 import eu
.etaxonomy
.cdm
.model
.description
.TextData
;
22 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
23 import eu
.etaxonomy
.taxeditor
.store
.StoreUtil
;
24 import eu
.etaxonomy
.taxeditor
.ui
.campanula
.compatibility
.ICdmFormElement
;
25 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
26 import eu
.etaxonomy
.taxeditor
.ui
.section
.AbstractCdmDetailElement
;
27 import eu
.etaxonomy
.taxeditor
.ui
.section
.AbstractCdmDetailSection
;
28 import eu
.etaxonomy
.taxeditor
.ui
.section
.description
.operation
.ChangeDescriptionElementType
;
31 * <p>DescriptionElementDetailSection class.</p>
34 * @created Mar 5, 2010
37 public class DescriptionElementDetailSection
extends
38 AbstractCdmDetailSection
<DescriptionElementBase
> {
41 * <p>Constructor for DescriptionElementDetailSection.</p>
43 * @param cdmFormFactory a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object.
44 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
45 * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} object.
46 * @param selectionProvider a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
49 public DescriptionElementDetailSection(CdmFormFactory cdmFormFactory
, ConversationHolder conversation
,
50 ICdmFormElement parentElement
, ISelectionProvider selectionProvider
, int style
) {
51 super(cdmFormFactory
, conversation
, parentElement
, selectionProvider
, style
);
56 protected Control
createToolbar() {
57 if(! hasSpecificElement()){
61 ToolBarManager toolBarManager
= new ToolBarManager(SWT
.FLAT
);
63 final String destinationString
= (getEntity() instanceof TextData
) ?
"the specific element" : "free text";
65 final String label
= "Change to " + destinationString
;
67 Action addAction
= new Action("Change Type", Action
.AS_PUSH_BUTTON
) {
69 * @see org.eclipse.jface.action.Action#run()
73 boolean confirmed
= StoreUtil
.confirmDialog("Confirmation", "Do you really want to change to "
74 + destinationString
+ "? Current data will be lost.");
77 ChangeDescriptionElementType operation
= new ChangeDescriptionElementType(label
,
78 getEntity(), StoreUtil
.getDetailsView(), StoreUtil
.getUndoContext());
79 StoreUtil
.executeOperation(operation
);
83 // TODO enable this once a proper icon has been found
84 // addAction.setImageDescriptor(new ImageDescriptor() {
87 // public ImageData getImageData() {
88 // return ImageResources.getImage(ImageResources.ADD_ICON).getImageData();
91 addAction
.setToolTipText(label
);
93 toolBarManager
.add(addAction
);
95 return toolBarManager
.createControl(this);
100 public String
getHeading() {
101 return "Description Element";
106 protected void setSectionTitle() {
107 this.setText(getHeading() + ": " + getEntity().getFeature().getLabel(CdmStore
.getDefaultLanguage()));
108 setTextClient(createToolbar());
111 private boolean hasSpecificElement(){
112 return getEntity().getFeature().isSupportsCategoricalData()
113 || getEntity().getFeature().isSupportsCommonTaxonName()
114 || getEntity().getFeature().isSupportsDistribution()
115 || getEntity().getFeature().isSupportsIndividualAssociation()
116 || getEntity().getFeature().isSupportsQuantitativeData()
117 || getEntity().getFeature().isSupportsTaxonInteraction();
121 * @see eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection#createCdmDetailElement(eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection, int)
124 protected AbstractCdmDetailElement
<DescriptionElementBase
> createCdmDetailElement(AbstractCdmDetailSection
<DescriptionElementBase
> parentElement
, int style
) {
125 return formFactory
.createDescriptionElementDetailElement(parentElement
, style
);