KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > mail > gui > composer > OpenAttachmentAction


1 package org.columba.mail.gui.composer;
2
3 import java.awt.event.ActionEvent JavaDoc;
4 import java.io.File JavaDoc;
5
6 import javax.swing.AbstractAction JavaDoc;
7
8 import org.columba.core.desktop.ColumbaDesktop;
9 import org.columba.ristretto.io.FileSource;
10 import org.columba.ristretto.message.LocalMimePart;
11 import org.columba.ristretto.message.MimePart;
12 import org.columba.ristretto.message.MimeType;
13 import org.frapuccino.iconpanel.IconPanel;
14
15 public class OpenAttachmentAction extends AbstractAction JavaDoc {
16
17     AttachmentView view;
18     
19     public OpenAttachmentAction(AttachmentView view) {
20         super();
21         
22         this.view = view;
23         
24         setEnabled(ColumbaDesktop.getInstance().supportsOpen());
25     }
26
27     public void actionPerformed(ActionEvent JavaDoc e) {
28         int index = ((IconPanel) e.getSource()).getSelectedIndex();
29         
30         MimePart mimePart = view.get(index);
31         MimeType type = mimePart.getHeader().getMimeType();
32         if( type.getType().equals("message") && type.getSubtype().equals("rfc822") ) {
33             //TODO: Open in message frame
34
//TODO: Handle also message attachments from OpenInComposer action
35
} else if( mimePart instanceof LocalMimePart && ((LocalMimePart)mimePart).getBody() instanceof FileSource){
36             File JavaDoc file = ((FileSource)((LocalMimePart)mimePart).getBody()).getFile();
37             
38             ColumbaDesktop.getInstance().open(file);
39         }
40     }
41
42 }
43
Popular Tags