1 | public class PluginListCellRenderer extends DefaultListCellRenderer {↵ | | 1 | public class PluginListCellRenderer extends DefaultListCellRenderer {↵
|
2 | protected IExtensionHandler pluginHandler;↵ | | 2 | protected IExtensionHandler pluginHandler;↵
|
|
3 | public PluginListCellRenderer() {↵ | | 3 | public PluginListCellRenderer() {↵
|
4 | super();↵ | | 4 | super();↵
|
|
5 | try {↵ | | |
|
6 | ↵ | | 5 | try {↵
|
7 | pluginHandler = PluginManager.getInstance()↵ | | 6 | pluginHandler = PluginManager.getInstance()↵
|
8 | .getExtensionHandler(↵ | | 7 | .getExtensionHandler(↵
|
9 | "org.columba.addressbook.import");↵ | | |
|
10 | ↵ | | 8 | IExtensionHandlerKeys.ORG_COLUMBA_MAIL_IMPORT);↵
|
11 | } catch (PluginHandlerNotFoundException ex) {↵ | | 9 | } catch (PluginHandlerNotFoundException ex) {↵
|
12 | ErrorDialog.createDialog(ex.getMessage(), ex);↵ | | 10 | ErrorDialog.createDialog(ex.getMessage(), ex);↵
|
13 | }↵ | | |
|
14 | }↵ | | |
|
|
15 | /↵ | | 11 | }↵
|
| | | 12 | }↵
|
|
| | | 13 | /*↵
|
16 | * (non-Javadoc)↵ | | 14 | * (non-Javadoc)↵
|
| | | 15 | * ↵
|
17 | * @see javax.swing.ListCellRenderer#getListCellRendererComponent(javax.swing.JList,↵ | | 16 | * @see javax.swing.ListCellRenderer#getListCellRendererComponent(javax.swing.JList,↵
|
18 | java.lang.Object, int, boolean, boolean)↵ | | 17 | * java.lang.Object, int, boolean, boolean)↵
|
19 | */↵ | | 18 | */↵
|
20 | public Component getListCellRendererComponent(JList list, Object value,↵ | | 19 | public Component getListCellRendererComponent(JList list, Object value,↵
|
21 | int index, boolean isSelected, boolean cellHasFocus) {↵ | | 20 | int index, boolean isSelected, boolean cellHasFocus) {↵
|
22 | if (isSelected) {↵ | | 21 | if (isSelected) {↵
|
23 | setBackground(list.getSelectionBackground());↵ | | 22 | setBackground(list.getSelectionBackground());↵
|
24 | setForeground(list.getSelectionForeground());↵ | | 23 | setForeground(list.getSelectionForeground());↵
|
25 | } else {↵ | | 24 | } else {↵
|
26 | setBackground(list.getBackground());↵ | | 25 | setBackground(list.getBackground());↵
|
27 | setForeground(list.getForeground());↵ | | 26 | setForeground(list.getForeground());↵
|
28 | }↵ | | |
|
|
29 | ↵ | | 27 | }↵
|
|
30 | setBorder((cellHasFocus)↵ | | 28 | setBorder((cellHasFocus)↵
|
31 | ? UIManager↵ | | 29 | ? UIManager↵
|
32 | .getBorder("List.focusCellHighlightBorder") : noFocusBorder);↵ | | 30 | .getBorder("List.focusCellHighlightBorder") : noFocusBorder);↵
|
|
33 | // id = org.columba.example.HelloWorld$HelloWorldPlugin↵ | | 31 | // id = org.columba.example.HelloWorld$HelloWorldPlugin↵
|
34 | String id = (String) value;↵ | | 32 | String id = (String) value;↵
|
35 | IExtension extension = pluginHandler.getExtension(id);↵ | | 33 | IExtension extension = pluginHandler.getExtension(id);↵
|
36 | String userVisibleName = extension.getMetadata().getId();↵ | | 34 | String userVisibleName = extension.getMetadata().getId();↵
|
37 | setText(userVisibleName);↵ | | 35 | setText(userVisibleName);↵
|
|
38 | return this;↵ | | 36 | return this;↵
|
39 | | | 37 |
|