Search in sources :

Example 6 with BundleApplications

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

Example 7 with BundleApplications

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

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

the class OverviewOfAllBundleApplicationsPanel method onInitializeComponents.

@Override
protected void onInitializeComponents() {
    super.onInitializeComponents();
    lblHeaderOverview = new javax.swing.JLabel();
    lblBundleApp = new javax.swing.JLabel();
    srcBundleApps = new javax.swing.JScrollPane();
    tableModel = new StringBundleApplicationsBundleApplicationsTableModel();
    tableModel.addList(getTableModelList());
    tblBundleApps = new GenericJXTable<>(tableModel);
    final TableColumn chooseColumn = tblBundleApps.getColumn("Choose");
    chooseColumn.setCellRenderer(new TableCellButtonRenderer(null, null) {

        private static final long serialVersionUID = 1L;

        @Override
        public Component getTableCellRendererComponent(final JTable table, final Object value, final boolean isSelected, final boolean hasFocus, final int row, final int column) {
            if (isSelected) {
                setForeground(newSelectionForeground(table));
                setBackground(newSelectionBackround(table));
            } else {
                setForeground(newForeground(table));
                setBackground(newBackround(table));
            }
            final String text = "Choose";
            setText(text);
            return this;
        }
    });
    chooseColumn.setCellEditor(new TableCellButtonEditor(new JCheckBox()) {

        private static final long serialVersionUID = 1L;

        @Override
        public Object getCellEditorValue() {
            final BundleApplications selectedBundleApplication = (BundleApplications) this.getValue();
            MainFrame.getInstance().setSelectedBundleApplication(selectedBundleApplication);
            final Model<ApplicationDashboardBean> baModel = MainFrame.getInstance().getSelectedBundleApplicationPropertyModel();
            final ApplicationDashboardContentPanel component = new ApplicationDashboardContentPanel(baModel);
            MainFrame.getInstance().replaceInternalFrame("Dashboard of " + selectedBundleApplication.getName() + " bundle app", component);
            final String text = "Select";
            return text;
        }

        @Override
        public Component getTableCellEditorComponent(final JTable table, final Object value, final boolean isSelected, final int row, final int column) {
            setRow(row);
            setColumn(column);
            setValue(value);
            if (isSelected) {
                getButton().setForeground(table.getSelectionForeground());
                getButton().setBackground(table.getSelectionBackground());
            } else {
                getButton().setForeground(table.getForeground());
                getButton().setBackground(table.getBackground());
            }
            final String text = "Choose";
            getButton().setText(text);
            setClicked(true);
            return getButton();
        }
    });
    final TableColumn deleteColumn = tblBundleApps.getColumn("Delete");
    deleteColumn.setCellRenderer(new TableCellButtonRenderer(null, null) {

        private static final long serialVersionUID = 1L;

        @Override
        public Component getTableCellRendererComponent(final JTable table, final Object value, final boolean isSelected, final boolean hasFocus, final int row, final int column) {
            if (isSelected) {
                setForeground(newSelectionForeground(table));
                setBackground(newSelectionBackround(table));
            } else {
                setForeground(newForeground(table));
                setBackground(newBackround(table));
            }
            final String text = "Delete";
            setText(text);
            return this;
        }
    });
    deleteColumn.setCellEditor(new TableCellButtonEditor(new JCheckBox()) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onClick() {
            try {
                super.onClick();
            } catch (IndexOutOfBoundsException e) {
                e.printStackTrace();
            }
        }

        @Override
        public Object getCellEditorValue() {
            final BundleApplications selectedBundleApplication = (BundleApplications) this.getValue();
            onDelete(selectedBundleApplication);
            final String text = "Delete";
            return text;
        }

        @Override
        public Component getTableCellEditorComponent(final JTable table, final Object value, final boolean isSelected, final int row, final int column) {
            setRow(row);
            setColumn(column);
            setValue(value);
            if (isSelected) {
                getButton().setForeground(table.getSelectionForeground());
                getButton().setBackground(table.getSelectionBackground());
            } else {
                getButton().setForeground(table.getForeground());
                getButton().setBackground(table.getBackground());
            }
            final String text = "Delete";
            getButton().setText(text);
            setClicked(true);
            return getButton();
        }
    });
    btnCreateBundleApp = new javax.swing.JButton();
    lblHeaderOverview.setText("Overview of all bundle applications");
    lblBundleApp.setText("Bundle application count");
    srcBundleApps.setViewportView(tblBundleApps);
    btnCreateBundleApp.setText("Create new bundle application");
    btnCreateBundleApp.addActionListener(e -> onCreateBundleApp(e));
}
Also used : BundleApplications(de.alpharogroup.db.resource.bundles.entities.BundleApplications) ApplicationDashboardContentPanel(de.alpharogroup.bundle.app.panels.dashboard.ApplicationDashboardContentPanel) TableColumn(javax.swing.table.TableColumn) JCheckBox(javax.swing.JCheckBox) TableCellButtonEditor(de.alpharogroup.swing.table.editor.TableCellButtonEditor) TableCellButtonRenderer(de.alpharogroup.swing.renderer.TableCellButtonRenderer) JTable(javax.swing.JTable) BaseModel(de.alpharogroup.model.BaseModel) StringBundleApplicationsBundleApplicationsTableModel(de.alpharogroup.bundle.app.table.model.StringBundleApplicationsBundleApplicationsTableModel) PropertyModel(de.alpharogroup.model.PropertyModel) Model(de.alpharogroup.model.api.Model) StringBundleApplicationsBundleApplicationsTableModel(de.alpharogroup.bundle.app.table.model.StringBundleApplicationsBundleApplicationsTableModel) Component(java.awt.Component)

