1 package SnowMailClient.view.actions; 2 3 import SnowMailClient.model.folders.*; 4 import SnowMailClient.model.MailMessage; 5 import SnowMailClient.model.accounts.*; 6 import SnowMailClient.view.folders.*; 7 import SnowMailClient.SnowMailClientApp; 8 import SnowMailClient.Language.Language; 9 10 import java.awt.*; 11 import java.awt.event.*; 12 import javax.swing.*; 13 import javax.swing.event.*; 14 import javax.swing.tree.*; 15 16 18 public class NewMailFromContent extends AbstractAction 19 { 20 FolderTreeNode inbox; 21 MailAccounts accounts; 22 23 public NewMailFromContent(MailAccounts accounts, FolderTreeNode inbox) 24 { 25 super(Language.translate("New mail message from content")); 26 this.inbox = inbox; 27 this.accounts = accounts; 28 29 35 36 putValue(AbstractAction.SHORT_DESCRIPTION, 37 "Create a new empty mail from a pasted content"); 38 39 } 41 public void actionPerformed(ActionEvent e) 42 { 43 JDialog dialog = new JDialog(SnowMailClientApp.getInstance(), 44 "Paste the content here and press ALT-F4, and look in the compose folder", true); 45 dialog.getContentPane().setLayout(new BorderLayout()); 46 JTextArea ta = new JTextArea(50,50); 47 dialog.getContentPane().add(new JScrollPane(ta), BorderLayout.CENTER); 48 dialog.setSize(500,500); 49 dialog.setVisible(true); 50 51 String from = "?"; 52 MailAccount ma = accounts.getSendMailAccount(); 53 if(ma!=null) from = ma.getAddress(); 54 55 MailMessage mess = new MailMessage(); 56 mess.parse(ta.getText()); 57 mess.setEditable(true); 58 59 try 60 { 61 inbox.getMailFolder().addMessage(mess); 62 inbox.saveMailFolder(false); } 64 catch(Exception ex) 65 { 66 JOptionPane.showMessageDialog( 67 SnowMailClientApp.getInstance(), 68 "Error: "+ex.getMessage(), 69 "Error parsing message", 70 JOptionPane.ERROR_MESSAGE); 71 } 72 } 73 74 75 76 } | Popular Tags |