01: //The contents of this file are subject to the Mozilla Public License Version 1.1
02: //(the "License"); you may not use this file except in compliance with the
03: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
04: //
05: //Software distributed under the License is distributed on an "AS IS" basis,
06: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
07: //for the specific language governing rights and
08: //limitations under the License.
09: //
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;
19:
20: import javax.swing.DefaultListCellRenderer;
21: import javax.swing.JComboBox;
22: import javax.swing.JList;
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 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 variant = new MailFilterAction(filterAction)
50: .getMarkVariant();
51:
52: // use "mark as read" as default fallback mechanism
53: if (variant == null) {
54: variant = "read";
55: }
56:
57: variantComboBox.setSelectedItem(variant);
58: } else {
59: new MailFilterAction(filterAction)
60: .setMarkVariant((String) variantComboBox
61: .getSelectedItem());
62: }
63: }
64:
65: public void initComponents() {
66: super .initComponents();
67:
68: String[] items = { "read", "unread", "expunged",
69: "not_expunged", "flagged", "not_flagged", "answered",
70: "spam", "no_spam" };
71:
72: variantComboBox = new JComboBox(items);
73: variantComboBox.setRenderer(new ComboBoxRenderer());
74: variantComboBox.setSelectedItem("read");
75: addComponent(variantComboBox);
76: }
77:
78: class ComboBoxRenderer extends DefaultListCellRenderer {
79: public ComboBoxRenderer() {
80: super ();
81: }
82:
83: public Component getListCellRendererComponent(JList arg0,
84: Object arg1, int arg2, boolean arg3, boolean arg4) {
85: setText(MailResourceLoader.getString("dialog", "filter",
86: (String) arg1));
87:
88: return this;
89: }
90: }
91: }
|