package GUI.dialogs; import java.awt.Dimension; import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.Vector; import javax.swing.Icon; import javax.swing.ImageIcon; import javax.swing.JFileChooser; import javax.swing.JOptionPane; import javax.swing.event.TableModelEvent; import javax.swing.event.TableModelListener; import javax.swing.table.TableRowSorter; import GUI.TablePanel; import main.config.Config; import main.error.VideothekException; import model.PriceCategory; import model.data.exceptions.RecordNotFoundException; import model.exceptions.EmptyFieldException; import model.exceptions.FalseFieldException; /** * * @author Waldemar Smirnow * @author Volha Baranouskaya */ public class SettingsDialog extends javax.swing.JDialog { private static final long serialVersionUID = -4374045845527969881L; private String invoiceFolder; private String warningInvoiceFolder; private String warningFolder; private boolean setCurrentDateOnStartup; /** Creates new form SettingsDialog */ public SettingsDialog(java.awt.Frame parent, boolean modal) { super(parent, modal); this.invoiceFolder = Config.get().getSetting(Config.Settings.INVOICEFOLDER); this.warningInvoiceFolder = Config.get().getSetting(Config.Settings.WARNINGINVOICEFOLDER); this.warningFolder = Config.get().getSetting(Config.Settings.WARNINGFOLDER); this.setCurrentDateOnStartup = Boolean.parseBoolean(Config.get().getSetting(Config.Settings.SETDATEONSTARTUP)); initComponents(); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() { jFileChooser2 = new javax.swing.JFileChooser(); jTabbedPane1 = new javax.swing.JTabbedPane(); settingsPanel = new javax.swing.JPanel(); setCurrentDateCheckbox = new javax.swing.JCheckBox(); invoiceFolderFileChooser = new javax.swing.JFileChooser(); jPanel1 = new javax.swing.JPanel(); jLabel2 = new javax.swing.JLabel(); invoiceFolderSetButton = new javax.swing.JButton(); jLabel3 = new javax.swing.JLabel(); warningInvoiceFolderSetButton = new javax.swing.JButton(); invoiceFolderTextField = new javax.swing.JTextField(); warningInvoiceFolderTextField = new javax.swing.JTextField(); jPanel2 = new javax.swing.JPanel(); jLabel4 = new javax.swing.JLabel(); warningFolderSetButton = new javax.swing.JButton(); warningFolderTextField = new javax.swing.JTextField(); warningPriceEuroSpinner = new javax.swing.JSpinner(); warningPriceCentSpinner = new javax.swing.JSpinner(); jLabel1 = new javax.swing.JLabel(); jLabel5 = new javax.swing.JLabel(); jLabel6 = new javax.swing.JLabel(); priceCategoriesPanel = new javax.swing.JPanel(); jScrollPane1 = new javax.swing.JScrollPane(); priceCategoryTable = new javax.swing.JTable(); addButton = new javax.swing.JButton(); deleteButton = new javax.swing.JButton(); editButton = new javax.swing.JButton(); okButton = new javax.swing.JButton(); cancelButton = new javax.swing.JButton(); okButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { okButtonActionPerformed(e); } }); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setTitle("Einstellungen"); setResizable(false); setCurrentDateCheckbox.setText("Tagesdatum bei Programmstart manuell festlegen"); setCurrentDateCheckbox.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); invoiceFolderFileChooser.setFileSelectionMode(javax.swing.JFileChooser.DIRECTORIES_ONLY); jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Quittungen")); jLabel2.setText("Ausleih-Quittungen ablegen in:"); // invoiceFolderSetButton.setText("Ordner festlegen"); invoiceFolderSetButton.setIcon(new ImageIcon("icons/folder_explore.png")); invoiceFolderSetButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { invoiceFolderSetButtonActionPerformed(evt); } }); jLabel3.setText("Mahnungs-Quittungen ablegen in:"); // warningInvoiceFolderSetButton.setText("Ordner festlegen"); warningInvoiceFolderSetButton.setIcon(new ImageIcon("icons/folder_explore.png")); warningInvoiceFolderSetButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { warningInvoiceFolderSetButtonActionPerformed(evt); } }); invoiceFolderTextField.setText("jTextField1"); warningInvoiceFolderTextField.setText("jTextField1"); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 656, Short.MAX_VALUE) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(invoiceFolderTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 489, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(invoiceFolderSetButton)) // .addComponent(invoiceFolderSetButton, javax.swing.GroupLayout.PREFERRED_SIZE, 161, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, 656, Short.MAX_VALUE) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(warningInvoiceFolderTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 489, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(warningInvoiceFolderSetButton))) // .addComponent(warningInvoiceFolderSetButton, javax.swing.GroupLayout.PREFERRED_SIZE, 161, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap()) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap() .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(invoiceFolderSetButton) .addComponent(invoiceFolderTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 19, Short.MAX_VALUE) .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(warningInvoiceFolderTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(warningInvoiceFolderSetButton)) .addGap(19, 19, 19)) ); jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Mahnungen")); jLabel4.setText("Mahnungen ablegen in:"); // warningFolderSetButton.setText("Ordner festlegen"); warningFolderSetButton.setIcon(new ImageIcon("icons/folder_explore.png")); warningFolderSetButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { warningFolderSetButtonActionPerformed(evt); } }); warningFolderTextField.setText("jTextField1"); jLabel1.setText(","); jLabel5.setText("Euro"); jLabel6.setText("Mahnungsgebühr:"); javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, 656, Short.MAX_VALUE) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup() .addComponent(warningFolderTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 489, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(warningFolderSetButton)) .addGroup(jPanel2Layout.createSequentialGroup() .addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, 360, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(warningPriceEuroSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 7, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(warningPriceCentSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(10, 10, 10) .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 157, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap()) ); jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addContainerGap() .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(warningFolderTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(warningFolderSetButton)) .addGap(18, 18, 18) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(warningPriceCentSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(warningPriceEuroSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel1) .addComponent(jLabel5)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); javax.swing.GroupLayout settingsPanelLayout = new javax.swing.GroupLayout(settingsPanel); settingsPanel.setLayout(settingsPanelLayout); settingsPanelLayout.setHorizontalGroup( settingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(setCurrentDateCheckbox, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 712, Short.MAX_VALUE) .addGroup(settingsPanelLayout.createSequentialGroup() .addContainerGap() .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addContainerGap()) .addGroup(settingsPanelLayout.createSequentialGroup() .addContainerGap() .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addContainerGap()) ); settingsPanelLayout.setVerticalGroup( settingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(settingsPanelLayout.createSequentialGroup() .addContainerGap() .addComponent(setCurrentDateCheckbox, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(39, 39, 39)) ); jTabbedPane1.addTab("Allgemeines", new ImageIcon("icons/cog_edit.png"), settingsPanel); fillTableContent(); addButton.setText("Hinzufügen"); addButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { addButtonActionPerformed(evt); } }); deleteButton.setText("Löschen"); deleteButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { deleteButtonActionPerformed(e); } }); editButton.setText("Bearbeiten"); editButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { editButtonActionPerformed(evt); } }); javax.swing.GroupLayout priceCategoriesPanelLayout = new javax.swing.GroupLayout(priceCategoriesPanel); priceCategoriesPanel.setLayout(priceCategoriesPanelLayout); priceCategoriesPanelLayout.setHorizontalGroup( priceCategoriesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(priceCategoriesPanelLayout.createSequentialGroup() .addContainerGap() .addGroup(priceCategoriesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 692, Short.MAX_VALUE) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, priceCategoriesPanelLayout.createSequentialGroup() .addComponent(deleteButton) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 439, Short.MAX_VALUE) .addComponent(editButton) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(addButton))) .addContainerGap()) ); priceCategoriesPanelLayout.setVerticalGroup( priceCategoriesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(priceCategoriesPanelLayout.createSequentialGroup() .addContainerGap() .addGroup(priceCategoriesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(addButton) .addComponent(deleteButton) .addComponent(editButton)) .addGap(11, 11, 11) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 313, Short.MAX_VALUE) .addContainerGap()) ); jTabbedPane1.addTab("Preiskategorien", new ImageIcon("icons/money_euro.png") ,priceCategoriesPanel); okButton.setText("OK"); okButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { okButtonActionPerformed(evt); } }); cancelButton.setText("Abbrechen"); cancelButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { cancelButtonActionPerformed(evt); } }); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 717, Short.MAX_VALUE) .addGroup(layout.createSequentialGroup() .addComponent(cancelButton) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(okButton, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap() .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 397, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(cancelButton, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(okButton, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap()) ); // textfelder nicht editierbar invoiceFolderTextField.setEditable(false); warningInvoiceFolderTextField.setEditable(false); warningFolderTextField.setEditable(false); // einstellungen aus config übernehmen invoiceFolderTextField.setText(this.invoiceFolder); warningInvoiceFolderTextField.setText(this.warningInvoiceFolder); warningFolderTextField.setText(this.warningFolder); setCurrentDateCheckbox.setSelected(this.setCurrentDateOnStartup); float warningPrice = Float.parseFloat(Config.get().getSetting(Config.Settings.WARNINGPRICE)); int euros = (int)warningPrice; int cents = (int) ((warningPrice - euros) * 100); warningPriceEuroSpinner.setValue(new Integer(euros)); warningPriceCentSpinner.setValue(new Integer(cents)); setToMiddle(); pack(); }// </editor-fold> private void fillTableContent() { Vector columnNames = new Vector(); columnNames.add("Nr."); columnNames.add("Name"); columnNames.add("Preis"); columnNames.add("Anzahl Filme"); priceCategoryTable.setModel(new javax.swing.table.DefaultTableModel( createEntries(), columnNames) { Class[] types = new Class[] { java.lang.Integer.class, java.lang.String.class, java.lang.Float.class, java.lang.Integer.class }; public Class getColumnClass(int columnIndex) { return types[columnIndex]; } public boolean isCellEditable(int row, int column) { return false; } }); TableRowSorter priceCategorySorter = TablePanel.createIntegerSorter(new int[]{0,3}, priceCategoryTable); priceCategoryTable.setRowSorter(priceCategorySorter); priceCategoryTable.getTableHeader().setReorderingAllowed(false); jScrollPane1.setViewportView(priceCategoryTable); priceCategoryTable.getColumnModel().getColumn(0).setPreferredWidth(100); priceCategoryTable.getColumnModel().getColumn(0).setMaxWidth(100); priceCategoryTable.getColumnModel().getColumn(1) .setPreferredWidth(1100); priceCategoryTable.getColumnModel().getColumn(2).setPreferredWidth(400); priceCategoryTable.getColumnModel().getColumn(3).setPreferredWidth(400); this.priceCategoryTable.getModel().addTableModelListener( new TableModelListener() { @Override public void tableChanged(TableModelEvent e) { fillTableContent(); } }); } private Vector createEntries() { Vector dataRows = new Vector(); for(PriceCategory pc : PriceCategory.findAll()) { Vector row = new Vector(); row.add(pc.getID()); row.add(pc.getName()); row.add(pc.getPrice()); row.add(pc.getVideos().size()); dataRows.add(row); } return dataRows; } private void addRow() throws FalseFieldException, EmptyFieldException { PriceCategoryDataDialog dialog = new PriceCategoryDataDialog(null, new PriceCategory("NAME", 1.99f)); dialog.setVisible(true); fillTableContent(); } /* * wird derzeit nicht gebraucht... private void savePriceCategoryRows() { for(int row = 0; row < this.priceCategoryTable.getRowCount(); row++) { Integer id = (Integer) this.priceCategoryTable.getValueAt(row, 0); String name = (String) this.priceCategoryTable.getValueAt(row, 1); Float price = (Float) this.priceCategoryTable.getValueAt(row, 2); PriceCategory pc; try { pc = PriceCategory.findByID(id); pc.setName(name); pc.setPrice(price); pc.save(); } catch (VideothekException e) { JOptionPane.showMessageDialog(this, e.getMessage(), "Fehler beim Speichern von Preiskategorien", JOptionPane.ERROR_MESSAGE); } } } */ private void setToMiddle() { // mittig zum hauptfenster (owner) setzen Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); int x = (int) (screenSize.getWidth() + super.getOwner().getLocationOnScreen().getX()) / 5; int y = (int) (screenSize.getHeight() + super.getOwner().getLocationOnScreen().getY()) / 5; this.setLocation(x, y); } private void okButtonActionPerformed(java.awt.event.ActionEvent evt) { // Einstellungen in Config speichern Config.get().setSetting(Config.Settings.SETDATEONSTARTUP, Boolean.toString(this.setCurrentDateCheckbox.isSelected())); Config.get().setSetting(Config.Settings.INVOICEFOLDER, this.invoiceFolder); Config.get().setSetting(Config.Settings.WARNINGFOLDER, this.warningFolder); Config.get().setSetting(Config.Settings.WARNINGINVOICEFOLDER, this.warningInvoiceFolder); int euros = (Integer)this.warningPriceEuroSpinner.getValue(); int cents = (Integer)this.warningPriceCentSpinner.getValue(); float price = (float) euros + ((float) cents / 100); if(price > 0.0f) { Config.get().setSetting(Config.Settings.WARNINGPRICE, Float.toString(price)); } // savePriceCategoryRows(); this.dispose(); } private void invoiceFolderSetButtonActionPerformed( java.awt.event.ActionEvent evt) { if (invoiceFolderFileChooser.showDialog(this, "Ordner auswählen") == JFileChooser.APPROVE_OPTION) { this.invoiceFolder = invoiceFolderFileChooser.getSelectedFile() .getPath(); this.invoiceFolderTextField.setText(this.invoiceFolder); } } private void warningInvoiceFolderSetButtonActionPerformed( java.awt.event.ActionEvent evt) { if (invoiceFolderFileChooser.showDialog(this, "Ordner auswählen") == JFileChooser.APPROVE_OPTION) { this.warningInvoiceFolder = invoiceFolderFileChooser .getSelectedFile().getPath(); this.warningInvoiceFolderTextField .setText(this.warningInvoiceFolder); } } private void warningFolderSetButtonActionPerformed( java.awt.event.ActionEvent evt) { if (invoiceFolderFileChooser.showDialog(this, "Ordner auswählen") == JFileChooser.APPROVE_OPTION) { this.warningFolder = invoiceFolderFileChooser.getSelectedFile() .getPath(); this.warningFolderTextField.setText(this.warningFolder); } } private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) { // keine Einstellungen speichern & dialog beenden this.dispose(); } private void addButtonActionPerformed(java.awt.event.ActionEvent evt) { // addRow(); PriceCategoryDataDialog dialog = new PriceCategoryDataDialog(null); dialog.setVisible(true); fillTableContent(); } private void editButtonActionPerformed(java.awt.event.ActionEvent evt) { PriceCategory selectedPriceCategory = null; try { int row = this.priceCategoryTable.getSelectedRow(); Integer id = (Integer) this.priceCategoryTable.getValueAt(row, 0); selectedPriceCategory = PriceCategory.findByID(id); PriceCategoryDataDialog dialog = new PriceCategoryDataDialog(null, selectedPriceCategory); dialog.setVisible(true); fillTableContent(); } catch (RecordNotFoundException e) { JOptionPane.showMessageDialog(this, e.getMessage(), "Fehler", JOptionPane.ERROR_MESSAGE); } catch(Exception e) { // hier einfach nichts tun JOptionPane.showMessageDialog(this, "Bitte erst eine Preiskategorie auswählen", "Keine Auswahl", JOptionPane.INFORMATION_MESSAGE); } } private void deleteButtonActionPerformed(java.awt.event.ActionEvent evt) { try { int selectedRow = this.priceCategoryTable.getSelectedRow(); Integer id = (Integer) this.priceCategoryTable.getValueAt(selectedRow, 0); PriceCategory pc = PriceCategory.findByID(id); int selectedOption = JOptionPane.showConfirmDialog(this.priceCategoriesPanel, "Möchten Sie die Preiskategorie mit der Nummer " + pc.getID() + " wirklich löschen?", "Preiskategorie Löschen", JOptionPane.YES_NO_OPTION); if(selectedOption == JOptionPane.YES_OPTION) { if(pc.getVideos().size() > 0) { throw new VideothekException("Fehler beim Löschen: Preiskategorie enthält noch Filme."); } else { pc.delete(); fillTableContent(); } } } catch (VideothekException e) { JOptionPane.showMessageDialog(this, e.getMessage(), "Fehler", JOptionPane.ERROR_MESSAGE); } catch(Exception e) { // hier einfach nichts tun JOptionPane.showMessageDialog(this, "Bitte erst eine Preiskategorie auswählen", "Keine Auswahl", JOptionPane.INFORMATION_MESSAGE); } } // Variables declaration - do not modify private javax.swing.JButton addButton; private javax.swing.JButton cancelButton; private javax.swing.JButton deleteButton; private javax.swing.JButton editButton; private javax.swing.JFileChooser invoiceFolderFileChooser; private javax.swing.JButton invoiceFolderSetButton; private javax.swing.JTextField invoiceFolderTextField; private javax.swing.JFileChooser jFileChooser2; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel5; private javax.swing.JLabel jLabel6; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JTabbedPane jTabbedPane1; private javax.swing.JButton okButton; private javax.swing.JPanel priceCategoriesPanel; private javax.swing.JTable priceCategoryTable; private javax.swing.JCheckBox setCurrentDateCheckbox; private javax.swing.JPanel settingsPanel; private javax.swing.JButton warningFolderSetButton; private javax.swing.JTextField warningFolderTextField; private javax.swing.JButton warningInvoiceFolderSetButton; private javax.swing.JTextField warningInvoiceFolderTextField; private javax.swing.JSpinner warningPriceCentSpinner; private javax.swing.JSpinner warningPriceEuroSpinner; // End of variables declaration }