Source Code Cross Referenced for SelectionOptionsPlugin.java in  » Mail-Clients » columba-1.4 » org » columba » mail » folderoptions » 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.folderoptions 
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.folderoptions;
019:
020:        import org.columa.core.config.IDefaultItem;
021:        import org.columba.core.config.DefaultItem;
022:        import org.columba.core.xml.XmlElement;
023:        import org.columba.mail.folder.IMailbox;
024:        import org.columba.mail.gui.frame.MailFrameMediator;
025:        import org.columba.mail.gui.frame.TableViewOwner;
026:        import org.columba.mail.gui.table.IMessageNode;
027:        import org.columba.mail.gui.table.ITableController;
028:
029:        /**
030:         * Handles selecting message after folder selection changes.
031:         * <p>
032:         * This implementation remembers the the selected message, and tries to reselect
033:         * it again. As default fall back it selects the first or last message,
034:         * depending on the sorting order.
035:         * 
036:         * @author fdietz, waffel
037:         */
038:        public class SelectionOptionsPlugin extends AbstractFolderOptionsPlugin {
039:
040:            /**
041:             * Constructor
042:             * 
043:             * @param mediator
044:             *            mail frame mediator
045:             */
046:            public SelectionOptionsPlugin(MailFrameMediator mediator) {
047:                super ("selection", "SelectionOptions", mediator);
048:            }
049:
050:            /**
051:             * 
052:             * Save currently selected message.
053:             * 
054:             * @see org.columba.mail.folderoptions.AbstractFolderOptionsPlugin#saveOptionsToXml(IMailbox)
055:             */
056:            public void saveOptionsToXml(IMailbox folder) {
057:                ITableController tableController = ((ITableController) ((TableViewOwner) getMediator())
058:                        .getTableController());
059:
060:                if (tableController.getSelectedNodes() == null)
061:                    return;
062:
063:                if (tableController.getSelectedNodes().length == 0)
064:                    return;
065:
066:                IMessageNode node = tableController.getSelectedNodes()[0];
067:                if ((node != null) && (folder != null))
068:                    folder.setLastSelection(node.getUid());
069:            }
070:
071:            /**
072:             * Restore selection.
073:             * 
074:             * @see org.columba.mail.folderoptions.AbstractFolderOptionsPlugin#loadOptionsFromXml(IMailbox)
075:             */
076:            public void loadOptionsFromXml(IMailbox folder) {
077:                XmlElement parent = getConfigNode(folder);
078:                IDefaultItem item = new DefaultItem(parent);
079:
080:                ITableController tableController = ((ITableController) ((TableViewOwner) getMediator())
081:                        .getTableController());
082:
083:                // TableView view = tableController.getView();
084:
085:                // should we re-use the last remembered selection?
086:                boolean remember = item.getBooleanWithDefault(
087:                        "remember_last_selection", true);
088:
089:                // sorting order
090:                boolean ascending = tableController.getSortingOrder();
091:
092:                // row count
093:                int row = tableController.getRowCount();
094:
095:                // row count == 0 --> empty table
096:                if (row == 0) {
097:                    // clear message viewer
098:                    // /tableController.valueChanged(new
099:                    // ListSelectionEvent(this,-1,-1,false));
100:                    tableController.clearSelection();
101:                    return;
102:                }
103:
104:                // if the last selection for the current folder is null, then we show
105:                // the
106:                // first/last message in the table and scroll to it.
107:                if ((!remember) || (folder.getLastSelection() == null)) {
108:                    // changing the selection to the first/last row based on ascending
109:                    // state
110:                    Object uid = null;
111:
112:                    if (ascending) {
113:                        uid = tableController.selectLastRow();
114:                    } else {
115:                        uid = tableController.selectFirstRow();
116:                    }
117:
118:                    // no messages in this folder
119:                    if (uid == null) {
120:                        return;
121:                    }
122:
123:                } else {
124:
125:                    // if a lastSelection for this folder is set
126:                    // getting the last selected uid
127:                    Object[] lastSelUids = { folder.getLastSelection() };
128:
129:                    // no messages in this folder
130:                    if (lastSelUids[0] == null) {
131:                        return;
132:                    }
133:
134:                    Object uid = lastSelUids[0];
135:
136:                    // this message doesn't exit in this folder anymore
137:                    if (tableController.getMessageNode(uid) == null) {
138:
139:                        if (ascending) {
140:                            uid = tableController.selectLastRow();
141:                        } else {
142:                            uid = tableController.selectFirstRow();
143:                        }
144:
145:                    } else {
146:
147:                        // selecting the message
148:                        tableController.setSelected(new Object[] { uid });
149:                    }
150:
151:                }
152:            }
153:
154:            /**
155:             * @see org.columba.mail.folderoptions.AbstractFolderOptionsPlugin#createDefaultElement()
156:             */
157:            public XmlElement createDefaultElement(boolean global) {
158:                XmlElement parent = super .createDefaultElement(global);
159:                parent.addAttribute("remember_last_selection", "true");
160:
161:                return parent;
162:            }
163:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.