fix i18n issue

This commit is contained in:
Peter Hormanns 2017-07-20 19:17:50 +02:00
parent bbf5f1389f
commit 5ad5f1b827
29 changed files with 127 additions and 92 deletions

View File

@ -1,6 +1,7 @@
package de.hsadmin.rpc; package de.hsadmin.rpc;
import de.hsadmin.model.TicketService; import de.hsadmin.model.TicketService;
import de.hsadmin.web.I18N;
public interface HSAdminSession { public interface HSAdminSession {
@ -12,4 +13,6 @@ public interface HSAdminSession {
public String getUser(); public String getUser();
public I18N getI18N();
} }

View File

@ -29,31 +29,32 @@ public class CustomerPanel extends CustomComponent implements IHSPanel, Selected
@Override @Override
public TabSheet createTabs(Object itemId) throws RpcException public TabSheet createTabs(Object itemId) throws RpcException
{ {
final I18N i18n = session.getI18N();
final TabSheet tabsheet = new TabSheet(); final TabSheet tabsheet = new TabSheet();
tabsheet.setSizeFull(); tabsheet.setSizeFull();
tabsheet.addSelectedTabChangeListener(this); tabsheet.addSelectedTabChangeListener(this);
tabsheet.addSelectedTabChangeListener(this); tabsheet.addSelectedTabChangeListener(this);
tabsheet.addTab(new GenericForm("customer", session, itemId, "name"), I18N.getText("customer")); tabsheet.addTab(new GenericForm("customer", session, itemId, "name"), i18n.getText("customer"));
final HSTab usersTab = new HSTab("contact", session, "customer", itemId, "email"); final HSTab usersTab = new HSTab("contact", session, "customer", itemId, "email");
usersTab.fillTable(); usersTab.fillTable();
tabsheet.addTab(usersTab, I18N.getText("contact")); tabsheet.addTab(usersTab, i18n.getText("contact"));
final HSTab aliasTab = new HSTab("mandat", session, "customer", itemId, "mandatRef"); final HSTab aliasTab = new HSTab("mandat", session, "customer", itemId, "mandatRef");
tabsheet.addTab(aliasTab, I18N.getText("mandat")); tabsheet.addTab(aliasTab, i18n.getText("mandat"));
final HSTab assetsTab = new HSTab("memberShare", session, "customer", itemId, "id"); final HSTab assetsTab = new HSTab("memberShare", session, "customer", itemId, "id");
assetsTab.getPanelToolbar().setUpdateEnabled(false); assetsTab.getPanelToolbar().setUpdateEnabled(false);
assetsTab.getPanelToolbar().setDeleteEnabled(false); assetsTab.getPanelToolbar().setDeleteEnabled(false);
tabsheet.addTab(assetsTab, I18N.getText("memberShare")); tabsheet.addTab(assetsTab, i18n.getText("memberShare"));
final HSTab assetsTab1 = new HSTab("memberAsset", session, "customer", itemId, "id"); final HSTab assetsTab1 = new HSTab("memberAsset", session, "customer", itemId, "id");
assetsTab1.getPanelToolbar().setUpdateEnabled(false); assetsTab1.getPanelToolbar().setUpdateEnabled(false);
assetsTab1.getPanelToolbar().setDeleteEnabled(false); assetsTab1.getPanelToolbar().setDeleteEnabled(false);
tabsheet.addTab(assetsTab1, I18N.getText("memberAsset")); tabsheet.addTab(assetsTab1, i18n.getText("memberAsset"));
final HSTab pacTab = new HSTab("pac", session, "customer", itemId, "name"); final HSTab pacTab = new HSTab("pac", session, "customer", itemId, "name");
tabsheet.addTab(pacTab, I18N.getText("pac")); tabsheet.addTab(pacTab, i18n.getText("pac"));
return tabsheet; return tabsheet;
} }

View File

@ -27,14 +27,15 @@ public class DomainOptionsEditor extends CustomComponent implements IHSEditor {
public DomainOptionsEditor(final PropertyInfo propertyInfo, final HSAdminSession session, final Map<String, String> whereContext) { public DomainOptionsEditor(final PropertyInfo propertyInfo, final HSAdminSession session, final Map<String, String> whereContext) {
this.checkboxes = new HashMap<>(); this.checkboxes = new HashMap<>();
this.propertyInfo = propertyInfo; this.propertyInfo = propertyInfo;
this.setCaption(I18N.getText(propertyInfo.getName())); final I18N i18n = session.getI18N();
this.setCaption(i18n.getText(propertyInfo.getName()));
layout = new VerticalLayout(); layout = new VerticalLayout();
for (String opt : OPTIONS) { for (String opt : OPTIONS) {
final CheckBox checkBox = new CheckBox(I18N.getText("domainoption." + opt)); final CheckBox checkBox = new CheckBox(i18n.getText("domainoption." + opt));
checkboxes.put(opt, checkBox); checkboxes.put(opt, checkBox);
layout.addComponent(checkBox); layout.addComponent(checkBox);
} }
layout.setCaption(I18N.getText(propertyInfo.getName())); layout.setCaption(i18n.getText(propertyInfo.getName()));
setCompositionRoot(layout); setCompositionRoot(layout);
} }

View File

@ -29,11 +29,12 @@ public class DomainPanel extends CustomComponent implements IHSPanel, SelectedTa
@Override @Override
public TabSheet createTabs(Object itemId) throws RpcException public TabSheet createTabs(Object itemId) throws RpcException
{ {
final I18N i18n = session.getI18N();
final TabSheet tabsheet = new TabSheet(); final TabSheet tabsheet = new TabSheet();
tabsheet.addTab(new GenericForm("domain", session, itemId, "name"), I18N.getText("domain")); tabsheet.addTab(new GenericForm("domain", session, itemId, "name"), i18n.getText("domain"));
HSTab emailTab = new HSTab("emailaddress", session, "domain", itemId, "id"); HSTab emailTab = new HSTab("emailaddress", session, "domain", itemId, "id");
emailTab.fillTable(); emailTab.fillTable();
tabsheet.addTab(emailTab, I18N.getText("emailaddress")); tabsheet.addTab(emailTab, i18n.getText("emailaddress"));
return tabsheet; return tabsheet;
} }

View File

@ -38,18 +38,20 @@ public class EMailTargetEditor extends CustomComponent implements IHSEditor, Val
private final AbstractOrderedLayout layout; private final AbstractOrderedLayout layout;
private final List<String> aliases; private final List<String> aliases;
private final List<String> postboxes; private final List<String> postboxes;
private final I18N i18n;
public EMailTargetEditor(final String action, final PropertyInfo propertyInfo, final HSAdminSession session, final Map<String, String> whereContext) { public EMailTargetEditor(final String action, final PropertyInfo propertyInfo, final HSAdminSession session, final Map<String, String> whereContext) {
this.i18n = session.getI18N();
this.isEditAble = PanelToolbar.ACTION_EDIT.equals(action) || PanelToolbar.ACTION_NEW.equals(action); this.isEditAble = PanelToolbar.ACTION_EDIT.equals(action) || PanelToolbar.ACTION_NEW.equals(action);
this.propertyInfo = propertyInfo; this.propertyInfo = propertyInfo;
this.validators = new ArrayList<>(); this.validators = new ArrayList<>();
this.setCaption(I18N.getText(propertyInfo.getName())); this.setCaption(i18n.getText(propertyInfo.getName()));
this.aliases = targetsSelect("emailalias", session, whereContext); this.aliases = targetsSelect("emailalias", session, whereContext);
this.postboxes = targetsSelect("user", session, whereContext); this.postboxes = targetsSelect("user", session, whereContext);
postboxes.removeAll(aliases); postboxes.removeAll(aliases);
layout = new VerticalLayout(); layout = new VerticalLayout();
layout.setCaption(I18N.getText(propertyInfo.getName())); layout.setCaption(i18n.getText(propertyInfo.getName()));
setCompositionRoot(layout); setCompositionRoot(layout);
} }
@ -175,7 +177,7 @@ public class EMailTargetEditor extends CustomComponent implements IHSEditor, Val
targetTypeSelect.setMultiSelect(false); targetTypeSelect.setMultiSelect(false);
targetTypeSelect.setNullSelectionAllowed(true); targetTypeSelect.setNullSelectionAllowed(true);
targetTypeSelect.setNullSelectionItemId(" "); targetTypeSelect.setNullSelectionItemId(" ");
targetTypeSelect.addItems(new Object[] { " ", I18N.getText("emailtarget.email"), I18N.getText("emailtarget.postbox"), I18N.getText("emailtarget.alias") }); targetTypeSelect.addItems(new Object[] { " ", i18n.getText("emailtarget.email"), i18n.getText("emailtarget.postbox"), i18n.getText("emailtarget.alias") });
targetTypeSelect.setValue(" "); targetTypeSelect.setValue(" ");
targetTypeSelect.setWidth("6.0em"); targetTypeSelect.setWidth("6.0em");
addComponent(targetTypeSelect); addComponent(targetTypeSelect);
@ -184,7 +186,7 @@ public class EMailTargetEditor extends CustomComponent implements IHSEditor, Val
AbstractComponent targetField = null; AbstractComponent targetField = null;
NativeSelect sel = null; NativeSelect sel = null;
if (aliases.contains(target)) { if (aliases.contains(target)) {
targetTypeSelect.setValue(I18N.getText("emailtarget.alias")); targetTypeSelect.setValue(i18n.getText("emailtarget.alias"));
sel = new NativeSelect(); sel = new NativeSelect();
sel.addItems(aliases); sel.addItems(aliases);
sel.setValue(target); sel.setValue(target);
@ -193,7 +195,7 @@ public class EMailTargetEditor extends CustomComponent implements IHSEditor, Val
targetField = sel; targetField = sel;
} else { } else {
if (postboxes.contains(target)) { if (postboxes.contains(target)) {
targetTypeSelect.setValue(I18N.getText("emailtarget.postbox")); targetTypeSelect.setValue(i18n.getText("emailtarget.postbox"));
sel = new NativeSelect(); sel = new NativeSelect();
sel.addItems(postboxes); sel.addItems(postboxes);
sel.setValue(target); sel.setValue(target);
@ -201,7 +203,7 @@ public class EMailTargetEditor extends CustomComponent implements IHSEditor, Val
sel.setEnabled(isEditAble); sel.setEnabled(isEditAble);
targetField = sel; targetField = sel;
} else { } else {
targetTypeSelect.setValue(I18N.getText("emailtarget.email")); targetTypeSelect.setValue(i18n.getText("emailtarget.email"));
targetField = new TextField(); targetField = new TextField();
targetField.setEnabled(isEditAble); targetField.setEnabled(isEditAble);
((TextField) targetField).setValue(target); ((TextField) targetField).setValue(target);
@ -229,16 +231,16 @@ public class EMailTargetEditor extends CustomComponent implements IHSEditor, Val
final String newValue = newValueObject.toString(); final String newValue = newValueObject.toString();
if (targetRow.getComponentCount() == 1) { if (targetRow.getComponentCount() == 1) {
AbstractComponent comp = null; AbstractComponent comp = null;
if (I18N.getText("emailtarget.email").equals(newValue)) { if (i18n.getText("emailtarget.email").equals(newValue)) {
final TextField textField = new TextField(); final TextField textField = new TextField();
textField.addValueChangeListener(editor); textField.addValueChangeListener(editor);
textField.setImmediate(true); textField.setImmediate(true);
textField.setEnabled(isEditAble); textField.setEnabled(isEditAble);
comp = textField; comp = textField;
} else { } else {
if (I18N.getText("emailtarget.alias").equals(newValue) || I18N.getText("emailtarget.postbox").equals(newValue)) { if (i18n.getText("emailtarget.alias").equals(newValue) || i18n.getText("emailtarget.postbox").equals(newValue)) {
final NativeSelect select = new NativeSelect(); final NativeSelect select = new NativeSelect();
if (I18N.getText("emailtarget.alias").equals(newValue)) { if (i18n.getText("emailtarget.alias").equals(newValue)) {
select.addItems(aliases); select.addItems(aliases);
} else { } else {
select.addItems(postboxes); select.addItems(postboxes);

View File

@ -24,6 +24,7 @@ import de.hsadmin.rpc.RpcException;
public class EntryPointsSelector extends CustomComponent implements ItemClickListener, SelectedTabChangeListener { public class EntryPointsSelector extends CustomComponent implements ItemClickListener, SelectedTabChangeListener {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private final MainWindow mainWindow; private final MainWindow mainWindow;
private Accordion accordion; private Accordion accordion;
@ -45,7 +46,7 @@ public class EntryPointsSelector extends CustomComponent implements ItemClickLis
final AbstractEntryPointsFactory entryPointsFactory = FactoryProducer.getEntryPointsFactory(mainWindow, "default"); final AbstractEntryPointsFactory entryPointsFactory = FactoryProducer.getEntryPointsFactory(mainWindow, "default");
int tabCount = 0; int tabCount = 0;
for(String tabName : entryPointsFactory.getEntryPointNames(role)) { for(String tabName : entryPointsFactory.getEntryPointNames(role)) {
accordion.addTab(new EntryPoint(this, tabName), I18N.getText(tabName)); accordion.addTab(new EntryPoint(this, tabName), mainWindow.getI18N().getText(tabName));
tabCount++; tabCount++;
} }
if (tabCount > 0) { if (tabCount > 0) {

View File

@ -13,9 +13,9 @@ public class FactoryProducer {
return new SubWindowFactory(); return new SubWindowFactory();
} }
public static IEditorFactory getEditorFactory(String choice) public static IEditorFactory getEditorFactory(I18N i18n, String choice)
{ {
return new GenericEditorFactory(); return new GenericEditorFactory(i18n);
} }
public static AbstractEntryPointsFactory getEntryPointsFactory(MainWindow window, String choice) { public static AbstractEntryPointsFactory getEntryPointsFactory(MainWindow window, String choice) {

View File

@ -22,6 +22,13 @@ public class GenericEditorFactory implements IEditorFactory, Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private final I18N i18n;
public GenericEditorFactory(I18N i18n) {
this.i18n = i18n;
}
@Override @Override
public IHSEditor getEditor(final String action, final PropertyInfo propertyInfo, final HSAdminSession session, final Map<String, String> whereContext) public IHSEditor getEditor(final String action, final PropertyInfo propertyInfo, final HSAdminSession session, final Map<String, String> whereContext)
{ {
@ -79,7 +86,7 @@ public class GenericEditorFactory implements IEditorFactory, Serializable {
private IHSEditor getMemberShareActionEditor(String action, PropertyInfo propertyInfo, HSAdminSession session, Map<String, String> whereContext) { private IHSEditor getMemberShareActionEditor(String action, PropertyInfo propertyInfo, HSAdminSession session, Map<String, String> whereContext) {
final String[] items = new String[] { "SUBSCRIPTION", "UNSUBSCRIPTION" }; final String[] items = new String[] { "SUBSCRIPTION", "UNSUBSCRIPTION" };
final HSSelect field = new HSSelect(propertyInfo, 0, Arrays.asList(items)); final HSSelect field = new HSSelect(session.getI18N(), propertyInfo, 0, Arrays.asList(items));
field.setWidth("100%"); field.setWidth("100%");
field.setEnabled(isWriteAble(propertyInfo, action)); field.setEnabled(isWriteAble(propertyInfo, action));
return field; return field;
@ -87,7 +94,7 @@ public class GenericEditorFactory implements IEditorFactory, Serializable {
private IHSEditor getMemberAssetActionEditor(String action, PropertyInfo propertyInfo, HSAdminSession session, Map<String, String> whereContext) { private IHSEditor getMemberAssetActionEditor(String action, PropertyInfo propertyInfo, HSAdminSession session, Map<String, String> whereContext) {
final String[] items = new String[] { "PAYMENT", "PAYBACK", "ADOPTION", "HANDOVER", "LOSS", "CLEARING", "PRESCRIPTION" }; final String[] items = new String[] { "PAYMENT", "PAYBACK", "ADOPTION", "HANDOVER", "LOSS", "CLEARING", "PRESCRIPTION" };
final HSSelect field = new HSSelect(propertyInfo, 0, Arrays.asList(items)); final HSSelect field = new HSSelect(session.getI18N(), propertyInfo, 0, Arrays.asList(items));
field.setWidth("100%"); field.setWidth("100%");
field.setEnabled(isWriteAble(propertyInfo, action)); field.setEnabled(isWriteAble(propertyInfo, action));
return field; return field;
@ -136,7 +143,7 @@ public class GenericEditorFactory implements IEditorFactory, Serializable {
private IHSEditor getSelectField(final String action, final PropertyInfo propertyInfo, final String... items) private IHSEditor getSelectField(final String action, final PropertyInfo propertyInfo, final String... items)
{ {
final HSSelect field = new HSSelect(propertyInfo, 0, Arrays.asList(items)); final HSSelect field = new HSSelect(i18n, propertyInfo, 0, Arrays.asList(items));
field.setWidth("100%"); field.setWidth("100%");
field.setEnabled(isWriteAble(propertyInfo, action)); field.setEnabled(isWriteAble(propertyInfo, action));
return field; return field;
@ -145,7 +152,7 @@ public class GenericEditorFactory implements IEditorFactory, Serializable {
private IHSEditor getPacPrefixedField(final String action, final PropertyInfo propertyInfo, final char delimiter) private IHSEditor getPacPrefixedField(final String action, final PropertyInfo propertyInfo, final char delimiter)
{ {
final HSPacPrefixedField field = new HSPacPrefixedField(propertyInfo, delimiter); final HSPacPrefixedField field = new HSPacPrefixedField(i18n, propertyInfo, delimiter);
field.setWidth("100%"); field.setWidth("100%");
field.setValue("xyz00-"); field.setValue("xyz00-");
enableAndValidate(action, propertyInfo, field); enableAndValidate(action, propertyInfo, field);
@ -155,7 +162,7 @@ public class GenericEditorFactory implements IEditorFactory, Serializable {
private IHSEditor getShellSelect(final String action, final PropertyInfo propertyInfo) private IHSEditor getShellSelect(final String action, final PropertyInfo propertyInfo)
{ {
final String[] items = new String[] { "/bin/false", "/bin/bash", "/bin/csh", "/bin/dash", "/bin/ksh", "/bin/tcsh", "/bin/zsh", "/usr/bin/passwd", "/usr/bin/scponly" }; final String[] items = new String[] { "/bin/false", "/bin/bash", "/bin/csh", "/bin/dash", "/bin/ksh", "/bin/tcsh", "/bin/zsh", "/usr/bin/passwd", "/usr/bin/scponly" };
final HSSelect field = new HSSelect(propertyInfo, 7, Arrays.asList(items)); final HSSelect field = new HSSelect(i18n, propertyInfo, 7, Arrays.asList(items));
field.setWidth("100%"); field.setWidth("100%");
field.setEnabled(isWriteAble(propertyInfo, action)); field.setEnabled(isWriteAble(propertyInfo, action));
return field; return field;
@ -163,7 +170,7 @@ public class GenericEditorFactory implements IEditorFactory, Serializable {
private IHSEditor getDateSelect(final String action, final PropertyInfo propertyInfo) private IHSEditor getDateSelect(final String action, final PropertyInfo propertyInfo)
{ {
final HSDateSelect field = new HSDateSelect(propertyInfo); final HSDateSelect field = new HSDateSelect(i18n, propertyInfo);
field.setWidth("100%"); field.setWidth("100%");
field.setEnabled(isWriteAble(propertyInfo, action)); field.setEnabled(isWriteAble(propertyInfo, action));
return field; return field;
@ -187,7 +194,7 @@ public class GenericEditorFactory implements IEditorFactory, Serializable {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
final HSSelect field = new HSSelect(propertyInfo, 0, selectList); final HSSelect field = new HSSelect(i18n, propertyInfo, 0, selectList);
field.setEnabled(isWriteAble(propertyInfo, action)); field.setEnabled(isWriteAble(propertyInfo, action));
field.setWidth("100%"); field.setWidth("100%");
return field; return field;
@ -195,7 +202,7 @@ public class GenericEditorFactory implements IEditorFactory, Serializable {
private IHSEditor getPasswordField(final String action, final PropertyInfo propertyInfo) private IHSEditor getPasswordField(final String action, final PropertyInfo propertyInfo)
{ {
final HSPasswordField field = new HSPasswordField(propertyInfo.getName(), "new".equals(action)); final HSPasswordField field = new HSPasswordField(i18n, propertyInfo.getName(), "new".equals(action));
field.setWidth("100%"); field.setWidth("100%");
field.setEnabled("new".equals(action) || "edit".equals(action)); field.setEnabled("new".equals(action) || "edit".equals(action));
return field; return field;
@ -203,7 +210,7 @@ public class GenericEditorFactory implements IEditorFactory, Serializable {
private IHSEditor getTextField(final String action, final PropertyInfo propertyInfo) private IHSEditor getTextField(final String action, final PropertyInfo propertyInfo)
{ {
final HSTextField field = new HSTextField(propertyInfo); final HSTextField field = new HSTextField(i18n, propertyInfo);
field.setWidth("100%"); field.setWidth("100%");
enableAndValidate(action, propertyInfo, field); enableAndValidate(action, propertyInfo, field);
return field; return field;

View File

@ -33,7 +33,7 @@ public class GenericForm extends CustomComponent {
while (iterator.hasNext()) { while (iterator.hasNext()) {
final PropertyInfo propertyInfo = iterator.next(); final PropertyInfo propertyInfo = iterator.next();
final String inputName = propertyInfo.getName(); final String inputName = propertyInfo.getName();
final IEditorFactory editorFactory = FactoryProducer.getEditorFactory(module); final IEditorFactory editorFactory = FactoryProducer.getEditorFactory(session.getI18N(), module);
final IHSEditor field = editorFactory.getEditor("view", propertyInfo); final IHSEditor field = editorFactory.getEditor("view", propertyInfo);
inputFields.put(inputName, field); inputFields.put(inputName, field);
formLayout.addComponent(field); formLayout.addComponent(field);

View File

@ -24,7 +24,8 @@ public class GenericFormWindow extends Window implements IHSWindow {
public GenericFormWindow(final HSTab parent, final String module, final String action, final HSAdminSession session, final Map<String, String> whereContext) public GenericFormWindow(final HSTab parent, final String module, final String action, final HSAdminSession session, final Map<String, String> whereContext)
{ {
super(I18N.getText(action) + " " + I18N.getText(module)); super(session.getI18N().getText(action) + " " + session.getI18N().getText(module));
I18N i18n = session.getI18N();
this.parent = parent; this.parent = parent;
center(); center();
setModal(true); setModal(true);
@ -40,7 +41,7 @@ public class GenericFormWindow extends Window implements IHSWindow {
continue; continue;
} }
final String inputName = propertyInfo.getName(); final String inputName = propertyInfo.getName();
final IEditorFactory editorFactory = FactoryProducer.getEditorFactory(module); final IEditorFactory editorFactory = FactoryProducer.getEditorFactory(i18n, module);
final IHSEditor field = editorFactory.getEditor(action, propertyInfo, session, whereContext); final IHSEditor field = editorFactory.getEditor(action, propertyInfo, session, whereContext);
inputFields.put(inputName, field); inputFields.put(inputName, field);
contentForm.addComponent(field); contentForm.addComponent(field);

View File

@ -1,5 +1,7 @@
package de.hsadmin.web; package de.hsadmin.web;
import java.util.Locale;
import javax.servlet.annotation.WebServlet; import javax.servlet.annotation.WebServlet;
import com.vaadin.annotations.Theme; import com.vaadin.annotations.Theme;
@ -34,6 +36,16 @@ public class HSAdminUI extends UI {
@Override @Override
protected void init(VaadinRequest request) { protected void init(VaadinRequest request) {
final String acceptLanguageHeader = request.getHeader("Accept-Language");
Locale userLocale = Locale.GERMAN;
if (acceptLanguageHeader.startsWith("en")) {
userLocale = Locale.ENGLISH;
}
if (acceptLanguageHeader.startsWith("es")) {
userLocale = new Locale("es_ES");
}
getUI().setLocale(userLocale);
getSession().setLocale(userLocale);
setSizeFull(); setSizeFull();
layout = new VerticalLayout(); layout = new VerticalLayout();
layout.setSizeFull(); layout.setSizeFull();

View File

@ -85,7 +85,7 @@ public class HSConfirmBox extends HorizontalLayout {
} }
} }
}); });
cancelButton = new Button(I18N.getText("cancel")); cancelButton = new Button(session.getI18N().getText("cancel"));
cancelButton.setClickShortcut(KeyCode.ESCAPE); cancelButton.setClickShortcut(KeyCode.ESCAPE);
cancelButton.addClickListener(new ClickListener() cancelButton.addClickListener(new ClickListener()
{ {

View File

@ -13,8 +13,8 @@ public class HSDateSelect extends DateField implements IHSEditor {
private String field; private String field;
public HSDateSelect(PropertyInfo propertyInfo) { public HSDateSelect(final I18N i18n, PropertyInfo propertyInfo) {
super(I18N.getText(propertyInfo.getResourceId())); super(i18n.getText(propertyInfo.getResourceId()));
field = propertyInfo.getName(); field = propertyInfo.getName();
setConverter(StringToDateConverter.class); setConverter(StringToDateConverter.class);
} }

View File

@ -13,8 +13,8 @@ public class HSPacPrefixedField extends HSTextField implements PacNamePrefixed {
private String pacName; private String pacName;
public HSPacPrefixedField(final PropertyInfo propertyInfo, final char delimiter) { public HSPacPrefixedField(final I18N i18n, final PropertyInfo propertyInfo, final char delimiter) {
super(propertyInfo); super(i18n, propertyInfo);
pacName = "xyz00"; pacName = "xyz00";
this.delimiter = delimiter; this.delimiter = delimiter;
addValidator(new PacNamePrefixValidator(this)); addValidator(new PacNamePrefixValidator(this));

View File

@ -8,8 +8,8 @@ public class HSPasswordField extends PasswordField implements IHSEditor {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public HSPasswordField(final String name, final boolean passwordRequired) { public HSPasswordField(final I18N i18n, final String name, final boolean passwordRequired) {
super(I18N.getText(name)); super(i18n.getText(name));
addValidator(new PasswordValidator(passwordRequired)); addValidator(new PasswordValidator(passwordRequired));
} }

View File

@ -13,8 +13,8 @@ public class HSSelect extends NativeSelect implements IHSEditor {
private final String propertyName; private final String propertyName;
public HSSelect(final PropertyInfo propertyInfo, final int defaultIndex, final List<String> values) { public HSSelect(final I18N i18n, final PropertyInfo propertyInfo, final int defaultIndex, final List<String> values) {
super(I18N.getText(propertyInfo.getResourceId())); super(i18n.getText(propertyInfo.getResourceId()));
this.propertyName = propertyInfo.getName(); this.propertyName = propertyInfo.getName();
super.addItems(values); super.addItems(values);
if (values != null && values.size() > defaultIndex) { if (values != null && values.size() > defaultIndex) {

View File

@ -10,7 +10,6 @@ import org.apache.xmlrpc.XmlRpcException;
import com.vaadin.ui.Alignment; import com.vaadin.ui.Alignment;
import com.vaadin.ui.CustomComponent; import com.vaadin.ui.CustomComponent;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Table; import com.vaadin.ui.Table;
import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.VerticalLayout;
@ -149,7 +148,7 @@ public class HSTab extends CustomComponent {
while (properties.hasNext()) { while (properties.hasNext()) {
final PropertyInfo propertyInfo = properties.next(); final PropertyInfo propertyInfo = properties.next();
if (showColumnInTable(propertyInfo)) { if (showColumnInTable(propertyInfo)) {
grid.addContainerProperty(I18N.getText(propertyInfo.getModule() + "." + propertyInfo.getName()), String.class, ""); grid.addContainerProperty(session.getI18N().getText(propertyInfo.getModule() + "." + propertyInfo.getName()), String.class, "");
} }
} }
grid.setSelectable(true); grid.setSelectable(true);

View File

@ -12,8 +12,8 @@ public class HSTextField extends TextField implements IHSEditor {
private final String propertyName; private final String propertyName;
public HSTextField(final PropertyInfo propertyInfo) { public HSTextField(final I18N i18n, final PropertyInfo propertyInfo) {
super(I18N.getText(propertyInfo.getResourceId())); super(i18n.getText(propertyInfo.getResourceId()));
this.propertyName = propertyInfo.getName(); this.propertyName = propertyInfo.getName();
} }

View File

@ -14,7 +14,7 @@ public class HelpWindow extends Window {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public HelpWindow(final String helpTopic) { public HelpWindow(final I18N i18n, final String helpTopic) {
// Create a sub-window and set the content // Create a sub-window and set the content
super("Help Window"); super("Help Window");
setWidth("80%"); setWidth("80%");
@ -25,7 +25,7 @@ public class HelpWindow extends Window {
final VerticalLayout subContent = new VerticalLayout(); final VerticalLayout subContent = new VerticalLayout();
subContent.setMargin(true); subContent.setMargin(true);
subContent.setSizeFull(); subContent.setSizeFull();
final String helpBaseURL = I18N.getText("help.baseurl"); final String helpBaseURL = i18n.getText("help.baseurl");
final Component helpContent = new BrowserFrame("Help Window", new ExternalResource(helpBaseURL + helpTopic)); final Component helpContent = new BrowserFrame("Help Window", new ExternalResource(helpBaseURL + helpTopic));
helpContent.setSizeFull(); helpContent.setSizeFull();
subContent.addComponent(helpContent); subContent.addComponent(helpContent);

View File

@ -1,28 +1,31 @@
package de.hsadmin.web; package de.hsadmin.web;
import java.util.Locale;
import java.util.MissingResourceException; import java.util.MissingResourceException;
import java.util.ResourceBundle; import java.util.ResourceBundle;
public class I18N { public class I18N {
private static final ResourceBundle TEXTS = ResourceBundle.getBundle("de.hsadmin.web.main"); private static final String BASE_NAME = "de.hsadmin.web.main";
/** public static I18N loc(final Locale locale) {
* Loads a String resource from the *.properties files. return new I18N(ResourceBundle.getBundle(BASE_NAME, locale));
* }
* @param optionallyQualifiedTextProperty
* ID of the resource, optionally qualified module the module name, private final ResourceBundle bundle;
* e.g. "customer.name" (preferred) or simply "name" (legacy).
* @return the String resource, e.g. a label or message, usually to be displayed to the user public I18N(final ResourceBundle bundle) {
*/ this.bundle = bundle;
public static String getText(final String optionallyQualifiedTextProperty) { }
public String getText(final String optionallyQualifiedTextProperty) {
String textValue = getTextImpl(optionallyQualifiedTextProperty); String textValue = getTextImpl(optionallyQualifiedTextProperty);
return textValue != null ? textValue : "./. " + optionallyQualifiedTextProperty; return textValue != null ? textValue : "./. " + optionallyQualifiedTextProperty;
} }
public static String getTextImpl(final String optionallyQualifiedTextProperty) { private String getTextImpl(final String optionallyQualifiedTextProperty) {
try { try {
return I18N.TEXTS.getString(optionallyQualifiedTextProperty); return bundle.getString(optionallyQualifiedTextProperty);
} catch(MissingResourceException e1) { } catch(MissingResourceException e1) {
String[] parts = optionallyQualifiedTextProperty.split(".", 2); String[] parts = optionallyQualifiedTextProperty.split(".", 2);
if ( parts.length > 1 ) { if ( parts.length > 1 ) {

View File

@ -4,7 +4,6 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import com.vaadin.event.ShortcutAction.KeyCode; import com.vaadin.event.ShortcutAction.KeyCode;
import com.vaadin.server.ExternalResource;
import com.vaadin.ui.AbstractTextField; import com.vaadin.ui.AbstractTextField;
import com.vaadin.ui.Button; import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickEvent;
@ -13,7 +12,6 @@ import com.vaadin.ui.Component;
import com.vaadin.ui.FormLayout; import com.vaadin.ui.FormLayout;
import com.vaadin.ui.HasComponents; import com.vaadin.ui.HasComponents;
import com.vaadin.ui.Label; import com.vaadin.ui.Label;
import com.vaadin.ui.Link;
import com.vaadin.ui.PasswordField; import com.vaadin.ui.PasswordField;
import com.vaadin.ui.TextField; import com.vaadin.ui.TextField;
import com.vaadin.ui.Window; import com.vaadin.ui.Window;
@ -27,7 +25,8 @@ public class LoginWindow extends Window {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public LoginWindow(final HSAdminUI parent, final TicketService ticketService) { public LoginWindow(final HSAdminUI parent, final TicketService ticketService) {
super(I18N.getText("login.title")); super(I18N.loc(parent.getSession().getLocale()).getText("login.title"));
final I18N i18n = I18N.loc(parent.getSession().getLocale());
center(); center();
setModal(true); setModal(true);
setWidth("480px"); setWidth("480px");
@ -35,11 +34,11 @@ public class LoginWindow extends Window {
final FormLayout subContent = new FormLayout(); final FormLayout subContent = new FormLayout();
subContent.setMargin(true); subContent.setMargin(true);
final TextField login = new TextField(I18N.getText("user.name")); final TextField login = new TextField(i18n.getText("user.name"));
login.setWidth("100%"); login.setWidth("100%");
subContent.addComponent(login); subContent.addComponent(login);
login.focus(); login.focus();
final PasswordField password = new PasswordField(I18N.getText("password")); final PasswordField password = new PasswordField(i18n.getText("password"));
password.setWidth("100%"); password.setWidth("100%");
subContent.addComponent(password); subContent.addComponent(password);
final Label feedback = new Label(""); final Label feedback = new Label("");
@ -48,7 +47,7 @@ public class LoginWindow extends Window {
subContent.addComponent(feedback); subContent.addComponent(feedback);
feedback.setStyleName(ValoTheme.LABEL_FAILURE); feedback.setStyleName(ValoTheme.LABEL_FAILURE);
final Button okButton = new Button(I18N.getText("login.button")); final Button okButton = new Button(i18n.getText("login.button"));
okButton.setStyleName(ValoTheme.BUTTON_PRIMARY); okButton.setStyleName(ValoTheme.BUTTON_PRIMARY);
okButton.setClickShortcut(KeyCode.ENTER); okButton.setClickShortcut(KeyCode.ENTER);
okButton.addClickListener(new ClickListener() okButton.addClickListener(new ClickListener()
@ -74,9 +73,9 @@ public class LoginWindow extends Window {
} }
} }
try { try {
final String user = credentials.get(I18N.getText("user.name")); final String user = credentials.get(i18n.getText("user.name"));
final String loginUser = user.length() == 3 ? "hsh00-" + user : user; final String loginUser = user.length() == 3 ? "hsh00-" + user : user;
final String password = credentials.get(I18N.getText("password")); final String password = credentials.get(i18n.getText("password"));
final String grantingTicket = ticketService.getGrantingTicket(loginUser, password); final String grantingTicket = ticketService.getGrantingTicket(loginUser, password);
if (grantingTicket != null && !grantingTicket.isEmpty()) { if (grantingTicket != null && !grantingTicket.isEmpty()) {
feedback.setValue("successful login"); feedback.setValue("successful login");
@ -99,8 +98,6 @@ public class LoginWindow extends Window {
} }
}); });
subContent.addComponent(okButton); subContent.addComponent(okButton);
final Link linkToOld = new Link(I18N.getText("main.panel.link_to_old"), new ExternalResource("https://admin.hostsharing.net/hsarweb"));
subContent.addComponent(linkToOld);
setContent(subContent); setContent(subContent);
} }

View File

@ -9,9 +9,9 @@ public class MainPanel extends CustomComponent{
private static final long serialVersionUID = -1085100738394404620L; private static final long serialVersionUID = -1085100738394404620L;
public MainPanel() { public MainPanel(final I18N i18n) {
final String helpBaseURL = I18N.getText("help.baseurl"); final String helpBaseURL = i18n.getText("help.baseurl");
final Component helpContent = new BrowserFrame(I18N.getText("main.panel.title"), new ExternalResource(helpBaseURL + "hsadmin")); final Component helpContent = new BrowserFrame(i18n.getText("main.panel.title"), new ExternalResource(helpBaseURL + "hsadmin"));
helpContent.setSizeFull(); helpContent.setSizeFull();
setCompositionRoot(helpContent); setCompositionRoot(helpContent);
setSizeFull(); setSizeFull();

View File

@ -52,7 +52,7 @@ public class MainToolbar extends CustomComponent implements ClickListener {
final Button btn = new Button(); final Button btn = new Button();
btn.setId(name + "-btn"); btn.setId(name + "-btn");
btn.setIcon(new ThemeResource("../icons/" + icon + "-icon.png")); btn.setIcon(new ThemeResource("../icons/" + icon + "-icon.png"));
btn.setDescription(I18N.getText(name + ".tooltip")); btn.setDescription(session.getI18N().getText(name + ".tooltip"));
btn.setStyleName("borderless"); btn.setStyleName("borderless");
btn.addClickListener(this); btn.addClickListener(this);
return btn; return btn;

View File

@ -31,6 +31,7 @@ public class MainWindow extends CustomComponent implements HSAdminSession {
final private TicketService ticketService; final private TicketService ticketService;
final private String grantingTicket; final private String grantingTicket;
final private String username; final private String username;
final private I18N i18n;
private ModulesManager modulesManager; private ModulesManager modulesManager;
private AbstractSplitPanel content; private AbstractSplitPanel content;
@ -39,6 +40,7 @@ public class MainWindow extends CustomComponent implements HSAdminSession {
this.ticketService = ticketService; this.ticketService = ticketService;
this.grantingTicket = grantingTicket; this.grantingTicket = grantingTicket;
this.username = username; this.username = username;
this.i18n = I18N.loc(getUI().getLocale());
setSizeFull(); setSizeFull();
final Panel mainPanel = new Panel(); final Panel mainPanel = new Panel();
@ -63,7 +65,7 @@ public class MainWindow extends CustomComponent implements HSAdminSession {
final EntryPointsSelector entryPoints = new EntryPointsSelector(this); final EntryPointsSelector entryPoints = new EntryPointsSelector(this);
entryPoints.setSizeFull(); entryPoints.setSizeFull();
content.setFirstComponent(entryPoints); content.setFirstComponent(entryPoints);
content.setSecondComponent(new MainPanel()); content.setSecondComponent(new MainPanel(i18n));
content.setSplitPosition(26.6f); content.setSplitPosition(26.6f);
} catch (RpcException | TechnicalException e) { } catch (RpcException | TechnicalException e) {
LOG.fatal(e.getLocalizedMessage(), e); LOG.fatal(e.getLocalizedMessage(), e);
@ -126,4 +128,9 @@ public class MainWindow extends CustomComponent implements HSAdminSession {
public String getUser() { public String getUser() {
return username; return username;
} }
@Override
public I18N getI18N() {
return i18n;
}
} }

View File

@ -31,23 +31,23 @@ public class PackagePanel extends CustomComponent implements IHSPanel, SelectedT
{ {
final TabSheet tabsheet = new TabSheet(); final TabSheet tabsheet = new TabSheet();
tabsheet.addSelectedTabChangeListener(this); tabsheet.addSelectedTabChangeListener(this);
tabsheet.addTab(new GenericForm("pac", session, itemId, "name"), I18N.getText("pac")); tabsheet.addTab(new GenericForm("pac", session, itemId, "name"), session.getI18N().getText("pac"));
final HSTab usersTab = new HSTab("user", session, "pac", itemId, "name"); final HSTab usersTab = new HSTab("user", session, "pac", itemId, "name");
usersTab.fillTable(); usersTab.fillTable();
tabsheet.addTab(usersTab, I18N.getText("user")); tabsheet.addTab(usersTab, session.getI18N().getText("user"));
final HSTab aliasTab = new HSTab("emailalias", session, "pac", itemId, "name"); final HSTab aliasTab = new HSTab("emailalias", session, "pac", itemId, "name");
tabsheet.addTab(aliasTab, I18N.getText("emailalias")); tabsheet.addTab(aliasTab, session.getI18N().getText("emailalias"));
final HSTab domainTab = new HSTab("domain", session, "pac", itemId, "name"); final HSTab domainTab = new HSTab("domain", session, "pac", itemId, "name");
tabsheet.addTab(domainTab, I18N.getText("domain")); tabsheet.addTab(domainTab, session.getI18N().getText("domain"));
final HSTab mysqluserTab = new HSTab("mysqluser", session, "pac", itemId, "name"); final HSTab mysqluserTab = new HSTab("mysqluser", session, "pac", itemId, "name");
tabsheet.addTab(mysqluserTab, I18N.getText("mysqluser")); tabsheet.addTab(mysqluserTab, session.getI18N().getText("mysqluser"));
final HSTab mysqldbTab = new HSTab("mysqldb", session, "pac", itemId, "name"); final HSTab mysqldbTab = new HSTab("mysqldb", session, "pac", itemId, "name");
tabsheet.addTab(mysqldbTab, I18N.getText("mysqldb")); tabsheet.addTab(mysqldbTab, session.getI18N().getText("mysqldb"));
final HSTab postgresqluserTab = new HSTab("postgresqluser", session, "pac", itemId, "name"); final HSTab postgresqluserTab = new HSTab("postgresqluser", session, "pac", itemId, "name");
tabsheet.addTab(postgresqluserTab, I18N.getText("postgresqluser")); tabsheet.addTab(postgresqluserTab, session.getI18N().getText("postgresqluser"));
final HSTab postgresqldbTab = new HSTab("postgresqldb", session, "pac", itemId, "name"); final HSTab postgresqldbTab = new HSTab("postgresqldb", session, "pac", itemId, "name");
tabsheet.addTab(postgresqldbTab, I18N.getText("postgresqldb")); tabsheet.addTab(postgresqldbTab, session.getI18N().getText("postgresqldb"));
return tabsheet; return tabsheet;
} }

View File

@ -60,7 +60,7 @@ public class PanelToolbar extends HorizontalLayout implements ClickListener {
if (image != null) { if (image != null) {
btn.setIcon(new ThemeResource("../icons/" + image + "-icon.png")); btn.setIcon(new ThemeResource("../icons/" + image + "-icon.png"));
} }
btn.setDescription(I18N.getText(tooltip)); btn.setDescription(session.getI18N().getText(tooltip));
btn.setStyleName("borderless"); btn.setStyleName("borderless");
btn.addClickListener(this); btn.addClickListener(this);
return btn; return btn;
@ -88,7 +88,7 @@ public class PanelToolbar extends HorizontalLayout implements ClickListener {
final Object value = parent.getSelection(); final Object value = parent.getSelection();
if (value == null) { if (value == null) {
if (ACTION_EDIT.equals(action) || ACTION_DELETE.equals(action)) { if (ACTION_EDIT.equals(action) || ACTION_DELETE.equals(action)) {
UI.getCurrent().addWindow(new InfoWindow(I18N.getText("emptySelectionMessage") + " " + action)); UI.getCurrent().addWindow(new InfoWindow(session.getI18N().getText("emptySelectionMessage") + " " + action));
return; return;
} }
} }

View File

@ -16,7 +16,7 @@ public class SubWindowFactory extends AbstractWindowFactory {
return null; return null;
} }
if (action.equalsIgnoreCase("help")) { if (action.equalsIgnoreCase("help")) {
return new HelpWindow(parent.getModule()); return new HelpWindow(session.getI18N(), parent.getModule());
} }
final Map<String, String> whereContext = new HashMap<>(); final Map<String, String> whereContext = new HashMap<>();
whereContext.put(parent.getSelectPropertyName(), parent.getSelectPropertyValue().toString()); whereContext.put(parent.getSelectPropertyName(), parent.getSelectPropertyValue().toString());

View File

@ -28,7 +28,7 @@ public class UserProfileWindow extends Window implements IHSWindow {
public UserProfileWindow(final HSAdminSession session, final Map<String, String> whereContext) public UserProfileWindow(final HSAdminSession session, final Map<String, String> whereContext)
{ {
super(I18N.getText("edit") + " " + I18N.getText("user")); super(session.getI18N().getText("edit") + " " + session.getI18N().getText("user"));
center(); center();
setModal(true); setModal(true);
setWidth("640px"); setWidth("640px");
@ -42,7 +42,7 @@ public class UserProfileWindow extends Window implements IHSWindow {
final PropertyInfo propertyInfo = iterator.next(); final PropertyInfo propertyInfo = iterator.next();
final String inputName = propertyInfo.getName(); final String inputName = propertyInfo.getName();
if (visibleFields.contains(inputName)) { if (visibleFields.contains(inputName)) {
final IEditorFactory editorFactory = FactoryProducer.getEditorFactory("user"); final IEditorFactory editorFactory = FactoryProducer.getEditorFactory(session.getI18N(), "user");
final IHSEditor field = editorFactory.getEditor(inputName.equals("password") ? "edit" : "view", propertyInfo, session, whereContext); final IHSEditor field = editorFactory.getEditor(inputName.equals("password") ? "edit" : "view", propertyInfo, session, whereContext);
inputFields.put(inputName, field); inputFields.put(inputName, field);
contentForm.addComponent(field); contentForm.addComponent(field);