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
.Feature
;
22 import eu
.etaxonomy
.cdm
.model
.description
.TextData
;
23 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
24 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
25 import eu
.etaxonomy
.taxeditor
.store
.StoreUtil
;
26 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
27 import eu
.etaxonomy
.taxeditor
.ui
.element
.ICdmFormElement
;
28 import eu
.etaxonomy
.taxeditor
.ui
.section
.AbstractCdmDetailElement
;
29 import eu
.etaxonomy
.taxeditor
.ui
.section
.AbstractCdmDetailSection
;
30 import eu
.etaxonomy
.taxeditor
.ui
.section
.description
.operation
.ChangeDescriptionElementType
;
33 * <p>DescriptionElementDetailSection class.</p>
36 * @created Mar 5, 2010
39 public class DescriptionElementDetailSection
extends
40 AbstractCdmDetailSection
<DescriptionElementBase
> {
43 * <p>Constructor for DescriptionElementDetailSection.</p>
45 * @param cdmFormFactory a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object.
46 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
47 * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} object.
48 * @param selectionProvider a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
51 public DescriptionElementDetailSection(CdmFormFactory cdmFormFactory
, ConversationHolder conversation
,
52 ICdmFormElement parentElement
, ISelectionProvider selectionProvider
, int style
) {
53 super(cdmFormFactory
, conversation
, parentElement
, selectionProvider
, style
);
58 protected Control
createToolbar() {
60 ToolBarManager toolBarManager
= new ToolBarManager(SWT
.FLAT
);
62 final String destinationString
= (getEntity().isInstanceOf(TextData
.class)) ?
"the specific element" : "free text";
64 final String label
= "Change to " + destinationString
;
66 Action addAction
= new Action("Change Type", Action
.AS_PUSH_BUTTON
) {
68 * @see org.eclipse.jface.action.Action#run()
72 boolean confirmed
= MessagingUtils
.confirmDialog("Confirmation", "Do you really want to change to "
73 + destinationString
+ "? Current data will be lost.");
76 ChangeDescriptionElementType operation
= new ChangeDescriptionElementType(label
,
77 getEntity(), StoreUtil
.getDetailsView(), StoreUtil
.getUndoContext());
78 StoreUtil
.executeOperation(operation
);
82 // 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()));
109 if(IsMoreThanOneTypeSupported()){
110 setTextClient(createToolbar());
114 private boolean IsMoreThanOneTypeSupported(){
116 Feature feature
= getEntity().getFeature();
117 if(feature
.isSupportsCategoricalData()){count
++;}
118 if(feature
.isSupportsCommonTaxonName()){count
++;}
119 if(feature
.isSupportsDistribution()){count
++;}
120 if(feature
.isSupportsIndividualAssociation()){count
++;}
121 if(feature
.isSupportsQuantitativeData()){count
++;}
122 if(feature
.isSupportsTaxonInteraction()){count
++;}
123 if(feature
.isSupportsTextData()){count
++;}
128 * @see eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection#createCdmDetailElement(eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection, int)
131 protected AbstractCdmDetailElement
<DescriptionElementBase
> createCdmDetailElement(AbstractCdmDetailSection
<DescriptionElementBase
> parentElement
, int style
) {
132 return formFactory
.createDescriptionElementDetailElement(parentElement
, style
);