Source Code Cross Referenced for FolderOptionsDialog.java in  » Mail-Clients » columba-1.4 » org » columba » mail » gui » config » folder » 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.folder 
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.folder;
018:
019:        import java.awt.BorderLayout;
020:        import java.awt.Color;
021:        import java.awt.Dimension;
022:        import java.awt.Font;
023:        import java.awt.GridLayout;
024:        import java.awt.event.ActionEvent;
025:        import java.awt.event.ActionListener;
026:        import java.awt.event.KeyEvent;
027:        import java.io.File;
028:
029:        import javax.swing.BorderFactory;
030:        import javax.swing.DefaultListSelectionModel;
031:        import javax.swing.JButton;
032:        import javax.swing.JCheckBox;
033:        import javax.swing.JComponent;
034:        import javax.swing.JDialog;
035:        import javax.swing.JFileChooser;
036:        import javax.swing.JLabel;
037:        import javax.swing.JPanel;
038:        import javax.swing.JScrollPane;
039:        import javax.swing.JTextField;
040:        import javax.swing.KeyStroke;
041:        import javax.swing.UIManager;
042:        import javax.swing.event.ListSelectionEvent;
043:        import javax.swing.event.ListSelectionListener;
044:
045:        import org.columba.core.command.CommandProcessor;
046:        import org.columba.core.gui.base.ButtonWithMnemonic;
047:        import org.columba.core.gui.base.CTabbedPane;
048:        import org.columba.core.gui.base.LabelWithMnemonic;
049:        import org.columba.core.gui.base.MultiLineLabel;
050:        import org.columba.core.help.HelpManager;
051:        import org.columba.core.xml.XmlElement;
052:        import org.columba.mail.command.MailFolderCommandReference;
053:        import org.columba.mail.config.IFolderItem;
054:        import org.columba.mail.folder.AbstractLocalFolder;
055:        import org.columba.mail.folder.IMailbox;
056:        import org.columba.mail.folder.IMailboxInfo;
057:        import org.columba.mail.folder.command.ExportFolderCommand;
058:        import org.columba.mail.folder.command.RenameFolderCommand;
059:        import org.columba.mail.folder.command.SyncSearchEngineCommand;
060:        import org.columba.mail.folder.search.LuceneQueryEngine;
061:        import org.columba.mail.folderoptions.FolderOptionsController;
062:        import org.columba.mail.gui.frame.MailFrameMediator;
063:        import org.columba.mail.gui.table.command.ViewHeaderListCommand;
064:        import org.columba.mail.util.MailResourceLoader;
065:        import org.frapuccino.checkablelist.CheckableItem;
066:        import org.frapuccino.checkablelist.CheckableItemListTableModel;
067:
068:        import com.jgoodies.forms.builder.ButtonStackBuilder;
069:        import com.jgoodies.forms.builder.PanelBuilder;
070:        import com.jgoodies.forms.layout.CellConstraints;
071:        import com.jgoodies.forms.layout.FormLayout;
072:
073:        /**
074:         * Folder Options Dialog. Shows status information about selected folder.
075:         * <p>
076:         * Note, that this dialog is not modal. A background thread is used to calculate
077:         * the total mailbox size.
078:         * 
079:         * @author fdietz
080:         */
081:
082:        public class FolderOptionsDialog extends JDialog implements 
083:                ActionListener, ListSelectionListener {
084:            public final static String[] tooltips = { "columns", "sorting",
085:                    "filter", "threadedview", "selection" };
086:
087:            private IMailbox folder;
088:
089:            private JLabel nameLabel;
090:
091:            private JTextField nameTextField;
092:
093:            private JLabel totalLabel;
094:
095:            private JLabel totalLabel2;
096:
097:            private JLabel unreadLabel;
098:
099:            private JLabel unreadLabel2;
100:
101:            private JLabel recentLabel;
102:
103:            private JLabel recentLabel2;
104:
105:            private JLabel locationLabel;
106:
107:            private JLabel locationLabel2;
108:
109:            private JLabel sizeLabel;
110:
111:            private JLabel sizeLabel2;
112:
113:            private JButton exportButton;
114:
115:            private MultiLineLabel enableLabel;
116:
117:            //private JLabel enableTextIndexingLabel;
118:
119:            private JCheckBox enableTextIndexingCheckBox;
120:
121:            private boolean renameFolder;
122:
123:            private String oldFolderName = null;
124:
125:            private MultiLineLabel overwriteLabel;
126:
127:            private JButton resetButton;
128:
129:            private JButton enableButton;
130:
131:            private JButton disableButton;
132:
133:            // JCheckBox overwriteOptionsCheckBox;
134:            private CheckableTooltipList checkableList;
135:
136:            private MailFrameMediator mediator;
137:
138:            /**
139:             * Constructor
140:             * 
141:             * @param folder
142:             *            selected folder
143:             * @param renameFolder
144:             *            this is a "rename folder" operation
145:             */
146:            public FolderOptionsDialog(IMailbox folder, boolean renameFolder,
147:                    MailFrameMediator mediator) {
148:                super (mediator.getView().getFrame(), MailResourceLoader
149:                        .getString("dialog", "folderoptions", "dialog_title"),
150:                        false);
151:
152:                this .folder = folder;
153:                this .renameFolder = renameFolder;
154:                this .mediator = mediator;
155:
156:                oldFolderName = folder.getName();
157:
158:                initComponents();
159:                updateComponents(true);
160:                pack();
161:                setLocationRelativeTo(null);
162:
163:                // focus name textfield
164:                if (renameFolder) {
165:                    nameTextField.selectAll();
166:                    nameTextField.requestFocus();
167:                }
168:
169:                setVisible(true);
170:            }
171:
172:            /**
173:             * Default constructor
174:             * 
175:             * @param folder
176:             *            selected folder
177:             */
178:            public FolderOptionsDialog(IMailbox folder,
179:                    MailFrameMediator mediator) {
180:                super (mediator.getView().getFrame(), MailResourceLoader
181:                        .getString("dialog", "folderoptions", "dialog_title"),
182:                        true);
183:
184:                this .folder = folder;
185:                this .mediator = mediator;
186:
187:                initComponents();
188:                updateComponents(true);
189:                pack();
190:                setLocationRelativeTo(null);
191:
192:                nameTextField.selectAll();
193:                nameTextField.requestFocus();
194:
195:                setVisible(true);
196:            }
197:
198:            protected JPanel createGeneralPanel() {
199:                // Create a FormLayout instance.
200:                FormLayout layout = new FormLayout(
201:                        "6dlu, right:max(25dlu;default), 3dlu, fill:default:grow, fill:0dlu:grow", //$NON-NLS-1$
202:
203:                        // 3 columns
204:                        "pref, 3dlu, pref, 6dlu, pref, 3dlu, pref, 3dlu, pref, 3dlu, pref, 6dlu, pref, 24dlu, pref, 3dlu, pref, 6dlu, default, 0dlu"); //$NON-NLS-1$
205:
206:                // create a form builder
207:                PanelBuilder builder = new PanelBuilder(layout);
208:                CellConstraints cc = new CellConstraints();
209:
210:                // create EmptyBorder between components and dialog-frame
211:                builder.setDefaultDialogBorder();
212:
213:                // Add components to the panel:
214:                builder.addSeparator(MailResourceLoader.getString("dialog",
215:                        "folderoptions", "general_info"), cc.xywh(1, 1, 5, 1)); //$NON-NLS-1$
216:
217:                builder.add(nameLabel, cc.xy(2, 3));
218:                builder.add(nameTextField, cc.xywh(4, 3, 2, 1));
219:
220:                builder.add(totalLabel, cc.xy(2, 5));
221:                builder.add(totalLabel2, cc.xy(4, 5));
222:
223:                builder.add(unreadLabel, cc.xy(2, 7));
224:                builder.add(unreadLabel2, cc.xy(4, 7));
225:
226:                builder.add(recentLabel, cc.xy(2, 9));
227:                builder.add(unreadLabel2, cc.xy(4, 9));
228:
229:                builder.add(sizeLabel, cc.xy(2, 11));
230:                builder.add(sizeLabel2, cc.xy(4, 11));
231:
232:                // @author tstich: Added Lucene gui element here
233:                //builder.add(enableTextIndexingLabel, cc.xy(2, 13));
234:                builder.add(enableTextIndexingCheckBox, cc.xywh(2, 13, 4, 1));
235:
236:                builder.appendGlueRow();
237:
238:                builder
239:                        .addSeparator(
240:                                MailResourceLoader.getString("dialog",
241:                                        "folderoptions", "archiving_messages"), cc.xywh(1, 15, 5, 1)); //$NON-NLS-1$
242:
243:                builder.add(locationLabel, cc.xy(2, 17));
244:                builder.add(locationLabel2, cc.xy(4, 17));
245:
246:                JPanel panel = new JPanel();
247:                panel.setLayout(new BorderLayout());
248:
249:                panel.add(exportButton, BorderLayout.EAST);
250:                builder.add(panel, cc.xywh(4, 19, 2, 1));
251:
252:                return builder.getPanel();
253:            }
254:
255:            /**
256:             * Create advanced panel.
257:             * <p>
258:             * 
259:             * @return panel
260:             */
261:            protected JPanel createAdvancedPanel() {
262:                // Create a FormLayout instance.
263:                FormLayout layout = new FormLayout(
264:                        "fill:default:grow, 6px, default", //$NON-NLS-1$
265:
266:                        // 3 columns
267:                        "pref, 6px, fill:pref:grow"); //$NON-NLS-1$
268:
269:                // create a form builder
270:                PanelBuilder builder = new PanelBuilder(layout);
271:                CellConstraints cc = new CellConstraints();
272:
273:                // create EmptyBorder between components and dialog-frame
274:                builder.setDefaultDialogBorder();
275:
276:                builder.add(overwriteLabel, cc.xywh(1, 1, 3, 1));
277:
278:                JScrollPane sp = new JScrollPane(checkableList);
279:                sp.setPreferredSize(new Dimension(200, 200));
280:                sp.getViewport().setBackground(Color.white);
281:                builder.add(sp, cc.xy(1, 3));
282:
283:                ButtonStackBuilder b = new ButtonStackBuilder();
284:                b.addGridded(enableButton);
285:                b.addRelatedGap();
286:                b.addGridded(disableButton);
287:                b.addUnrelatedGap();
288:                b.addGlue();
289:                b.addFixed(resetButton);
290:
291:                JPanel buttonPanel = b.getPanel();
292:                builder.add(buttonPanel, cc.xy(3, 3));
293:
294:                /*
295:                 * JPanel panel= new JPanel(); panel.setLayout(new BorderLayout());
296:                 * panel.add(resetButton, BorderLayout.EAST); builder.add(panel,
297:                 * cc.xywh(5, 7, 1, 1));
298:                 */
299:                /*
300:                 * builder.addSeparator("Full-text indexing");
301:                 * 
302:                 * builder.add(enableLabel, cc.xywh(1, 7, 5, 1));
303:                 * builder.add(enableTextIndexingCheckBox, cc.xywh(2, 9, 4, 1));
304:                 */
305:                return builder.getPanel();
306:            }
307:
308:            protected void initComponents() {
309:                Font boldFont = (Font) UIManager.get("Label.font"); //$NON-NLS-1$
310:                boldFont = boldFont.deriveFont(Font.BOLD);
311:
312:                nameLabel = new LabelWithMnemonic(MailResourceLoader.getString(
313:                        "dialog", "folderoptions", "name")); //$NON-NLS-1$
314:                //nameLabel.setFont(boldFont);
315:                nameTextField = new JTextField();
316:
317:                totalLabel = new JLabel(MailResourceLoader.getString("dialog",
318:                        "folderoptions", "total")); //$NON-NLS-1$
319:                //totalLabel.setFont(boldFont);
320:                totalLabel2 = new JLabel("0"); //$NON-NLS-1$
321:
322:                unreadLabel = new JLabel(MailResourceLoader.getString("dialog",
323:                        "folderoptions", "unread")); //$NON-NLS-1$
324:                //unreadLabel.setFont(boldFont);
325:                unreadLabel2 = new JLabel("0"); //$NON-NLS-1$
326:
327:                recentLabel = new JLabel(MailResourceLoader.getString("dialog",
328:                        "folderoptions", "recent")); //$NON-NLS-1$
329:                //recentLabel.setFont(boldFont);
330:                recentLabel2 = new JLabel("0"); //$NON-NLS-1$
331:
332:                sizeLabel = new JLabel(MailResourceLoader.getString("dialog",
333:                        "folderoptions", "mailbox_size")); //$NON-NLS-1$
334:                //sizeLabel.setFont(boldFont);
335:                sizeLabel2 = new JLabel(); //$NON-NLS-1$
336:
337:                locationLabel = new JLabel(MailResourceLoader.getString(
338:                        "dialog", "folderoptions", "location")); //$NON-NLS-1$
339:                //locationLabel.setFont(boldFont);
340:                locationLabel2 = new JLabel(""); //$NON-NLS-1$
341:
342:                exportButton = new ButtonWithMnemonic(MailResourceLoader
343:                        .getString("dialog", "folderoptions", "export")); //$NON-NLS-1$
344:                exportButton.setActionCommand("EXPORT"); //$NON-NLS-1$
345:                exportButton.addActionListener(this );
346:
347:                enableTextIndexingCheckBox = new JCheckBox(
348:                        MailResourceLoader
349:                                .getString(
350:                                        "dialog", "folderoptions", "enable_full-text_indexing")); //$NON-NLS-1$
351:                enableTextIndexingCheckBox.setToolTipText(MailResourceLoader
352:                        .getString("dialog", "folderoptions",
353:                                "enable_full-text_indexing_tooltip"));
354:
355:                enableLabel = new MultiLineLabel(
356:                        MailResourceLoader
357:                                .getString(
358:                                        "dialog", "folderoptions", "this_is_an_experimental_feature")); //$NON-NLS-1$
359:                //enableLabel.setFont(boldFont);
360:
361:                overwriteLabel = new MultiLineLabel(MailResourceLoader
362:                        .getString("dialog", "folderoptions",
363:                                "select_individual_options"));
364:
365:                resetButton = new ButtonWithMnemonic(MailResourceLoader
366:                        .getString("dialog", "folderoptions", "reset")); //$NON-NLS-1$
367:                resetButton.setActionCommand("RESET"); //$NON-NLS-1$
368:                resetButton.addActionListener(this );
369:
370:                enableButton = new ButtonWithMnemonic(MailResourceLoader
371:                        .getString("dialog", "folderoptions", "overwrite")); //$NON-NLS-1$
372:                enableButton.setActionCommand("ENABLED"); //$NON-NLS-1$
373:                enableButton.addActionListener(this );
374:                disableButton = new ButtonWithMnemonic(MailResourceLoader
375:                        .getString("dialog", "folderoptions", "use_default")); //$NON-NLS-1$
376:                disableButton.setActionCommand("DISABLED"); //$NON-NLS-1$
377:                disableButton.addActionListener(this );
378:                enableButton.setEnabled(false);
379:                disableButton.setEnabled(false);
380:
381:                /*
382:                 * overwriteOptionsCheckBox = new JCheckBox("Overwrite global
383:                 * settings"); overwriteOptionsCheckBox.addActionListener(this);
384:                 * overwriteOptionsCheckBox.setActionCommand("OVERWRITE");
385:                 */
386:                checkableList = new CheckableTooltipList();
387:                checkableList.setOptionsCellRenderer(new OptionsRenderer());
388:                checkableList.getSelectionModel()
389:                        .addListSelectionListener(this );
390:
391:                CTabbedPane tp = new CTabbedPane();
392:                tp.setBorder(BorderFactory.createEmptyBorder(0, 6, 0, 6));
393:
394:                tp.add(MailResourceLoader.getString("dialog", "folderoptions",
395:                        "general_options"), createGeneralPanel()); //$NON-NLS-1$
396:                tp.add(MailResourceLoader.getString("dialog", "folderoptions",
397:                        "advanced"), createAdvancedPanel()); //$NON-NLS-1$
398:
399:                getContentPane().add(tp, BorderLayout.CENTER);
400:
401:                getContentPane().add(createButtonPanel(), BorderLayout.SOUTH);
402:                getRootPane().registerKeyboardAction(this ,
403:                        "CANCEL", //$NON-NLS-1$
404:                        KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
405:                        JComponent.WHEN_IN_FOCUSED_WINDOW);
406:            }
407:
408:            protected JPanel createButtonPanel() {
409:                JPanel bottom = new JPanel();
410:                bottom.setLayout(new BorderLayout());
411:
412:                // bottom.setBorder(new SingleSideEtchedBorder(SwingConstants.TOP));
413:                // bottom.setLayout( new BoxLayout( bottom, BoxLayout.X_AXIS ) );
414:                // bottom.add( Box.createHorizontalStrut());
415:                ButtonWithMnemonic cancelButton = new ButtonWithMnemonic(
416:                        MailResourceLoader.getString("global", "cancel")); //$NON-NLS-1$ //$NON-NLS-2$
417:
418:                //$NON-NLS-1$ //$NON-NLS-2$
419:                cancelButton.addActionListener(this );
420:                cancelButton.setActionCommand("CANCEL"); //$NON-NLS-1$
421:
422:                ButtonWithMnemonic okButton = new ButtonWithMnemonic(
423:                        MailResourceLoader.getString("global", "ok")); //$NON-NLS-1$ //$NON-NLS-2$
424:
425:                //$NON-NLS-1$ //$NON-NLS-2$
426:                okButton.addActionListener(this );
427:                okButton.setActionCommand("OK"); //$NON-NLS-1$
428:                okButton.setDefaultCapable(true);
429:                getRootPane().setDefaultButton(okButton);
430:
431:                ButtonWithMnemonic helpButton = new ButtonWithMnemonic(
432:                        MailResourceLoader.getString("global", "help")); //$NON-NLS-1$ //$NON-NLS-2$
433:
434:                // associate with JavaHelp
435:                HelpManager.getInstance().enableHelpOnButton(helpButton,
436:                        "folder_options");
437:                HelpManager.getInstance().enableHelpKey(getRootPane(),
438:                        "folder_options");
439:
440:                JPanel buttonPanel = new JPanel();
441:                buttonPanel.setBorder(BorderFactory.createEmptyBorder(12, 12,
442:                        12, 12));
443:                buttonPanel.setLayout(new GridLayout(1, 3, 6, 0));
444:                buttonPanel.add(okButton);
445:                buttonPanel.add(cancelButton);
446:                buttonPanel.add(helpButton);
447:
448:                // bottom.add( Box.createHorizontalGlue() );
449:                bottom.add(buttonPanel, BorderLayout.EAST);
450:
451:                return bottom;
452:            }
453:
454:            public void updateComponents(boolean b) {
455:                if (b) {
456:                    IMailboxInfo info = folder.getMessageFolderInfo();
457:
458:                    nameTextField.setText(folder.getName());
459:
460:                    totalLabel2.setText(Integer.toString(info.getExists()));
461:                    unreadLabel2.setText(Integer.toString(info.getUnseen()));
462:                    recentLabel2.setText(Integer.toString(info.getRecent()));
463:
464:                    locationLabel2.setText(folder.getDirectoryFile().getPath());
465:
466:                    IFolderItem item = folder.getConfiguration();
467:                    XmlElement property = item.getElement("property"); //$NON-NLS-1$
468:
469:                    CheckableItemListTableModel model = new CheckableItemListTableModel();
470:
471:                    for (int i = 0; i < property.count(); i++) {
472:                        OptionsItem optionsItem = new OptionsItem(
473:                                (XmlElement) property.getElement(i).clone());
474:
475:                        model.addElement(optionsItem);
476:                    }
477:
478:                    checkableList.setModel(model);
479:
480:                    /*
481:                     * if (property.getAttribute("overwrite_default_settings", "false")
482:                     * .equals("true")) { overwriteOptionsCheckBox.setSelected(true); }
483:                     * else { overwriteOptionsCheckBox.setSelected(false); }
484:                     */
485:
486:                    // only local folders have an full-text indexing capability
487:                    if (folder instanceof  AbstractLocalFolder) {
488:                        item = folder.getConfiguration();
489:                        // enable lucene search index by default
490:                        boolean bool = item.getBooleanWithDefault(
491:                                "property", "enable_lucene", true); //$NON-NLS-1$ //$NON-NLS-2$
492:
493:                        enableTextIndexingCheckBox.setSelected(bool);
494:                    } else {
495:                        //enableTextIndexingLabel.setEnabled(false);
496:                        enableTextIndexingCheckBox.setEnabled(false);
497:                    }
498:                } else {
499:                    if (renameFolder) {
500:                        if (!oldFolderName.equals(nameTextField.getText())) {
501:                            // user changed folder name
502:                            MailFolderCommandReference r = new MailFolderCommandReference(
503:                                    folder);
504:                            r.setFolderName(nameTextField.getText());
505:                            CommandProcessor.getInstance().addOp(
506:                                    new RenameFolderCommand(r));
507:                        }
508:                    }
509:
510:                    IFolderItem item = folder.getConfiguration();
511:                    XmlElement property = item.getElement("property"); //$NON-NLS-1$
512:
513:                    // remove all old elements
514:                    property.removeAllElements();
515:
516:                    CheckableItemListTableModel model = (CheckableItemListTableModel) checkableList
517:                            .getModel();
518:
519:                    for (int i = 0; i < model.count(); i++) {
520:                        OptionsItem optionsItem = (OptionsItem) model
521:                                .getElement(i);
522:
523:                        // add new element
524:                        property.addElement(optionsItem.getElement());
525:                    }
526:
527:                    // only local folders have an full-text indexing capability
528:                    if (folder instanceof  AbstractLocalFolder) {
529:                        item = folder.getConfiguration();
530:
531:                        boolean bool = enableTextIndexingCheckBox.isSelected();
532:                        item.setBoolean("property", "enable_lucene", bool); //$NON-NLS-1$ //$NON-NLS-2$
533:
534:                        // cast to Local AbstractMessageFolder is safe here
535:                        AbstractLocalFolder localFolder = (AbstractLocalFolder) folder;
536:
537:                        if (bool) {
538:                            localFolder.getSearchEngine().setNonDefaultEngine(
539:                                    new LuceneQueryEngine(localFolder));
540:
541:                            // execute resyncing command
542:                            MailFolderCommandReference r = new MailFolderCommandReference(
543:                                    folder);
544:                            CommandProcessor.getInstance().addOp(
545:                                    new SyncSearchEngineCommand(r));
546:                        } else {
547:                            localFolder.setSearchEngine(null);
548:                        }
549:                    }
550:
551:                    // restore settings
552:                    getMediator().getFolderOptionsController().load(
553:                            FolderOptionsController.STATE_BEFORE);
554:
555:                    // re-select folder to make changes visible to the user
556:                    MailFolderCommandReference r = new MailFolderCommandReference(
557:                            folder);
558:                    CommandProcessor.getInstance().addOp(
559:                            new ViewHeaderListCommand(getMediator(), r));
560:                }
561:            }
562:
563:            public void actionPerformed(ActionEvent arg0) {
564:                String action = arg0.getActionCommand();
565:
566:                if (action.equals("CANCEL")) { //$NON-NLS-1$
567:                    setVisible(false);
568:                } else if (action.equals("OK")) { //$NON-NLS-1$
569:                    setVisible(false);
570:                    updateComponents(false);
571:                } else if (action.equals("EXPORT")) { //$NON-NLS-1$
572:
573:                    File destFile = null;
574:
575:                    // ask the user about the destination file
576:                    JFileChooser chooser = new JFileChooser();
577:                    chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
578:                    chooser.setMultiSelectionEnabled(false);
579:
580:                    int result = chooser.showSaveDialog(this );
581:
582:                    if (result == JFileChooser.APPROVE_OPTION) {
583:                        File file = chooser.getSelectedFile();
584:
585:                        destFile = file;
586:                    } else {
587:                        return;
588:                    }
589:
590:                    setVisible(false);
591:
592:                    MailFolderCommandReference r = new MailFolderCommandReference(
593:                            folder);
594:                    r.setDestFile(destFile);
595:                    CommandProcessor.getInstance().addOp(
596:                            new ExportFolderCommand(r));
597:                } else if (action.equals("RESET")) { //$NON-NLS-1$
598:
599:                    IFolderItem item = folder.getConfiguration();
600:                    XmlElement property = item.getElement("property"); //$NON-NLS-1$
601:
602:                    // remove all options
603:                    property.removeAllElements();
604:
605:                    // create new default options
606:                    getMediator().getFolderOptionsController()
607:                            .createDefaultSettings(folder);
608:
609:                    /*
610:                     * for (int i= 0; i < property.count(); i++) { XmlElement child=
611:                     * property.getElement(i);
612:                     * 
613:                     * child.addAttribute("overwrite", "false"); //$NON-NLS-1$
614:                     * //$NON-NLS-2$ }
615:                     */
616:
617:                    // update list view
618:                    CheckableItemListTableModel model = new CheckableItemListTableModel();
619:
620:                    for (int i = 0; i < property.count(); i++) {
621:                        OptionsItem optionsItem = new OptionsItem(
622:                                (XmlElement) property.getElement(i).clone());
623:
624:                        model.addElement(optionsItem);
625:                    }
626:
627:                    checkableList.setModel(model);
628:                } else if (action.equals("ENABLED")) { //$NON-NLS-1$
629:
630:                    CheckableItem item = (CheckableItem) checkableList
631:                            .getSelected();
632:                    item.setSelected(!item.isSelected());
633:                    ((CheckableItemListTableModel) checkableList.getModel())
634:                            .updateRow(item);
635:                    updateButtonState(item.isSelected());
636:                } else if (action.equals("DISABLED")) { //$NON-NLS-1$
637:
638:                    CheckableItem item = (CheckableItem) checkableList
639:                            .getSelected();
640:                    item.setSelected(!item.isSelected());
641:                    ((CheckableItemListTableModel) checkableList.getModel())
642:                            .updateRow(item);
643:                    updateButtonState(item.isSelected());
644:                }
645:            }
646:
647:            private void updateButtonState(boolean selected) {
648:                if (selected) {
649:                    enableButton.setEnabled(false);
650:                    disableButton.setEnabled(true);
651:                } else {
652:                    enableButton.setEnabled(true);
653:                    disableButton.setEnabled(false);
654:                }
655:            }
656:
657:            public void valueChanged(ListSelectionEvent e) {
658:                if (e.getValueIsAdjusting()) {
659:                    return;
660:                }
661:
662:                DefaultListSelectionModel theList = (DefaultListSelectionModel) e
663:                        .getSource();
664:
665:                if (!theList.isSelectionEmpty()) {
666:
667:                    CheckableItem item = (CheckableItem) checkableList
668:                            .getSelected();
669:                    updateButtonState(item.isSelected());
670:                }
671:            }
672:
673:            /**
674:             * Set size of mailbox.
675:             * 
676:             * @param size
677:             *            size of mailbox
678:             */
679:            public void setMailboxSize(int sizeInKB) {
680:                StringBuffer buf = new StringBuffer();
681:
682:                // if size > than 1000 KB, transform to MB
683:                if (sizeInKB > 1000)
684:                    buf.append(new Integer(sizeInKB / 1000).toString() + " MB");
685:                else
686:                    buf.append(new Integer(sizeInKB).toString() + " KB");
687:
688:                sizeLabel2.setText(buf.toString());
689:            }
690:
691:            /**
692:             * @return
693:             */
694:            public MailFrameMediator getMediator() {
695:                return mediator;
696:            }
697:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.