Source Code Cross Referenced for SecurityPanel.java in  » Mail-Clients » columba-1.4 » org » columba » mail » gui » config » account » 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.config.account 
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 Stich.
013:        //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003. 
014:        //
015:        //All Rights Reserved.
016:
017:        package org.columba.mail.gui.config.account;
018:
019:        import java.awt.Component;
020:        import java.awt.event.ActionEvent;
021:        import java.awt.event.ActionListener;
022:        import java.io.File;
023:
024:        import javax.swing.JButton;
025:        import javax.swing.JCheckBox;
026:        import javax.swing.JComboBox;
027:        import javax.swing.JFileChooser;
028:        import javax.swing.JLabel;
029:        import javax.swing.JTextField;
030:
031:        import org.columba.core.gui.base.CheckBoxWithMnemonic;
032:        import org.columba.core.gui.base.LabelWithMnemonic;
033:        import org.columba.mail.config.SecurityItem;
034:        import org.columba.mail.util.MailResourceLoader;
035:
036:        import com.jgoodies.forms.builder.DefaultFormBuilder;
037:        import com.jgoodies.forms.layout.FormLayout;
038:
039:        /**
040:         * Shows PGP-related options.
041:         */
042:        public class SecurityPanel extends DefaultPanel implements 
043:                ActionListener {
044:            private JLabel idLabel;
045:
046:            private JTextField idTextField;
047:
048:            private JLabel typeLabel;
049:
050:            private JComboBox typeComboBox;
051:
052:            private JLabel pathLabel;
053:
054:            private JButton pathButton;
055:
056:            private JCheckBox enableCheckBox;
057:
058:            private JCheckBox alwaysSignCheckBox;
059:
060:            private JCheckBox alwaysEncryptCheckBox;
061:
062:            private SecurityItem item;
063:
064:            public SecurityPanel(SecurityItem item) {
065:                super ();
066:                this .item = item;
067:
068:                initComponents();
069:                updateComponents(true);
070:                layoutComponents();
071:
072:                //enableCheckBox.setEnabled(false);
073:            }
074:
075:            protected void updateComponents(boolean b) {
076:                if (b) {
077:                    idTextField.setText(item.get(SecurityItem.ID));
078:                    pathButton.setText(item.get(SecurityItem.PATH));
079:
080:                    enableCheckBox.setSelected(item
081:                            .getBoolean(SecurityItem.ENABLED));
082:
083:                    alwaysSignCheckBox.setSelected(item
084:                            .getBoolean(SecurityItem.ALWAYS_SIGN));
085:                    alwaysEncryptCheckBox.setSelected(item
086:                            .getBoolean(SecurityItem.ALWAYS_ENCRYPT));
087:
088:                    enablePGP(enableCheckBox.isSelected());
089:                } else {
090:                    item.setString(SecurityItem.ID, idTextField.getText());
091:                    item.setString(SecurityItem.PATH, pathButton.getText());
092:
093:                    item.setBoolean(SecurityItem.ENABLED, enableCheckBox
094:                            .isSelected());
095:
096:                    item.setBoolean(SecurityItem.ALWAYS_SIGN,
097:                            alwaysSignCheckBox.isSelected());
098:                    item.setBoolean(SecurityItem.ALWAYS_ENCRYPT,
099:                            alwaysEncryptCheckBox.isSelected());
100:                }
101:            }
102:
103:            protected void layoutComponents() {
104:                // Create a FormLayout instance.
105:                FormLayout layout = new FormLayout(
106:                        "10dlu, max(70dlu;default), 3dlu, fill:max(150dlu;default):grow ",
107:
108:                        // 2 columns
109:                        ""); // rows are added dynamically (no need to define them here)
110:
111:                // create a form builder
112:                DefaultFormBuilder builder = new DefaultFormBuilder(layout,
113:                        this );
114:
115:                // create EmptyBorder between components and dialog-frame
116:                builder.setDefaultDialogBorder();
117:
118:                // skip the first column
119:                builder.setLeadingColumnOffset(1);
120:
121:                // Add components to the panel:
122:                builder.appendSeparator(MailResourceLoader.getString("dialog",
123:                        "account", "pgp_options"));
124:                builder.nextLine();
125:
126:                builder.append(enableCheckBox, 3);
127:                builder.nextLine();
128:
129:                builder.append(idLabel, 1);
130:                builder.append(idTextField);
131:                builder.nextLine();
132:
133:                builder.append(alwaysSignCheckBox, 3);
134:                builder.nextLine();
135:
136:                //      TODO: reactivate when feature is supported
137:                /*
138:                 * builder.append(alwaysEncryptCheckBox, 3); builder.nextLine();
139:                 */
140:            }
141:
142:            protected void initComponents() {
143:                enableCheckBox = new CheckBoxWithMnemonic(MailResourceLoader
144:                        .getString("dialog", "account", "enable_PGP_Support"));
145:                enableCheckBox.setAlignmentX(Component.LEFT_ALIGNMENT);
146:                enableCheckBox.setActionCommand("ENABLE");
147:                enableCheckBox.addActionListener(this );
148:
149:                idLabel = new LabelWithMnemonic(MailResourceLoader.getString(
150:                        "dialog", "account", "User_ID"));
151:
152:                typeLabel = new JLabel(MailResourceLoader.getString("dialog",
153:                        "account", "PGP_Version")); //$NON-NLS-1$
154:
155:                pathLabel = new JLabel(MailResourceLoader.getString("dialog",
156:                        "account", "Path_to_Binary")); //$NON-NLS-1$
157:
158:                idTextField = new JTextField();
159:
160:                typeComboBox = new JComboBox();
161:
162:                //typeComboBox.setMargin( new Insets( 0,0,0,0 ) );
163:                typeComboBox.insertItemAt("GnuPG", 0);
164:                typeComboBox.insertItemAt("PGP2", 1);
165:                typeComboBox.insertItemAt("PGP5", 2);
166:                typeComboBox.insertItemAt("PGP6", 3);
167:                typeComboBox.setSelectedIndex(0);
168:                typeComboBox.setEnabled(false);
169:
170:                pathButton = new JButton();
171:
172:                //pathButton.setMargin( new Insets( 0,0,0,0 ) );
173:                pathButton.setActionCommand("PATH");
174:                pathButton.addActionListener(this );
175:
176:                alwaysSignCheckBox = new CheckBoxWithMnemonic(
177:                        MailResourceLoader.getString("dialog", "account",
178:                                "Always_sign_when_sending_messages"));
179:                alwaysSignCheckBox.setAlignmentX(Component.LEFT_ALIGNMENT);
180:                alwaysSignCheckBox.setEnabled(false);
181:
182:                alwaysEncryptCheckBox = new CheckBoxWithMnemonic(
183:                        MailResourceLoader
184:                                .getString(
185:                                        "dialog", "account", "Always_encrypt_when_sending_messages")); //$NON-NLS-1$
186:                alwaysEncryptCheckBox.setAlignmentX(Component.LEFT_ALIGNMENT);
187:                alwaysEncryptCheckBox.setEnabled(false);
188:            }
189:
190:            public void enablePGP(boolean b) {
191:                //typeComboBox.setEnabled(b);
192:                idTextField.setEnabled(b);
193:                idLabel.setEnabled(b);
194:                typeLabel.setEnabled(b);
195:                pathLabel.setEnabled(b);
196:                pathButton.setEnabled(b);
197:                alwaysSignCheckBox.setEnabled(b);
198:                alwaysEncryptCheckBox.setEnabled(b);
199:            }
200:
201:            public void actionPerformed(ActionEvent e) {
202:                String action = e.getActionCommand();
203:
204:                if (action.equals("ENABLE")) {
205:                    enablePGP(enableCheckBox.isSelected());
206:                } else if (action.equals("PATH")) {
207:                    JFileChooser fileChooser = new JFileChooser();
208:                    fileChooser.setDialogTitle(MailResourceLoader.getString(
209:                            "dialog", "account", "PGP_Binary")); //$NON-NLS-1$
210:                    fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
211:
212:                    int returnVal = fileChooser.showDialog(null,
213:                            MailResourceLoader.getString(
214:                                    "dialog", "account", "Select_File")); //$NON-NLS-1$
215:
216:                    if (returnVal == JFileChooser.APPROVE_OPTION) {
217:                        File file = fileChooser.getSelectedFile();
218:                        pathButton.setText(file.getPath());
219:                    }
220:                }
221:            }
222:
223:            public boolean isFinished() {
224:                boolean result = true;
225:
226:                return result;
227:            }
228:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.