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;
import de.hsadmin.model.TicketService;
import de.hsadmin.web.I18N;
public interface HSAdminSession {
@ -12,4 +13,6 @@ public interface HSAdminSession {
public String getUser();
public I18N getI18N();
}

View File

@ -29,31 +29,32 @@ public class CustomerPanel extends CustomComponent implements IHSPanel, Selected
@Override
public TabSheet createTabs(Object itemId) throws RpcException
{
final I18N i18n = session.getI18N();
final TabSheet tabsheet = new TabSheet();
tabsheet.setSizeFull();
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");
usersTab.fillTable();
tabsheet.addTab(usersTab, I18N.getText("contact"));
tabsheet.addTab(usersTab, i18n.getText("contact"));
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");
assetsTab.getPanelToolbar().setUpdateEnabled(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");
assetsTab1.getPanelToolbar().setUpdateEnabled(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");
tabsheet.addTab(pacTab, I18N.getText("pac"));
tabsheet.addTab(pacTab, i18n.getText("pac"));
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) {
this.checkboxes = new HashMap<>();
this.propertyInfo = propertyInfo;
this.setCaption(I18N.getText(propertyInfo.getName()));
final I18N i18n = session.getI18N();
this.setCaption(i18n.getText(propertyInfo.getName()));
layout = new VerticalLayout();
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);
layout.addComponent(checkBox);
}
layout.setCaption(I18N.getText(propertyInfo.getName()));
layout.setCaption(i18n.getText(propertyInfo.getName()));
setCompositionRoot(layout);
}

View File

@ -29,11 +29,12 @@ public class DomainPanel extends CustomComponent implements IHSPanel, SelectedTa
@Override
public TabSheet createTabs(Object itemId) throws RpcException
{
final I18N i18n = session.getI18N();
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");
emailTab.fillTable();
tabsheet.addTab(emailTab, I18N.getText("emailaddress"));
tabsheet.addTab(emailTab, i18n.getText("emailaddress"));
return tabsheet;
}

View File

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

View File

@ -24,6 +24,7 @@ import de.hsadmin.rpc.RpcException;
public class EntryPointsSelector extends CustomComponent implements ItemClickListener, SelectedTabChangeListener {
private static final long serialVersionUID = 1L;
private final MainWindow mainWindow;
private Accordion accordion;
@ -45,7 +46,7 @@ public class EntryPointsSelector extends CustomComponent implements ItemClickLis
final AbstractEntryPointsFactory entryPointsFactory = FactoryProducer.getEntryPointsFactory(mainWindow, "default");
int tabCount = 0;
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++;
}
if (tabCount > 0) {

View File

@ -13,9 +13,9 @@ public class FactoryProducer {
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) {

View File

@ -21,6 +21,13 @@ import de.hsadmin.rpc.enums.ReadWritePolicy;
public class GenericEditorFactory implements IEditorFactory, Serializable {
private static final long serialVersionUID = 1L;
private final I18N i18n;
public GenericEditorFactory(I18N i18n) {
this.i18n = i18n;
}
@Override
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) {
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.setEnabled(isWriteAble(propertyInfo, action));
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) {
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.setEnabled(isWriteAble(propertyInfo, action));
return field;
@ -136,7 +143,7 @@ public class GenericEditorFactory implements IEditorFactory, Serializable {
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.setEnabled(isWriteAble(propertyInfo, action));
return field;
@ -145,7 +152,7 @@ public class GenericEditorFactory implements IEditorFactory, Serializable {
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.setValue("xyz00-");
enableAndValidate(action, propertyInfo, field);
@ -155,7 +162,7 @@ public class GenericEditorFactory implements IEditorFactory, Serializable {
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 HSSelect field = new HSSelect(propertyInfo, 7, Arrays.asList(items));
final HSSelect field = new HSSelect(i18n, propertyInfo, 7, Arrays.asList(items));
field.setWidth("100%");
field.setEnabled(isWriteAble(propertyInfo, action));
return field;
@ -163,7 +170,7 @@ public class GenericEditorFactory implements IEditorFactory, Serializable {
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.setEnabled(isWriteAble(propertyInfo, action));
return field;
@ -187,7 +194,7 @@ public class GenericEditorFactory implements IEditorFactory, Serializable {
// TODO Auto-generated catch block
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.setWidth("100%");
return field;
@ -195,7 +202,7 @@ public class GenericEditorFactory implements IEditorFactory, Serializable {
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.setEnabled("new".equals(action) || "edit".equals(action));
return field;
@ -203,7 +210,7 @@ public class GenericEditorFactory implements IEditorFactory, Serializable {
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%");
enableAndValidate(action, propertyInfo, field);
return field;

View File

@ -33,7 +33,7 @@ public class GenericForm extends CustomComponent {
while (iterator.hasNext()) {
final PropertyInfo propertyInfo = iterator.next();
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);
inputFields.put(inputName, 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)
{
super(I18N.getText(action) + " " + I18N.getText(module));
super(session.getI18N().getText(action) + " " + session.getI18N().getText(module));
I18N i18n = session.getI18N();
this.parent = parent;
center();
setModal(true);
@ -40,7 +41,7 @@ public class GenericFormWindow extends Window implements IHSWindow {
continue;
}
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);
inputFields.put(inputName, field);
contentForm.addComponent(field);

View File

@ -1,5 +1,7 @@
package de.hsadmin.web;
import java.util.Locale;
import javax.servlet.annotation.WebServlet;
import com.vaadin.annotations.Theme;
@ -34,6 +36,16 @@ public class HSAdminUI extends UI {
@Override
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();
layout = new VerticalLayout();
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.addClickListener(new ClickListener()
{

View File

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

View File

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

View File

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

View File

@ -13,8 +13,8 @@ public class HSSelect extends NativeSelect implements IHSEditor {
private final String propertyName;
public HSSelect(final PropertyInfo propertyInfo, final int defaultIndex, final List<String> values) {
super(I18N.getText(propertyInfo.getResourceId()));
public HSSelect(final I18N i18n, final PropertyInfo propertyInfo, final int defaultIndex, final List<String> values) {
super(i18n.getText(propertyInfo.getResourceId()));
this.propertyName = propertyInfo.getName();
super.addItems(values);
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.CustomComponent;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Table;
import com.vaadin.ui.VerticalLayout;
@ -149,7 +148,7 @@ public class HSTab extends CustomComponent {
while (properties.hasNext()) {
final PropertyInfo propertyInfo = properties.next();
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);

View File

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

View File

@ -14,7 +14,7 @@ public class HelpWindow extends Window {
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
super("Help Window");
setWidth("80%");
@ -25,7 +25,7 @@ public class HelpWindow extends Window {
final VerticalLayout subContent = new VerticalLayout();
subContent.setMargin(true);
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));
helpContent.setSizeFull();
subContent.addComponent(helpContent);

View File

@ -1,35 +1,38 @@
package de.hsadmin.web;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
public class I18N {
private static final ResourceBundle TEXTS = ResourceBundle.getBundle("de.hsadmin.web.main");
private static final String BASE_NAME = "de.hsadmin.web.main";
/**
* Loads a String resource from the *.properties files.
*
* @param optionallyQualifiedTextProperty
* ID of the resource, optionally qualified module the module name,
* 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 static String getText(final String optionallyQualifiedTextProperty) {
public static I18N loc(final Locale locale) {
return new I18N(ResourceBundle.getBundle(BASE_NAME, locale));
}
private final ResourceBundle bundle;
public I18N(final ResourceBundle bundle) {
this.bundle = bundle;
}
public String getText(final String optionallyQualifiedTextProperty) {
String textValue = getTextImpl(optionallyQualifiedTextProperty);
return textValue != null ? textValue : "./. " + optionallyQualifiedTextProperty;
}
public static String getTextImpl(final String optionallyQualifiedTextProperty) {
private String getTextImpl(final String optionallyQualifiedTextProperty) {
try {
return I18N.TEXTS.getString(optionallyQualifiedTextProperty);
return bundle.getString(optionallyQualifiedTextProperty);
} catch(MissingResourceException e1) {
String[] parts = optionallyQualifiedTextProperty.split(".", 2);
if ( parts.length > 1 ) {
return getTextImpl(parts[1]);
}
}
return null;
return null;
}
}

View File

@ -14,5 +14,5 @@ public interface IHSEditor extends Component {
public void addValidator(Validator validator);
public boolean isValid();
}

View File

@ -4,7 +4,6 @@ import java.util.HashMap;
import java.util.Map;
import com.vaadin.event.ShortcutAction.KeyCode;
import com.vaadin.server.ExternalResource;
import com.vaadin.ui.AbstractTextField;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
@ -13,7 +12,6 @@ import com.vaadin.ui.Component;
import com.vaadin.ui.FormLayout;
import com.vaadin.ui.HasComponents;
import com.vaadin.ui.Label;
import com.vaadin.ui.Link;
import com.vaadin.ui.PasswordField;
import com.vaadin.ui.TextField;
import com.vaadin.ui.Window;
@ -27,7 +25,8 @@ public class LoginWindow extends Window {
private static final long serialVersionUID = 1L;
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();
setModal(true);
setWidth("480px");
@ -35,11 +34,11 @@ public class LoginWindow extends Window {
final FormLayout subContent = new FormLayout();
subContent.setMargin(true);
final TextField login = new TextField(I18N.getText("user.name"));
final TextField login = new TextField(i18n.getText("user.name"));
login.setWidth("100%");
subContent.addComponent(login);
login.focus();
final PasswordField password = new PasswordField(I18N.getText("password"));
final PasswordField password = new PasswordField(i18n.getText("password"));
password.setWidth("100%");
subContent.addComponent(password);
final Label feedback = new Label("");
@ -48,7 +47,7 @@ public class LoginWindow extends Window {
subContent.addComponent(feedback);
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.setClickShortcut(KeyCode.ENTER);
okButton.addClickListener(new ClickListener()
@ -74,9 +73,9 @@ public class LoginWindow extends Window {
}
}
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 password = credentials.get(I18N.getText("password"));
final String password = credentials.get(i18n.getText("password"));
final String grantingTicket = ticketService.getGrantingTicket(loginUser, password);
if (grantingTicket != null && !grantingTicket.isEmpty()) {
feedback.setValue("successful login");
@ -99,8 +98,6 @@ public class LoginWindow extends Window {
}
});
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);
}

View File

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

View File

@ -52,7 +52,7 @@ public class MainToolbar extends CustomComponent implements ClickListener {
final Button btn = new Button();
btn.setId(name + "-btn");
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.addClickListener(this);
return btn;

View File

@ -31,6 +31,7 @@ public class MainWindow extends CustomComponent implements HSAdminSession {
final private TicketService ticketService;
final private String grantingTicket;
final private String username;
final private I18N i18n;
private ModulesManager modulesManager;
private AbstractSplitPanel content;
@ -39,6 +40,7 @@ public class MainWindow extends CustomComponent implements HSAdminSession {
this.ticketService = ticketService;
this.grantingTicket = grantingTicket;
this.username = username;
this.i18n = I18N.loc(getUI().getLocale());
setSizeFull();
final Panel mainPanel = new Panel();
@ -63,7 +65,7 @@ public class MainWindow extends CustomComponent implements HSAdminSession {
final EntryPointsSelector entryPoints = new EntryPointsSelector(this);
entryPoints.setSizeFull();
content.setFirstComponent(entryPoints);
content.setSecondComponent(new MainPanel());
content.setSecondComponent(new MainPanel(i18n));
content.setSplitPosition(26.6f);
} catch (RpcException | TechnicalException e) {
LOG.fatal(e.getLocalizedMessage(), e);
@ -126,4 +128,9 @@ public class MainWindow extends CustomComponent implements HSAdminSession {
public String getUser() {
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();
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");
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");
tabsheet.addTab(aliasTab, I18N.getText("emailalias"));
tabsheet.addTab(aliasTab, session.getI18N().getText("emailalias"));
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");
tabsheet.addTab(mysqluserTab, I18N.getText("mysqluser"));
tabsheet.addTab(mysqluserTab, session.getI18N().getText("mysqluser"));
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");
tabsheet.addTab(postgresqluserTab, I18N.getText("postgresqluser"));
tabsheet.addTab(postgresqluserTab, session.getI18N().getText("postgresqluser"));
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;
}

View File

@ -60,7 +60,7 @@ public class PanelToolbar extends HorizontalLayout implements ClickListener {
if (image != null) {
btn.setIcon(new ThemeResource("../icons/" + image + "-icon.png"));
}
btn.setDescription(I18N.getText(tooltip));
btn.setDescription(session.getI18N().getText(tooltip));
btn.setStyleName("borderless");
btn.addClickListener(this);
return btn;
@ -88,7 +88,7 @@ public class PanelToolbar extends HorizontalLayout implements ClickListener {
final Object value = parent.getSelection();
if (value == null) {
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;
}
}

View File

@ -16,7 +16,7 @@ public class SubWindowFactory extends AbstractWindowFactory {
return null;
}
if (action.equalsIgnoreCase("help")) {
return new HelpWindow(parent.getModule());
return new HelpWindow(session.getI18N(), parent.getModule());
}
final Map<String, String> whereContext = new HashMap<>();
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)
{
super(I18N.getText("edit") + " " + I18N.getText("user"));
super(session.getI18N().getText("edit") + " " + session.getI18N().getText("user"));
center();
setModal(true);
setWidth("640px");
@ -42,7 +42,7 @@ public class UserProfileWindow extends Window implements IHSWindow {
final PropertyInfo propertyInfo = iterator.next();
final String inputName = propertyInfo.getName();
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);
inputFields.put(inputName, field);
contentForm.addComponent(field);