//# 0 errors, 33 messages
//#
/*
    //#TopicHistoryPane.java:1:1: class: com.dmdirc.addons.ui_swing.dialogs.channelsetting.TopicHistoryPane
    //#TopicHistoryPane.java:1:1: method: com.dmdirc.addons.ui_swing.dialogs.channelsetting.TopicHistoryPane.com.dmdirc.addons.ui_swing.dialogs.channelsetting.TopicHistoryPane__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.dialogs.channelsetting;

import com.dmdirc.addons.ui_swing.components.renderers.TopicCellRenderer;
import com.dmdirc.addons.ui_swing.UIUtilities;
import com.dmdirc.Channel;
import com.dmdirc.Topic;

import java.awt.Dimension;
import java.util.Collections;
import java.util.List;

import javax.swing.DefaultListModel;
import javax.swing.JList;
import javax.swing.JPanel;

import net.miginfocom.swing.MigLayout;

/**
 * Topic history panel.
 */
public class TopicHistoryPane extends JPanel {
    
    /**
     * 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;
    /** Topic history list. */
    private JList topicHistory;

    /**
     * Instantiates a new topic history pane.
     * 
     * @param channel Parent channel
     */
    public TopicHistoryPane(final Channel channel) {
    //#TopicHistoryPane.java:59: method: void com.dmdirc.addons.ui_swing.dialogs.channelsetting.TopicHistoryPane.com.dmdirc.addons.ui_swing.dialogs.channelsetting.TopicHistoryPane(Channel)
    //#input(void com.dmdirc.addons.ui_swing.dialogs.channelsetting.TopicHistoryPane(Channel)): channel
    //#input(void com.dmdirc.addons.ui_swing.dialogs.channelsetting.TopicHistoryPane(Channel)): this
    //#output(void com.dmdirc.addons.ui_swing.dialogs.channelsetting.TopicHistoryPane(Channel)): new JList(TopicHistoryPane#1) num objects
    //#output(void com.dmdirc.addons.ui_swing.dialogs.channelsetting.TopicHistoryPane(Channel)): this.topicHistory
    //#new obj(void com.dmdirc.addons.ui_swing.dialogs.channelsetting.TopicHistoryPane(Channel)): new JList(TopicHistoryPane#1)
    //#pre[1] (void com.dmdirc.addons.ui_swing.dialogs.channelsetting.TopicHistoryPane(Channel)): channel != null
    //#presumption(void com.dmdirc.addons.ui_swing.dialogs.channelsetting.TopicHistoryPane(Channel)): com.dmdirc.Channel:getTopics(...)@60 != null
    //#presumption(void com.dmdirc.addons.ui_swing.dialogs.channelsetting.TopicHistoryPane(Channel)): java.util.List:size(...)@63 >= -2_147_483_647
    //#presumption(void com.dmdirc.addons.ui_swing.dialogs.channelsetting.TopicHistoryPane(Channel)): javax.swing.JList:getModel(...)@70 != null
    //#presumption(void com.dmdirc.addons.ui_swing.dialogs.channelsetting.TopicHistoryPane(Channel)): javax.swing.JList:getModel(...)@73 != null
    //#presumption(void com.dmdirc.addons.ui_swing.dialogs.channelsetting.TopicHistoryPane(Channel)): javax.swing.JList:getModel(...)@74 != null
    //#post(void com.dmdirc.addons.ui_swing.dialogs.channelsetting.TopicHistoryPane(Channel)): this.topicHistory == &new JList(TopicHistoryPane#1)
    //#post(void com.dmdirc.addons.ui_swing.dialogs.channelsetting.TopicHistoryPane(Channel)): new JList(TopicHistoryPane#1) num objects == 1
    //#unanalyzed(void com.dmdirc.addons.ui_swing.dialogs.channelsetting.TopicHistoryPane(Channel)): Effects-of-calling:javax.swing.JPanel
    //#test_vector(void com.dmdirc.addons.ui_swing.dialogs.channelsetting.TopicHistoryPane(Channel)): java.util.Iterator:hasNext(...)@69: {0}, {1}
    //#test_vector(void com.dmdirc.addons.ui_swing.dialogs.channelsetting.TopicHistoryPane(Channel)): java.util.List:size(...)@62: {-2_147_483_648..0}, {1..4_294_967_295}
    //#test_vector(void com.dmdirc.addons.ui_swing.dialogs.channelsetting.TopicHistoryPane(Channel)): javax.swing.ListModel:getSize(...)@73: {-2_147_483_648..-1, 1..4_294_967_295}, {0}
        final List<Topic> topics = channel.getTopics();
    //#TopicHistoryPane.java:60: Warning: method not available - call not analyzed
    //#    call on List com.dmdirc.Channel:getTopics()
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.ui_swing.dialogs.channelsetting.TopicHistoryPane
    //#    method: void com.dmdirc.addons.ui_swing.dialogs.channelsetting.TopicHistoryPane(Channel)
    //#    unanalyzed callee: List com.dmdirc.Channel:getTopics()
        Collections.reverse(topics);
        if (topics.size() > 0) {
            topics.remove(topics.size() - 1);
        }
        
        topicHistory = new JList(new DefaultListModel());
        topicHistory.setCellRenderer(new TopicCellRenderer());
        
        for (Topic topic : topics) {
            ((DefaultListModel) topicHistory.getModel()).addElement(topic);
        }
        
        if (topicHistory.getModel().getSize() == 0) {
            ((DefaultListModel) topicHistory.getModel()).addElement("No previous topics.");
            topicHistory.setBackground(getBackground());
    //#TopicHistoryPane.java:75: Warning: method not available - call not analyzed
    //#    call on Color com.dmdirc.addons.ui_swing.dialogs.channelsetting.TopicHistoryPane:getBackground()
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.ui_swing.dialogs.channelsetting.TopicHistoryPane
    //#    method: void com.dmdirc.addons.ui_swing.dialogs.channelsetting.TopicHistoryPane(Channel)
    //#    unanalyzed callee: Color com.dmdirc.addons.ui_swing.dialogs.channelsetting.TopicHistoryPane:getBackground()
            topicHistory.setForeground(getForeground());
    //#TopicHistoryPane.java:76: Warning: method not available - call not analyzed
    //#    call on Color com.dmdirc.addons.ui_swing.dialogs.channelsetting.TopicHistoryPane:getForeground()
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.ui_swing.dialogs.channelsetting.TopicHistoryPane
    //#    method: void com.dmdirc.addons.ui_swing.dialogs.channelsetting.TopicHistoryPane(Channel)
    //#    unanalyzed callee: Color com.dmdirc.addons.ui_swing.dialogs.channelsetting.TopicHistoryPane:getForeground()
        }
        
        setLayout(new MigLayout("ins 0"));
    //#TopicHistoryPane.java:79: Warning: method not available - call not analyzed
    //#    call on void net.miginfocom.swing.MigLayout(String)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.ui_swing.dialogs.channelsetting.TopicHistoryPane
    //#    method: void com.dmdirc.addons.ui_swing.dialogs.channelsetting.TopicHistoryPane(Channel)
    //#    unanalyzed callee: void net.miginfocom.swing.MigLayout(String)
    //#TopicHistoryPane.java:79: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.addons.ui_swing.dialogs.channelsetting.TopicHistoryPane:setLayout(LayoutManager)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.ui_swing.dialogs.channelsetting.TopicHistoryPane
    //#    method: void com.dmdirc.addons.ui_swing.dialogs.channelsetting.TopicHistoryPane(Channel)
    //#    unanalyzed callee: void com.dmdirc.addons.ui_swing.dialogs.channelsetting.TopicHistoryPane:setLayout(LayoutManager)
        topicHistory.setMaximumSize(new Dimension(400, Integer.MAX_VALUE));
        add(topicHistory, "grow, push");
    //#TopicHistoryPane.java:81: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.addons.ui_swing.dialogs.channelsetting.TopicHistoryPane:add(Component, Object)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.ui_swing.dialogs.channelsetting.TopicHistoryPane
    //#    method: void com.dmdirc.addons.ui_swing.dialogs.channelsetting.TopicHistoryPane(Channel)
    //#    unanalyzed callee: void com.dmdirc.addons.ui_swing.dialogs.channelsetting.TopicHistoryPane:add(Component, Object)
        
        this.setOpaque(UIUtilities.getTabbedPaneOpaque());
    //#TopicHistoryPane.java:83: Warning: method not available - call not analyzed
    //#    call on bool com.dmdirc.addons.ui_swing.UIUtilities:getTabbedPaneOpaque()
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.ui_swing.dialogs.channelsetting.TopicHistoryPane
    //#    method: void com.dmdirc.addons.ui_swing.dialogs.channelsetting.TopicHistoryPane(Channel)
    //#    unanalyzed callee: bool com.dmdirc.addons.ui_swing.UIUtilities:getTabbedPaneOpaque()
    //#TopicHistoryPane.java:83: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.addons.ui_swing.dialogs.channelsetting.TopicHistoryPane:setOpaque(bool)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.ui_swing.dialogs.channelsetting.TopicHistoryPane
    //#    method: void com.dmdirc.addons.ui_swing.dialogs.channelsetting.TopicHistoryPane(Channel)
    //#    unanalyzed callee: void com.dmdirc.addons.ui_swing.dialogs.channelsetting.TopicHistoryPane:setOpaque(bool)
    }
    //#TopicHistoryPane.java:84: end of method: void com.dmdirc.addons.ui_swing.dialogs.channelsetting.TopicHistoryPane.com.dmdirc.addons.ui_swing.dialogs.channelsetting.TopicHistoryPane(Channel)

}
    //#output(com.dmdirc.addons.ui_swing.dialogs.channelsetting.TopicHistoryPane__static_init): __Descendant_Table[com/dmdirc/addons/ui_swing/dialogs/channelsetting/TopicHistoryPane]
    //#post(com.dmdirc.addons.ui_swing.dialogs.channelsetting.TopicHistoryPane__static_init): __Descendant_Table[com/dmdirc/addons/ui_swing/dialogs/channelsetting/TopicHistoryPane] == &__Dispatch_Table
    //#TopicHistoryPane.java:: end of method: com.dmdirc.addons.ui_swing.dialogs.channelsetting.TopicHistoryPane.com.dmdirc.addons.ui_swing.dialogs.channelsetting.TopicHistoryPane__static_init
    //#TopicHistoryPane.java:: end of class: com.dmdirc.addons.ui_swing.dialogs.channelsetting.TopicHistoryPane
