//# 2 errors, 68 messages
//#
/*
    //#AddonCellRenderer.java:1:1: class: com.dmdirc.addons.ui_swing.components.renderers.AddonCellRenderer
    //#AddonCellRenderer.java:1:1: method: com.dmdirc.addons.ui_swing.components.renderers.AddonCellRenderer.com.dmdirc.addons.ui_swing.components.renderers.AddonCellRenderer__static_init
 * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

package com.dmdirc.addons.ui_swing.components.renderers;

import com.dmdirc.addons.ui_swing.components.pluginpanel.PluginInfoToggle;
import com.dmdirc.addons.ui_swing.components.themepanel.ThemeToggle;
import static com.dmdirc.addons.ui_swing.UIUtilities.SMALL_BORDER;

import java.awt.Color;
import java.awt.Component;
import java.awt.Font;

import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JSeparator;
import javax.swing.ListCellRenderer;

import net.miginfocom.swing.MigLayout;

/**
 * Handles the rendering of the JList used for plugin and theme management.
 * @author chris
 */
public final class AddonCellRenderer extends JPanel implements ListCellRenderer {
    
    /**
     * A version number for this class. It should be changed whenever the class
     * structure is changed (or anything else that would prevent serialized
     * objects being unserialized with the new class).
     */
    private static final long serialVersionUID = 1;    
    
    /** Creates a new instance of AddonCellRenderer. */
    public AddonCellRenderer() {
        super();
    //#AddonCellRenderer.java:57: method: void com.dmdirc.addons.ui_swing.components.renderers.AddonCellRenderer.com.dmdirc.addons.ui_swing.components.renderers.AddonCellRenderer()
    //#input(void com.dmdirc.addons.ui_swing.components.renderers.AddonCellRenderer()): this
    }
    //#AddonCellRenderer.java:58: end of method: void com.dmdirc.addons.ui_swing.components.renderers.AddonCellRenderer.com.dmdirc.addons.ui_swing.components.renderers.AddonCellRenderer()
    
