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.view.*; 9 import SnowMailClient.SnowMailClientApp; 10 import SnowMailClient.Language.Language; 11 12 import java.awt.*; 13 import java.awt.event.*; 14 import javax.swing.*; 15 import javax.swing.event.*; 16 import javax.swing.tree.*; 17 18 public class ForwardAction extends AbstractAction 19 { 20 FolderTreeNode inbox; 21 MailAccounts accounts; 22 FolderView folderView; 23 24 boolean copyContent = true; 25 26 public ForwardAction(FolderView _folderView, MailAccounts accounts, FolderTreeNode inbox) 27 { 28 super(Language.translate("Forward")); 29 30 this.inbox = inbox; 31 this.accounts = accounts; 32 this.folderView = _folderView; 33 34 putValue(AbstractAction.SMALL_ICON, 35 SnowMailClientApp.loadImageIcon("pics/forward.PNG") ); 36 37 putValue(AbstractAction.ACCELERATOR_KEY, 38 KeyStroke.getKeyStroke( KeyEvent.VK_F, KeyEvent.CTRL_MASK ) ); 39 40 putValue(AbstractAction.SHORT_DESCRIPTION, 41 Language.translate("Forward the actual message")); 42 43 folderView.getTableSelectionModel().addListSelectionListener( new ListSelectionListener() 44 { 45 public void valueChanged(ListSelectionEvent e) 46 { 47 setEnabled(folderView.getTableSelectionCount()==1); 48 } 49 }); 50 setEnabled(folderView.getTableSelectionCount()==1); 51 52 } 54 public void actionPerformed(ActionEvent e) 55 { 56 MailMessage[] messs = folderView.getSelectedMessages(); 57 if(messs.length==1) 58 { 59 MailMessage mess = messs[0]; 60 61 Address to = mess.getFromAddress(); 62 63 Address from = new Address(); 65 MailAccount ma = accounts.getSendMailAccount(); 66 if(ma!=null) 67 { 68 from.setMailAddress( ma.getAddress() ); 69 from.setName( ma.getName() ); 70 } 71 72 try 73 { 74 MailMessage replyMessage = new MailMessage(); 75 replyMessage.createFromVectorRepresentation(mess.getVectorRepresentation()); 76 replyMessage.setMessageHeader(null, null, 79 Language.translate("Forward")+": "+mess.getHeader().getEntryValue("subject", "?")); 80 replyMessage.setEditable(true); 81 82 83 inbox.getMailFolder().addMessage(replyMessage); 84 inbox.saveMailFolder(false); } 86 catch(Exception ex) 87 { 88 ex.printStackTrace(); 89 } 90 } 91 } 92 93 } | Popular Tags |