Search in sources :

Example 1 with Languages

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);
    }
}
Also used : BundleApplicationsService(de.alpharogroup.db.resource.bundles.service.api.BundleApplicationsService) LanguageLocales(de.alpharogroup.db.resource.bundles.entities.LanguageLocales) LanguagesService(de.alpharogroup.db.resource.bundles.service.api.LanguagesService) BundleApplications(de.alpharogroup.db.resource.bundles.entities.BundleApplications) Languages(de.alpharogroup.db.resource.bundles.entities.Languages) LanguageLocalesService(de.alpharogroup.db.resource.bundles.service.api.LanguageLocalesService)

Example 2 with Languages

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;
}
Also used : LanguagesComboBoxRenderer(de.alpharogroup.bundle.app.combobox.renderer.LanguagesComboBoxRenderer) Languages(de.alpharogroup.db.resource.bundles.entities.Languages) LanguagesComboBoxModel(de.alpharogroup.bundle.app.combobox.model.LanguagesComboBoxModel)

Example 3 with Languages

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);
    }
}
Also used : LanguageLocales(de.alpharogroup.db.resource.bundles.entities.LanguageLocales) Countries(de.alpharogroup.db.resource.bundles.entities.Countries) Languages(de.alpharogroup.db.resource.bundles.entities.Languages) CountriesComboBoxModel(de.alpharogroup.bundle.app.combobox.model.CountriesComboBoxModel) LanguagesComboBoxModel(de.alpharogroup.bundle.app.combobox.model.LanguagesComboBoxModel)

Aggregations

Languages (de.alpharogroup.db.resource.bundles.entities.Languages)3 LanguagesComboBoxModel (de.alpharogroup.bundle.app.combobox.model.LanguagesComboBoxModel)2 LanguageLocales (de.alpharogroup.db.resource.bundles.entities.LanguageLocales)2 CountriesComboBoxModel (de.alpharogroup.bundle.app.combobox.model.CountriesComboBoxModel)1 LanguagesComboBoxRenderer (de.alpharogroup.bundle.app.combobox.renderer.LanguagesComboBoxRenderer)1 BundleApplications (de.alpharogroup.db.resource.bundles.entities.BundleApplications)1 Countries (de.alpharogroup.db.resource.bundles.entities.Countries)1 BundleApplicationsService (de.alpharogroup.db.resource.bundles.service.api.BundleApplicationsService)1 LanguageLocalesService (de.alpharogroup.db.resource.bundles.service.api.LanguageLocalesService)1 LanguagesService (de.alpharogroup.db.resource.bundles.service.api.LanguagesService)1