1 package org.columba.mail.gui.config.mailboximport; 17 18 import java.awt.Component ; 19 20 import javax.swing.DefaultListCellRenderer ; 21 import javax.swing.JList ; 22 import javax.swing.UIManager ; 23 24 import org.columba.api.plugin.IExtension; 25 import org.columba.api.plugin.IExtensionHandler; 26 import org.columba.api.plugin.PluginHandlerNotFoundException; 27 import org.columba.core.gui.dialog.ErrorDialog; 28 import org.columba.core.plugin.PluginManager; 29 import org.columba.mail.plugin.IExtensionHandlerKeys; 30 31 public class PluginListCellRenderer extends DefaultListCellRenderer { 32 protected IExtensionHandler pluginHandler; 33 34 public PluginListCellRenderer() { 35 super(); 36 37 try { 38 pluginHandler = PluginManager.getInstance() 39 .getExtensionHandler(IExtensionHandlerKeys.ORG_COLUMBA_MAIL_IMPORT); 40 } catch (PluginHandlerNotFoundException ex) { 41 ErrorDialog.createDialog(ex.getMessage(), ex); 42 } 43 } 44 45 51 public Component getListCellRendererComponent(JList list, Object value, 52 int index, boolean isSelected, boolean cellHasFocus) { 53 if (isSelected) { 54 setBackground(list.getSelectionBackground()); 55 setForeground(list.getSelectionForeground()); 56 } else { 57 setBackground(list.getBackground()); 58 setForeground(list.getForeground()); 59 } 60 61 setBorder((cellHasFocus) ? UIManager 62 .getBorder("List.focusCellHighlightBorder") : noFocusBorder); 63 64 String id = (String ) value; 66 IExtension extension = pluginHandler.getExtension(id); 67 String userVisibleName = extension.getMetadata().getId(); 68 setText(userVisibleName); 69 70 return this; 71 } 72 } 73 | Popular Tags |