Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
public class ClientSession extends AbstractClientSession {

public static final String PREF_USER_LOCALE = "PREF_USER_LOCALE";
public static final String PREF_USER_LAYOUT = "PREF_USER_LAYOUT";

public ClientSession() {
super(true);
Expand All @@ -35,12 +36,15 @@ public static ClientSession get() {
protected void execLoadSession() {
initializeSharedVariables();

// The locale needs to be set before the Desktop is created.
String denseLayout = ClientUIPreferences.getClientPreferences(get()).get(PREF_USER_LAYOUT, null);
String localeString = ClientUIPreferences.getClientPreferences(get()).get(PREF_USER_LOCALE, null);

// The locale needs to be set before the Desktop is created.
if (localeString != null) {
setLocale(Locale.forLanguageTag(localeString));
}

setDesktop(new Desktop());
getDesktop().setDense(Boolean.parseBoolean(denseLayout));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,9 @@ protected String getConfiguredTitle() {

@Override
protected void execInitForm() {
String theme = ObjectUtility.nvl(getDesktop().getTheme(), DefaultCode.ID);
getUiThemeField().setValue(theme);
getUiThemeField().setValue(ObjectUtility.nvl(getDesktop().getTheme(), DefaultCode.ID));
getDenseRadioButtonGroup().setValue(getDesktop().isDense());

String localeString = ClientUIPreferences.getClientPreferences(ClientSession.get()).get(ClientSession.PREF_USER_LOCALE, null);
if (localeString != null) {
getLocaleField().setValue(Locale.forLanguageTag(localeString));
}
getLocaleField().setValue(ObjectUtility.nvl(ClientSession.get().getLocale(), Locale.getDefault()));
}

public MainBox getMainBox() {
Expand All @@ -70,15 +65,22 @@ public LocaleField getLocaleField() {

protected void storeOptions() {
// Not inside form handler, because the form is used in a FormToolButton without a handler
getDesktop().setTheme(getUiThemeField().getValue());
getDesktop().setDense(getDenseRadioButtonGroup().getValue());
boolean denseLayout = ObjectUtility.nvl(getDenseRadioButtonGroup().getValue(), false);
Locale locale = ObjectUtility.nvl(getLocaleField().getValue(), Locale.getDefault());

boolean layoutChanged = ClientUIPreferences.getClientPreferences(ClientSession.get()).put(ClientSession.PREF_USER_LAYOUT, String.valueOf(denseLayout));
boolean localeChanged = ClientUIPreferences.getClientPreferences(ClientSession.get()).put(ClientSession.PREF_USER_LOCALE, locale.toLanguageTag());
if (localeChanged) {

getDesktop().setTheme(getUiThemeField().getValue());
getDesktop().setDense(denseLayout);

if (layoutChanged || localeChanged) {
ClientUIPreferences.getClientPreferences(ClientSession.get()).flush();
MessageBoxes.createOk()
.withBody(TEXTS.get("ChangeOfLanguageAppliedOnNextLogin"))
.show();
if(localeChanged) {
MessageBoxes.createOk()
.withBody(TEXTS.get("ChangeOfLanguageAppliedOnNextLogin"))
.show();
}
}
}

Expand Down Expand Up @@ -186,7 +188,7 @@ protected boolean getConfiguredStatusVisible() {

@Override
protected Class<? extends ILookupCall<Locale>> getConfiguredLookupCall() {
return (Class<? extends ILookupCall<Locale>>) AvailableLocaleLookupCall.class;
return AvailableLocaleLookupCall.class;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
package org.eclipse.scout.contacts.client.person;

import java.util.Date;
import java.util.regex.Pattern;

import org.eclipse.scout.contacts.client.Icons;
import org.eclipse.scout.contacts.client.common.AbstractDirtyFormHandler;
import org.eclipse.scout.contacts.client.common.AbstractEmailField;
import org.eclipse.scout.contacts.client.common.ContactsHelper;
import org.eclipse.scout.contacts.client.common.CountryLookupCall;
import org.eclipse.scout.contacts.client.common.MapHelper;
Expand Down Expand Up @@ -637,33 +637,7 @@ protected String getConfiguredLabel() {
// tag::email[]
@Order(40)
@ClassId("5f9d9363-8e57-4151-b281-7d401e64702c")
public class EmailField extends AbstractStringField {

// end::email[]
// http://www.mkyong.com/regular-expressions/how-to-validate-email-address-with-regular-expression/
// tag::email[]
private static final String EMAIL_PATTERN = // <1>
"^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@" +
"[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$";

@Override
protected String getConfiguredLabel() {
return TEXTS.get("Email");
}

@Override // <2>
protected int getConfiguredMaxLength() {
return 64;
}

@Override // <3>
protected String execValidateValue(String rawValue) {
if (rawValue != null && !Pattern.matches(EMAIL_PATTERN, rawValue)) {
throw new VetoException(TEXTS.get("BadEmailAddress")); // <4>
}

return rawValue; // <5>
}
public class EmailField extends AbstractEmailField {
}
// end::email[]
// tag::layout[]
Expand Down Expand Up @@ -720,12 +694,7 @@ protected String getConfiguredLabel() {

@Order(40)
@ClassId("7f693443-ec4e-47fb-874e-b31328cc22fb")
public class EmailWorkField extends AbstractStringField {

@Override
protected String getConfiguredLabel() {
return TEXTS.get("Email");
}
public class EmailWorkField extends AbstractEmailField {
}
// tag::layout[]
// tag::organizationField[]
Expand Down