1 package SnowMailClient.view.actions; 2 3 import SnowMailClient.model.folders.*; 4 import SnowMailClient.model.MailMessage; 5 import SnowMailClient.model.accounts.*; 6 import SnowMailClient.model.Address; 7 import SnowMailClient.view.folders.*; 8 import SnowMailClient.SnowMailClientApp; 9 import SnowMailClient.Language.Language; 10 11 import java.awt.*; 12 import java.util.*; 13 import java.awt.event.*; 14 import javax.swing.*; 15 import javax.swing.event.*; 16 import javax.swing.tree.*; 17 18 public class CreateNewMail extends AbstractAction 19 { 20 FolderTreeNode inbox; 21 MailAccounts accounts; 22 23 public CreateNewMail(MailAccounts accounts, FolderTreeNode inbox) 24 { 25 super(Language.translate("New mail message")); 26 this.inbox = inbox; 27 this.accounts = accounts; 28 29 putValue(AbstractAction.SMALL_ICON, 30 SnowMailClientApp.loadImageIcon("pics/composemail.PNG") ); 31 32 putValue(AbstractAction.ACCELERATOR_KEY, 33 KeyStroke.getKeyStroke( KeyEvent.VK_N, KeyEvent.CTRL_MASK ) ); 34 35 putValue(AbstractAction.SHORT_DESCRIPTION, 36 Language.translate("Create a new empty mail")); 37 38 } 40 public void actionPerformed(ActionEvent e) 41 { 42 Address from = new Address(); 43 MailAccount ma = accounts.getSendMailAccount(); 44 if(ma!=null) 45 { 46 from.setMailAddress( ma.getAddress() ); 47 from.setName( ma.getName() ); 48 } 49 50 MailMessage mess = new MailMessage(); 51 mess.setMessage(from, new Vector<Address>(), "?", "new message"); 52 mess.setEditable(true); 53 54 try 55 { 56 inbox.getMailFolder().addMessage(mess); 57 inbox.saveMailFolder(false); } 59 catch(Exception ex) 60 { 61 ex.printStackTrace(); 62 } 63 } 64 65 66 67 } | Popular Tags |