My First try is:
public MultiLangugeText(Composite parent, int style) {
super(parent, style);
setLayout(new RowLayout(SWT.HORIZONTAL));
Map<Locale, String> texts = new HashMap<Locale, String>();
texts.put(Locale.GERMAN, "Hey du");
texts.put(Locale.ENGLISH, "Hey you");
texts.put(Locale.FRENCH, "Bon Jour");
setTexts(texts);
public void setTexts(Map<Locale, String> texts) {
for (Locale locale : texts.keySet()) {
createTextComposite(locale, texts.get(locale));
}
}
private void createTextComposite(Locale locle, String localizedString) {
Composite composite = formToolkit.createComposite(this, SWT.BORDER);
formToolkit.paintBordersFor(composite);
composite.setLayout(new RowLayout(SWT.HORIZONTAL));
CLabel label = new CLabel(composite, SWT.NONE);
label.setText(locle.toString());
formToolkit.adapt(label);
formToolkit.paintBordersFor(label);
Text txtString = new Text(composite, SWT.BORDER);
txtString.setText(localizedString);
formToolkit.adapt(txtString, true, true);
}
But this code will not draw anything on my UI. At least when I try to render it in the Deisigner and in the Preview. I have to tests if this works, when I use it in my application. But I don't get where error is.
Okay it only fails in the designer, not when you actually use the composite elsewehre.