Source Code Cross Referenced for MailScreen.java in  » Ajax » NextApp-Echo2 » echo2example » email » 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 » Ajax » NextApp Echo2 » echo2example.email 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* 
002:         * This file is part of the Echo Web Application Framework (hereinafter "Echo").
003:         * Copyright (C) 2002-2005 NextApp, Inc.
004:         *
005:         * Version: MPL 1.1/GPL 2.0/LGPL 2.1
006:         *
007:         * The contents of this file are subject to the Mozilla Public License Version
008:         * 1.1 (the "License"); you may not use this file except in compliance with
009:         * the License. You may obtain a copy of the License at
010:         * http://www.mozilla.org/MPL/
011:         *
012:         * Software distributed under the License is distributed on an "AS IS" basis,
013:         * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
014:         * for the specific language governing rights and limitations under the
015:         * License.
016:         *
017:         * Alternatively, the contents of this file may be used under the terms of
018:         * either the GNU General Public License Version 2 or later (the "GPL"), or
019:         * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
020:         * in which case the provisions of the GPL or the LGPL are applicable instead
021:         * of those above. If you wish to allow use of your version of this file only
022:         * under the terms of either the GPL or the LGPL, and not to allow others to
023:         * use your version of this file under the terms of the MPL, indicate your
024:         * decision by deleting the provisions above and replace them with the notice
025:         * and other provisions required by the GPL or the LGPL. If you do not delete
026:         * the provisions above, a recipient may use your version of this file under
027:         * the terms of any one of the MPL, the GPL or the LGPL.
028:         */
029:
030:        package echo2example.email;
031:
032:        import javax.mail.Folder;
033:        import javax.mail.Message;
034:        import javax.mail.MessagingException;
035:        import javax.mail.Store;
036:
037:        import echo2example.email.MessageListTable.MessageSelectionEvent;
038:        import echo2example.email.PageNavigator.PageIndexChangeEvent;
039:
040:        import nextapp.echo2.app.Button;
041:        import nextapp.echo2.app.Column;
042:        import nextapp.echo2.app.Component;
043:        import nextapp.echo2.app.ContentPane;
044:        import nextapp.echo2.app.Extent;
045:        import nextapp.echo2.app.Label;
046:        import nextapp.echo2.app.Row;
047:        import nextapp.echo2.app.SelectField;
048:        import nextapp.echo2.app.SplitPane;
049:        import nextapp.echo2.app.event.ActionEvent;
050:        import nextapp.echo2.app.event.ActionListener;
051:        import nextapp.echo2.app.list.AbstractListModel;
052:
053:        /**
054:         * The multi-paned main mail-viewing screen of the application.
055:         * This component contains the page navigator, message list, and message
056:         * preview panes.
057:         */
058:        public class MailScreen extends ContentPane {
059:
060:            // Constants for new dialog positioning algorithm.
061:            private static final int DIALOG_POSITION_INITIAL = 80;
062:            private static final int DIALOG_POSITION_INCREMENT = 20;
063:            private static final int DIALOG_POSITION_MAXIMUM = 200;
064:
065:            private Folder[] folders;
066:
067:            private MessageListTable messageListTable;
068:            private PageNavigator pageNavigator;
069:            private MessagePane messagePane;
070:            private SelectField folderSelect;
071:            private Message selectedMessage;
072:            private int dialogPosition = DIALOG_POSITION_INITIAL;
073:
074:            /**
075:             * Creates a new <code>MailScreen</code>.
076:             */
077:            public MailScreen() {
078:                super ();
079:
080:                SplitPane mainSplitPane = new SplitPane(
081:                        SplitPane.ORIENTATION_HORIZONTAL, new Extent(175));
082:                mainSplitPane.setSeparatorWidth(new Extent(1, Extent.PX));
083:                add(mainSplitPane);
084:
085:                SplitPane titleOptionSplitPane = new SplitPane(
086:                        SplitPane.ORIENTATION_VERTICAL, new Extent(70));
087:                titleOptionSplitPane
088:                        .setSeparatorHeight(new Extent(1, Extent.PX));
089:                mainSplitPane.add(titleOptionSplitPane);
090:
091:                Column titleColumn = new Column();
092:                titleColumn.setStyleName("MailScreen.TitleColumn");
093:                titleOptionSplitPane.add(titleColumn);
094:                Label label;
095:
096:                label = new Label(Messages.getString("Application.Title.Main"));
097:                label.setStyleName("Title.Main");
098:                titleColumn.add(label);
099:
100:                label = new Label(Messages.getString("Application.Title.Sub"));
101:                label.setStyleName("Title.Sub");
102:                titleColumn.add(label);
103:
104:                titleOptionSplitPane.add(createOptionPane());
105:
106:                SplitPane mailSplitPane = new SplitPane(
107:                        SplitPane.ORIENTATION_VERTICAL, new Extent(320));
108:                mailSplitPane.setResizable(true);
109:                mainSplitPane.add(mailSplitPane);
110:
111:                SplitPane messageListSplitPane = new SplitPane(
112:                        SplitPane.ORIENTATION_VERTICAL, new Extent(32));
113:                messageListSplitPane
114:                        .setSeparatorHeight(new Extent(1, Extent.PX));
115:                mailSplitPane.add(messageListSplitPane);
116:
117:                Row controlPane = new Row();
118:                controlPane.setStyleName("ControlPane");
119:                messageListSplitPane.add(controlPane);
120:
121:                pageNavigator = new PageNavigator();
122:                pageNavigator
123:                        .addPageIndexChangeListener(new PageNavigator.PageIndexChangeListener() {
124:                            public void pageIndexChanged(PageIndexChangeEvent e) {
125:                                try {
126:                                    messageListTable.setPageIndex(e
127:                                            .getNewPageIndex());
128:                                    messagePane.setMessage(null);
129:                                } catch (MessagingException ex) {
130:                                    EmailApp.getApp().processFatalException(ex);
131:                                }
132:                            }
133:                        });
134:                controlPane.add(pageNavigator);
135:
136:                messageListTable = new MessageListTable();
137:                messageListTable
138:                        .addMessageSelectionListener(new MessageListTable.MessageSelectionListener() {
139:                            public void messageSelected(MessageSelectionEvent e) {
140:                                try {
141:                                    selectedMessage = e.getMessage();
142:                                    messagePane.setMessage(selectedMessage);
143:                                } catch (MessagingException ex) {
144:                                    EmailApp.getApp().processFatalException(ex);
145:                                }
146:                            }
147:                        });
148:                messageListSplitPane.add(messageListTable);
149:
150:                messagePane = new MessagePane();
151:                mailSplitPane.add(messagePane);
152:            }
153:
154:            /**
155:             * Creates the "option pane".
156:             * 
157:             * @return the option pane <code>Component</code>
158:             */
159:            private Component createOptionPane() {
160:                Button button;
161:                Label label;
162:
163:                Column optionColumn = new Column();
164:                optionColumn.setStyleName("MailScreen.OptionColumn");
165:
166:                Column folderSelectColumn = new Column();
167:                folderSelectColumn
168:                        .setStyleName("MailScreen.FolderSelectColumn");
169:                optionColumn.add(folderSelectColumn);
170:
171:                label = new Label(Messages
172:                        .getString("MailScreen.PromptFolderSelect"));
173:                folderSelectColumn.add(label);
174:
175:                folderSelect = new SelectField();
176:                folderSelect.addActionListener(new ActionListener() {
177:                    public void actionPerformed(ActionEvent e) {
178:                        setFolder(folders[folderSelect.getSelectedIndex()]);
179:                    }
180:                });
181:                folderSelectColumn.add(folderSelect);
182:
183:                Column actionsColumn = new Column();
184:                optionColumn.add(actionsColumn);
185:
186:                button = new Button(Messages
187:                        .getString("MailScreen.ButtonNewMessage"),
188:                        Styles.ICON_24_MAIL_COMPOSE);
189:                button.setStyleName("MailScreen.OptionButton");
190:                button.addActionListener(new ActionListener() {
191:                    public void actionPerformed(ActionEvent e) {
192:                        processCompose(null);
193:                    }
194:                });
195:                actionsColumn.add(button);
196:
197:                button = new Button(Messages
198:                        .getString("MailScreen.ButtonReplyTo"),
199:                        Styles.ICON_24_MAIL_REPLY);
200:                button.setStyleName("MailScreen.OptionButton");
201:                button.addActionListener(new ActionListener() {
202:                    public void actionPerformed(ActionEvent e) {
203:                        if (selectedMessage != null) {
204:                            processCompose(selectedMessage);
205:                        }
206:                    }
207:                });
208:                actionsColumn.add(button);
209:
210:                button = new Button(Messages
211:                        .getString("MailScreen.ButtonLogOut"),
212:                        Styles.ICON_24_EXIT);
213:                button.setStyleName("MailScreen.OptionButton");
214:                button.addActionListener(new ActionListener() {
215:                    public void actionPerformed(ActionEvent e) {
216:                        ((EmailApp) getApplicationInstance()).disconnect();
217:                    }
218:                });
219:                optionColumn.add(button);
220:
221:                return optionColumn;
222:            }
223:
224:            /**
225:             * Processes a user request to compose/reply to a message.
226:             * 
227:             * @param message the message to reply to, or null to a compose a new 
228:             *        message.
229:             */
230:            private void processCompose(Message message) {
231:                ComposeWindow composeWindow = new ComposeWindow(message);
232:                Extent dialogPositionExtent = new Extent(dialogPosition);
233:                composeWindow.setPositionX(dialogPositionExtent);
234:                composeWindow.setPositionY(dialogPositionExtent);
235:                dialogPosition += DIALOG_POSITION_INCREMENT;
236:                if (dialogPosition > DIALOG_POSITION_MAXIMUM) {
237:                    dialogPosition = DIALOG_POSITION_INITIAL;
238:                }
239:
240:                getApplicationInstance().getDefaultWindow().getContent().add(
241:                        composeWindow);
242:            }
243:
244:            /**
245:             * Sets the active folder.
246:             * 
247:             * @param folder the <code>Folder</code>
248:             */
249:            private void setFolder(Folder folder) {
250:                try {
251:                    messageListTable.setFolder(null);
252:                    int messageCount = folder.getMessageCount();
253:                    int totalPages = folder.getMessageCount()
254:                            / EmailApp.MESSAGES_PER_PAGE;
255:                    if (messageCount % EmailApp.MESSAGES_PER_PAGE > 0) {
256:                        ++totalPages;
257:                    }
258:                    pageNavigator.setTotalPages(totalPages);
259:                    pageNavigator.setPageIndex(totalPages - 1);
260:                    messageListTable.setFolder(folder);
261:                    messagePane.setMessage(null);
262:                } catch (MessagingException ex) {
263:                    EmailApp.getApp().processFatalException(ex);
264:                }
265:            }
266:
267:            /**
268:             * Sets the mail <code>Store</code>.
269:             * This method is invoked by the <code>EmailApp</code> instance to 
270:             * initialize the <code>MailScreen</code>.
271:             * 
272:             * @param store the <code>Store</code>
273:             */
274:            public void setStore(Store store) throws MessagingException {
275:                folders = store.getDefaultFolder().list("*");
276:                folderSelect.setModel(new AbstractListModel() {
277:
278:                    public Object get(int index) {
279:                        return folders[index].getName();
280:                    }
281:
282:                    public int size() {
283:                        return folders.length;
284:                    }
285:                });
286:                for (int i = 0; i < folders.length; ++i) {
287:                    if ("INBOX".equals(folders[i].getName())) {
288:                        folderSelect.setSelectedIndex(i);
289:                        setFolder(folders[i]);
290:                        break;
291:                    }
292:                }
293:            }
294:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.