java/rozsirene-atributy/src/cz/frantovo/rozsireneatributy/gui/Panel.java
branchv_0
changeset 30 d511e4bf7d8f
parent 29 8d42303538ed
child 31 1ab5ce94a146
     1.1 --- a/java/rozsirene-atributy/src/cz/frantovo/rozsireneatributy/gui/Panel.java	Mon Dec 11 00:49:59 2023 +0100
     1.2 +++ b/java/rozsirene-atributy/src/cz/frantovo/rozsireneatributy/gui/Panel.java	Tue Dec 12 21:19:11 2023 +0100
     1.3 @@ -28,8 +28,7 @@
     1.4  import javax.swing.event.ListSelectionListener;
     1.5  
     1.6  /**
     1.7 - *
     1.8 - * @author fiki
     1.9 + * @author Ing. František Kučera (frantovo.cz)
    1.10   */
    1.11  public class Panel extends javax.swing.JPanel {
    1.12  
    1.13 @@ -46,6 +45,11 @@
    1.14  		this.model = model;
    1.15  		initComponents();
    1.16  
    1.17 +		tlačítkoZamknout.setEnabled(model.isZámekPodporovaný());
    1.18 +		tlačítkoZamknout.setToolTipText(model.isZámekPodporovaný()
    1.19 +			? překlady.getString("zamknout.popis")
    1.20 +			: překlady.getString("chyba.lzeZamknoutJenSoubor"));
    1.21 +
    1.22  		tabulka = new JTable(model);
    1.23  		nastavEditor();
    1.24  		tabulka.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    1.25 @@ -85,8 +89,9 @@
    1.26  	}
    1.27  
    1.28  	private void zobrazChybovouHlášku(String hláška, Throwable chyba) {
    1.29 -		JOptionPane.showMessageDialog(this, hláška,
    1.30 -			překlady.getString("chyba"), JOptionPane.ERROR_MESSAGE);
    1.31 +		JOptionPane.showMessageDialog(this, hláška + "\n"
    1.32 +			+ chyba.getLocalizedMessage(),
    1.33 +			překlady.getString("chyba.titulek"), JOptionPane.ERROR_MESSAGE);
    1.34  		log.log(Level.WARNING, hláška, chyba);
    1.35  	}
    1.36  
    1.37 @@ -98,6 +103,7 @@
    1.38          tlačítkoPřidat = new javax.swing.JButton();
    1.39          tlačítkoSmazat = new javax.swing.JButton();
    1.40          tlačítkoZnovuNačíst = new javax.swing.JButton();
    1.41 +        tlačítkoZamknout = new javax.swing.JToggleButton();
    1.42  
    1.43          tlačítkoPřidat.setMnemonic('p');
    1.44          java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("cz/frantovo/rozsireneatributy/Překlady"); // NOI18N
    1.45 @@ -125,6 +131,13 @@
    1.46              }
    1.47          });
    1.48  
    1.49 +        tlačítkoZamknout.setText(bundle.getString("zamknout")); // NOI18N
    1.50 +        tlačítkoZamknout.addActionListener(new java.awt.event.ActionListener() {
    1.51 +            public void actionPerformed(java.awt.event.ActionEvent evt) {
    1.52 +                tlačítkoZamknoutActionPerformed(evt);
    1.53 +            }
    1.54 +        });
    1.55 +
    1.56          javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
    1.57          this.setLayout(layout);
    1.58          layout.setHorizontalGroup(
    1.59 @@ -136,7 +149,9 @@
    1.60                  .addComponent(tlačítkoSmazat)
    1.61                  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
    1.62                  .addComponent(tlačítkoZnovuNačíst)
    1.63 -                .addContainerGap(222, Short.MAX_VALUE))
    1.64 +                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
    1.65 +                .addComponent(tlačítkoZamknout)
    1.66 +                .addContainerGap(122, Short.MAX_VALUE))
    1.67              .addComponent(posuvnýPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 543, Short.MAX_VALUE)
    1.68          );
    1.69          layout.setVerticalGroup(
    1.70 @@ -147,7 +162,8 @@
    1.71                  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
    1.72                      .addComponent(tlačítkoPřidat)
    1.73                      .addComponent(tlačítkoSmazat)
    1.74 -                    .addComponent(tlačítkoZnovuNačíst))
    1.75 +                    .addComponent(tlačítkoZnovuNačíst)
    1.76 +                    .addComponent(tlačítkoZamknout))
    1.77                  .addContainerGap())
    1.78          );
    1.79      }// </editor-fold>//GEN-END:initComponents
    1.80 @@ -173,10 +189,21 @@
    1.81  				.getString("chyba.nepodařiloSeNačíst"), e);
    1.82  		}
    1.83  	}//GEN-LAST:event_tlačítkoZnovuNačístActionPerformed
    1.84 +
    1.85 +    private void tlačítkoZamknoutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tlačítkoZamknoutActionPerformed
    1.86 +        try {
    1.87 +			model.nastavZámek(tlačítkoZamknout.isSelected());
    1.88 +		} catch (Exception e) {
    1.89 +			zobrazChybovouHlášku(překlady
    1.90 +				.getString("chyba.nepodařiloSeNastavitZámek"), e);
    1.91 +		}
    1.92 +    }//GEN-LAST:event_tlačítkoZamknoutActionPerformed
    1.93 +
    1.94      // Variables declaration - do not modify//GEN-BEGIN:variables
    1.95      private javax.swing.JScrollPane posuvnýPanel;
    1.96      private javax.swing.JButton tlačítkoPřidat;
    1.97      private javax.swing.JButton tlačítkoSmazat;
    1.98 +    private javax.swing.JToggleButton tlačítkoZamknout;
    1.99      private javax.swing.JButton tlačítkoZnovuNačíst;
   1.100      // End of variables declaration//GEN-END:variables
   1.101  }