Project

General

Profile

Revision d98abaef

IDd98abaef29b5433d727b786aaf14af258495c631
Parent 717636b2
Child e5c6119c

Added by Patrick Plitzner over 3 years ago

ref #4302 Escape '&' in section titles

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/StoreUtil.java
119 119
		return TaxeditorStorePlugin.PLUGIN_ID;
120 120
	}
121 121

  
122
    /**
123
     * Cleans title string for output in section titles<br>
124
     * E.g. escapes '&' with "&&" to avoid mnemonic handling (see
125
     * Label.setText() documentation)<br>
126
     * see also #4302
127
     *
128
     * @param title
129
     *            the title string to clean
130
     * @return the cleaned title string
131
     */
132
	public static String cleanTitleString(String title){
133
	    return title.replace("&", "&&");
134
	}
135

  
122 136
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/AbstractCdmDetailSection.java
29 29
import eu.etaxonomy.cdm.model.description.TextData;
30 30
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
31 31
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
32
import eu.etaxonomy.taxeditor.store.StoreUtil;
32 33
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
33 34
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
34 35
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
......
74 75
        }
75 76
	}
76 77

  
78
	@Override
79
	public void setText(String title) {
80
	    super.setText(StoreUtil.cleanTitleString(title));
81
	}
82

  
77 83
	protected void createControlsByType(AbstractCdmDetailSection<ENTITY> formElement, Class<ENTITY> entityClass, int style) {
78 84
	    TableWrapLayout layout = (TableWrapLayout) getLayoutComposite().getLayout();
79 85
	    layout.topMargin = 10;
......
159 165
				label =((IdentifiableEntity) getEntity()).getTitleCache();
160 166
			}
161 167
			title = ": " + label;
162

  
163
			// we have to duplicate ampersands otherwise they are treated as
164
			// mnenomic (see Label.setText() documentation)
165
			// see also #4302
166
			title = title.replace("&", "&&");
167 168
		}
168 169
		this.setText(String.format("%s%s", getHeading(), title));
169 170
		setTextClient(createToolbar());
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/supplemental/HeadlineSection.java
7 7
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
8 8
import eu.etaxonomy.cdm.model.common.ICdmBase;
9 9
import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
10
import eu.etaxonomy.taxeditor.store.StoreUtil;
10 11
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
11 12
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
12 13
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
......
37 38
		ICdmBase entity = HibernateProxyHelper.deproxy(cdmBase);
38 39
		super.setEntity(entity);
39 40

  
40
		setText(entity.getClass().getSimpleName() + (entity instanceof IdentifiableEntity ? ": " + ((IdentifiableEntity) entity).generateTitle() : ""));
41
		String simpleName = entity.getClass().getSimpleName();
42
        String titleString = entity instanceof IdentifiableEntity ? ": " + ((IdentifiableEntity) entity).generateTitle() : "";
43
        titleString = StoreUtil.cleanTitleString(titleString);
44
        setText(simpleName + titleString);
41 45
		layout();
42 46
	}
43 47

  

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)