KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > mail > gui > config > filter > plugins > MarkActionRow


1 //The contents of this file are subject to the Mozilla Public License Version 1.1
2
//(the "License"); you may not use this file except in compliance with the
3
//License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
4
//
5
//Software distributed under the License is distributed on an "AS IS" basis,
6
//WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
7
//for the specific language governing rights and
8
//limitations under the License.
9
//
10
//The Original Code is "The Columba Project"
11
//
12
//The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
13
//Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
14
//
15
//All Rights Reserved.
16
package org.columba.mail.gui.config.filter.plugins;
17
18 import java.awt.Component JavaDoc;
19
20 import javax.swing.DefaultListCellRenderer JavaDoc;
21 import javax.swing.JComboBox JavaDoc;
22 import javax.swing.JList JavaDoc;
23
24 import org.columba.api.gui.frame.IFrameMediator;
25 import org.columba.core.filter.FilterAction;
26 import org.columba.core.filter.IFilterAction;
27 import org.columba.mail.filter.MailFilterAction;
28 import org.columba.mail.gui.config.filter.ActionList;
29 import org.columba.mail.util.MailResourceLoader;
30
31 /**
32  * Mark message filter action.
33  *
34  *
35  * @author fdietz
36  */

37 public class MarkActionRow extends DefaultActionRow {
38     JComboBox JavaDoc variantComboBox;
39
40     public MarkActionRow(IFrameMediator mediator, ActionList list,
41             IFilterAction action) {
42         super(mediator, list, action);
43     }
44
45     public void updateComponents(boolean b) {
46         super.updateComponents(b);
47
48         if (b) {
49             String JavaDoc variant = new MailFilterAction(filterAction).getMarkVariant();
50
51             // use "mark as read" as default fallback mechanism
52
if (variant == null) {
53                 variant = "read";
54             }
55
56             variantComboBox.setSelectedItem(variant);
57         } else {
58             new MailFilterAction(filterAction)
59                     .setMarkVariant((String JavaDoc) variantComboBox.getSelectedItem());
60         }
61     }
62
63     public void initComponents() {
64         super.initComponents();
65
66         String JavaDoc[] items = { "read", "unread", "expunged", "not_expunged",
67                 "flagged", "not_flagged", "answered", "spam", "no_spam" };
68
69         variantComboBox = new JComboBox JavaDoc(items);
70         variantComboBox.setRenderer(new ComboBoxRenderer());
71         variantComboBox.setSelectedItem("read");
72         addComponent(variantComboBox);
73     }
74
75      class ComboBoxRenderer extends DefaultListCellRenderer JavaDoc {
76         public ComboBoxRenderer() {
77             super();
78         }
79
80         public Component JavaDoc getListCellRendererComponent(JList JavaDoc arg0, Object JavaDoc arg1,
81                 int arg2, boolean arg3, boolean arg4) {
82             setText(MailResourceLoader.getString("dialog", "filter",
83                     (String JavaDoc) arg1));
84
85             return this;
86         }
87     }
88 }
Popular Tags