use of de.alpharogroup.db.resource.bundles.entities.Languages in project bundle-app-ui by astrapi69.
the class SpringApplicationContext method initDb.
protected void initDb(final ApplicationContext ac) {
final LanguagesService languagesService = (LanguagesService) ac.getBean("languagesService");
final LanguageLocalesService languageLocalesService = (LanguageLocalesService) ac.getBean("languageLocalesService");
final BundleApplicationsService bundleApplicationsService = getBundleApplicationsService();
final List<Languages> languages = DataObjectFactory.newLanguages();
for (final Languages language : languages) {
final Languages found = languagesService.find(language.getName(), language.getIso639Dash1());
if (found == null) {
languagesService.merge(language);
}
}
final List<LanguageLocales> languageLocales = DataObjectFactory.newLanguageLocales();
for (final LanguageLocales languageLocale : languageLocales) {
final LanguageLocales found = languageLocalesService.find(languageLocale.getLocale());
if (found == null) {
languageLocalesService.merge(languageLocale);
}
}
BundleApplications baseBundleApplication = bundleApplicationsService.find(BundleApplications.BASE_BUNDLE_APPLICATION);
if (baseBundleApplication == null) {
baseBundleApplication = BundleApplications.builder().name(BundleApplications.BASE_BUNDLE_APPLICATION).build();
baseBundleApplication = bundleApplicationsService.merge(baseBundleApplication);
}
}
use of de.alpharogroup.db.resource.bundles.entities.Languages in project bundle-app-ui by astrapi69.
the class NewCustomLocalePanel method newCmbLanguage.
protected javax.swing.JComboBox<Languages> newCmbLanguage(final Model<ApplicationDashboardBean> model) {
LanguagesComboBoxModel cmbModel = LanguagesComboBoxModel.get();
final javax.swing.JComboBox<Languages> comboBox = new javax.swing.JComboBox<>(cmbModel);
comboBox.addItemListener(e -> onChangeLanguage(e));
comboBox.setRenderer(new LanguagesComboBoxRenderer());
comboBox.setMaximumRowCount(10);
return comboBox;
}
use of de.alpharogroup.db.resource.bundles.entities.Languages in project bundle-app-ui by astrapi69.
the class NewCustomLocalePanel method onSave.
private void onSave(final ActionEvent e) {
System.out.println("de.alpharogroup.bundle.app.panels.creation.NewCustomLocalePanel.onSave()");
Languages selectedLanguage = (Languages) cmbLanguage.getSelectedItem();
Countries selectedCountry = (Countries) cmbCountry.getSelectedItem();
String variant = txtVariant.getText();
String localeCode = selectedLanguage.getIso639Dash1() + "_" + selectedCountry.getIso3166A2name() + "_" + variant;
LanguageLocales languageLocales = SpringApplicationContext.getInstance().getLanguageLocalesService().find(localeCode);
if (languageLocales == null) {
SpringApplicationContext.getInstance().getLanguageLocalesService().merge(LanguageLocales.builder().locale(localeCode).build());
cmbCountry.setModel(new CountriesComboBoxModel());
cmbLanguage.setModel(new LanguagesComboBoxModel());
txtVariant.setText("");
this.revalidate();
this.repaint();
} else {
// no owner frame
JOptionPane.showMessageDialog(// no owner frame
null, // text to display
"Locale already exists", // title
"Invalid Value", JOptionPane.WARNING_MESSAGE);
}
}
Aggregations