KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > SnowMailClient > view > accounts > SnowraverAccountDialog


1 package SnowMailClient.view.accounts;
2
3 import SnowMailClient.SnowMailClientApp;
4 import SnowMailClient.model.accounts.*;
5 import SnowMailClient.view.actions.*;
6 import SnowMailClient.utils.storage.*;
7 import snow.utils.gui.*;
8 import SnowMailClient.view.dialogs.*;
9 import SnowMailClient.Language.Language;
10 import snow.lookandfeel.*;
11 import java.util.*;
12 import java.awt.*;
13 import javax.swing.*;
14 import javax.swing.border.*;
15 import javax.swing.event.*;
16
17 /** Let access to the snowraver special functions
18     (A) = only for admin users
19      + change password
20      + add new user (A)
21      + set user password (A)
22      + view server log (A)
23 */

24 public class SnowraverAccountDialog extends JDialog
25 {
26   private static String JavaDoc TITLE = Language.translate("Snowraver Account Functions");
27
28   public SnowraverAccountDialog(AccountsEditor accountsEditor, MailAccount account)
29   {
30      super(accountsEditor, TITLE, true);
31      this.getContentPane().setLayout(new BorderLayout());
32
33      boolean admin = false;
34      try
35      {
36        admin = account.getCheckedPopConnection().hasAdminPrivileges();
37      }
38      catch(Exception JavaDoc e) {}
39
40
41      // south
42
CloseControlPanel ccp = new CloseControlPanel(this, false, false, Language.translate("Close"));
43      this.getContentPane().add(ccp, BorderLayout.SOUTH);
44
45      // center
46
JPanel functionsPanel_ = new JPanel(); //new GridLayout((admin?4:1), 2, 5, 5));
47
GridLayout3 grid = new GridLayout3(2,functionsPanel_);
48      functionsPanel_.setBorder(new EmptyBorder(5,5,5,5));
49      this.getContentPane().add(functionsPanel_, BorderLayout.CENTER);
50
51      JButton chu = new JButton(new ChangeAccountPassword(account, this));
52      chu.setFont(ThemesManager.getInstance().getSmallFont());
53      grid.add(chu, true);
54      grid.add(new JLabel(Language.translate("Change the password for %",account.getAddress())), false);
55
56      if(admin)
57      {
58         setTitle(TITLE+Language.translate(" [Admin Mode]"));
59         JButton anu = new JButton(new AddNewUser(this, account));
60         anu.setFont(ThemesManager.getInstance().getSmallFont());
61         grid.add(anu, true);
62         grid.add(new JLabel(Language.translate("Add a new user@%", account.getPop())), false);
63
64         JButton sup = new JButton(new SetUserPass(this, account));
65         sup.setFont(ThemesManager.getInstance().getSmallFont());
66         grid.add(sup, true);
67         grid.add(new JLabel(Language.translate("Set a user password")), false);
68
69         JButton vsl = new JButton(new ViewServerLog(this, account));
70         vsl.setFont(ThemesManager.getInstance().getSmallFont());
71         grid.add(vsl, true);
72         grid.add(new JLabel(Language.translate("View the server log from %",account.getPop())), false);
73      }
74      pack();
75      SnowMailClientApp.centerComponentOnMainFrame(this);
76      setVisible(true);
77   }
78
79 } // SnowraverAccountDialog
Popular Tags