use of de.alpharogroup.db.resource.bundles.entities.Resourcebundles 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();
}
use of de.alpharogroup.db.resource.bundles.entities.Resourcebundles in project bundle-app-ui by astrapi69.
the class OverviewResourceBundleAddEntryPanel method onInitializeComponents.
@Override
protected void onInitializeComponents() {
super.onInitializeComponents();
lblKey = new javax.swing.JLabel();
lblHeaderOverview = new javax.swing.JLabel();
lblValue = new javax.swing.JLabel();
srcBundles = new javax.swing.JScrollPane();
tableModel = new StringResourcebundlesTableModel();
tableModel.addList(getTableModelList());
tblBundles = new GenericJXTable<>(tableModel);
btnToDashboard = new javax.swing.JButton();
btnExport = new javax.swing.JButton();
btnDelete = new javax.swing.JButton();
final TableColumn editValueColumn = tblBundles.getColumn("Edit");
editValueColumn.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 = "Edit";
setText(text);
return this;
}
});
editValueColumn.setCellEditor(new TableCellButtonEditor(new JCheckBox()) {
private static final long serialVersionUID = 1L;
@Override
public Object getCellEditorValue() {
final Resourcebundles selected = (Resourcebundles) this.getValue();
MainFrame.getInstance().getModelObject().getSelectedBundleApplication().setSelectedResourcebundle(selected);
txtKey.setText(selected.getKey().getName());
txtValue.setText(selected.getValue());
final String text = "Edit";
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 = "Edit";
getButton().setText(text);
setClicked(true);
return getButton();
}
});
// ============================================================================================
final TableColumn deleteValueColumn = tblBundles.getColumn("Delete");
deleteValueColumn.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;
}
});
deleteValueColumn.setCellEditor(new TableCellButtonEditor(new JCheckBox()) {
private static final long serialVersionUID = 1L;
@Override
public Object getCellEditorValue() {
final Resourcebundles selected = (Resourcebundles) this.getValue();
final ResourcebundlesService resourcebundlesService = SpringApplicationContext.getInstance().getResourcebundlesService();
resourcebundlesService.delete(selected);
if (selected.equals(MainFrame.getInstance().getModelObject().getSelectedBundleApplication().getSelectedResourcebundle())) {
txtKey.setText("");
txtValue.setText("");
MainFrame.getInstance().getModelObject().getSelectedBundleApplication().setSelectedResourcebundle(null);
}
reloadTableModel();
revalidate();
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();
}
});
// ============================================================================================
btnAddEntry = new javax.swing.JButton();
txtKey = new javax.swing.JTextField();
txtValue = new javax.swing.JTextField();
lblKey.setText("Key");
lblHeaderOverview.setText("Overview of resource bundle " + getModelObject().getSelectedBundleName().getBaseName().getName());
lblValue.setText("Value");
srcBundles.setViewportView(tblBundles);
btnAddEntry.setText("Add new entry");
btnAddEntry.addActionListener(e -> onAddEntry(e));
btnToDashboard.setText("Return to Dashboard");
btnToDashboard.addActionListener(ReturnToDashboardAction.of());
btnExport.setText("Export");
btnExport.addActionListener(e -> onExport(e));
btnDelete.setText("Delete");
btnDelete.addActionListener(e -> onDelete(e));
}
use of de.alpharogroup.db.resource.bundles.entities.Resourcebundles 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())));
}
Aggregations