Search in sources :

Example 1 with LanguageLocales

use of de.alpharogroup.db.resource.bundles.entities.LanguageLocales in project bundle-app-ui by astrapi69.

the class NewBundleApplicationPanel method onSave.

protected void onSave(final ActionEvent e) {
    final BundleApplicationsService bundleApplicationsService = (BundleApplicationsService) SpringApplicationContext.getInstance().getApplicationContext().getBean("bundleApplicationsService");
    final String name = getTxtBundleName().getText();
    BundleApplications currentBundleApplication;
    if (getModelObject().getBundleApplication() != null) {
        currentBundleApplication = getModelObject().getBundleApplication();
        currentBundleApplication.setName(name);
        Locale dl = getModelObject().getDefaultLocale();
        LanguageLocales defaultLocale = SpringApplicationContext.getInstance().getLanguageLocalesService().getOrCreateNewLanguageLocales(dl);
        if (currentBundleApplication.getDefaultLocale() != null) {
            if (!currentBundleApplication.getDefaultLocale().equals(defaultLocale)) {
                currentBundleApplication.setDefaultLocale(defaultLocale);
            }
        } else {
            currentBundleApplication.setDefaultLocale(defaultLocale);
        }
        currentBundleApplication = bundleApplicationsService.merge(currentBundleApplication);
        getModelObject().setBundleApplication(currentBundleApplication);
    } else {
        BundleApplications newBundleApplication = bundleApplicationsService.find(name);
        if (newBundleApplication == null) {
            Locale dl = getModelObject().getDefaultLocale();
            LanguageLocales defaultLocale = SpringApplicationContext.getInstance().getLanguageLocalesService().find(dl);
            newBundleApplication = BundleApplications.builder().name(name).defaultLocale(defaultLocale).build();
            newBundleApplication = bundleApplicationsService.merge(newBundleApplication);
        }
        if (!MainFrame.getInstance().getModelObject().getBundleApplications().contains(newBundleApplication)) {
            MainFrame.getInstance().getModelObject().getBundleApplications().add(newBundleApplication);
        }
        getModelObject().setBundleApplication(newBundleApplication);
    }
}
Also used : Locale(java.util.Locale) BundleApplicationsService(de.alpharogroup.db.resource.bundles.service.api.BundleApplicationsService) LanguageLocales(de.alpharogroup.db.resource.bundles.entities.LanguageLocales) BundleApplications(de.alpharogroup.db.resource.bundles.entities.BundleApplications)

Example 2 with LanguageLocales

use of de.alpharogroup.db.resource.bundles.entities.LanguageLocales 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 3 with LanguageLocales

use of de.alpharogroup.db.resource.bundles.entities.LanguageLocales in project bundle-app-ui by astrapi69.

the class NewBundleApplicationPanel method newCmbDefaultLocale.

protected javax.swing.JComboBox<Locale> newCmbDefaultLocale(final Model<ApplicationDashboardBean> model) {
    ApplicationDashboardBean bean = model.getObject();
    BundleApplications bundleApplication = bean.getBundleApplication();
    LocalesComboBoxModel cmbModel = LocalesComboBoxModel.get();
    Locale dl = Locale.getDefault();
    if (bundleApplication != null) {
        LanguageLocales defaultLocale = bundleApplication.getDefaultLocale();
        if (defaultLocale != null) {
            dl = SpringApplicationContext.getInstance().getLanguageLocalesService().resolveLocale(defaultLocale);
        }
    }
    cmbModel.setSelectedItem(dl);
    final javax.swing.JComboBox<Locale> cmbDefaultLocale = new javax.swing.JComboBox<>(cmbModel);
    cmbDefaultLocale.addItemListener(e -> onChangeDefaultLocale(e));
    final Model<Locale> defaultLocaleModel = model(from(getModel()).getDefaultLocale());
    cmbDefaultLocale.setRenderer(new LocalesComboBoxRenderer(defaultLocaleModel));
    return cmbDefaultLocale;
}
Also used : Locale(java.util.Locale) LocalesComboBoxModel(de.alpharogroup.bundle.app.combobox.model.LocalesComboBoxModel) LanguageLocales(de.alpharogroup.db.resource.bundles.entities.LanguageLocales) LocalesComboBoxRenderer(de.alpharogroup.bundle.app.combobox.renderer.LocalesComboBoxRenderer) ApplicationDashboardBean(de.alpharogroup.bundle.app.panels.dashboard.ApplicationDashboardBean) BundleApplications(de.alpharogroup.db.resource.bundles.entities.BundleApplications)

Example 4 with LanguageLocales

use of de.alpharogroup.db.resource.bundles.entities.LanguageLocales 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)

Example 5 with LanguageLocales

use of de.alpharogroup.db.resource.bundles.entities.LanguageLocales in project bundle-app-ui by astrapi69.

the class NewBundleNamePanel method onSave.

protected void onSave(final ActionEvent e) {
    BundleApplications bundleApplication = getModelObject().getBundleApplication();
    final BundleNamesService bundleNamesService = SpringApplicationContext.getInstance().getBundleNamesService();
    final String baseName = txtBasename.getText();
    final LanguageLocales selectedItem = (LanguageLocales) cmbLocale.getSelectedItem();
    if (selectedItem != null) {
        final Locale locale = LocaleResolver.resolveLocale(selectedItem.getLocale());
        bundleNamesService.getOrCreateNewBundleNames(bundleApplication, baseName, locale);
    } else {
        final LanguageLocales languageLocales = getModelObject().getBundleApplication().getDefaultLocale();
        final Locale locale = SpringApplicationContext.getInstance().getLanguageLocalesService().resolveLocale(languageLocales);
        bundleNamesService.getOrCreateNewBundleNames(bundleApplication, baseName, locale);
    }
}
Also used : Locale(java.util.Locale) LanguageLocales(de.alpharogroup.db.resource.bundles.entities.LanguageLocales) BundleApplications(de.alpharogroup.db.resource.bundles.entities.BundleApplications) BundleNamesService(de.alpharogroup.db.resource.bundles.service.api.BundleNamesService)

Aggregations

LanguageLocales (de.alpharogroup.db.resource.bundles.entities.LanguageLocales)5 BundleApplications (de.alpharogroup.db.resource.bundles.entities.BundleApplications)4 Locale (java.util.Locale)3 Languages (de.alpharogroup.db.resource.bundles.entities.Languages)2 BundleApplicationsService (de.alpharogroup.db.resource.bundles.service.api.BundleApplicationsService)2 CountriesComboBoxModel (de.alpharogroup.bundle.app.combobox.model.CountriesComboBoxModel)1 LanguagesComboBoxModel (de.alpharogroup.bundle.app.combobox.model.LanguagesComboBoxModel)1 LocalesComboBoxModel (de.alpharogroup.bundle.app.combobox.model.LocalesComboBoxModel)1 LocalesComboBoxRenderer (de.alpharogroup.bundle.app.combobox.renderer.LocalesComboBoxRenderer)1 ApplicationDashboardBean (de.alpharogroup.bundle.app.panels.dashboard.ApplicationDashboardBean)1 Countries (de.alpharogroup.db.resource.bundles.entities.Countries)1 BundleNamesService (de.alpharogroup.db.resource.bundles.service.api.BundleNamesService)1 LanguageLocalesService (de.alpharogroup.db.resource.bundles.service.api.LanguageLocalesService)1 LanguagesService (de.alpharogroup.db.resource.bundles.service.api.LanguagesService)1