@Override public void initialise() { WidgetUtil.tryBindCheckbox(this, "disableAutosave", BindHelper.bindBeanProperty("disableAutosave", config.getNuiEditor(), Boolean.TYPE)); WidgetUtil.tryBindCheckbox(this, "disableIcons", BindHelper.bindBeanProperty("disableIcons", config.getNuiEditor(), Boolean.TYPE)); WidgetUtil.trySubscribe(this, "close", button -> getManager().closeScreen(ASSET_URI)); alternativeLocale = find("alternativeLocale", UIDropdownScrollable.class); if (alternativeLocale != null) { // Build the list of available locales and set the dropdown's options to them. TranslationProject menuProject = translationSystem.getProject(new SimpleUri("engine:menu")); List<Locale> locales = new ArrayList<>(menuProject.getAvailableLocales()); Collections.sort(locales, ((Object o1, Object o2) -> (o1.toString().compareTo(o2.toString())))); alternativeLocale.setOptions(Lists.newArrayList(locales)); alternativeLocale.setVisibleOptions(5); alternativeLocale.setOptionRenderer(new LocaleRenderer(translationSystem)); // If an alternative locale has been previously selected, select it; otherwise select the system locale. if (config.getNuiEditor().getAlternativeLocale() != null) { alternativeLocale.setSelection(config.getNuiEditor().getAlternativeLocale()); } else { alternativeLocale.setSelection(config.getSystem().getLocale()); } } }
@Override public void onClosed() { if (!alternativeLocale.getSelection().equals(config.getNuiEditor().getAlternativeLocale())) { config.getNuiEditor().setAlternativeLocale(alternativeLocale.getSelection()); } if (getManager().isOpen(NUIEditorScreen.ASSET_URI)) { ((NUIEditorScreen) getManager().getScreen(NUIEditorScreen.ASSET_URI)).updateConfig(); } if (getManager().isOpen(NUISkinEditorScreen.ASSET_URI)) { ((NUISkinEditorScreen) getManager().getScreen(NUISkinEditorScreen.ASSET_URI)).updateConfig(); } } }
/** * {@inheritDoc} */ @Override protected void updateConfig() { NUIEditorConfig nuiEditorConfig = config.getNuiEditor(); setDisableAutosave(nuiEditorConfig.isDisableAutosave()); // Update the editor's item renderer. getEditor().setItemRenderer(nuiEditorConfig.isDisableIcons() ? new ToStringTextRenderer<>() : new NUIEditorItemRenderer(getEditor().getModel())); if (nuiEditorConfig.getAlternativeLocale() != null && !nuiEditorConfig.getAlternativeLocale().equals(alternativeLocale)) { alternativeLocale = nuiEditorConfig.getAlternativeLocale(); if (selectedScreen != null) { resetPreviewWidget(); } } }
/** * {@inheritDoc} */ @Override protected void updateConfig() { NUIEditorConfig nuiEditorConfig = config.getNuiEditor(); setDisableAutosave(nuiEditorConfig.isDisableAutosave()); // Update the editor's item renderer. getEditor().setItemRenderer(nuiEditorConfig.isDisableIcons() ? new ToStringTextRenderer<>() : new NUIEditorItemRenderer(getEditor().getModel())); // Update the alternative locale. If it has been updated, change the preview widget's locale. if (nuiEditorConfig.getAlternativeLocale() != null && !nuiEditorConfig.getAlternativeLocale().equals(alternativeLocale)) { alternativeLocale = nuiEditorConfig.getAlternativeLocale(); if (selectedAsset != null) { resetPreviewWidget(); } } }