//# 0 errors, 78 messages
//#
/*
    //#NicklistRenderer.java:1:1: class: com.dmdirc.addons.ui_swing.components.renderers.NicklistRenderer
    //#NicklistRenderer.java:1:1: method: com.dmdirc.addons.ui_swing.components.renderers.NicklistRenderer.com.dmdirc.addons.ui_swing.components.renderers.NicklistRenderer__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.ChannelClientProperty;
import com.dmdirc.interfaces.ConfigChangeListener;
import com.dmdirc.config.ConfigManager;
import com.dmdirc.parser.irc.ChannelClientInfo;

import java.awt.Color;
import java.awt.Component;
import java.util.Map;

import javax.swing.BorderFactory;
import javax.swing.DefaultListCellRenderer;
import javax.swing.JList;

/** Renders the nicklist. */
public final class NicklistRenderer extends DefaultListCellRenderer implements
        ConfigChangeListener {

    /**
     * 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 = 5;
    /** Config manager. */
    private final ConfigManager config;
    /** Nicklist alternate background colour. */
    private Color altBackgroundColour;
    /** Show nick colours. */
    private boolean showColours;
    /** The list that we're using for the nicklist. */
    private final JList nicklist;

    /**
     * Creates a new instance of NicklistRenderer.
     *
     * @param config ConfigManager for the associated channel
     * @param nicklist The nicklist that we're rendering for.
     */
    public NicklistRenderer(final ConfigManager config, final JList nicklist) {
        super();
    //#NicklistRenderer.java:64: method: void com.dmdirc.addons.ui_swing.components.renderers.NicklistRenderer.com.dmdirc.addons.ui_swing.components.renderers.NicklistRenderer(ConfigManager, JList)
    //#input(void com.dmdirc.addons.ui_swing.components.renderers.NicklistRenderer(ConfigManager, JList)): config
    //#input(void com.dmdirc.addons.ui_swing.components.renderers.NicklistRenderer(ConfigManager, JList)): nicklist
    //#input(void com.dmdirc.addons.ui_swing.components.renderers.NicklistRenderer(ConfigManager, JList)): this
    //#output(void com.dmdirc.addons.ui_swing.components.renderers.NicklistRenderer(ConfigManager, JList)): this.altBackgroundColour
    //#output(void com.dmdirc.addons.ui_swing.components.renderers.NicklistRenderer(ConfigManager, JList)): this.config
    //#output(void com.dmdirc.addons.ui_swing.components.renderers.NicklistRenderer(ConfigManager, JList)): this.nicklist
    //#output(void com.dmdirc.addons.ui_swing.components.renderers.NicklistRenderer(ConfigManager, JList)): this.showColours
    //#pre[1] (void com.dmdirc.addons.ui_swing.components.renderers.NicklistRenderer(ConfigManager, JList)): config != null
    //#post(void com.dmdirc.addons.ui_swing.components.renderers.NicklistRenderer(ConfigManager, JList)): init'ed(this.altBackgroundColour)
    //#post(void com.dmdirc.addons.ui_swing.components.renderers.NicklistRenderer(ConfigManager, JList)): this.config == config
    //#post(void com.dmdirc.addons.ui_swing.components.renderers.NicklistRenderer(ConfigManager, JList)): this.config != null
    //#post(void com.dmdirc.addons.ui_swing.components.renderers.NicklistRenderer(ConfigManager, JList)): this.nicklist == nicklist
    //#post(void com.dmdirc.addons.ui_swing.components.renderers.NicklistRenderer(ConfigManager, JList)): init'ed(this.nicklist)
    //#post(void com.dmdirc.addons.ui_swing.components.renderers.NicklistRenderer(ConfigManager, JList)): init'ed(this.showColours)

        this.config = config;
        this.nicklist = nicklist;

        config.addChangeListener("ui", "shownickcoloursinnicklist", this);
    //#NicklistRenderer.java:69: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.config.ConfigManager:addChangeListener(String, String, ConfigChangeListener)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.ui_swing.components.renderers.NicklistRenderer
    //#    method: void com.dmdirc.addons.ui_swing.components.renderers.NicklistRenderer(ConfigManager, JList)
    //#    unanalyzed callee: void com.dmdirc.config.ConfigManager:addChangeListener(String, String, ConfigChangeListener)
        config.addChangeListener("ui", "nicklistbackgroundcolour", this);
    //#NicklistRenderer.java:70: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.config.ConfigManager:addChangeListener(String, String, ConfigChangeListener)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.ui_swing.components.renderers.NicklistRenderer
    //#    method: void com.dmdirc.addons.ui_swing.components.renderers.NicklistRenderer(ConfigManager, JList)
    //#    unanalyzed callee: void com.dmdirc.config.ConfigManager:addChangeListener(String, String, ConfigChangeListener)
        config.addChangeListener("ui", "backgroundcolour", this);
    //#NicklistRenderer.java:71: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.config.ConfigManager:addChangeListener(String, String, ConfigChangeListener)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.ui_swing.components.renderers.NicklistRenderer
    //#    method: void com.dmdirc.addons.ui_swing.components.renderers.NicklistRenderer(ConfigManager, JList)
    //#    unanalyzed callee: void com.dmdirc.config.ConfigManager:addChangeListener(String, String, ConfigChangeListener)
        config.addChangeListener("ui", "nickListAltBackgroundColour", this);
    //#NicklistRenderer.java:72: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.config.ConfigManager:addChangeListener(String, String, ConfigChangeListener)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.ui_swing.components.renderers.NicklistRenderer
    //#    method: void com.dmdirc.addons.ui_swing.components.renderers.NicklistRenderer(ConfigManager, JList)
    //#    unanalyzed callee: void com.dmdirc.config.ConfigManager:addChangeListener(String, String, ConfigChangeListener)
        altBackgroundColour = config.getOptionColour(
    //#NicklistRenderer.java:73: Warning: method not available - call not analyzed
    //#    call on Color com.dmdirc.config.ConfigManager:getOptionColour(String, String, String[])
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.ui_swing.components.renderers.NicklistRenderer
    //#    method: void com.dmdirc.addons.ui_swing.components.renderers.NicklistRenderer(ConfigManager, JList)
    //#    unanalyzed callee: Color com.dmdirc.config.ConfigManager:getOptionColour(String, String, String[])
                "ui", "nickListAltBackgroundColour",
                "ui", "nicklistbackgroundcolour",
                "ui", "backgroundcolour");
        showColours = config.getOptionBool("ui", "shownickcoloursinnicklist");
    //#NicklistRenderer.java:77: Warning: method not available - call not analyzed
    //#    call on bool com.dmdirc.config.ConfigManager:getOptionBool(String, String)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.ui_swing.components.renderers.NicklistRenderer
    //#    method: void com.dmdirc.addons.ui_swing.components.renderers.NicklistRenderer(ConfigManager, JList)
    //#    unanalyzed callee: bool com.dmdirc.config.ConfigManager:getOptionBool(String, String)
    }
    //#NicklistRenderer.java:78: end of method: void com.dmdirc.addons.ui_swing.components.renderers.NicklistRenderer.com.dmdirc.addons.ui_swing.components.renderers.NicklistRenderer(ConfigManager, JList)

    /** {@inheritDoc} */
    @Override
    public Component getListCellRendererComponent(final JList list,
            final Object value, final int index, final boolean isSelected,
            final boolean cellHasFocus) {

        super.getListCellRendererComponent(list, value, index, isSelected,
    //#NicklistRenderer.java:86: method: Component com.dmdirc.addons.ui_swing.components.renderers.NicklistRenderer.getListCellRendererComponent(JList, Object, int, bool, bool)
    //#input(Component getListCellRendererComponent(JList, Object, int, bool, bool)): cellHasFocus
    //#input(Component getListCellRendererComponent(JList, Object, int, bool, bool)): com.dmdirc.ChannelClientProperty.NICKLIST_BACKGROUND
    //#input(Component getListCellRendererComponent(JList, Object, int, bool, bool)): com.dmdirc.ChannelClientProperty.NICKLIST_FOREGROUND
    //#input(Component getListCellRendererComponent(JList, Object, int, bool, bool)): index
    //#input(Component getListCellRendererComponent(JList, Object, int, bool, bool)): isSelected
    //#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)): this.altBackgroundColour
    //#input(Component getListCellRendererComponent(JList, Object, int, bool, bool)): this.showColours
    //#input(Component getListCellRendererComponent(JList, Object, int, bool, bool)): value
    //#output(Component getListCellRendererComponent(JList, Object, int, bool, bool)): return_value
    //#pre[10] (Component getListCellRendererComponent(JList, Object, int, bool, bool)): init'ed(this.showColours)
    //#pre[11] (Component getListCellRendererComponent(JList, Object, int, bool, bool)): value != null
    //#pre[9] (Component getListCellRendererComponent(JList, Object, int, bool, bool)): (soft) init'ed(this.altBackgroundColour)
    //#presumption(Component getListCellRendererComponent(JList, Object, int, bool, bool)): init'ed(com.dmdirc.ChannelClientProperty.NICKLIST_BACKGROUND)
    //#presumption(Component getListCellRendererComponent(JList, Object, int, bool, bool)): init'ed(com.dmdirc.ChannelClientProperty.NICKLIST_FOREGROUND)
    //#post(Component getListCellRendererComponent(JList, Object, int, bool, bool)): return_value == this
    //#post(Component getListCellRendererComponent(JList, Object, int, bool, bool)): return_value != null
    //#test_vector(Component getListCellRendererComponent(JList, Object, int, bool, bool)): index mod 2: {0}, {1}
    //#test_vector(Component getListCellRendererComponent(JList, Object, int, bool, bool)): isSelected: {1}, {0}
    //#test_vector(Component getListCellRendererComponent(JList, Object, int, bool, bool)): this.showColours: {0}, {1}
    //#test_vector(Component getListCellRendererComponent(JList, Object, int, bool, bool)): com.dmdirc.parser.irc.ChannelClientInfo:getMap(...)@93: Addr_Set{null}, Inverse{null}
    //#test_vector(Component getListCellRendererComponent(JList, Object, int, bool, bool)): java.util.Map:containsKey(...)@100: {0}, {1}
    //#test_vector(Component getListCellRendererComponent(JList, Object, int, bool, bool)): java.util.Map:containsKey(...)@96: {0}, {1}
                cellHasFocus);

        if (!isSelected && (index & 1) == 1) {
            setBackground(altBackgroundColour);
    //#NicklistRenderer.java:90: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.addons.ui_swing.components.renderers.NicklistRenderer:setBackground(Color)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.ui_swing.components.renderers.NicklistRenderer
    //#    method: Component getListCellRendererComponent(JList, Object, int, bool, bool)
    //#    unanalyzed callee: void com.dmdirc.addons.ui_swing.components.renderers.NicklistRenderer:setBackground(Color)
        }

        final Map map = ((ChannelClientInfo) value).getMap();
    //#NicklistRenderer.java:93: Warning: method not available - call not analyzed
    //#    call on Map com.dmdirc.parser.irc.ChannelClientInfo:getMap()
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.ui_swing.components.renderers.NicklistRenderer
    //#    method: Component getListCellRendererComponent(JList, Object, int, bool, bool)
    //#    unanalyzed callee: Map com.dmdirc.parser.irc.ChannelClientInfo:getMap()

        if (showColours && map != null) {
            if (map.containsKey(ChannelClientProperty.NICKLIST_FOREGROUND)) {
                setForeground((Color) map.get(ChannelClientProperty.NICKLIST_FOREGROUND));
    //#NicklistRenderer.java:97: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.addons.ui_swing.components.renderers.NicklistRenderer:setForeground(Color)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.ui_swing.components.renderers.NicklistRenderer
    //#    method: Component getListCellRendererComponent(JList, Object, int, bool, bool)
    //#    unanalyzed callee: void com.dmdirc.addons.ui_swing.components.renderers.NicklistRenderer:setForeground(Color)
            }

            if (map.containsKey(ChannelClientProperty.NICKLIST_BACKGROUND)) {
                setBackground((Color) map.get(ChannelClientProperty.NICKLIST_BACKGROUND));
    //#NicklistRenderer.java:101: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.addons.ui_swing.components.renderers.NicklistRenderer:setBackground(Color)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.ui_swing.components.renderers.NicklistRenderer
    //#    method: Component getListCellRendererComponent(JList, Object, int, bool, bool)
    //#    unanalyzed callee: void com.dmdirc.addons.ui_swing.components.renderers.NicklistRenderer:setBackground(Color)
            }
        }

        setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 2));
    //#NicklistRenderer.java:105: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.addons.ui_swing.components.renderers.NicklistRenderer:setBorder(Border)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.ui_swing.components.renderers.NicklistRenderer
    //#    method: Component getListCellRendererComponent(JList, Object, int, bool, bool)
    //#    unanalyzed callee: void com.dmdirc.addons.ui_swing.components.renderers.NicklistRenderer:setBorder(Border)

        return this;
    //#NicklistRenderer.java:107: end of method: Component com.dmdirc.addons.ui_swing.components.renderers.NicklistRenderer.getListCellRendererComponent(JList, Object, int, bool, bool)
    }

    /** {@inheritDoc} */
    @Override
    public void configChanged(final String domain, final String key) {
        if ("shownickcoloursinnicklist".equals(key)) {
    //#NicklistRenderer.java:113: method: void com.dmdirc.addons.ui_swing.components.renderers.NicklistRenderer.configChanged(String, String)
    //#input(void configChanged(String, String)): key
    //#input(void configChanged(String, String)): this
    //#input(void configChanged(String, String)): this.config
    //#input(void configChanged(String, String)): this.nicklist
    //#output(void configChanged(String, String)): this.altBackgroundColour
    //#output(void configChanged(String, String)): this.showColours
    //#pre[5] (void configChanged(String, String)): this.config != null
    //#pre[6] (void configChanged(String, String)): this.nicklist != null
    //#post(void configChanged(String, String)): possibly_updated(this.altBackgroundColour)
    //#post(void configChanged(String, String)): possibly_updated(this.showColours)
    //#test_vector(void configChanged(String, String)): java.lang.String:equals(...)@113: {0}, {1}
            showColours = config.getOptionBool("ui", "shownickcoloursinnicklist");
    //#NicklistRenderer.java:114: Warning: method not available - call not analyzed
    //#    call on bool com.dmdirc.config.ConfigManager:getOptionBool(String, String)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.ui_swing.components.renderers.NicklistRenderer
    //#    method: void configChanged(String, String)
    //#    unanalyzed callee: bool com.dmdirc.config.ConfigManager:getOptionBool(String, String)

        } else {
            altBackgroundColour =
    //#NicklistRenderer.java:117: Warning: method not available - call not analyzed
    //#    call on Color com.dmdirc.config.ConfigManager:getOptionColour(String, String, String[])
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.ui_swing.components.renderers.NicklistRenderer
    //#    method: void configChanged(String, String)
    //#    unanalyzed callee: Color com.dmdirc.config.ConfigManager:getOptionColour(String, String, String[])
                    config.getOptionColour(
                    "ui", "nickListAltBackgroundColour",
                    "ui", "nicklistbackgroundcolour",
                    "ui", "backgroundcolour");
        }
        nicklist.repaint();
    }
    //#NicklistRenderer.java:124: end of method: void com.dmdirc.addons.ui_swing.components.renderers.NicklistRenderer.configChanged(String, String)
}
    //#output(com.dmdirc.addons.ui_swing.components.renderers.NicklistRenderer__static_init): __Descendant_Table[com/dmdirc/addons/ui_swing/components/renderers/NicklistRenderer]
    //#output(com.dmdirc.addons.ui_swing.components.renderers.NicklistRenderer__static_init): __Dispatch_Table.configChanged(Ljava/lang/String;Ljava/lang/String;)V
    //#output(com.dmdirc.addons.ui_swing.components.renderers.NicklistRenderer__static_init): __Dispatch_Table.getListCellRendererComponent(Ljavax/swing/JList;Ljava/lang/Object;IZZ)Ljava/awt/Component;
    //#post(com.dmdirc.addons.ui_swing.components.renderers.NicklistRenderer__static_init): __Descendant_Table[com/dmdirc/addons/ui_swing/components/renderers/NicklistRenderer] == &__Dispatch_Table
    //#post(com.dmdirc.addons.ui_swing.components.renderers.NicklistRenderer__static_init): __Dispatch_Table.configChanged(Ljava/lang/String;Ljava/lang/String;)V == &configChanged
    //#post(com.dmdirc.addons.ui_swing.components.renderers.NicklistRenderer__static_init): __Dispatch_Table.getListCellRendererComponent(Ljavax/swing/JList;Ljava/lang/Object;IZZ)Ljava/awt/Component; == &getListCellRendererComponent
    //#NicklistRenderer.java:: end of method: com.dmdirc.addons.ui_swing.components.renderers.NicklistRenderer.com.dmdirc.addons.ui_swing.components.renderers.NicklistRenderer__static_init
    //#NicklistRenderer.java:: end of class: com.dmdirc.addons.ui_swing.components.renderers.NicklistRenderer
