Project

General

Profile

« Previous | Next » 

Revision b30eea31

Added by Patrick Plitzner about 8 years ago

Only show "Change Type" when more than one type is available #5565

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/description/DescriptionElementDetailSection.java
18 18

  
19 19
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
20 20
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
21
import eu.etaxonomy.cdm.model.description.Feature;
21 22
import eu.etaxonomy.cdm.model.description.TextData;
22 23
import eu.etaxonomy.taxeditor.model.MessagingUtils;
23 24
import eu.etaxonomy.taxeditor.store.CdmStore;
......
55 56

  
56 57
	@Override
57 58
    protected Control createToolbar() {
58
		if(! hasSpecificElement()){
59
			return null;
60
		}
61 59

  
62 60
		ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
63 61

  
64
		final String destinationString = (getEntity() instanceof TextData) ? "the specific element" : "free text";
62
		final String destinationString = (getEntity().isInstanceOf(TextData.class)) ? "the specific element" : "free text";
65 63

  
66 64
		final String label = "Change to " + destinationString;
67 65

  
......
107 105
	@Override
108 106
	protected void setSectionTitle() {
109 107
		this.setText(getHeading() + ": " + getEntity().getFeature().getLabel(CdmStore.getDefaultLanguage()));
110
		setTextClient(createToolbar());
108

  
109
        if(IsMoreThanOneTypeSupported()){
110
            setTextClient(createToolbar());
111
        }
111 112
	}
112 113

  
113
	private boolean hasSpecificElement(){
114
		return  getEntity().getFeature().isSupportsCategoricalData()
115
				|| getEntity().getFeature().isSupportsCommonTaxonName()
116
				|| getEntity().getFeature().isSupportsDistribution()
117
				|| getEntity().getFeature().isSupportsIndividualAssociation()
118
				|| getEntity().getFeature().isSupportsQuantitativeData()
119
				|| getEntity().getFeature().isSupportsTaxonInteraction();
114
	private boolean IsMoreThanOneTypeSupported(){
115
	    int count = 0;
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++;}
124
	    return count > 1;
120 125
	}
121 126

  
122 127
	/* (non-Javadoc)

Also available in: Unified diff