//# 0 errors, 79 messages
//#
/*
    //#AddonInfoListCellRenderer.java:1:1: class: com.dmdirc.addons.addonbrowser.AddonInfoListCellRenderer
    //#AddonInfoListCellRenderer.java:1:1: method: com.dmdirc.addons.addonbrowser.AddonInfoListCellRenderer.com.dmdirc.addons.addonbrowser.AddonInfoListCellRenderer__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.addonbrowser;

import com.dmdirc.addons.ui_swing.components.text.TextLabel;
import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import javax.swing.BorderFactory;
import javax.swing.JButton;
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;

/**
 *
 */
public class AddonInfoListCellRenderer extends JPanel implements ListCellRenderer {
    //#AddonInfoListCellRenderer.java:41: method: void com.dmdirc.addons.addonbrowser.AddonInfoListCellRenderer.com.dmdirc.addons.addonbrowser.AddonInfoListCellRenderer()
    //#input(void com.dmdirc.addons.addonbrowser.AddonInfoListCellRenderer()): this
    //#AddonInfoListCellRenderer.java:41: end of method: void com.dmdirc.addons.addonbrowser.AddonInfoListCellRenderer.com.dmdirc.addons.addonbrowser.AddonInfoListCellRenderer()

    /**
     * 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;
    
    /** {@inheritDoc} */
    @Override
    public Component getListCellRendererComponent(JList list, Object value,
            int index, boolean isSelected, boolean cellHasFocus) {
        final AddonInfo info = (AddonInfo) value;
    //#AddonInfoListCellRenderer.java:54: method: Component com.dmdirc.addons.addonbrowser.AddonInfoListCellRenderer.getListCellRendererComponent(JList, Object, int, bool, bool)
    //#input(Component getListCellRendererComponent(JList, Object, int, bool, bool)): ", rated "._tainted
    //#input(Component getListCellRendererComponent(JList, Object, int, bool, bool)): ".10"._tainted
    //#input(Component getListCellRendererComponent(JList, Object, int, bool, bool)): "addon-"._tainted
    //#input(Component getListCellRendererComponent(JList, Object, int, bool, bool)): com/dmdirc/addons/addonbrowser/AddonInfo.__Descendant_Table[com/dmdirc/addons/addonbrowser/AddonInfo]
    //#input(Component getListCellRendererComponent(JList, Object, int, bool, bool)): com/dmdirc/addons/addonbrowser/AddonInfo.__Descendant_Table[others]
    //#input(Component getListCellRendererComponent(JList, Object, int, bool, bool)): com/dmdirc/addons/addonbrowser/AddonInfo.__Dispatch_Table.getDescription()Ljava/lang/String;
    //#input(Component getListCellRendererComponent(JList, Object, int, bool, bool)): com/dmdirc/addons/addonbrowser/AddonInfo.__Dispatch_Table.getId()I
    //#input(Component getListCellRendererComponent(JList, Object, int, bool, bool)): com/dmdirc/addons/addonbrowser/AddonInfo.__Dispatch_Table.getRating()I
    //#input(Component getListCellRendererComponent(JList, Object, int, bool, bool)): com/dmdirc/addons/addonbrowser/AddonInfo.__Dispatch_Table.getScreenshot()Ljavax/swing/ImageIcon;
    //#input(Component getListCellRendererComponent(JList, Object, int, bool, bool)): com/dmdirc/addons/addonbrowser/AddonInfo.__Dispatch_Table.getTitle()Ljava/lang/String;
    //#input(Component getListCellRendererComponent(JList, Object, int, bool, bool)): com/dmdirc/addons/addonbrowser/AddonInfo.__Dispatch_Table.getType()Lcom/dmdirc/addons/addonbrowser/AddonInfo$AddonType;
    //#input(Component getListCellRendererComponent(JList, Object, int, bool, bool)): com/dmdirc/addons/addonbrowser/AddonInfo.__Dispatch_Table.isDownloadable()Z
    //#input(Component getListCellRendererComponent(JList, Object, int, bool, bool)): com/dmdirc/addons/addonbrowser/AddonInfo.__Dispatch_Table.isInstalled()Z
    //#input(Component getListCellRendererComponent(JList, Object, int, bool, bool)): index
    //#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)): java.awt.Color.WHITE
    //#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.description
    //#input(Component getListCellRendererComponent(JList, Object, int, bool, bool)): value.id
    //#input(Component getListCellRendererComponent(JList, Object, int, bool, bool)): value.rating
    //#input(Component getListCellRendererComponent(JList, Object, int, bool, bool)): value.screenshot
    //#input(Component getListCellRendererComponent(JList, Object, int, bool, bool)): value.title
    //#input(Component getListCellRendererComponent(JList, Object, int, bool, bool)): value.type
    //#input(Component getListCellRendererComponent(JList, Object, int, bool, bool)): value.type._tainted
    //#output(Component getListCellRendererComponent(JList, Object, int, bool, bool)): return_value
    //#pre[4] (Component getListCellRendererComponent(JList, Object, int, bool, bool)): value != null
    //#pre[11] (Component getListCellRendererComponent(JList, Object, int, bool, bool)): value.type != null
    //#pre[5] (Component getListCellRendererComponent(JList, Object, int, bool, bool)): (soft) value.__Tag == com/dmdirc/addons/addonbrowser/AddonInfo
    //#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)): init'ed(java.awt.Color.WHITE)
    //#presumption(Component getListCellRendererComponent(JList, Object, int, bool, bool)): java.awt.Font:deriveFont(...)@60 != null
    //#presumption(Component getListCellRendererComponent(JList, Object, int, bool, bool)): javax.swing.JLabel:getFont(...)@60 != 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:java.lang.StringBuilder
    //#unanalyzed(Component getListCellRendererComponent(JList, Object, int, bool, bool)): Effects-of-calling:java.lang.Enum:toString
    //#unanalyzed(Component getListCellRendererComponent(JList, Object, int, bool, bool)): Effects-of-calling:java.lang.String:charAt
    //#unanalyzed(Component getListCellRendererComponent(JList, Object, int, bool, bool)): Effects-of-calling:java.lang.StringBuilder:append
    //#unanalyzed(Component getListCellRendererComponent(JList, Object, int, bool, bool)): Effects-of-calling:java.lang.String:substring
    //#unanalyzed(Component getListCellRendererComponent(JList, Object, int, bool, bool)): Effects-of-calling:java.lang.String:toLowerCase
    //#unanalyzed(Component getListCellRendererComponent(JList, Object, int, bool, bool)): Effects-of-calling:java.lang.String:replace
    //#unanalyzed(Component getListCellRendererComponent(JList, Object, int, bool, bool)): Effects-of-calling:java.lang.StringBuilder:toString
    //#unanalyzed(Component getListCellRendererComponent(JList, Object, int, bool, bool)): Effects-of-calling:java.lang.String:equals
    //#unanalyzed(Component getListCellRendererComponent(JList, Object, int, bool, bool)): Effects-of-calling:com.dmdirc.updater.UpdateChecker:getComponents
    //#unanalyzed(Component getListCellRendererComponent(JList, Object, int, bool, bool)): Effects-of-calling:java.util.List:iterator
    //#unanalyzed(Component getListCellRendererComponent(JList, Object, int, bool, bool)): Effects-of-calling:java.util.Iterator:hasNext
    //#unanalyzed(Component getListCellRendererComponent(JList, Object, int, bool, bool)): Effects-of-calling:java.util.Iterator:next
    //#unanalyzed(Component getListCellRendererComponent(JList, Object, int, bool, bool)): Effects-of-calling:com.dmdirc.updater.UpdateComponent:getName
        removeAll();
    //#AddonInfoListCellRenderer.java:55: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.addons.addonbrowser.AddonInfoListCellRenderer:removeAll()
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.addonbrowser.AddonInfoListCellRenderer
    //#    method: Component getListCellRendererComponent(JList, Object, int, bool, bool)
    //#    unanalyzed callee: void com.dmdirc.addons.addonbrowser.AddonInfoListCellRenderer:removeAll()
        setLayout(new MigLayout("fillx, ins 0"));
    //#AddonInfoListCellRenderer.java:56: Warning: method not available - call not analyzed
    //#    call on void net.miginfocom.swing.MigLayout(String)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.addonbrowser.AddonInfoListCellRenderer
    //#    method: Component getListCellRendererComponent(JList, Object, int, bool, bool)
    //#    unanalyzed callee: void net.miginfocom.swing.MigLayout(String)
    //#AddonInfoListCellRenderer.java:56: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.addons.addonbrowser.AddonInfoListCellRenderer:setLayout(LayoutManager)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.addonbrowser.AddonInfoListCellRenderer
    //#    method: Component getListCellRendererComponent(JList, Object, int, bool, bool)
    //#    unanalyzed callee: void com.dmdirc.addons.addonbrowser.AddonInfoListCellRenderer:setLayout(LayoutManager)
        setBackground(index % 2 == 1 ? new Color(0xEE, 0xEE, 0xFF) : Color.WHITE);
    //#AddonInfoListCellRenderer.java:57: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.addons.addonbrowser.AddonInfoListCellRenderer:setBackground(Color)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.addonbrowser.AddonInfoListCellRenderer
    //#    method: Component getListCellRendererComponent(JList, Object, int, bool, bool)
    //#    unanalyzed callee: void com.dmdirc.addons.addonbrowser.AddonInfoListCellRenderer:setBackground(Color)
        
        JLabel title = new JLabel(info.getTitle());
        title.setFont(title.getFont().deriveFont(16f).deriveFont(Font.BOLD));
        add(title, "wmin 165, wmax 165, gaptop 5, gapleft 5");
    //#AddonInfoListCellRenderer.java:61: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.addons.addonbrowser.AddonInfoListCellRenderer:add(Component, Object)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.addonbrowser.AddonInfoListCellRenderer
    //#    method: Component getListCellRendererComponent(JList, Object, int, bool, bool)
    //#    unanalyzed callee: void com.dmdirc.addons.addonbrowser.AddonInfoListCellRenderer:add(Component, Object)
        
        title = new JLabel(info.getScreenshot());
        title.setBorder(BorderFactory.createLineBorder(Color.BLACK));
        add(title, "wmin 150, wmax 150, height 150::, wrap, spany 4, gaptop 5, gapright 5");
    //#AddonInfoListCellRenderer.java:65: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.addons.addonbrowser.AddonInfoListCellRenderer:add(Component, Object)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.addonbrowser.AddonInfoListCellRenderer
    //#    method: Component getListCellRendererComponent(JList, Object, int, bool, bool)
    //#    unanalyzed callee: void com.dmdirc.addons.addonbrowser.AddonInfoListCellRenderer:add(Component, Object)

        title = new JLabel(info.getType().toString() + ", rated "
                + info.getRating() + "/10");
        add(title, "gapleft 5, wrap");
    //#AddonInfoListCellRenderer.java:69: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.addons.addonbrowser.AddonInfoListCellRenderer:add(Component, Object)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.addonbrowser.AddonInfoListCellRenderer
    //#    method: Component getListCellRendererComponent(JList, Object, int, bool, bool)
    //#    unanalyzed callee: void com.dmdirc.addons.addonbrowser.AddonInfoListCellRenderer:add(Component, Object)
        
        TextLabel label = new TextLabel(info.getDescription());
    //#AddonInfoListCellRenderer.java:71: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.addons.ui_swing.components.text.TextLabel(String)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.addonbrowser.AddonInfoListCellRenderer
    //#    method: Component getListCellRendererComponent(JList, Object, int, bool, bool)
    //#    unanalyzed callee: void com.dmdirc.addons.ui_swing.components.text.TextLabel(String)
        add(label, "wmax 100%-170, hmax 150, growy, wrap, gapleft 5, gapbottom 5, pushy");
    //#AddonInfoListCellRenderer.java:72: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.addons.addonbrowser.AddonInfoListCellRenderer:add(Component, Object)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.addonbrowser.AddonInfoListCellRenderer
    //#    method: Component getListCellRendererComponent(JList, Object, int, bool, bool)
    //#    unanalyzed callee: void com.dmdirc.addons.addonbrowser.AddonInfoListCellRenderer:add(Component, Object)
        
        final JButton button = new JButton("Install");
        button.addActionListener(new InstallListener(info));
        final boolean installed = info.isInstalled();
        
        if (installed || !info.isDownloadable()) {
    //#AddonInfoListCellRenderer.java:78: Warning: test always goes same way
    //#    Test predetermined because isDownloadable(...) == 0
    //#    severity: LOW
    //#    class: com.dmdirc.addons.addonbrowser.AddonInfoListCellRenderer
    //#    method: Component getListCellRendererComponent(JList, Object, int, bool, bool)
    //#    from bb: bb_5
    //#    live edge: bb_5-->bb_6
    //#    tested vn: 0
    //#    tested vn values: {0}
            button.setEnabled(false);
        }
        
        add(button, "gapleft 5, split");
    //#AddonInfoListCellRenderer.java:82: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.addons.addonbrowser.AddonInfoListCellRenderer:add(Component, Object)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.addonbrowser.AddonInfoListCellRenderer
    //#    method: Component getListCellRendererComponent(JList, Object, int, bool, bool)
    //#    unanalyzed callee: void com.dmdirc.addons.addonbrowser.AddonInfoListCellRenderer:add(Component, Object)
        
        if (installed || !info.isDownloadable()) {
    //#AddonInfoListCellRenderer.java:84: Warning: test always goes same way
    //#    Test predetermined because isDownloadable(...) == 0
    //#    severity: LOW
    //#    class: com.dmdirc.addons.addonbrowser.AddonInfoListCellRenderer
    //#    method: Component getListCellRendererComponent(JList, Object, int, bool, bool)
    //#    from bb: bb_8
    //#    live edge: bb_8-->bb_9
    //#    tested vn: 0
    //#    tested vn values: {0}
            title = new JLabel(installed ? "Already installed" : "No download available");
            title.setForeground(Color.GRAY);
            add(title);
    //#AddonInfoListCellRenderer.java:87: Warning: method not available - call not analyzed
    //#    call on Component com.dmdirc.addons.addonbrowser.AddonInfoListCellRenderer:add(Component)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.addonbrowser.AddonInfoListCellRenderer
    //#    method: Component getListCellRendererComponent(JList, Object, int, bool, bool)
    //#    unanalyzed callee: Component com.dmdirc.addons.addonbrowser.AddonInfoListCellRenderer:add(Component)
        }
        
        add(new JSeparator(), "newline, span, growx, pushx, gaptop 5");
    //#AddonInfoListCellRenderer.java:90: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.addons.addonbrowser.AddonInfoListCellRenderer:add(Component, Object)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.addonbrowser.AddonInfoListCellRenderer
    //#    method: Component getListCellRendererComponent(JList, Object, int, bool, bool)
    //#    unanalyzed callee: void com.dmdirc.addons.addonbrowser.AddonInfoListCellRenderer:add(Component, Object)
        
        return this;
    //#AddonInfoListCellRenderer.java:92: end of method: Component com.dmdirc.addons.addonbrowser.AddonInfoListCellRenderer.getListCellRendererComponent(JList, Object, int, bool, bool)
    }
}
    //#output(com.dmdirc.addons.addonbrowser.AddonInfoListCellRenderer__static_init): __Descendant_Table[com/dmdirc/addons/addonbrowser/AddonInfoListCellRenderer]
    //#output(com.dmdirc.addons.addonbrowser.AddonInfoListCellRenderer__static_init): __Dispatch_Table.getListCellRendererComponent(Ljavax/swing/JList;Ljava/lang/Object;IZZ)Ljava/awt/Component;
    //#post(com.dmdirc.addons.addonbrowser.AddonInfoListCellRenderer__static_init): __Descendant_Table[com/dmdirc/addons/addonbrowser/AddonInfoListCellRenderer] == &__Dispatch_Table
    //#post(com.dmdirc.addons.addonbrowser.AddonInfoListCellRenderer__static_init): __Dispatch_Table.getListCellRendererComponent(Ljavax/swing/JList;Ljava/lang/Object;IZZ)Ljava/awt/Component; == &getListCellRendererComponent
    //#AddonInfoListCellRenderer.java:: end of method: com.dmdirc.addons.addonbrowser.AddonInfoListCellRenderer.com.dmdirc.addons.addonbrowser.AddonInfoListCellRenderer__static_init
    //#AddonInfoListCellRenderer.java:: end of class: com.dmdirc.addons.addonbrowser.AddonInfoListCellRenderer
