1 package SnowMailClient.view.actions; 2 3 import snow.utils.gui.Icons; 4 import SnowMailClient.MailEngine.*; 5 import SnowMailClient.*; 6 import SnowMailClient.model.*; 7 import SnowMailClient.model.accounts.*; 8 import SnowMailClient.view.*; 9 import SnowMailClient.view.dialogs.*; 10 import SnowMailClient.Language.Language; 11 12 import java.awt.*; 13 import java.awt.event.*; 14 import javax.swing.*; 15 16 17 19 public final class AddNewUser extends AbstractAction 20 { 21 MailAccount admin; 22 JDialog ref; 23 24 public AddNewUser(JDialog ref, MailAccount admin) 25 { 26 super(Language.translate("Add new user")); 27 this.admin = admin; 28 this.ref= ref; 29 30 putValue(AbstractAction.SMALL_ICON, Icons.PlusIcon.shared10); 31 putValue(AbstractAction.ACCELERATOR_KEY, 32 KeyStroke.getKeyStroke( KeyEvent.VK_U, 33 KeyEvent.CTRL_MASK ) ); 34 } 35 36 public void actionPerformed(ActionEvent actionEvent) 37 { 38 45 46 AddNewUserDialog dialog = new AddNewUserDialog(ref, admin.getPop()); 47 dialog.pack(); 48 SnowMailClientApp.centerComponentOnMainFrame(dialog); 49 dialog.setVisible(true); 50 51 if(dialog.addNewUserOnExit) 52 { 53 try 54 { 55 SecurePopConnection sp = admin.getCheckedPopConnection(); 56 sp.addNewUser( dialog.getUserName(), dialog.getPassword() ); 57 sp.terminateSession(); 58 } 59 catch(Exception ex) 60 { 61 ex.printStackTrace(); 63 JOptionPane.showMessageDialog( 64 ref, "Error: \n"+ex.getMessage(), 65 "Failed to add new user", 66 JOptionPane.ERROR_MESSAGE); 67 } 68 } 69 70 } 71 72 } | Popular Tags |