KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > SnowMailClient > view > actions > CopyMessagesToClipboardAsText


1 package SnowMailClient.view.actions;
2
3 import SnowMailClient.SnowMailClientApp;
4 import SnowMailClient.model.folders.*;
5 import SnowMailClient.model.*;
6 import SnowMailClient.view.folders.*;
7 import SnowMailClient.view.*;
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.table.*;
15 import java.awt.dnd.*;
16
17
18
19 /** delete the selected mail (move in the deleted folder)
20 */

21 public final class CopyMessagesToClipboardAsText extends AbstractAction
22 {
23   final private FolderView folderView;
24
25   public CopyMessagesToClipboardAsText(FolderView _folderView)
26   {
27      super(Language.translate("Copy Messages Content To Clipboard"));
28      this.folderView = _folderView;
29
30      //putValue(AbstractAction.SMALL_ICON, SnowMailClientApp.loadImageIcon("pics/addtospam.PNG"));
31

32
33      folderView.getTableSelectionModel().addListSelectionListener( new ListSelectionListener()
34      {
35         public void valueChanged(ListSelectionEvent e)
36         {
37            setEnabled(folderView.getTableSelectionCount()>0);
38         }
39      });
40      setEnabled(folderView.getTableSelectionCount()>0);
41
42   } // Constructor
43

44   public void actionPerformed(ActionEvent e)
45   {
46      StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
47      MailMessage[] messs = folderView.getSelectedMessages();
48      for(int i=0; i<messs.length; i++)
49      {
50         MailMessage mess = messs[i];
51         sb.append(mess.getTextRepresentationForPrinting());
52         if(i<messs.length-1) sb.append("\n\n\n");
53      }
54      SnowMailClientApp.getInstance().copyToClipboard(sb.toString());
55   }
56 }
57  // CopyMessagesToClipboardAsText
Popular Tags