1 package SnowMailClient.view.folders; 2 3 import snow.utils.gui.Icons; 4 import SnowMailClient.model.folders.*; 5 import SnowMailClient.model.*; 6 import SnowMailClient.SnowMailClientApp; 7 import SnowMailClient.Language.Language; 8 9 import java.awt.*; 10 import java.awt.event.*; 11 import javax.swing.*; 12 import javax.swing.event.*; 13 import javax.swing.tree.*; 14 15 public class EmptyFolderAction extends AbstractAction 16 { 17 18 FolderTreeNode node; 19 JTree tree; 20 FolderTreeNode deletedMailsNode; 21 22 public EmptyFolderAction( FolderTreeNode node, JTree tree, FolderTreeNode deletedMailsNode ) 23 { 24 super(Language.translate("Delete all mails in folder %",node.getFolderName())); 25 putValue(AbstractAction.SMALL_ICON, Icons.CrossIcon.shared10); 26 27 this.node = node; 28 this.tree = tree; 29 this.deletedMailsNode = deletedMailsNode; 30 } 31 32 public void actionPerformed(ActionEvent e) 33 { 34 35 try 36 { 37 MailFolder folder = node.getMailFolder(); 38 39 int reply = JOptionPane.showConfirmDialog(tree, 40 Language.translate("Are you sure you want to delete the % mails in the folder ?", ""+folder.getRowCount()), 41 Language.translate("Confirm deletion"), JOptionPane.YES_NO_OPTION); 42 43 if(reply==JOptionPane.OK_OPTION) 44 { 45 for(MailMessage mess: folder.getAllMessages()) 47 { 48 if(folder.equals(deletedMailsNode.getMailFolder())) 49 { 50 } 52 else 53 { 54 deletedMailsNode.getMailFolder().addMessage(mess); 56 } 57 58 folder.removeMessage(mess); 59 } 60 } 61 } 62 catch(Exception e2) 63 { 64 JOptionPane.showMessageDialog(tree, Language.translate("Error")+": "+e2.getMessage(), 65 Language.translate("Cannot delete all mails in folder"), 66 JOptionPane.ERROR_MESSAGE); 67 68 } 69 70 } 71 72 } | Popular Tags |