001: // The contents of this file are subject to the Mozilla Public License Version
002: // 1.1
003: //(the "License"); you may not use this file except in compliance with the
004: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
005: //
006: //Software distributed under the License is distributed on an "AS IS" basis,
007: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
008: //for the specific language governing rights and
009: //limitations under the License.
010: //
011: //The Original Code is "The Columba Project"
012: //
013: //The Initial Developers of the Original Code are Frederik Dietz and Timo
014: // Stich.
015: //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
016: //
017: //All Rights Reserved.
018: package org.columba.mail.gui.message.viewer;
019:
020: import java.util.List;
021:
022: import org.columba.mail.folder.IMailbox;
023: import org.columba.ristretto.message.MimePart;
024: import org.columba.ristretto.message.MimeTree;
025: import org.columba.ristretto.message.StreamableMimePart;
026:
027: public class AttachmentModel {
028:
029: private IMailbox folder;
030:
031: private Object uid;
032:
033: private List displayedMimeParts;
034:
035: private MimeTree collection;
036:
037: public AttachmentModel() {
038:
039: }
040:
041: public synchronized void setFolder(IMailbox folder) {
042: this .folder = folder;
043: }
044:
045: public synchronized void setUid(Object uid) {
046: this .uid = uid;
047: }
048:
049: public IMailbox getFolder() {
050: return folder;
051: }
052:
053: public Object getUid() {
054: return uid;
055: }
056:
057: /**
058: * Returns the collection.
059: *
060: * @return MimePartTree
061: */
062: public MimeTree getCollection() {
063: return collection;
064: }
065:
066: /**
067: * Sets the collection.
068: *
069: * @param collection
070: * The collection to set
071: */
072: public void setCollection(MimeTree collection) {
073: this .collection = collection;
074:
075: // Get all MimeParts
076: displayedMimeParts = collection.getAllLeafs();
077:
078: // Remove the BodyPart(s) if any
079: StreamableMimePart bodyPart = (StreamableMimePart) collection
080: .getFirstTextPart("plain");
081:
082: if (bodyPart != null) {
083: MimePart bodyParent = bodyPart.getParent();
084:
085: if (bodyParent != null) {
086: if (bodyParent.getHeader().getMimeType().getSubtype()
087: .equals("alternative")) {
088: List bodyParts = bodyParent.getChilds();
089: displayedMimeParts.removeAll(bodyParts);
090: } else {
091: displayedMimeParts.remove(bodyPart);
092: }
093: } else {
094: displayedMimeParts.remove(bodyPart);
095: }
096: }
097: }
098:
099: /**
100: * Returns the displayedMimeParts.
101: *
102: * @return List
103: */
104: public List 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 displayedMimeParts) {
115: this.displayedMimeParts = displayedMimeParts;
116: }
117: }
|