KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > mail > gui > config > filter > util > ActionComboBoxRenderer


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.util;
17
18 import java.awt.Component JavaDoc;
19
20 import javax.swing.DefaultListCellRenderer JavaDoc;
21 import javax.swing.JList JavaDoc;
22 import javax.swing.UIManager JavaDoc;
23
24 import org.columba.api.plugin.IExtensionHandler;
25 import org.columba.api.plugin.PluginHandlerNotFoundException;
26 import org.columba.core.gui.dialog.ErrorDialog;
27 import org.columba.core.plugin.PluginManager;
28 import org.columba.mail.plugin.IExtensionHandlerKeys;
29
30 /**
31  * @author frd
32  *
33  * To change this generated comment go to Window>Preferences>Java>Code
34  * Generation>Code and Comments
35  */

36
37 public class ActionComboBoxRenderer extends DefaultListCellRenderer JavaDoc {
38     protected IExtensionHandler pluginHandler;
39
40     /**
41      *
42      */

43     public ActionComboBoxRenderer() {
44         super();
45
46         try {
47             pluginHandler = PluginManager
48                     .getInstance().getExtensionHandler(IExtensionHandlerKeys.ORG_COLUMBA_MAIL_FILTERACTION);
49         } catch (PluginHandlerNotFoundException ex) {
50             ErrorDialog.createDialog(ex.getMessage(), ex);
51         }
52     }
53
54     /*
55      * (non-Javadoc)
56      *
57      * @see javax.swing.ListCellRenderer#getListCellRendererComponent(javax.swing.JList,
58      * java.lang.Object, int, boolean, boolean)
59      */

60     public Component JavaDoc getListCellRendererComponent(JList JavaDoc list, Object JavaDoc value,
61             int index, boolean isSelected, boolean cellHasFocus) {
62         if (cellHasFocus) {
63             setBackground(list.getSelectionBackground());
64             setForeground(list.getSelectionForeground());
65         } else {
66             setBackground(list.getBackground());
67             setForeground(list.getForeground());
68         }
69
70         setBorder((cellHasFocus) ? UIManager
71                 .getBorder("List.focusCellHighlightBorder") : noFocusBorder);
72
73         // id = org.columba.example.HelloWorld$HelloWorldPlugin
74
String JavaDoc id = (String JavaDoc) value;
75
76         //String userVisibleName = pluginHandler.getUserVisibleName(id);
77
String JavaDoc userVisibleName = id;
78
79         setText(userVisibleName);
80
81         return this;
82     }
83 }
84
Popular Tags