Source Code Cross Referenced for MailOptionsDialog.java in  » Mail-Clients » columba-1.4 » org » columba » mail » gui » config » general » 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.general 
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:        package org.columba.mail.gui.config.general;
017:
018:        import java.awt.BorderLayout;
019:        import java.awt.Color;
020:        import java.awt.GridLayout;
021:        import java.awt.event.ActionEvent;
022:        import java.awt.event.ActionListener;
023:        import java.awt.event.KeyEvent;
024:        import java.util.Enumeration;
025:        import java.util.Vector;
026:
027:        import javax.swing.BorderFactory;
028:        import javax.swing.JButton;
029:        import javax.swing.JCheckBox;
030:        import javax.swing.JColorChooser;
031:        import javax.swing.JComboBox;
032:        import javax.swing.JComponent;
033:        import javax.swing.JDialog;
034:        import javax.swing.JFrame;
035:        import javax.swing.JLabel;
036:        import javax.swing.JOptionPane;
037:        import javax.swing.JPanel;
038:        import javax.swing.JSpinner;
039:        import javax.swing.KeyStroke;
040:        import javax.swing.SpinnerNumberModel;
041:        import javax.swing.SwingConstants;
042:
043:        import org.columba.api.plugin.IExtension;
044:        import org.columba.api.plugin.IExtensionHandler;
045:        import org.columba.api.plugin.IExtensionHandlerKeys;
046:        import org.columba.api.plugin.PluginHandlerNotFoundException;
047:        import org.columba.core.gui.base.ButtonWithMnemonic;
048:        import org.columba.core.gui.base.CheckBoxWithMnemonic;
049:        import org.columba.core.gui.base.LabelWithMnemonic;
050:        import org.columba.core.gui.base.SingleSideEtchedBorder;
051:        import org.columba.core.gui.util.DialogHeaderPanel;
052:        import org.columba.core.help.HelpManager;
053:        import org.columba.core.plugin.PluginManager;
054:        import org.columba.mail.config.ComposerItem;
055:        import org.columba.mail.config.MailConfig;
056:        import org.columba.mail.config.OptionsItem;
057:        import org.columba.mail.util.MailResourceLoader;
058:
059:        import com.jgoodies.forms.builder.DefaultFormBuilder;
060:        import com.jgoodies.forms.layout.FormLayout;
061:
062:        /**
063:         * Mail General Options Dialog
064:         *
065:         * @author fdietz
066:         */
067:        public class MailOptionsDialog extends JDialog implements 
068:                ActionListener {
069:            protected JButton okButton;
070:
071:            protected JButton cancelButton;
072:
073:            protected JButton helpButton;
074:
075:            protected CheckBoxWithMnemonic markCheckBox;
076:
077:            protected JSpinner markSpinner;
078:
079:            protected CheckBoxWithMnemonic preferHtmlCheckBox;
080:
081:            protected CheckBoxWithMnemonic disableHtmlCheckBox;
082:
083:            protected CheckBoxWithMnemonic enableSmiliesCheckBox;
084:
085:            protected CheckBoxWithMnemonic quotedColorCheckBox;
086:
087:            protected JButton quotedColorButton;
088:
089:            protected JCheckBox emptyTrashCheckBox;
090:
091:            protected CheckBoxWithMnemonic emptySubjectCheckBox;
092:
093:            protected CheckBoxWithMnemonic sendHtmlMultipartCheckBox;
094:
095:            protected CheckBoxWithMnemonic showAttachmentsInlineCheckBox;
096:
097:            private JLabel selectedBrowserLabel;
098:
099:            protected JComboBox selectedBrowserComboBox;
100:
101:            protected LabelWithMnemonic forwardLabel;
102:
103:            protected JComboBox forwardComboBox;
104:
105:            public MailOptionsDialog(JFrame frame) {
106:                super (frame, MailResourceLoader.getString("dialog", "general",
107:                        "dialog_title"), true);
108:
109:                initComponents();
110:
111:                layoutComponents();
112:
113:                updateComponents(true);
114:
115:                pack();
116:                setLocationRelativeTo(null);
117:                setVisible(true);
118:            }
119:
120:            public void updateComponents(boolean b) {
121:                OptionsItem optionsItem = MailConfig.getInstance()
122:                        .getOptionsItem();
123:                ComposerItem composerItem = MailConfig.getInstance()
124:                        .getComposerItem();
125:
126:                if (b) {
127:
128:                    showAttachmentsInlineCheckBox
129:                            .setSelected(optionsItem.getBooleanWithDefault(
130:                                    OptionsItem.MESSAGEVIEWER,
131:                                    OptionsItem.INLINE_ATTACHMENTS_BOOL, false));
132:
133:                    selectedBrowserComboBox.setSelectedItem(optionsItem
134:                            .getStringWithDefault(OptionsItem.MESSAGEVIEWER,
135:                                    OptionsItem.SELECTED_BROWSER, "Default"));
136:
137:                    int delay = optionsItem.getIntegerWithDefault(
138:                            OptionsItem.MARKASREAD, OptionsItem.DELAY_INT, 2);
139:                    boolean enable = optionsItem.getBooleanWithDefault(
140:                            OptionsItem.MARKASREAD, OptionsItem.ENABLED_BOOL,
141:                            true);
142:
143:                    markCheckBox.setSelected(enable);
144:                    markSpinner.setValue(new Integer(delay));
145:
146:                    boolean enableSmilies = optionsItem.getBooleanWithDefault(
147:                            OptionsItem.MESSAGEVIEWER_SMILIES,
148:                            OptionsItem.ENABLED_BOOL, true);
149:
150:                    enableSmiliesCheckBox.setSelected(enableSmilies);
151:
152:                    boolean preferHtml = optionsItem.getBooleanWithDefault(
153:                            OptionsItem.HTML, OptionsItem.PREFER_BOOL, true);
154:
155:                    preferHtmlCheckBox.setSelected(preferHtml);
156:
157:                    boolean disablehtml = optionsItem.getBooleanWithDefault(
158:                            OptionsItem.HTML, OptionsItem.DISABLE_BOOL, true);
159:
160:                    disableHtmlCheckBox.setSelected(disablehtml);
161:
162:                    boolean askSubject = composerItem.getBooleanWithDefault(
163:                            ComposerItem.SUBJECT,
164:                            ComposerItem.ASK_IF_EMPTY_BOOL, true);
165:
166:                    emptySubjectCheckBox.setSelected(askSubject);
167:
168:                    boolean sendHtml = composerItem.getBooleanWithDefault(
169:                            ComposerItem.HTML, ComposerItem.SEND_AS_MULTIPART,
170:                            true);
171:
172:                    sendHtmlMultipartCheckBox.setSelected(sendHtml);
173:
174:                    int forwardStyle = composerItem.getIntegerWithDefault(
175:                            ComposerItem.FORWARD, ComposerItem.STYLE, 0);
176:
177:                    forwardComboBox.setSelectedIndex(forwardStyle);
178:
179:                } else {
180:
181:                    optionsItem.setInteger(OptionsItem.MARKASREAD,
182:                            OptionsItem.DELAY_INT, ((Integer) markSpinner
183:                                    .getValue()).intValue());
184:
185:                    optionsItem
186:                            .setBoolean(OptionsItem.MARKASREAD,
187:                                    OptionsItem.ENABLED_BOOL, markCheckBox
188:                                            .isSelected());
189:
190:                    // notify configuration changes listeners
191:                    // @see org.columba.mail.gui.table.util.MarkAsReadTimer
192:                    optionsItem.notifyObservers(OptionsItem.MARKASREAD);
193:
194:                    optionsItem.setBoolean(OptionsItem.MESSAGEVIEWER_SMILIES,
195:                            OptionsItem.ENABLED_BOOL, enableSmiliesCheckBox
196:                                    .isSelected());
197:
198:                    optionsItem.setBoolean(OptionsItem.MESSAGEVIEWER,
199:                            OptionsItem.INLINE_ATTACHMENTS_BOOL,
200:                            showAttachmentsInlineCheckBox.isSelected());
201:
202:                    optionsItem.setString(OptionsItem.MESSAGEVIEWER,
203:                            OptionsItem.SELECTED_BROWSER,
204:                            (String) selectedBrowserComboBox.getSelectedItem());
205:
206:                    // notify configuration changes listeners
207:                    // @see org.columba.mail.gui.message.TextViewer
208:                    optionsItem.notifyObservers(OptionsItem.SELECTED_BROWSER);
209:
210:                    // send notification event
211:                    // @see org.columba.mail.gui.message.TextViewer
212:                    optionsItem
213:                            .notifyObservers(OptionsItem.MESSAGEVIEWER_SMILIES);
214:
215:                    optionsItem.setBoolean(OptionsItem.HTML,
216:                            OptionsItem.PREFER_BOOL, preferHtmlCheckBox
217:                                    .isSelected());
218:
219:                    optionsItem.setBoolean(OptionsItem.HTML,
220:                            OptionsItem.DISABLE_BOOL, disableHtmlCheckBox
221:                                    .isSelected());
222:
223:                    composerItem.setBoolean(ComposerItem.SUBJECT,
224:                            ComposerItem.ASK_IF_EMPTY_BOOL,
225:                            emptySubjectCheckBox.isSelected());
226:
227:                    // notify listeners
228:                    // @see org.columba.mail.gui.composer.SubjectController
229:                    composerItem.notifyObservers(ComposerItem.SUBJECT);
230:
231:                    composerItem.setBoolean(ComposerItem.HTML,
232:                            ComposerItem.SEND_AS_MULTIPART,
233:                            sendHtmlMultipartCheckBox.isSelected());
234:                    // notify listeners
235:                    composerItem.notifyObservers(ComposerItem.HTML);
236:
237:                    composerItem.setInteger(ComposerItem.FORWARD,
238:                            ComposerItem.STYLE, forwardComboBox
239:                                    .getSelectedIndex());
240:
241:                    // notify listeners
242:                    // @see org.columba.mail.gui.table.action.ForwardAction
243:                    composerItem.notifyObservers(ComposerItem.FORWARD);
244:
245:                }
246:            }
247:
248:            protected void initComponents() {
249:                // general
250:                markCheckBox = new CheckBoxWithMnemonic(MailResourceLoader
251:                        .getString("dialog", "general", "mark_messages_read"));
252:
253:                markSpinner = new JSpinner();
254:                markSpinner.setModel(new SpinnerNumberModel(1, 0, 99, 1));
255:
256:                emptyTrashCheckBox = new CheckBoxWithMnemonic(
257:                        MailResourceLoader.getString("dialog", "general",
258:                                "empty_trash"));
259:                emptyTrashCheckBox.setEnabled(false);
260:
261:                enableSmiliesCheckBox = new CheckBoxWithMnemonic(
262:                        MailResourceLoader.getString("dialog", "general",
263:                                "enable_smilies"));
264:
265:                quotedColorCheckBox = new CheckBoxWithMnemonic(
266:                        MailResourceLoader.getString("dialog", "general",
267:                                "color_quoted_text"));
268:                quotedColorButton = new JButton("...");
269:                quotedColorButton.setActionCommand("COLOR");
270:                quotedColorButton.addActionListener(this );
271:
272:                preferHtmlCheckBox = new CheckBoxWithMnemonic(
273:                        MailResourceLoader.getString("dialog", "general",
274:                                "prefer_html"));
275:                disableHtmlCheckBox = new CheckBoxWithMnemonic(
276:                        MailResourceLoader.getString("dialog", "general",
277:                                "disable_html"));
278:                // composer
279:                emptySubjectCheckBox = new CheckBoxWithMnemonic(
280:                        MailResourceLoader.getString("dialog", "general",
281:                                "ask_on_empty_subject"));
282:
283:                sendHtmlMultipartCheckBox = new CheckBoxWithMnemonic(
284:                        MailResourceLoader.getString("dialog", "general",
285:                                "send_html_multipart"));
286:
287:                forwardLabel = new LabelWithMnemonic(MailResourceLoader
288:                        .getString("dialog", "general", "forward_as"));
289:
290:                String[] items = {
291:                        MailResourceLoader.getString("dialog", "general",
292:                                "forward_as_attachment"),
293:                        MailResourceLoader.getString("dialog", "general",
294:                                "forward_as_quoted") };
295:
296:                forwardComboBox = new JComboBox(items);
297:
298:                showAttachmentsInlineCheckBox = new CheckBoxWithMnemonic(
299:                        "Show Attachments &Inline");
300:                showAttachmentsInlineCheckBox
301:                        .setActionCommand("ATTACHMENTS_INLINE");
302:                showAttachmentsInlineCheckBox.addActionListener(this );
303:
304:                selectedBrowserLabel = new JLabel("Message Renderer");
305:                Vector<String> v = new Vector<String>();
306:                try {
307:                    IExtensionHandler handler = PluginManager
308:                            .getInstance()
309:                            .getExtensionHandler(
310:                                    IExtensionHandlerKeys.ORG_COLUMBA_CORE_HTMLVIEWER);
311:                    Enumeration e = handler.getExtensionEnumeration();
312:                    while (e.hasMoreElements()) {
313:                        IExtension ext = (IExtension) e.nextElement();
314:                        String id = ext.getMetadata().getId();
315:                        v.add(id);
316:                    }
317:                } catch (PluginHandlerNotFoundException e) {
318:                    e.printStackTrace();
319:                }
320:                selectedBrowserComboBox = new JComboBox(v
321:                        .toArray(new String[0]));
322:                selectedBrowserComboBox.setSelectedIndex(0);
323:                selectedBrowserComboBox.addActionListener(new ActionListener() {
324:                    public void actionPerformed(ActionEvent e) {
325:                        if (selectedBrowserComboBox.getSelectedIndex() != 0)
326:                            JOptionPane
327:                                    .showMessageDialog(MailOptionsDialog.this ,
328:                                            "This is an experimental feature and therefore requires a restart of Columba");
329:                    }
330:                });
331:
332:                // button panel
333:                okButton = new ButtonWithMnemonic(MailResourceLoader.getString(
334:                        "global", "ok"));
335:                okButton.setActionCommand("OK");
336:                okButton.addActionListener(this );
337:
338:                cancelButton = new ButtonWithMnemonic(MailResourceLoader
339:                        .getString("global", "cancel"));
340:                cancelButton.setActionCommand("CANCEL");
341:                cancelButton.addActionListener(this );
342:
343:                helpButton = new ButtonWithMnemonic(MailResourceLoader
344:                        .getString("global", "help"));
345:
346:                // associate with JavaHelp
347:                HelpManager.getInstance().enableHelpOnButton(helpButton,
348:                        "configuring_columba_7");
349:                HelpManager.getInstance().enableHelpKey(getRootPane(),
350:                        "configuring_columba_7");
351:            }
352:
353:            protected void layoutComponents() {
354:                JPanel contentPane = new JPanel();
355:                setContentPane(contentPane);
356:                contentPane.setLayout(new BorderLayout());
357:
358:                // Create a FormLayout instance.
359:                FormLayout layout = new FormLayout(
360:                        "12dlu, default, 3dlu, max(10dlu;default), 3dlu, default",
361:
362:                        // 3 columns
363:                        ""); // rows are added dynamically (no need to define them here)
364:
365:                // create a form builder
366:                DefaultFormBuilder builder = new DefaultFormBuilder(layout);
367:
368:                // create EmptyBorder between components and dialog-frame
369:                builder.setDefaultDialogBorder();
370:
371:                // skip the first column
372:                builder.setLeadingColumnOffset(1);
373:
374:                // Add components to the panel:
375:                builder.appendSeparator(MailResourceLoader.getString("dialog",
376:                        "general", "general"));
377:                builder.nextLine();
378:
379:                builder.append(preferHtmlCheckBox, 4);
380:                builder.nextLine();
381:                builder.append(disableHtmlCheckBox, 4);
382:                builder.nextLine();
383:                builder.append(enableSmiliesCheckBox, 4);
384:                builder.nextLine();
385:                //		builder.append(showAttachmentsInlineCheckBox, 4);
386:                //		builder.nextLine();
387:
388:                // its maybe better to leave this option out of the dialog
389:                // -> make it configurable in the xml file anyway
390:                /*
391:                 * builder.append(quotedColorCheckBox, quotedColorButton);
392:                 * builder.nextLine();
393:                 */
394:                builder.append(markCheckBox, markSpinner);
395:                builder.nextLine();
396:                builder.append(selectedBrowserLabel, selectedBrowserComboBox);
397:                builder.nextLine();
398:
399:                //builder.nextLine();
400:
401:                builder.appendSeparator(MailResourceLoader.getString("dialog",
402:                        "general", "composing_messages"));
403:                builder.nextLine();
404:
405:                builder.append(emptySubjectCheckBox, 4);
406:                builder.nextLine();
407:
408:                builder.append(sendHtmlMultipartCheckBox, 4);
409:                builder.nextLine();
410:
411:                builder.append(forwardLabel, forwardComboBox);
412:                builder.nextLine();
413:
414:                //layout.setRowGroups(new int[][]{ {1, 3, 5, 7, 9, 11, 13, 15} });
415:                /*
416:                 * builder.append(spellLabel, spellButton); builder.nextLine();
417:                 */
418:                contentPane.add(builder.getPanel(), BorderLayout.CENTER);
419:
420:                // init bottom panel with OK, Cancel buttons
421:                JPanel bottomPanel = new JPanel(new BorderLayout(0, 0));
422:                bottomPanel.setBorder(new SingleSideEtchedBorder(
423:                        SwingConstants.TOP));
424:
425:                JPanel buttonPanel = new JPanel(new GridLayout(1, 3, 6, 0));
426:                buttonPanel.setBorder(BorderFactory.createEmptyBorder(12, 12,
427:                        12, 12));
428:
429:                buttonPanel.add(okButton);
430:
431:                buttonPanel.add(cancelButton);
432:                buttonPanel.add(helpButton);
433:
434:                bottomPanel.add(buttonPanel, BorderLayout.EAST);
435:                contentPane.add(bottomPanel, BorderLayout.SOUTH);
436:
437:                getRootPane().setDefaultButton(okButton);
438:                getRootPane().registerKeyboardAction(this , "CANCEL",
439:                        KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
440:                        JComponent.WHEN_IN_FOCUSED_WINDOW);
441:
442:                contentPane.add(new DialogHeaderPanel("Mail Options",
443:                        "Change email-specific options"), BorderLayout.NORTH);
444:
445:            }
446:
447:            public void actionPerformed(ActionEvent event) {
448:                String action = event.getActionCommand();
449:
450:                if (action.equals("OK")) {
451:                    setVisible(false);
452:
453:                    updateComponents(false);
454:                } else if (action.equals("CANCEL")) {
455:                    setVisible(false);
456:                } else if (action.equals("COLOR")) {
457:                    //Set up color chooser for setting quoted color
458:                    Color newColor = JColorChooser.showDialog(this ,
459:                            MailResourceLoader.getString("dialog", "general",
460:                                    "choose_text_color"), null);
461:
462:                    if (newColor != null) {
463:                        quotedColorButton.setBackground(newColor);
464:                    }
465:                }
466:            }
467:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.