    /** {@inheritDoc} */
    @Override
    public Component getListCellRendererComponent(final JList list,
            final Object value, final int index, final boolean isSelected,
            final boolean cellHasFocus) {
       
        removeAll();
    //#AddonCellRenderer.java:66: method: Component com.dmdirc.addons.ui_swing.components.renderers.AddonCellRenderer.getListCellRendererComponent(JList, Object, int, bool, bool)
    //#AddonCellRenderer.java:66: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.addons.ui_swing.components.renderers.AddonCellRenderer:removeAll()
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.ui_swing.components.renderers.AddonCellRenderer
    //#    method: Component getListCellRendererComponent(JList, Object, int, bool, bool)
    //#    unanalyzed callee: void com.dmdirc.addons.ui_swing.components.renderers.AddonCellRenderer:removeAll()
    //#input(Component getListCellRendererComponent(JList, Object, int, bool, bool)): com/dmdirc/addons/ui_swing/components/pluginpanel/PluginInfoToggle.__Descendant_Table[com/dmdirc/addons/ui_swing/components/pluginpanel/PluginInfoToggle]
    //#input(Component getListCellRendererComponent(JList, Object, int, bool, bool)): com/dmdirc/addons/ui_swing/components/pluginpanel/PluginInfoToggle.__Descendant_Table[others]
    //#input(Component getListCellRendererComponent(JList, Object, int, bool, bool)): com/dmdirc/addons/ui_swing/components/pluginpanel/PluginInfoToggle.__Dispatch_Table.getPluginInfo()Lcom/dmdirc/plugins/PluginInfo;
    //#input(Component getListCellRendererComponent(JList, Object, int, bool, bool)): com/dmdirc/addons/ui_swing/components/pluginpanel/PluginInfoToggle.__Dispatch_Table.getState()Z
    //#input(Component getListCellRendererComponent(JList, Object, int, bool, bool)): com/dmdirc/addons/ui_swing/components/themepanel/ThemeToggle.__Descendant_Table[com/dmdirc/addons/ui_swing/components/themepanel/ThemeToggle]
    //#input(Component getListCellRendererComponent(JList, Object, int, bool, bool)): com/dmdirc/addons/ui_swing/components/themepanel/ThemeToggle.__Descendant_Table[others]
    //#input(Component getListCellRendererComponent(JList, Object, int, bool, bool)): com/dmdirc/addons/ui_swing/components/themepanel/ThemeToggle.__Dispatch_Table.getState()Z
    //#input(Component getListCellRendererComponent(JList, Object, int, bool, bool)): com/dmdirc/addons/ui_swing/components/themepanel/ThemeToggle.__Dispatch_Table.getTheme()Lcom/dmdirc/ui/themes/Theme;
    //#input(Component getListCellRendererComponent(JList, Object, int, bool, bool)): isSelected
    //#input(Component getListCellRendererComponent(JList, Object, int, bool, bool)): java.awt.Color.BLACK
    //#input(Component getListCellRendererComponent(JList, Object, int, bool, bool)): java.awt.Color.GRAY
    //#input(Component getListCellRendererComponent(JList, Object, int, bool, bool)): list
    //#input(Component getListCellRendererComponent(JList, Object, int, bool, bool)): this
    //#input(Component getListCellRendererComponent(JList, Object, int, bool, bool)): value
    //#input(Component getListCellRendererComponent(JList, Object, int, bool, bool)): value.__Tag
    //#input(Component getListCellRendererComponent(JList, Object, int, bool, bool)): value.enable
    //#input(Component getListCellRendererComponent(JList, Object, int, bool, bool)): value.pi
    //#input(Component getListCellRendererComponent(JList, Object, int, bool, bool)): value.theme
    //#input(Component getListCellRendererComponent(JList, Object, int, bool, bool)): value.toggle
    //#output(Component getListCellRendererComponent(JList, Object, int, bool, bool)): return_value
    //#pre[2] (Component getListCellRendererComponent(JList, Object, int, bool, bool)): list != null
    //#pre[6] (Component getListCellRendererComponent(JList, Object, int, bool, bool)): (soft) init'ed(value.enable)
    //#pre[7] (Component getListCellRendererComponent(JList, Object, int, bool, bool)): (soft) value.pi != null
    //#pre[8] (Component getListCellRendererComponent(JList, Object, int, bool, bool)): (soft) value.theme != null
    //#pre[9] (Component getListCellRendererComponent(JList, Object, int, bool, bool)): (soft) init'ed(value.toggle)
    //#presumption(Component getListCellRendererComponent(JList, Object, int, bool, bool)): init'ed(java.awt.Color.BLACK)
    //#presumption(Component getListCellRendererComponent(JList, Object, int, bool, bool)): init'ed(java.awt.Color.GRAY)
    //#presumption(Component getListCellRendererComponent(JList, Object, int, bool, bool)): javax.swing.JLabel:getFont(...)@104 != null
    //#post(Component getListCellRendererComponent(JList, Object, int, bool, bool)): return_value == this
    //#post(Component getListCellRendererComponent(JList, Object, int, bool, bool)): return_value != null
    //#unanalyzed(Component getListCellRendererComponent(JList, Object, int, bool, bool)): Effects-of-calling:com.dmdirc.plugins.PluginInfo:isLoaded
    //#test_vector(Component getListCellRendererComponent(JList, Object, int, bool, bool)): isSelected: {0}, {1}
    //#test_vector(Component getListCellRendererComponent(JList, Object, int, bool, bool)): value.__Tag: {370_944}, {400_640}
    //#test_vector(Component getListCellRendererComponent(JList, Object, int, bool, bool)): value.enable: {1}, {0}
    //#test_vector(Component getListCellRendererComponent(JList, Object, int, bool, bool)): value.toggle ^ com.dmdirc.plugins.PluginInfo:isLoaded(...)@65: {1}, {0}
        setLayout(new MigLayout("fill, ins 3 0 0 0"));        
    //#AddonCellRenderer.java:67: Warning: method not available - call not analyzed
    //#    call on void net.miginfocom.swing.MigLayout(String)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.ui_swing.components.renderers.AddonCellRenderer
    //#    method: Component getListCellRendererComponent(JList, Object, int, bool, bool)
    //#    unanalyzed callee: void net.miginfocom.swing.MigLayout(String)
    //#AddonCellRenderer.java:67: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.addons.ui_swing.components.renderers.AddonCellRenderer:setLayout(LayoutManager)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.ui_swing.components.renderers.AddonCellRenderer
    //#    method: Component getListCellRendererComponent(JList, Object, int, bool, bool)
    //#    unanalyzed callee: void com.dmdirc.addons.ui_swing.components.renderers.AddonCellRenderer:setLayout(LayoutManager)
        
        if (isSelected) {
            setBackground(list.getSelectionBackground());
    //#AddonCellRenderer.java:70: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.addons.ui_swing.components.renderers.AddonCellRenderer:setBackground(Color)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.ui_swing.components.renderers.AddonCellRenderer
    //#    method: Component getListCellRendererComponent(JList, Object, int, bool, bool)
    //#    unanalyzed callee: void com.dmdirc.addons.ui_swing.components.renderers.AddonCellRenderer:setBackground(Color)
        } else {
            setBackground(list.getBackground());
    //#AddonCellRenderer.java:72: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.addons.ui_swing.components.renderers.AddonCellRenderer:setBackground(Color)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.ui_swing.components.renderers.AddonCellRenderer
    //#    method: Component getListCellRendererComponent(JList, Object, int, bool, bool)
    //#    unanalyzed callee: void com.dmdirc.addons.ui_swing.components.renderers.AddonCellRenderer:setBackground(Color)
        }
        
        Color foreground = Color.BLACK;
        final JLabel name = new JLabel(), version = new JLabel(),
                author = new JLabel(), desc = new JLabel();

        if (value instanceof PluginInfoToggle) {
            final PluginInfoToggle plugin = (PluginInfoToggle) value;

            if (!plugin.getState()) {
                foreground = Color.GRAY;
            }

            name.setText(plugin.getPluginInfo().getNiceName());
    //#AddonCellRenderer.java:86: ?null dereference
    //#    com/dmdirc/addons/ui_swing/components/pluginpanel/PluginInfoToggle.__Descendant_Table[plugin.__Tag] != null
    //#    severity: SUPPRESSED
    //#    class: com.dmdirc.addons.ui_swing.components.renderers.AddonCellRenderer
    //#    method: Component getListCellRendererComponent(JList, Object, int, bool, bool)
    //#    basic block: bb_7
    //#    assertion: com/dmdirc/addons/ui_swing/components/pluginpanel/PluginInfoToggle.__Descendant_Table[plugin.__Tag] != null
    //#    VN: com/dmdirc/addons/ui_swing/components/pluginpanel/PluginInfoToggle.__Descendant_Table[value.__Tag]
    //#    Expected: Inverse{null}
    //#    Bad: Addr_Set{null}
    //#    Attribs:  Ptr  null in Bad
    //#AddonCellRenderer.java:86: Warning: method not available - call not analyzed
    //#    call on String com.dmdirc.plugins.PluginInfo:getNiceName()
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.ui_swing.components.renderers.AddonCellRenderer
    //#    method: Component getListCellRendererComponent(JList, Object, int, bool, bool)
    //#    unanalyzed callee: String com.dmdirc.plugins.PluginInfo:getNiceName()
            version.setText(plugin.getPluginInfo().getFriendlyVersion());
    //#AddonCellRenderer.java:87: Warning: method not available - call not analyzed
    //#    call on String com.dmdirc.plugins.PluginInfo:getFriendlyVersion()
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.ui_swing.components.renderers.AddonCellRenderer
    //#    method: Component getListCellRendererComponent(JList, Object, int, bool, bool)
    //#    unanalyzed callee: String com.dmdirc.plugins.PluginInfo:getFriendlyVersion()
            author.setText(plugin.getPluginInfo().getAuthor());
    //#AddonCellRenderer.java:88: Warning: method not available - call not analyzed
    //#    call on String com.dmdirc.plugins.PluginInfo:getAuthor()
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.ui_swing.components.renderers.AddonCellRenderer
    //#    method: Component getListCellRendererComponent(JList, Object, int, bool, bool)
    //#    unanalyzed callee: String com.dmdirc.plugins.PluginInfo:getAuthor()
            desc.setText(plugin.getPluginInfo().getDescription());
    //#AddonCellRenderer.java:89: Warning: method not available - call not analyzed
    //#    call on String com.dmdirc.plugins.PluginInfo:getDescription()
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.ui_swing.components.renderers.AddonCellRenderer
    //#    method: Component getListCellRendererComponent(JList, Object, int, bool, bool)
    //#    unanalyzed callee: String com.dmdirc.plugins.PluginInfo:getDescription()
        } else if (value instanceof ThemeToggle) {
            final ThemeToggle theme = (ThemeToggle) value;
            
            if (!theme.getState()) {
                foreground = Color.GRAY;
            }
            
            name.setText(theme.getTheme().getName());
    //#AddonCellRenderer.java:97: ?null dereference
    //#    com/dmdirc/addons/ui_swing/components/themepanel/ThemeToggle.__Descendant_Table[theme.__Tag] != null
    //#    severity: SUPPRESSED
    //#    class: com.dmdirc.addons.ui_swing.components.renderers.AddonCellRenderer
    //#    method: Component getListCellRendererComponent(JList, Object, int, bool, bool)
    //#    basic block: bb_11
    //#    assertion: com/dmdirc/addons/ui_swing/components/themepanel/ThemeToggle.__Descendant_Table[theme.__Tag] != null
    //#    VN: com/dmdirc/addons/ui_swing/components/themepanel/ThemeToggle.__Descendant_Table[value.__Tag]
    //#    Expected: Inverse{null}
    //#    Bad: Addr_Set{null}
    //#    Attribs:  Ptr  null in Bad
    //#AddonCellRenderer.java:97: Warning: method not available - call not analyzed
    //#    call on String com.dmdirc.ui.themes.Theme:getName()
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.ui_swing.components.renderers.AddonCellRenderer
    //#    method: Component getListCellRendererComponent(JList, Object, int, bool, bool)
    //#    unanalyzed callee: String com.dmdirc.ui.themes.Theme:getName()
            version.setText(theme.getTheme().getVersion());
    //#AddonCellRenderer.java:98: Warning: method not available - call not analyzed
    //#    call on String com.dmdirc.ui.themes.Theme:getVersion()
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.ui_swing.components.renderers.AddonCellRenderer
    //#    method: Component getListCellRendererComponent(JList, Object, int, bool, bool)
    //#    unanalyzed callee: String com.dmdirc.ui.themes.Theme:getVersion()
            author.setText(theme.getTheme().getAuthor());
    //#AddonCellRenderer.java:99: Warning: method not available - call not analyzed
    //#    call on String com.dmdirc.ui.themes.Theme:getAuthor()
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.ui_swing.components.renderers.AddonCellRenderer
    //#    method: Component getListCellRendererComponent(JList, Object, int, bool, bool)
    //#    unanalyzed callee: String com.dmdirc.ui.themes.Theme:getAuthor()
            desc.setText(theme.getTheme().getDescription());
    //#AddonCellRenderer.java:100: Warning: method not available - call not analyzed
    //#    call on String com.dmdirc.ui.themes.Theme:getDescription()
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.ui_swing.components.renderers.AddonCellRenderer
    //#    method: Component getListCellRendererComponent(JList, Object, int, bool, bool)
    //#    unanalyzed callee: String com.dmdirc.ui.themes.Theme:getDescription()
        }
        
        name.setForeground(foreground);
        name.setFont(name.getFont().deriveFont(Font.BOLD));
        version.setForeground(foreground);
        version.setHorizontalAlignment(JLabel.CENTER);
        author.setForeground(foreground);
        desc.setForeground(foreground);
        desc.setBorder(BorderFactory.createEmptyBorder(SMALL_BORDER, 0, 0, 0));
        
        add(name, "gapleft 3");
    //#AddonCellRenderer.java:111: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.addons.ui_swing.components.renderers.AddonCellRenderer:add(Component, Object)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.ui_swing.components.renderers.AddonCellRenderer
    //#    method: Component getListCellRendererComponent(JList, Object, int, bool, bool)
    //#    unanalyzed callee: void com.dmdirc.addons.ui_swing.components.renderers.AddonCellRenderer:add(Component, Object)
        add(version, "pushx");
    //#AddonCellRenderer.java:112: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.addons.ui_swing.components.renderers.AddonCellRenderer:add(Component, Object)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.ui_swing.components.renderers.AddonCellRenderer
    //#    method: Component getListCellRendererComponent(JList, Object, int, bool, bool)
    //#    unanalyzed callee: void com.dmdirc.addons.ui_swing.components.renderers.AddonCellRenderer:add(Component, Object)
        add(author, "wrap, gapright 3");
    //#AddonCellRenderer.java:113: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.addons.ui_swing.components.renderers.AddonCellRenderer:add(Component, Object)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.ui_swing.components.renderers.AddonCellRenderer
    //#    method: Component getListCellRendererComponent(JList, Object, int, bool, bool)
    //#    unanalyzed callee: void com.dmdirc.addons.ui_swing.components.renderers.AddonCellRenderer:add(Component, Object)
        add(desc, "span 3, growx, pushx, wrap, gapleft 3, gapright 3");
    //#AddonCellRenderer.java:114: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.addons.ui_swing.components.renderers.AddonCellRenderer:add(Component, Object)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.ui_swing.components.renderers.AddonCellRenderer
    //#    method: Component getListCellRendererComponent(JList, Object, int, bool, bool)
    //#    unanalyzed callee: void com.dmdirc.addons.ui_swing.components.renderers.AddonCellRenderer:add(Component, Object)
        add(new JSeparator(), "span 3, growx, pushx");
    //#AddonCellRenderer.java:115: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.addons.ui_swing.components.renderers.AddonCellRenderer:add(Component, Object)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.ui_swing.components.renderers.AddonCellRenderer
    //#    method: Component getListCellRendererComponent(JList, Object, int, bool, bool)
    //#    unanalyzed callee: void com.dmdirc.addons.ui_swing.components.renderers.AddonCellRenderer:add(Component, Object)
        
        return this;
    //#AddonCellRenderer.java:117: end of method: Component com.dmdirc.addons.ui_swing.components.renderers.AddonCellRenderer.getListCellRendererComponent(JList, Object, int, bool, bool)
    }
    
}
    //#output(com.dmdirc.addons.ui_swing.components.renderers.AddonCellRenderer__static_init): __Descendant_Table[com/dmdirc/addons/ui_swing/components/renderers/AddonCellRenderer]
    //#output(com.dmdirc.addons.ui_swing.components.renderers.AddonCellRenderer__static_init): __Dispatch_Table.getListCellRendererComponent(Ljavax/swing/JList;Ljava/lang/Object;IZZ)Ljava/awt/Component;
    //#post(com.dmdirc.addons.ui_swing.components.renderers.AddonCellRenderer__static_init): __Descendant_Table[com/dmdirc/addons/ui_swing/components/renderers/AddonCellRenderer] == &__Dispatch_Table
    //#post(com.dmdirc.addons.ui_swing.components.renderers.AddonCellRenderer__static_init): __Dispatch_Table.getListCellRendererComponent(Ljavax/swing/JList;Ljava/lang/Object;IZZ)Ljava/awt/Component; == &getListCellRendererComponent
    //#AddonCellRenderer.java:: end of method: com.dmdirc.addons.ui_swing.components.renderers.AddonCellRenderer.com.dmdirc.addons.ui_swing.components.renderers.AddonCellRenderer__static_init
    //#AddonCellRenderer.java:: end of class: com.dmdirc.addons.ui_swing.components.renderers.AddonCellRenderer
