//# 0 errors, 69 messages
//#
/*
    //#BrowserPlugin.java:1:1: class: com.dmdirc.addons.addonbrowser.BrowserPlugin
    //#BrowserPlugin.java:1:1: method: com.dmdirc.addons.addonbrowser.BrowserPlugin.com.dmdirc.addons.addonbrowser.BrowserPlugin__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.config.prefs.PreferencesManager;
import com.dmdirc.plugins.Plugin;
import com.dmdirc.addons.ui_swing.components.pluginpanel.PluginPanel;

import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;

/**
 * Allows the user to browse and download plugins from within the DMDirc ui.
 * 
 * @author chris
 */
public class BrowserPlugin extends Plugin implements ActionListener {
    //#BrowserPlugin.java:40: method: void com.dmdirc.addons.addonbrowser.BrowserPlugin.com.dmdirc.addons.addonbrowser.BrowserPlugin()
    //#BrowserPlugin.java:40: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.plugins.Plugin()
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.addonbrowser.BrowserPlugin
    //#    method: void com.dmdirc.addons.addonbrowser.BrowserPlugin()
    //#    unanalyzed callee: void com.dmdirc.plugins.Plugin()
    //#input(void com.dmdirc.addons.addonbrowser.BrowserPlugin()): this
    //#output(void com.dmdirc.addons.addonbrowser.BrowserPlugin()): this.loaded
    //#post(void com.dmdirc.addons.addonbrowser.BrowserPlugin()): this.loaded == 0
    
    /** Whether or not we're loaded. */
    private boolean loaded = false;
    //#BrowserPlugin.java:43: end of method: void com.dmdirc.addons.addonbrowser.BrowserPlugin.com.dmdirc.addons.addonbrowser.BrowserPlugin()

    /** {@inheritDoc} */
    @Override
    public void onLoad() {
        loaded = true;
    //#BrowserPlugin.java:48: method: void com.dmdirc.addons.addonbrowser.BrowserPlugin.onLoad()
    //#input(void onLoad()): this
    //#output(void onLoad()): this.loaded
    //#post(void onLoad()): this.loaded == 1
    }
    //#BrowserPlugin.java:49: end of method: void com.dmdirc.addons.addonbrowser.BrowserPlugin.onLoad()

    /** {@inheritDoc} */
    @Override
    public void onUnload() {
        loaded = false;
    //#BrowserPlugin.java:54: method: void com.dmdirc.addons.addonbrowser.BrowserPlugin.onUnload()
    //#input(void onUnload()): this
    //#output(void onUnload()): this.loaded
    //#post(void onUnload()): this.loaded == 0
    }
    //#BrowserPlugin.java:55: end of method: void com.dmdirc.addons.addonbrowser.BrowserPlugin.onUnload()

    /** {@inheritDoc} */
    @Override
    public void showConfig(final PreferencesManager manager) {
        if (loaded) {
    //#BrowserPlugin.java:60: method: void com.dmdirc.addons.addonbrowser.BrowserPlugin.showConfig(PreferencesManager)
    //#input(void showConfig(PreferencesManager)): manager
    //#input(void showConfig(PreferencesManager)): this
    //#input(void showConfig(PreferencesManager)): this.loaded
    //#pre[3] (void showConfig(PreferencesManager)): init'ed(this.loaded)
    //#pre[1] (void showConfig(PreferencesManager)): (soft) manager != null
    //#presumption(void showConfig(PreferencesManager)): arr$.length@62 <= 4_294_967_295
    //#presumption(void showConfig(PreferencesManager)): arr$.length@66 <= 4_294_967_295
    //#presumption(void showConfig(PreferencesManager)): com.dmdirc.addons.ui_swing.components.pluginpanel.PluginPanel:getComponents(...)@62 != null
    //#presumption(void showConfig(PreferencesManager)): com.dmdirc.config.prefs.PreferencesCategory:getObject(...)@61 != null
    //#presumption(void showConfig(PreferencesManager)): com.dmdirc.config.prefs.PreferencesManager:getCategory(...)@61 != null
    //#presumption(void showConfig(PreferencesManager)): javax.swing.JButton:getActionListeners(...)@66 != null
    //#presumption(void showConfig(PreferencesManager)): javax.swing.JButton:getText(...)@63 != null
    //#test_vector(void showConfig(PreferencesManager)): this.loaded: {0}, {1}
    //#test_vector(void showConfig(PreferencesManager)): java.lang.String:startsWith(...)@63: {0}, {1}
            final PluginPanel pp = ((PluginPanel) manager.getCategory("Plugins").getObject());
    //#BrowserPlugin.java:61: Warning: method not available - call not analyzed
    //#    call on PreferencesCategory com.dmdirc.config.prefs.PreferencesManager:getCategory(String)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.addonbrowser.BrowserPlugin
    //#    method: void showConfig(PreferencesManager)
    //#    unanalyzed callee: PreferencesCategory com.dmdirc.config.prefs.PreferencesManager:getCategory(String)
    //#BrowserPlugin.java:61: Warning: method not available - call not analyzed
    //#    call on PreferencesInterface com.dmdirc.config.prefs.PreferencesCategory:getObject()
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.addonbrowser.BrowserPlugin
    //#    method: void showConfig(PreferencesManager)
    //#    unanalyzed callee: PreferencesInterface com.dmdirc.config.prefs.PreferencesCategory:getObject()
            for (Component comp : pp.getComponents()) {
    //#BrowserPlugin.java:62: Warning: method not available - call not analyzed
    //#    call on Component[] com.dmdirc.addons.ui_swing.components.pluginpanel.PluginPanel:getComponents()
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.addonbrowser.BrowserPlugin
    //#    method: void showConfig(PreferencesManager)
    //#    unanalyzed callee: Component[] com.dmdirc.addons.ui_swing.components.pluginpanel.PluginPanel:getComponents()
                if (comp instanceof JButton && ((JButton) comp).getText().startsWith("Get more")) {
                    final JButton button = (JButton) comp;
                    
                    for (ActionListener listener : button.getActionListeners()) {
                        button.removeActionListener(listener);
                    }
                    
                    button.addActionListener(this);
                }
            }
        }
    }
    //#BrowserPlugin.java:74: end of method: void com.dmdirc.addons.addonbrowser.BrowserPlugin.showConfig(PreferencesManager)

