KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > SnowMailClient > view > actions > SetUserPass


1 package SnowMailClient.view.actions;
2
3 import SnowMailClient.MailEngine.*;
4 import SnowMailClient.*;
5 import SnowMailClient.model.*;
6 import SnowMailClient.model.accounts.*;
7 import SnowMailClient.view.*;
8 import SnowMailClient.view.dialogs.*;
9 import SnowMailClient.Language.Language;
10
11 import java.awt.*;
12 import java.awt.event.*;
13 import javax.swing.*;
14
15
16 /** this command is only avaiable for admin users
17 */

18 public class SetUserPass extends AbstractAction
19 {
20    MailAccount account;
21    JDialog ref;
22
23    public SetUserPass(JDialog ref, MailAccount account)
24    {
25        super(Language.translate("Set a user pasword"));
26        this.account = account;
27        this.ref= ref;
28
29        putValue(AbstractAction.SMALL_ICON, SnowMailClientApp.loadImageIcon("pics/key.PNG"));
30 /* putValue(AbstractAction.ACCELERATOR_KEY,
31                  KeyStroke.getKeyStroke( KeyEvent.VK_U,
32                                          KeyEvent.CTRL_MASK ) ); */

33    }
34
35    public void actionPerformed(ActionEvent actionEvent)
36    {
37 /* MailAccount admin = accounts.getSnowraverAdministratorMailAccount();
38        if(admin==null)
39        {
40           JOptionPane.showMessageDialog(
41              ref, "ERROR: No account has administrator privileges");
42           return;
43        } */

44
45        AddNewUserDialog dialog = new AddNewUserDialog(ref, account.getPop());
46        dialog.setTitle(
47          Language.translate("Set a % user password", account.getPop()));
48        dialog.pack();
49        SnowMailClientApp.centerComponentOnMainFrame(dialog);
50        dialog.setVisible(true);
51
52        if(dialog.addNewUserOnExit)
53        {
54           try
55           {
56              SecurePopConnection sp = account.getCheckedPopConnection();
57              sp.setUserPassword( dialog.getUserName(), dialog.getPassword() );
58              sp.terminateSession();
59           }
60           catch(Exception JavaDoc ex)
61           {
62              // ### shit, the message is not nice
63
ex.printStackTrace();
64              JOptionPane.showMessageDialog(
65                ref, "Error: \n"+ex.getMessage(),
66                "Failed to add new user",
67                JOptionPane.ERROR_MESSAGE);
68           }
69        }
70
71    }
72
73 }// SetUserPass
Popular Tags