Example 9 with BundleApplications

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

the class OverviewOfAllBundleApplicationsPanel method onDelete.

protected void onDelete(final BundleApplications selectedBundleApplication) {
    int dialogResult = JOptionPane.showConfirmDialog(null, "This will delete this bundle application and is not recoverable?(cannot be undone)", "Warning", JOptionPane.YES_NO_OPTION);
    if (dialogResult == JOptionPane.YES_OPTION) {
        SpringApplicationContext.getInstance().getBundleApplicationsService().delete(selectedBundleApplication);
        final List<BundleApplications> bundleApplications = SpringApplicationContext.getInstance().getBundleApplicationsService().findAll();
        MainFrame.getInstance().getModelObject().setBundleApplications(bundleApplications);
        MainFrame.getInstance().replaceInternalFrame("Overview bundle apps", new MainDashboardPanel(PropertyModel.<MainDashboardBean>of(MainFrame.getInstance(), "model.object")));
    }
}
Also used : MainDashboardPanel(de.alpharogroup.bundle.app.panels.dashboard.mainapp.MainDashboardPanel) BundleApplications(de.alpharogroup.db.resource.bundles.entities.BundleApplications) MainDashboardBean(de.alpharogroup.bundle.app.panels.dashboard.mainapp.MainDashboardBean)

Example 10 with BundleApplications

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

the class OverviewResourceBundleAddEntryPanel method reloadTableModelList.