    /** {@inheritDoc} */
    @Override
    public void actionPerformed(final ActionEvent e) {
        new DownloaderWindow();
    //#BrowserPlugin.java:79: method: void com.dmdirc.addons.addonbrowser.BrowserPlugin.actionPerformed(ActionEvent)
    //#input(void actionPerformed(ActionEvent)): com/dmdirc/Main.controller
    //#pre[1] (void actionPerformed(ActionEvent)): com/dmdirc/Main.controller != null
    //#unanalyzed(void actionPerformed(ActionEvent)): Effects-of-calling:javax.swing.JDialog
    //#unanalyzed(void actionPerformed(ActionEvent)): Effects-of-calling:javax.swing.JProgressBar
    //#unanalyzed(void actionPerformed(ActionEvent)): Effects-of-calling:com.dmdirc.addons.addonbrowser.DownloaderWindow:setTitle
    //#unanalyzed(void actionPerformed(ActionEvent)): Effects-of-calling:net.miginfocom.swing.MigLayout
    //#unanalyzed(void actionPerformed(ActionEvent)): Effects-of-calling:com.dmdirc.addons.addonbrowser.DownloaderWindow:setLayout
    //#unanalyzed(void actionPerformed(ActionEvent)): Effects-of-calling:com.dmdirc.addons.addonbrowser.DownloaderWindow:add
    //#unanalyzed(void actionPerformed(ActionEvent)): Effects-of-calling:com.dmdirc.addons.addonbrowser.DownloaderWindow:pack
    //#unanalyzed(void actionPerformed(ActionEvent)): Effects-of-calling:com.dmdirc.addons.addonbrowser.DownloaderWindow:setDefaultCloseOperation
    //#unanalyzed(void actionPerformed(ActionEvent)): Effects-of-calling:com.dmdirc.ui.interfaces.UIController:getMainWindow
    //#unanalyzed(void actionPerformed(ActionEvent)): Effects-of-calling:com.dmdirc.addons.addonbrowser.DownloaderWindow:setLocationRelativeTo
    //#unanalyzed(void actionPerformed(ActionEvent)): Effects-of-calling:com.dmdirc.ui.interfaces.MainWindow:getIcon
    //#unanalyzed(void actionPerformed(ActionEvent)): Effects-of-calling:javax.swing.ImageIcon:getImage
    //#unanalyzed(void actionPerformed(ActionEvent)): Effects-of-calling:com.dmdirc.addons.addonbrowser.DownloaderWindow:setIconImage
    //#unanalyzed(void actionPerformed(ActionEvent)): Effects-of-calling:com.dmdirc.addons.addonbrowser.DownloaderWindow:setVisible
    //#unanalyzed(void actionPerformed(ActionEvent)): Effects-of-calling:java.lang.Thread
    //#unanalyzed(void actionPerformed(ActionEvent)): Effects-of-calling:java.lang.Thread:start
    }
    //#BrowserPlugin.java:80: end of method: void com.dmdirc.addons.addonbrowser.BrowserPlugin.actionPerformed(ActionEvent)

}
    //#output(com.dmdirc.addons.addonbrowser.BrowserPlugin__static_init): __Descendant_Table[com/dmdirc/addons/addonbrowser/BrowserPlugin]
    //#output(com.dmdirc.addons.addonbrowser.BrowserPlugin__static_init): __Dispatch_Table.actionPerformed(Ljava/awt/event/ActionEvent;)V
    //#output(com.dmdirc.addons.addonbrowser.BrowserPlugin__static_init): __Dispatch_Table.onLoad()V
    //#output(com.dmdirc.addons.addonbrowser.BrowserPlugin__static_init): __Dispatch_Table.onUnload()V
    //#output(com.dmdirc.addons.addonbrowser.BrowserPlugin__static_init): __Dispatch_Table.showConfig(Lcom/dmdirc/config/prefs/PreferencesManager;)V
    //#post(com.dmdirc.addons.addonbrowser.BrowserPlugin__static_init): __Descendant_Table[com/dmdirc/addons/addonbrowser/BrowserPlugin] == &__Dispatch_Table
    //#post(com.dmdirc.addons.addonbrowser.BrowserPlugin__static_init): __Dispatch_Table.actionPerformed(Ljava/awt/event/ActionEvent;)V == &actionPerformed
    //#post(com.dmdirc.addons.addonbrowser.BrowserPlugin__static_init): __Dispatch_Table.onLoad()V == &onLoad
    //#post(com.dmdirc.addons.addonbrowser.BrowserPlugin__static_init): __Dispatch_Table.onUnload()V == &onUnload
    //#post(com.dmdirc.addons.addonbrowser.BrowserPlugin__static_init): __Dispatch_Table.showConfig(Lcom/dmdirc/config/prefs/PreferencesManager;)V == &showConfig
    //#BrowserPlugin.java:: end of method: com.dmdirc.addons.addonbrowser.BrowserPlugin.com.dmdirc.addons.addonbrowser.BrowserPlugin__static_init
    //#BrowserPlugin.java:: end of class: com.dmdirc.addons.addonbrowser.BrowserPlugin
