Subversion Repository Public Repository

Satyam

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bestray.healthcareemr.Views;

import com.bestray.healthcarecommonutil.exception.HealthCareException;
import com.bestray.healthcarecommonutil.exception.ProcessingException;
import com.bestray.healthcarecommonutil.vo.TAccount;
import com.bestray.healthcareemr.Controller.UserSetupController;
import com.bestray.healthcareemr.Util.MessageProperties;
import com.bestray.healthcarecommonutil.util.PreferenceUtil;
import java.util.prefs.Preferences;
import javax.swing.JOptionPane;
import org.springframework.orm.hibernate3.HibernateOptimisticLockingFailureException;

// TODO: Auto-generated Javadoc
/**
 * The Class ChangePasswordDialog.
 *
 * @author user3
 */
public class ChangePasswordDialog extends javax.swing.JDialog {

    /**
     * Creates new form ChangePasswordDialog.
     *
     * @param parent the parent
     * @param modal the modal
     */
    public ChangePasswordDialog(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        Preferences myPrefObj = Preferences.userRoot();
      try{
            userSetupController = (UserSetupController)HealthcareLogin.context.getBean("userSetupController");
            useraccount=(TAccount)PreferenceUtil.getObject(myPrefObj, "user");
                
        }catch(Exception e){
            throw new HealthCareException("Not Getting the loggedin User");
        }
        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.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        oldPassword_pwdField = new javax.swing.JPasswordField();
        jLabel1 = new javax.swing.JLabel();
        newPassword_pwdField = new javax.swing.JPasswordField();
        jLabel2 = new javax.swing.JLabel();
        confirmPassword_pwdField = new javax.swing.JPasswordField();
        reset_bt = new javax.swing.JButton();
        save_bt = new javax.swing.JButton();
        jLabel16 = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Change Password");
        setPreferredSize(new java.awt.Dimension(442, 214));
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jPanel1.setOpaque(false);

        jLabel3.setForeground(new java.awt.Color(255, 255, 255));
        jLabel3.setText("Old Password :");

        jLabel1.setForeground(new java.awt.Color(255, 255, 255));
        jLabel1.setText("New Password :");

        jLabel2.setForeground(new java.awt.Color(255, 255, 255));
        jLabel2.setText("Confirm Password :");

        reset_bt.setText("Reset");
        reset_bt.setOpaque(false);
        reset_bt.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                reset_btActionPerformed(evt);
            }
        });

        save_bt.setText("Save");
        save_bt.setOpaque(false);
        save_bt.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                save_btActionPerformed(evt);
            }
        });

        jLabel16.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel16.setForeground(new java.awt.Color(255, 51, 0));
        jLabel16.setText("*");

        jLabel18.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel18.setForeground(new java.awt.Color(255, 51, 0));
        jLabel18.setText("*");

        jLabel19.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel19.setForeground(new java.awt.Color(255, 51, 0));
        jLabel19.setText("*");

        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(jLabel16)
                    .addComponent(jLabel18)
                    .addComponent(jLabel19))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel3)
                    .addComponent(jLabel1)
                    .addComponent(jLabel2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(reset_bt)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(save_bt)
                        .addGap(0, 76, Short.MAX_VALUE))
                    .addComponent(oldPassword_pwdField)
                    .addComponent(newPassword_pwdField)
                    .addComponent(confirmPassword_pwdField))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(oldPassword_pwdField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel16))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(newPassword_pwdField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel18))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(confirmPassword_pwdField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel19))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(save_bt)
                    .addComponent(reset_bt))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        getContentPane().add(jPanel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 20, 330, 130));

        jLabel4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/background-grey-4.jpg"))); // NOI18N
        getContentPane().add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(-130, -50, 670, 580));

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
     * Save_bt action performed.
     *
     * @param evt the evt
     */
    private void save_btActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_save_btActionPerformed
        // TODO add your handling code here:
        if(ValidatePatient()){
            try{
                newUserAccount=useraccount;
                String oldPassword=useraccount.getPassword();
                if(oldPassword.equals(oldPassword_pwdField.getText())){
                        newUserAccount.setPassword(confirmPassword_pwdField.getText());
                        userSetupController.updateUserPassword(newUserAccount);
                        JOptionPane.showMessageDialog(null, MessageProperties.getMessage("success.save",new Object[]{"Password"}));
                        dispose();
                }else{
                        JOptionPane.showMessageDialog(null, "You have entered wrong password...");
                }
                reset();
            }catch(HibernateOptimisticLockingFailureException e){
                JOptionPane.showMessageDialog(null, MessageProperties.getMessage("error.update",new Object[]{"Password"}));
            }catch(Exception e){
                JOptionPane.showMessageDialog(null, MessageProperties.getMessage("error.save",new Object[]{"Password"}));
            }
        }
        
    }//GEN-LAST:event_save_btActionPerformed

    /**
     * Reset_bt action performed.
     *
     * @param evt the evt
     */
    private void reset_btActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_reset_btActionPerformed
       reset();
    }//GEN-LAST:event_reset_btActionPerformed
    
    /**
     * Reset.
     */
    public void reset(){
        oldPassword_pwdField.setText(null);
        newPassword_pwdField.setText(null);
        confirmPassword_pwdField.setText(null);
    }
    
    /** The confirm password_pwd field. @Override public void windowClosing(java.awt.event.WindowEvent e) { System.exit(0); } }); dialog.setVisible(true); } }); } */
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPasswordField confirmPassword_pwdField;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPasswordField newPassword_pwdField;
    private javax.swing.JPasswordField oldPassword_pwdField;
    private javax.swing.JButton reset_bt;
    private javax.swing.JButton save_bt;
    // End of variables declaration//GEN-END:variables
    /** The new user account. */
    TAccount useraccount,newUserAccount;
    
    /** The user setup controller. */
    UserSetupController userSetupController;
    
    private boolean ValidatePatient() {
        boolean valid = true;
        String newPassword= newPassword_pwdField.getText();
        String confirmPassword= confirmPassword_pwdField.getText();
        if(oldPassword_pwdField.getText().length()==0){
            JOptionPane.showMessageDialog(null, "Old Password can't be empty...");
            oldPassword_pwdField.requestFocus();
            valid = false;
        }else if(newPassword_pwdField.getText().length()==0){
            JOptionPane.showMessageDialog(null, "New Password can't be empty...");
            newPassword_pwdField.requestFocus();
            valid = false;
        }else if(newPassword_pwdField.getText().contains(" ")){
            JOptionPane.showMessageDialog(null, "Space is not allowed in password field...");
            newPassword_pwdField.requestFocus();
            valid = false;
        }else if(confirmPassword_pwdField.getText().length()==0){
            JOptionPane.showMessageDialog(null, "Confirm Password can't be empty...");
            confirmPassword_pwdField.requestFocus();
            valid = false;
        }else if(confirmPassword_pwdField.getText().contains(" ")){
            JOptionPane.showMessageDialog(null, "Space is not allowed in password field...");
            confirmPassword_pwdField.requestFocus();
            valid = false;
        }else if(!newPassword.equals(confirmPassword)){
            JOptionPane.showMessageDialog(null, "Your confirm password doesn't match with new password...");
            confirmPassword_pwdField.requestFocus();
            valid = false;
        }
        return valid;
    }
    
}

Commits for Satyam/AuroCareEMR/src/main/java/com/bestray/healthcareemr/Views/ChangePasswordDialog.java

Diff revisions: vs.
Revision Author Commited Message
1 girijabapi picture girijabapi Fri 20 Jul, 2018 05:59:17 +0000