From b30eea31f8a303f00f7c1d3e3f23fe8181576d47 Mon Sep 17 00:00:00 2001
From: Patrick Plitzner
Date: Tue, 29 Mar 2016 15:03:26 +0200
Subject: [PATCH] Only show "Change Type" when more than one type is available
#5565
---
.../DescriptionElementDetailSection.java | 29 +++++++++++--------
1 file changed, 17 insertions(+), 12 deletions(-)
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/description/DescriptionElementDetailSection.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/description/DescriptionElementDetailSection.java
index 48131bf00..c66e67a93 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/description/DescriptionElementDetailSection.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/description/DescriptionElementDetailSection.java
@@ -18,6 +18,7 @@ import org.eclipse.swt.widgets.Control;
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
+import eu.etaxonomy.cdm.model.description.Feature;
import eu.etaxonomy.cdm.model.description.TextData;
import eu.etaxonomy.taxeditor.model.MessagingUtils;
import eu.etaxonomy.taxeditor.store.CdmStore;
@@ -55,13 +56,10 @@ public class DescriptionElementDetailSection extends
@Override
protected Control createToolbar() {
- if(! hasSpecificElement()){
- return null;
- }
ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
- final String destinationString = (getEntity() instanceof TextData) ? "the specific element" : "free text";
+ final String destinationString = (getEntity().isInstanceOf(TextData.class)) ? "the specific element" : "free text";
final String label = "Change to " + destinationString;
@@ -107,16 +105,23 @@ public class DescriptionElementDetailSection extends
@Override
protected void setSectionTitle() {
this.setText(getHeading() + ": " + getEntity().getFeature().getLabel(CdmStore.getDefaultLanguage()));
- setTextClient(createToolbar());
+
+ if(IsMoreThanOneTypeSupported()){
+ setTextClient(createToolbar());
+ }
}
- private boolean hasSpecificElement(){
- return getEntity().getFeature().isSupportsCategoricalData()
- || getEntity().getFeature().isSupportsCommonTaxonName()
- || getEntity().getFeature().isSupportsDistribution()
- || getEntity().getFeature().isSupportsIndividualAssociation()
- || getEntity().getFeature().isSupportsQuantitativeData()
- || getEntity().getFeature().isSupportsTaxonInteraction();
+ private boolean IsMoreThanOneTypeSupported(){
+ int count = 0;
+ Feature feature = getEntity().getFeature();
+ if(feature.isSupportsCategoricalData()){count++;}
+ if(feature.isSupportsCommonTaxonName()){count++;}
+ if(feature.isSupportsDistribution()){count++;}
+ if(feature.isSupportsIndividualAssociation()){count++;}
+ if(feature.isSupportsQuantitativeData()){count++;}
+ if(feature.isSupportsTaxonInteraction()){count++;}
+ if(feature.isSupportsTextData()){count++;}
+ return count > 1;
}
/* (non-Javadoc)
--
2.34.1