private void reloadTableModelList() {
    tableModelList = new ArrayList<>();
    final ResourcebundlesService resourcebundlesService = SpringApplicationContext.getInstance().getResourcebundlesService();
    BundleApplications bundleApplication = getModelObject().getBundleApplication();
    final String baseName = getModelObject().getSelectedBundleName().getBaseName().getName();
    final Locale locale = LocaleResolver.resolveLocale(getModelObject().getSelectedBundleName().getLocale().getLocale());
    final List<Resourcebundles> list = resourcebundlesService.findResourceBundles(bundleApplication, baseName, locale);
    for (final Resourcebundles resourcebundle : list) {
        tableModelList.add(Quattro.<String, String, Resourcebundles, Resourcebundles>builder().topLeft(resourcebundle.getKey().getName()).topRight(resourcebundle.getValue()).bottomLeft(resourcebundle).bottomRight(resourcebundle).build());
    }
    Collections.sort(tableModelList, NullCheckComparator.<Quattro<String, String, Resourcebundles, Resourcebundles>>of((o1, o2) -> o1.getTopLeft().compareTo(o2.getTopLeft())));
}
Also used : Locale(java.util.Locale) PropertiesKeysService(de.alpharogroup.db.resource.bundles.service.api.PropertiesKeysService) TableCellButtonEditor(de.alpharogroup.swing.table.editor.TableCellButtonEditor) BundleApplications(de.alpharogroup.db.resource.bundles.entities.BundleApplications) BaseModel(de.alpharogroup.model.BaseModel) MainFrame(de.alpharogroup.bundle.app.MainFrame) ArrayList(java.util.ArrayList) PropertiesExtensions(de.alpharogroup.collections.properties.PropertiesExtensions) LocaleResolver(de.alpharogroup.resourcebundle.locale.LocaleResolver) Locale(java.util.Locale) StringResourcebundlesTableModel(de.alpharogroup.bundle.app.table.model.StringResourcebundlesTableModel) BasePanel(de.alpharogroup.swing.base.BasePanel) JFileChooser(javax.swing.JFileChooser) SpringApplicationContext(de.alpharogroup.bundle.app.spring.SpringApplicationContext) Properties(java.util.Properties) Resourcebundles(de.alpharogroup.db.resource.bundles.entities.Resourcebundles) ResourcebundlesService(de.alpharogroup.db.resource.bundles.service.api.ResourcebundlesService) TableColumn(javax.swing.table.TableColumn) Model(de.alpharogroup.model.api.Model) FileOutputStream(java.io.FileOutputStream) ApplicationDashboardContentPanel(de.alpharogroup.bundle.app.panels.dashboard.ApplicationDashboardContentPanel) IOException(java.io.IOException) JOptionPane(javax.swing.JOptionPane) Component(java.awt.Component) ActionEvent(java.awt.event.ActionEvent) File(java.io.File) NullCheckComparator(de.alpharogroup.comparators.NullCheckComparator) ResourceBundlesDomainObjectFactory(de.alpharogroup.db.resource.bundles.factories.ResourceBundlesDomainObjectFactory) GenericJXTable(de.alpharogroup.swing.x.GenericJXTable) List(java.util.List) Slf4j(lombok.extern.slf4j.Slf4j) ReturnToDashboardAction(de.alpharogroup.bundle.app.actions.ReturnToDashboardAction) JCheckBox(javax.swing.JCheckBox) ApplicationDashboardBean(de.alpharogroup.bundle.app.panels.dashboard.ApplicationDashboardBean) JTable(javax.swing.JTable) PropertiesKeys(de.alpharogroup.db.resource.bundles.entities.PropertiesKeys) TableCellButtonRenderer(de.alpharogroup.swing.renderer.TableCellButtonRenderer) Collections(java.util.Collections) Quattro(de.alpharogroup.collections.pairs.Quattro) 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)

Aggregations

BundleApplications (de.alpharogroup.db.resource.bundles.entities.BundleApplications)15 Locale (java.util.Locale)8 ApplicationDashboardBean (de.alpharogroup.bundle.app.panels.dashboard.ApplicationDashboardBean)4 LanguageLocales (de.alpharogroup.db.resource.bundles.entities.LanguageLocales)4 BundleApplicationsService (de.alpharogroup.db.resource.bundles.service.api.BundleApplicationsService)4 ResourcebundlesService (de.alpharogroup.db.resource.bundles.service.api.ResourcebundlesService)4 ApplicationDashboardContentPanel (de.alpharogroup.bundle.app.panels.dashboard.ApplicationDashboardContentPanel)3 MainDashboardBean (de.alpharogroup.bundle.app.panels.dashboard.mainapp.MainDashboardBean)3 MainDashboardPanel (de.alpharogroup.bundle.app.panels.dashboard.mainapp.MainDashboardPanel)3 Triple (de.alpharogroup.collections.pairs.Triple)3 BaseModel (de.alpharogroup.model.BaseModel)3 Model (de.alpharogroup.model.api.Model)3 TableCellButtonRenderer (de.alpharogroup.swing.renderer.TableCellButtonRenderer)3 TableCellButtonEditor (de.alpharogroup.swing.table.editor.TableCellButtonEditor)3 Component (java.awt.Component)3 JCheckBox (javax.swing.JCheckBox)3 JTable (javax.swing.JTable)3 TableColumn (javax.swing.table.TableColumn)3 MainFrame (de.alpharogroup.bundle.app.MainFrame)2 ReturnToDashboardAction (de.alpharogroup.bundle.app.actions.ReturnToDashboardAction)2