This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Index: ../../git/magnolia-5.4-repo/ui/magnolia-ui-dialog/src/main/java/info/magnolia/ui/dialog/formdialog/FormPresenterImpl.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>UTF-8 | |
| =================================================================== | |
| --- ../../git/magnolia-5.4-repo/ui/magnolia-ui-dialog/src/main/java/info/magnolia/ui/dialog/formdialog/FormPresenterImpl.java (revision 7203fef314cb301f7e023083337f688ba63b90af) | |
| +++ ../../git/magnolia-5.4-repo/ui/magnolia-ui-dialog/src/main/java/info/magnolia/ui/dialog/formdialog/FormPresenterImpl.java (revision ) | |
| @@ -35,6 +35,7 @@ | |
| import info.magnolia.ui.api.app.SubAppContext; | |
| import info.magnolia.ui.api.context.UiContext; | |
| +import info.magnolia.ui.api.i18n.I18NAuthoringSupport; | |
| import info.magnolia.ui.form.FormItem; | |
| import info.magnolia.ui.form.FormPresenter; | |
| import info.magnolia.ui.form.definition.FormDefinition; | |
| @@ -86,10 +87,13 @@ | |
| private Item itemDatasource; | |
| + private final I18NAuthoringSupport i18nAuthoringSupport; | |
| + | |
| @Inject | |
| - public FormPresenterImpl(FormBuilder formBuilder, UiContext uiContext) { | |
| + public FormPresenterImpl(FormBuilder formBuilder, UiContext uiContext, I18NAuthoringSupport i18nAuthoringSupport) { | |
| this.formBuilder = formBuilder; | |
| this.uiContext = uiContext; | |
| + this.i18nAuthoringSupport = i18nAuthoringSupport; | |
| } | |
| @Override | |
| @@ -104,11 +108,17 @@ | |
| // We should expand locale-awareness onto all the UI contexts. | |
| if (uiContext instanceof SubAppContext) { | |
| - this.activeLocale = ((SubAppContext)uiContext).getAuthoringLocale(); | |
| + this.activeLocale = ((SubAppContext) uiContext).getAuthoringLocale(); | |
| + | |
| + // In case active Local does not exist, get default locale instead | |
| + if (this.activeLocale == null) { | |
| + this.activeLocale = i18nAuthoringSupport.getDefaultLocale(item); | |
| + } | |
| + | |
| formView.setListener(new FormView.Listener() { | |
| @Override | |
| public void localeChanged(Locale newLocale) { | |
| - if (newLocale != null && !ObjectUtils.equals(((SubAppContext)uiContext).getAuthoringLocale(), newLocale)) { | |
| + if (newLocale != null && !ObjectUtils.equals(((SubAppContext) uiContext).getAuthoringLocale(), newLocale)) { | |
| setLocale(newLocale); | |
| } | |
| } | |
| @@ -134,7 +144,7 @@ | |
| if (uiContext instanceof SubAppContext && !ObjectUtils.equals(locale, this.activeLocale)) { | |
| final Locale formerLocale = this.activeLocale; | |
| this.activeLocale = locale; | |
| - ((SubAppContext)uiContext).setAuthoringLocale(locale); | |
| + ((SubAppContext) uiContext).setAuthoringLocale(locale); | |
| final Map<TabDefinition, FormSection> currentFormSections = localeToFormSections.get(formerLocale); | |
| final Map<TabDefinition, FormSection> newFormSections = getLocaleSpecificFormSections(this.activeLocale); | |
| Index: ../../git/magnolia-5.4-repo/ui/magnolia-ui-dialog/src/test/java/info/magnolia/ui/dialog/formdialog/FormPresenterImplTest.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>UTF-8 | |
| =================================================================== | |
| --- ../../git/magnolia-5.4-repo/ui/magnolia-ui-dialog/src/test/java/info/magnolia/ui/dialog/formdialog/FormPresenterImplTest.java (revision 7203fef314cb301f7e023083337f688ba63b90af) | |
| +++ ../../git/magnolia-5.4-repo/ui/magnolia-ui-dialog/src/test/java/info/magnolia/ui/dialog/formdialog/FormPresenterImplTest.java (revision ) | |
| @@ -114,7 +114,7 @@ | |
| doReturn(mock(BasicTransformer.class)).when(componentProvider).newInstance(eq(BasicTransformer.class), anyVararg()); | |
| this.item = new PropertysetItem(); | |
| this.formBuilder = new FormBuilder(fieldFactoryFactory, i18NAuthoringSupport, subAppContext, componentProvider); | |
| - this.formPresenter = new FormPresenterImpl(formBuilder, subAppContext); | |
| + this.formPresenter = new FormPresenterImpl(formBuilder, subAppContext, i18NAuthoringSupport); | |
| this.formView = new ItemFormView(i18n); | |
| } | |
| \ No newline at end of file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment