01: package org.columba.mail.gui.composer;
02:
03: import java.awt.event.ActionEvent;
04: import java.io.File;
05:
06: import javax.swing.AbstractAction;
07:
08: import org.columba.core.desktop.ColumbaDesktop;
09: 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")
33: && type.getSubtype().equals("rfc822")) {
34: //TODO: Open in message frame
35: //TODO: Handle also message attachments from OpenInComposer action
36: } else if (mimePart instanceof LocalMimePart
37: && ((LocalMimePart) mimePart).getBody() instanceof FileSource) {
38: File file = ((FileSource) ((LocalMimePart) mimePart)
39: .getBody()).getFile();
40:
41: ColumbaDesktop.getInstance().open(file);
42: }
43: }
44:
45: }
|