Search in sources :

Example 1 with LanguagesComboBoxModel

use of de.alpharogroup.bundle.app.combobox.model.LanguagesComboBoxModel 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 2 with LanguagesComboBoxModel

use of de.alpharogroup.bundle.app.combobox.model.LanguagesComboBoxModel 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

LanguagesComboBoxModel (de.alpharogroup.bundle.app.combobox.model.LanguagesComboBoxModel)2 Languages (de.alpharogroup.db.resource.bundles.entities.Languages)2 CountriesComboBoxModel (de.alpharogroup.bundle.app.combobox.model.CountriesComboBoxModel)1 LanguagesComboBoxRenderer (de.alpharogroup.bundle.app.combobox.renderer.LanguagesComboBoxRenderer)1 Countries (de.alpharogroup.db.resource.bundles.entities.Countries)1 LanguageLocales (de.alpharogroup.db.resource.bundles.entities.LanguageLocales)1