KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > mail > gui > message > filter > AbstractFilter


1 //The contents of this file are subject to the Mozilla Public License Version 1.1
2
//(the "License"); you may not use this file except in compliance with the
3
//License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
4
//
5
//Software distributed under the License is distributed on an "AS IS" basis,
6
//WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
7
//for the specific language governing rights and
8
//limitations under the License.
9
//
10
//The Original Code is "The Columba Project"
11
//
12
//The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
13
//Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
14
//
15
//All Rights Reserved.
16

17 package org.columba.mail.gui.message.filter;
18
19 import org.columba.api.gui.frame.IFrameMediator;
20 import org.columba.mail.command.IMailFolderCommandReference;
21 import org.columba.mail.command.MailFolderCommandReference;
22 import org.columba.mail.folder.IMailbox;
23 import org.columba.mail.folder.temp.TempFolder;
24 import org.columba.mail.gui.frame.MailFrameMediator;
25 import org.columba.mail.gui.message.IMessageController;
26 import org.columba.mail.gui.table.selection.TableSelectionHandler;
27 import org.columba.mail.gui.tree.FolderTreeModel;
28 import org.columba.mail.message.IColumbaMessage;
29
30 /**
31  * Should be used by every filter, which alters the message contents. This
32  * is done the following way:
33  * <p>
34  * A new message is created and added to a temporary folder. All references of
35  * the sources folder are re-mapped to the message in the temporary folder.
36  * <p>
37  *
38  * @author fdietz
39  */

40 public abstract class AbstractFilter implements Filter {
41
42     private MailFrameMediator mediator;
43
44     
45     public AbstractFilter(MailFrameMediator mediator, IMessageController messageViewer) {
46         this.mediator = mediator;
47     }
48     /**
49      * @return
50      * @see org.columba.mail.gui.message.filter.Filter#filter(IMailbox, java.lang.Object)
51      */

52     public IMailFolderCommandReference filter(IMailbox folder, Object JavaDoc uid, IColumbaMessage message) throws Exception JavaDoc {
53 // map selection to this temporary message
54
TempFolder tempFolder = FolderTreeModel.getInstance().getTempFolder();
55
56         // add message to temporary folder
57
uid = tempFolder.addMessage(message);
58
59         
60         // create reference to this message
61
MailFolderCommandReference local = new MailFolderCommandReference(tempFolder,
62                 new Object JavaDoc[] {uid});
63
64         // if we don't use this here - actions like reply would only work
65
// on the
66
// the encrypted message
67
TableSelectionHandler h1 = ((TableSelectionHandler) mediator
68                 .getSelectionManager().getHandler(TableSelectionHandler.HANDLER_ID));
69
70         h1.setLocalReference(local);
71
72         // this is needed to be able to open attachments of the decrypted
73
// message
74

75         // TODO check if we have to manually set the folder/uid in
76
// message controller to make this work
77

78         //messageController.setAttachmentSelectionReference(local);
79

80         return local;
81     }
82
83     /**
84      * @return Returns the mediator.
85      */

86     public IFrameMediator getMediator() {
87         return mediator;
88     }
89 }
90
Popular Tags