Search in sources :

Example 1 with PropertiesKeysService

use of de.alpharogroup.db.resource.bundles.service.api.PropertiesKeysService in project bundle-app-ui by astrapi69.

the class OverviewResourceBundleAddEntryPanel method onAddEntry.

protected void onAddEntry(final ActionEvent e) {
    final String key = txtKey.getText();
    final String value = txtValue.getText();
    BundleApplications bundleApplication = getModelObject().getBundleApplication();
    final String baseName = getModelObject().getSelectedBundleName().getBaseName().getName();
    final Locale locale = LocaleResolver.resolveLocale(getModelObject().getSelectedBundleName().getLocale().getLocale());
    final PropertiesKeysService propertiesKeysService = SpringApplicationContext.getInstance().getPropertiesKeysService();
    final ResourcebundlesService resourcebundlesService = SpringApplicationContext.getInstance().getResourcebundlesService();
    final boolean update = true;
    Resourcebundles resourcebundle = resourcebundlesService.getResourcebundle(bundleApplication, baseName, locale, key);
    if (resourcebundle != null) {
        if (update) {
            resourcebundle.setValue(value);
        }
    } else {
        final PropertiesKeys pkey = propertiesKeysService.getOrCreateNewPropertiesKeys(key);
        resourcebundle = Resourcebundles.builder().bundleName(getModelObject().getSelectedBundleName()).key(pkey).value(value).build();
        ResourceBundlesDomainObjectFactory.getInstance().newResourcebundles(getModelObject().getSelectedBundleName(), pkey, value);
    }
    resourcebundle = resourcebundlesService.merge(resourcebundle);
    reloadTableModel();
    MainFrame.getInstance().getModelObject().getSelectedBundleApplication().setSelectedResourcebundle(null);
    txtKey.setText("");
    txtValue.setText("");
    revalidate();
}
Also used : Locale(java.util.Locale) ResourcebundlesService(de.alpharogroup.db.resource.bundles.service.api.ResourcebundlesService) BundleApplications(de.alpharogroup.db.resource.bundles.entities.BundleApplications) Resourcebundles(de.alpharogroup.db.resource.bundles.entities.Resourcebundles) PropertiesKeysService(de.alpharogroup.db.resource.bundles.service.api.PropertiesKeysService) PropertiesKeys(de.alpharogroup.db.resource.bundles.entities.PropertiesKeys)

Aggregations

BundleApplications (de.alpharogroup.db.resource.bundles.entities.BundleApplications)1 PropertiesKeys (de.alpharogroup.db.resource.bundles.entities.PropertiesKeys)1 Resourcebundles (de.alpharogroup.db.resource.bundles.entities.Resourcebundles)1 PropertiesKeysService (de.alpharogroup.db.resource.bundles.service.api.PropertiesKeysService)1 ResourcebundlesService (de.alpharogroup.db.resource.bundles.service.api.ResourcebundlesService)1 Locale (java.util.Locale)1