Source Code Cross Referenced for SecurityStatusViewer.java in  » Mail-Clients » columba-1.4 » org » columba » mail » gui » message » viewer » 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.message.viewer 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        //The contents of this file are subject to the Mozilla Public License Version 1.1
002:        //(the "License"); you may not use this file except in compliance with the
003:        //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
004:        //
005:        //Software distributed under the License is distributed on an "AS IS" basis,
006:        //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
007:        //for the specific language governing rights and
008:        //limitations under the License.
009:        //
010:        //The Original Code is "The Columba Project"
011:        //
012:        //The Initial Developers of the Original Code are Frederik Dietz and Timo
013:        // Stich.
014:        //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
015:        //
016:        //All Rights Reserved.
017:        package org.columba.mail.gui.message.viewer;
018:
019:        import java.awt.BorderLayout;
020:        import java.awt.Color;
021:        import java.awt.Image;
022:
023:        import javax.swing.BorderFactory;
024:        import javax.swing.ImageIcon;
025:        import javax.swing.JComponent;
026:        import javax.swing.JLabel;
027:        import javax.swing.JPanel;
028:
029:        import org.columba.core.resourceloader.ImageLoader;
030:        import org.columba.mail.folder.IMailbox;
031:        import org.columba.mail.gui.frame.MailFrameMediator;
032:        import org.columba.mail.gui.message.filter.SecurityStatusEvent;
033:        import org.columba.mail.gui.message.filter.SecurityStatusListener;
034:        import org.columba.mail.parser.text.HtmlParser;
035:        import org.columba.mail.util.MailResourceLoader;
036:
037:        /**
038:         * IViewer displays security status information.
039:         * 
040:         * @author fdietz
041:         * 
042:         */
043:        public class SecurityStatusViewer extends JPanel implements 
044:                ICustomViewer, SecurityStatusListener {
045:
046:            public static final int DECRYPTION_SUCCESS = 0;
047:
048:            public static final int DECRYPTION_FAILURE = 1;
049:
050:            public static final int VERIFICATION_SUCCESS = 2;
051:
052:            public static final int VERIFICATION_FAILURE = 3;
053:
054:            public static final int NO_KEY = 4;
055:
056:            public static final int NOOP = 5;
057:
058:            protected JLabel icon;
059:
060:            protected JLabel text;
061:
062:            protected JPanel left;
063:
064:            private boolean visible;
065:
066:            public SecurityStatusViewer() {
067:                super ();
068:
069:                setLayout(new BorderLayout());
070:
071:                left = new JPanel();
072:                left.setLayout(new BorderLayout());
073:                left.setBorder(BorderFactory.createEmptyBorder(0, 5, 5, 5));
074:
075:                icon = new JLabel();
076:                left.add(icon, BorderLayout.NORTH);
077:
078:                add(left, BorderLayout.WEST);
079:                text = new JLabel();
080:                add(text, BorderLayout.CENTER);
081:
082:                setValue(SecurityStatusViewer.NOOP, "");
083:
084:                updateUI();
085:
086:                visible = false;
087:            }
088:
089:            public void updateUI() {
090:                super .updateUI();
091:
092:                setBorder(new MessageBorder(new Color(255, 255, 60), 1, true));
093:
094:                Color color = new Color(255, 255, 160);
095:
096:                setBackground(color);
097:
098:                if (icon != null) {
099:                    icon.setBackground(color);
100:                }
101:
102:                if (text != null) {
103:                    text.setBackground(color);
104:                }
105:
106:                if (left != null) {
107:                    left.setBackground(color);
108:                }
109:            }
110:
111:            private void setValue(int value, String message) {
112:                ImageIcon image = null;
113:
114:                switch (value) {
115:                case SecurityStatusViewer.DECRYPTION_SUCCESS: {
116:                    image = ImageLoader.getMiscIcon("signature-ok.png");
117:
118:                    icon.setToolTipText(MailResourceLoader.getString("menu",
119:                            "mainframe", "security_decrypt_success"));
120:                    text.setText(transformToHTML(MailResourceLoader.getString(
121:                            "menu", "mainframe", "security_decrypt_success"),
122:                            message));
123:
124:                    break;
125:                }
126:
127:                case SecurityStatusViewer.DECRYPTION_FAILURE: {
128:                    image = ImageLoader.getMiscIcon("signature-bad.png");
129:                    icon.setToolTipText(MailResourceLoader.getString("menu",
130:                            "mainframe", "security_encrypt_fail"));
131:                    text.setText(transformToHTML(MailResourceLoader.getString(
132:                            "menu", "mainframe", "security_encrypt_fail"),
133:                            message));
134:
135:                    break;
136:                }
137:
138:                case SecurityStatusViewer.VERIFICATION_SUCCESS: {
139:                    image = ImageLoader.getMiscIcon("signature-ok.png");
140:                    icon.setToolTipText(MailResourceLoader.getString("menu",
141:                            "mainframe", "security_verify_success"));
142:                    text.setText(transformToHTML(MailResourceLoader.getString(
143:                            "menu", "mainframe", "security_verify_success"),
144:                            message));
145:
146:                    break;
147:                }
148:
149:                case SecurityStatusViewer.VERIFICATION_FAILURE: {
150:                    image = ImageLoader.getMiscIcon("signature-bad.png");
151:
152:                    icon.setToolTipText(MailResourceLoader.getString("menu",
153:                            "mainframe", "security_verify_fail"));
154:                    text.setText(transformToHTML(MailResourceLoader.getString(
155:                            "menu", "mainframe", "security_verify_fail"),
156:                            message));
157:
158:                    break;
159:                }
160:
161:                case SecurityStatusViewer.NO_KEY: {
162:                    image = ImageLoader.getMiscIcon("signature-nokey.png");
163:                    icon.setToolTipText(MailResourceLoader.getString("menu",
164:                            "mainframe", "security_verify_nokey"));
165:                    text.setText(transformToHTML(MailResourceLoader.getString(
166:                            "menu", "mainframe", "security_verify_nokey"),
167:                            message));
168:
169:                    break;
170:                }
171:
172:                case SecurityStatusViewer.NOOP: {
173:                    text.setText("");
174:                    icon.setIcon(null);
175:
176:                    break;
177:                }
178:                }
179:
180:                if (image != null) {
181:                    // scale image
182:                    image = new ImageIcon(image.getImage().getScaledInstance(
183:                            16, 16, Image.SCALE_SMOOTH));
184:
185:                    icon.setIcon(image);
186:                }
187:
188:                updateUI();
189:            }
190:
191:            protected String transformToHTML(String title, String message) {
192:                // convert special characters
193:                String html = null;
194:
195:                if (message != null) {
196:                    html = HtmlParser.substituteSpecialCharacters(message);
197:                }
198:
199:                StringBuffer buf = new StringBuffer();
200:
201:                buf.append("<html><body><p>");
202:                // buf.append("<b>" + title + "</b><br>");
203:                buf.append(title + "<br>");
204:                buf.append(html);
205:                buf.append("</p></body></html>");
206:
207:                return buf.toString();
208:            }
209:
210:            /**
211:             * @see org.columba.mail.gui.message.viewer.IViewer#view(IMailbox,
212:             *      java.lang.Object, org.columba.mail.gui.frame.MailFrameMediator)
213:             */
214:            public void view(IMailbox folder, Object uid,
215:                    MailFrameMediator mediator) throws Exception {
216:
217:            }
218:
219:            /**
220:             * @see org.columba.mail.gui.message.viewer.IViewer#getView()
221:             */
222:            public JComponent getView() {
223:                return this ;
224:            }
225:
226:            /**
227:             * @see org.columba.mail.gui.message.filter.SecurityStatusListener#statusUpdate(org.columba.mail.gui.message.filter.SecurityStatusEvent)
228:             */
229:            public void statusUpdate(SecurityStatusEvent event) {
230:                String message = event.getMessage();
231:                int status = event.getStatus();
232:
233:                setValue(status, message);
234:
235:                if (status == NOOP)
236:                    visible = false;
237:                else
238:                    visible = true;
239:            }
240:
241:            /**
242:             * @see org.columba.mail.gui.message.viewer.IViewer#isVisible()
243:             */
244:            public boolean isVisible() {
245:                return visible;
246:            }
247:
248:            /**
249:             * @see org.columba.mail.gui.message.viewer.IViewer#updateGUI()
250:             */
251:            public void updateGUI() throws Exception {
252:
253:            }
254:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.