Search in sources :

Example 1 with StringBundleNamesTableModel

use of de.alpharogroup.bundle.app.table.model.StringBundleNamesTableModel in project bundle-app-ui by astrapi69.

the class OverviewOfAllResourceBundlesPanel method onInitializeComponents.

@Override
protected void onInitializeComponents() {
    super.onInitializeComponents();
    lblHeaderOverview = new javax.swing.JLabel();
    lblBundleName = new javax.swing.JLabel();
    srcBundles = new javax.swing.JScrollPane();
    btnCreateBundle = new javax.swing.JButton();
    btnCreateBundle.addActionListener(e -> onCreateBundle(e));
    btnToDashboard = new javax.swing.JButton();
    btnToDashboard.setText("Return to Dashboard");
    btnToDashboard.addActionListener(ReturnToDashboardAction.of());
    tableModel = new StringBundleNamesTableModel();
    tableModel.addList(getTableModelList());
    tblBundles = new GenericJXTable<>(tableModel);
    final TableColumn valueColumn = tblBundles.getColumn("Action");
    valueColumn.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;
        }
    });
    valueColumn.setCellEditor(new TableCellButtonEditor(new JCheckBox()) {

        private static final long serialVersionUID = 1L;

        @Override
        public Object getCellEditorValue() {
            final BundleNames selectedBundleName = (BundleNames) this.getValue();
            final Model<ApplicationDashboardBean> baModel = MainFrame.getInstance().getSelectedBundleApplicationPropertyModel();
            MainFrame.getInstance().getModelObject().getSelectedBundleApplication().setSelectedBundleName(selectedBundleName);
            final OverviewResourceBundleAddEntryPanel component = new OverviewResourceBundleAddEntryPanel(baModel);
            MainFrame.getInstance().replaceInternalFrame("Values of resource bundle " + selectedBundleName.getBaseName().getName() + " with locale " + selectedBundleName.getLocale().getLocale() + "", component);
            final String text = "Choose";
            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();
        }
    });
    lblHeaderOverview.setText("Overview of all resource bundles");
    lblBundleName.setText("Bundle count");
    srcBundles.setViewportView(tblBundles);
    btnCreateBundle.setText("Create new resource bundle");
}
Also used : StringBundleNamesTableModel(de.alpharogroup.bundle.app.table.model.StringBundleNamesTableModel) TableColumn(javax.swing.table.TableColumn) JCheckBox(javax.swing.JCheckBox) TableCellButtonEditor(de.alpharogroup.swing.table.editor.TableCellButtonEditor) BundleNames(de.alpharogroup.db.resource.bundles.entities.BundleNames) TableCellButtonRenderer(de.alpharogroup.swing.renderer.TableCellButtonRenderer) JTable(javax.swing.JTable) BaseModel(de.alpharogroup.model.BaseModel) Model(de.alpharogroup.model.api.Model) StringBundleNamesTableModel(de.alpharogroup.bundle.app.table.model.StringBundleNamesTableModel) Component(java.awt.Component)

Aggregations

StringBundleNamesTableModel (de.alpharogroup.bundle.app.table.model.StringBundleNamesTableModel)1 BundleNames (de.alpharogroup.db.resource.bundles.entities.BundleNames)1 BaseModel (de.alpharogroup.model.BaseModel)1 Model (de.alpharogroup.model.api.Model)1 TableCellButtonRenderer (de.alpharogroup.swing.renderer.TableCellButtonRenderer)1 TableCellButtonEditor (de.alpharogroup.swing.table.editor.TableCellButtonEditor)1 Component (java.awt.Component)1 JCheckBox (javax.swing.JCheckBox)1 JTable (javax.swing.JTable)1 TableColumn (javax.swing.table.TableColumn)1