View Javadoc

1   /*
2    * PreferencesJPanel.java
3    *
4    * Created on 13 January 2007, 06:03
5    */
6   
7   package org.wiztools.jenkryptor;
8   
9   import javax.swing.SwingUtilities;
10  
11  /***
12   *
13   * @author  subhash
14   */
15  public class PreferencesJPanel extends javax.swing.JPanel {
16      
17      /*** Creates new form PreferencesJPanel */
18      public PreferencesJPanel() {
19          initComponents();
20      }
21      
22      public void setPreferences(final boolean overwriteDest, final boolean delSrc){
23          SwingUtilities.invokeLater(new Runnable() {
24              public void run() {
25                  jcbOverwriteDest.setSelected(overwriteDest);
26                  jcbDeleteSource.setSelected(delSrc);
27              }
28          });
29      }
30      
31      /*** This method is called from within the constructor to
32       * initialize the form.
33       * WARNING: Do NOT modify this code. The content of this method is
34       * always regenerated by the Form Editor.
35       */
36      // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
37      private void initComponents() {
38          jPanel1 = new javax.swing.JPanel();
39          jcbOverwriteDest = new javax.swing.JCheckBox();
40          jcbDeleteSource = new javax.swing.JCheckBox();
41          jButton1 = new javax.swing.JButton();
42          jbOk = new javax.swing.JButton();
43          jbCancel = new javax.swing.JButton();
44  
45          jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Preferences"));
46          jcbOverwriteDest.setText("Overwrite Destination File?");
47          jcbOverwriteDest.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
48          jcbOverwriteDest.setMargin(new java.awt.Insets(0, 0, 0, 0));
49  
50          jcbDeleteSource.setSelected(true);
51          jcbDeleteSource.setText("Delete Source File After Encrypting/Decrypting");
52          jcbDeleteSource.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
53          jcbDeleteSource.setMargin(new java.awt.Insets(0, 0, 0, 0));
54  
55          jButton1.setText("Restore Default");
56          jButton1.addActionListener(new java.awt.event.ActionListener() {
57              public void actionPerformed(java.awt.event.ActionEvent evt) {
58                  jButton1ActionPerformed(evt);
59              }
60          });
61  
62          jbOk.setText("Ok");
63          jbOk.addActionListener(new java.awt.event.ActionListener() {
64              public void actionPerformed(java.awt.event.ActionEvent evt) {
65                  jbOkActionPerformed(evt);
66              }
67          });
68  
69          jbCancel.setText("Cancel");
70          jbCancel.addActionListener(new java.awt.event.ActionListener() {
71              public void actionPerformed(java.awt.event.ActionEvent evt) {
72                  jbCancelActionPerformed(evt);
73              }
74          });
75  
76          javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
77          jPanel1.setLayout(jPanel1Layout);
78          jPanel1Layout.setHorizontalGroup(
79              jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
80              .addGroup(jPanel1Layout.createSequentialGroup()
81                  .addContainerGap()
82                  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
83                      .addGroup(jPanel1Layout.createSequentialGroup()
84                          .addGap(17, 17, 17)
85                          .addComponent(jButton1)
86                          .addGap(23, 23, 23)
87                          .addComponent(jbCancel)
88                          .addGap(23, 23, 23)
89                          .addComponent(jbOk))
90                      .addComponent(jcbOverwriteDest, javax.swing.GroupLayout.PREFERRED_SIZE, 286, javax.swing.GroupLayout.PREFERRED_SIZE)
91                      .addComponent(jcbDeleteSource, javax.swing.GroupLayout.PREFERRED_SIZE, 356, javax.swing.GroupLayout.PREFERRED_SIZE))
92                  .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
93          );
94          jPanel1Layout.setVerticalGroup(
95              jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
96              .addGroup(jPanel1Layout.createSequentialGroup()
97                  .addContainerGap()
98                  .addComponent(jcbOverwriteDest)
99                  .addGap(16, 16, 16)
100                 .addComponent(jcbDeleteSource)
101                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 13, Short.MAX_VALUE)
102                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
103                     .addComponent(jbOk)
104                     .addComponent(jButton1)
105                     .addComponent(jbCancel))
106                 .addContainerGap())
107         );
108 
109         javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
110         this.setLayout(layout);
111         layout.setHorizontalGroup(
112             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
113             .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 375, Short.MAX_VALUE)
114         );
115         layout.setVerticalGroup(
116             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
117             .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
118         );
119     }// </editor-fold>//GEN-END:initComponents
120 
121     private void jbOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbOkActionPerformed
122         Preferences.overwriteDestination_pref = jcbOverwriteDest.isSelected();
123         Preferences.deleteSource_pref = jcbDeleteSource.isSelected();
124         Globals.MAIN_FRAME.setJDVisible(false);
125     }//GEN-LAST:event_jbOkActionPerformed
126 
127     private void jbCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbCancelActionPerformed
128         Globals.MAIN_FRAME.setJDVisible(false);
129     }//GEN-LAST:event_jbCancelActionPerformed
130 
131     private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
132         SwingUtilities.invokeLater(new Runnable(){
133             public void run(){
134                 jcbOverwriteDest.setSelected(false);
135                 jcbDeleteSource.setSelected(true);
136             }
137         });
138     }//GEN-LAST:event_jButton1ActionPerformed
139     
140     
141     // Variables declaration - do not modify//GEN-BEGIN:variables
142     private javax.swing.JButton jButton1;
143     private javax.swing.JPanel jPanel1;
144     private javax.swing.JButton jbCancel;
145     private javax.swing.JButton jbOk;
146     private javax.swing.JCheckBox jcbDeleteSource;
147     private javax.swing.JCheckBox jcbOverwriteDest;
148     // End of variables declaration//GEN-END:variables
149     
150 }