1 package org.columba.mail.gui.composer; 2 3 import java.awt.event.ActionEvent ; 4 import java.io.File ; 5 6 import javax.swing.AbstractAction ; 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 { 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 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 } else if( mimePart instanceof LocalMimePart && ((LocalMimePart)mimePart).getBody() instanceof FileSource){ 36 File file = ((FileSource)((LocalMimePart)mimePart).getBody()).getFile(); 37 38 ColumbaDesktop.getInstance().open(file); 39 } 40 } 41 42 } 43 | Popular Tags |