Source Code Cross Referenced for ReplyWithTemplateCommand.java in  » Mail-Clients » columba-1.4 » org » columba » mail » gui » composer » command » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Mail Clients » columba 1.4 » org.columba.mail.gui.composer.command 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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.composer.command;
019:
020:        import java.io.IOException;
021:        import java.io.InputStream;
022:
023:        import org.columba.api.command.ICommandReference;
024:        import org.columba.api.command.IWorkerStatusController;
025:        import org.columba.api.gui.frame.IFrameMediator;
026:        import org.columba.core.command.CommandCancelledException;
027:        import org.columba.core.io.StreamUtils;
028:        import org.columba.core.xml.XmlElement;
029:        import org.columba.mail.command.MailFolderCommandReference;
030:        import org.columba.mail.config.MailConfig;
031:        import org.columba.mail.folder.IMailbox;
032:        import org.columba.mail.gui.composer.ComposerModel;
033:        import org.columba.mail.gui.config.template.ChooseTemplateDialog;
034:        import org.columba.mail.gui.tree.FolderTreeModel;
035:        import org.columba.mail.message.IHeaderList;
036:        import org.columba.ristretto.message.MimePart;
037:        import org.columba.ristretto.message.MimeTree;
038:
039:        /**
040:         * Opens a dialog to ask the user which template to use
041:         * 
042:         * @author fdietz
043:         */
044:        public class ReplyWithTemplateCommand extends ReplyCommand {
045:
046:            private IFrameMediator mediator;
047:
048:            public ReplyWithTemplateCommand(IFrameMediator mediator,
049:                    ICommandReference reference) {
050:                super (reference);
051:
052:                this .mediator = mediator;
053:            }
054:
055:            public void execute(IWorkerStatusController worker)
056:                    throws Exception {
057:                // create composer model
058:                model = new ComposerModel();
059:
060:                // get selected folder
061:                IMailbox folder = (IMailbox) ((MailFolderCommandReference) getReference())
062:                        .getSourceFolder();
063:
064:                // get first selected message
065:                Object[] uids = ((MailFolderCommandReference) getReference())
066:                        .getUids();
067:
068:                // ->set source reference in composermodel
069:                // when replying this is the original sender's message
070:                // you selected and replied to
071:                MailFolderCommandReference ref = new MailFolderCommandReference(
072:                        folder, uids);
073:                model.setSourceReference(ref);
074:
075:                // setup to, references and account
076:                initHeader(folder, uids);
077:
078:                // get mimeparts
079:                MimeTree mimePartTree = folder.getMimePartTree(uids[0]);
080:
081:                XmlElement html = MailConfig.getInstance()
082:                        .getMainFrameOptionsConfig().getRoot().getElement(
083:                                "/options/html");
084:
085:                // Which Bodypart shall be shown? (html/plain)
086:                MimePart bodyPart = null;
087:
088:                if (Boolean.valueOf(html.getAttribute("prefer")).booleanValue()) {
089:                    bodyPart = mimePartTree.getFirstTextPart("html");
090:                } else {
091:                    bodyPart = mimePartTree.getFirstTextPart("plain");
092:                }
093:
094:                if (bodyPart != null) {
095:                    // setup charset and html
096:                    initMimeHeader(bodyPart);
097:
098:                    Integer[] address = bodyPart.getAddress();
099:
100:                    String quotedBodyText = createQuotedBody(bodyPart
101:                            .getHeader(), folder, uids, address);
102:
103:                    // get answer from template
104:                    String templateBody = getTemplateBody();
105:
106:                    model.setBodyText(quotedBodyText + templateBody);
107:                } else {
108:                    model.setBodyText(getTemplateBody());
109:                }
110:            }
111:
112:            private String getTemplateBody() throws Exception,
113:                    CommandCancelledException, IOException {
114:                // template folder has uid=107
115:                IMailbox templateFolder = (IMailbox) FolderTreeModel
116:                        .getInstance().getFolder("107");
117:
118:                // retrieve headerlist of tempate folder
119:                IHeaderList list = templateFolder.getHeaderList();
120:
121:                // choose template
122:                ChooseTemplateDialog d = new ChooseTemplateDialog(mediator
123:                        .getView().getFrame(), list);
124:
125:                Object uid = null;
126:
127:                if (d.isResult()) {
128:                    // user pressed OK
129:                    uid = d.getUid();
130:                } else {
131:                    throw new CommandCancelledException();
132:                }
133:
134:                // get bodytext of template message
135:                MimeTree tree = templateFolder.getMimePartTree(uid);
136:
137:                // *20030926, karlpeder* Added html support
138:                // MimePart mp = tree.getFirstTextPart("plain");
139:                MimePart mp;
140:
141:                if (model.isHtml()) {
142:                    mp = tree.getFirstTextPart("html");
143:                } else {
144:                    mp = tree.getFirstTextPart("text");
145:                }
146:
147:                InputStream bodyStream = templateFolder.getMimePartBodyStream(
148:                        uid, mp.getAddress());
149:
150:                String body = StreamUtils.readCharacterStream(bodyStream)
151:                        .toString();
152:
153:                bodyStream.close();
154:                return body;
155:            }
156:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.