@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
boolean cellHasFocus) {
JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (value instanceof SeparatorMenuItem) {
LineComponent comp = new LineComponent(label.getForeground());
comp.setBackground(label.getBackground());
comp.setOpaque(isSelected);
comp.setPreferredSize(label.getPreferredSize());
return comp;
} else if (value instanceof ConfigMenuItem) {
mItemSelected.setSelected(!mDeactivatedItems.contains(value));
mItemLabel.setIcon(TVBrowserIcons.preferences(TVBrowserIcons.SIZE_SMALL));
mItemLabel.setText(value.toString());
mItemLabel.setForeground(label.getForeground());
mItemPanel.setBackground(label.getBackground());
mItemPanel.setOpaque(isSelected);
return mItemPanel;
} else if (value instanceof LeaveFullScreenMenuItem) {
mItemSelected.setSelected(!mDeactivatedItems.contains(value));
mItemLabel.setIcon(TVBrowserIcons.fullScreen(TVBrowserIcons.SIZE_SMALL));
mItemLabel.setText(value.toString());
mItemLabel.setForeground(label.getForeground());
mItemPanel.setBackground(label.getBackground());
mItemPanel.setOpaque(isSelected);
return mItemPanel;
} else if (value instanceof ContextMenuIf) {
ContextMenuIf menuIf = (ContextMenuIf) value;
Program exampleProgram = Plugin.getPluginManager().getExampleProgram();
// Get the context menu item text
StringBuilder text = new StringBuilder();
Icon icon = null;
// Action[] actionArr = plugin.getContextMenuActions(exampleProgram);
ActionMenu actionMenu = menuIf.getContextMenuActions(exampleProgram);
if (actionMenu != null) {
Action action = actionMenu.getAction();
if (action != null) {
text.append((String) action.getValue(Action.NAME));
icon = (Icon) action.getValue(Action.SMALL_ICON);
if (icon != null) {
icon = new FixedSizeIcon(16, 16, icon);
}
} else if (menuIf instanceof PluginProxy) {
text.append(((PluginProxy) menuIf).getInfo().getName());
icon = ((PluginProxy) menuIf).getMarkIcon();
} else {
text.append("unknown");
icon = null;
}
}
mItemLabel.setIcon(icon);
mItemLabel.setText(text.toString());
mItemLabel.setForeground(label.getForeground());
mItemSelected.setSelected(!mDeactivatedItems.contains(value));
mItemPanel.setBackground(label.getBackground());
mItemPanel.setOpaque(isSelected);
return mItemPanel;
}
return label;