KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > mail > gui > message > viewer > AttachmentModel


1 // The contents of this file are subject to the Mozilla Public License Version
2
// 1.1
3
//(the "License"); you may not use this file except in compliance with the
4
//License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
5
//
6
//Software distributed under the License is distributed on an "AS IS" basis,
7
//WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
8
//for the specific language governing rights and
9
//limitations under the License.
10
//
11
//The Original Code is "The Columba Project"
12
//
13
//The Initial Developers of the Original Code are Frederik Dietz and Timo
14
// Stich.
15
//Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
16
//
17
//All Rights Reserved.
18
package org.columba.mail.gui.message.viewer;
19
20 import java.util.List JavaDoc;
21
22 import org.columba.mail.folder.IMailbox;
23 import org.columba.ristretto.message.MimePart;
24 import org.columba.ristretto.message.MimeTree;
25 import org.columba.ristretto.message.StreamableMimePart;
26
27 public class AttachmentModel {
28
29     private IMailbox folder;
30
31     private Object JavaDoc uid;
32
33     private List JavaDoc displayedMimeParts;
34
35     private MimeTree collection;
36
37     public AttachmentModel() {
38
39     }
40
41     public synchronized void setFolder(IMailbox folder) {
42         this.folder = folder;
43     }
44
45     public synchronized void setUid(Object JavaDoc uid) {
46         this.uid = uid;
47     }
48
49     public IMailbox getFolder() {
50         return folder;
51     }
52
53     public Object JavaDoc getUid() {
54         return uid;
55     }
56
57     /**
58      * Returns the collection.
59      *
60      * @return MimePartTree
61      */

62     public MimeTree getCollection() {
63         return collection;
64     }
65
66     /**
67      * Sets the collection.
68      *
69      * @param collection
70      * The collection to set
71      */

72     public void setCollection(MimeTree collection) {
73         this.collection = collection;
74
75         // Get all MimeParts
76
displayedMimeParts = collection.getAllLeafs();
77
78         // Remove the BodyPart(s) if any
79
StreamableMimePart bodyPart = (StreamableMimePart) collection
80                 .getFirstTextPart("plain");
81
82         if (bodyPart != null) {
83             MimePart bodyParent = bodyPart.getParent();
84
85             if (bodyParent != null) {
86                 if (bodyParent.getHeader().getMimeType().getSubtype().equals(
87                         "alternative")) {
88                     List JavaDoc bodyParts = bodyParent.getChilds();
89                     displayedMimeParts.removeAll(bodyParts);
90                 } else {
91                     displayedMimeParts.remove(bodyPart);
92                 }
93             } else {
94                 displayedMimeParts.remove(bodyPart);
95             }
96         }
97     }
98
99     /**
100      * Returns the displayedMimeParts.
101      *
102      * @return List
103      */

104     public List JavaDoc getDisplayedMimeParts() {
105         return displayedMimeParts;
106     }
107
108     /**
109      * Sets the displayedMimeParts.
110      *
111      * @param displayedMimeParts
112      * The displayedMimeParts to set
113      */

114     public void setDisplayedMimeParts(List JavaDoc displayedMimeParts) {
115         this.displayedMimeParts = displayedMimeParts;
116     }
117 }
Popular Tags