//# 0 errors, 62 messages
//#
/*
    //#PluginInfoToggle.java:1:1: class: com.dmdirc.addons.ui_swing.components.pluginpanel.PluginInfoToggle
    //#PluginInfoToggle.java:1:1: method: com.dmdirc.addons.ui_swing.components.pluginpanel.PluginInfoToggle.com.dmdirc.addons.ui_swing.components.pluginpanel.PluginInfoToggle__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.pluginpanel;

import com.dmdirc.plugins.PluginInfo;
import com.dmdirc.plugins.PluginManager;

/**
 * Wraps a PluginInfo object with a boolean to indicate whether it should be
 * toggled or not.
 * 
 * @author chris
 */
public class PluginInfoToggle {
    
    /** The PluginInfo object we're wrapping. */
    private final PluginInfo pi;
    
    /** Whether or not to toggle it. */
    private boolean toggle = false;

    /**
     * Creates a new instance of PluginInfoToggle to wrap the specified
     * PluginInfo.
     * 
     * @param pi The PluginInfo to be wrapped
     */
    public PluginInfoToggle(final PluginInfo pi) {
    //#PluginInfoToggle.java:47: method: void com.dmdirc.addons.ui_swing.components.pluginpanel.PluginInfoToggle.com.dmdirc.addons.ui_swing.components.pluginpanel.PluginInfoToggle(PluginInfo)
    //#input(void com.dmdirc.addons.ui_swing.components.pluginpanel.PluginInfoToggle(PluginInfo)): pi
    //#input(void com.dmdirc.addons.ui_swing.components.pluginpanel.PluginInfoToggle(PluginInfo)): this
    //#output(void com.dmdirc.addons.ui_swing.components.pluginpanel.PluginInfoToggle(PluginInfo)): this.pi
    //#output(void com.dmdirc.addons.ui_swing.components.pluginpanel.PluginInfoToggle(PluginInfo)): this.toggle
    //#post(void com.dmdirc.addons.ui_swing.components.pluginpanel.PluginInfoToggle(PluginInfo)): this.pi == pi
    //#post(void com.dmdirc.addons.ui_swing.components.pluginpanel.PluginInfoToggle(PluginInfo)): init'ed(this.pi)
    //#post(void com.dmdirc.addons.ui_swing.components.pluginpanel.PluginInfoToggle(PluginInfo)): this.toggle == 0
        this.pi = pi;
    }
    //#PluginInfoToggle.java:49: end of method: void com.dmdirc.addons.ui_swing.components.pluginpanel.PluginInfoToggle.com.dmdirc.addons.ui_swing.components.pluginpanel.PluginInfoToggle(PluginInfo)
    
    /**
     * Toggles this PluginInfoToggle.
     */
    public void toggle() {
        toggle = !toggle;
    //#PluginInfoToggle.java:55: method: void com.dmdirc.addons.ui_swing.components.pluginpanel.PluginInfoToggle.toggle()
    //#input(void toggle()): this
    //#input(void toggle()): this.toggle
    //#output(void toggle()): this.toggle
    //#pre[1] (void toggle()): init'ed(this.toggle)
    //#post(void toggle()): init'ed(this.toggle)
    }
    //#PluginInfoToggle.java:56: end of method: void com.dmdirc.addons.ui_swing.components.pluginpanel.PluginInfoToggle.toggle()
    
    /**
     * Gets the state of this PluginInfo, taking into account the state
     * of the toggle setting.
     * 
     * @return True if the plugin is or should be loaded, false otherwise.
     */
    public boolean getState() {
        return toggle ^ pi.isLoaded();
    //#PluginInfoToggle.java:65: method: bool com.dmdirc.addons.ui_swing.components.pluginpanel.PluginInfoToggle.getState()
    //#PluginInfoToggle.java:65: Warning: method not available - call not analyzed
    //#    call on bool com.dmdirc.plugins.PluginInfo:isLoaded()
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.ui_swing.components.pluginpanel.PluginInfoToggle
    //#    method: bool getState()
    //#    unanalyzed callee: bool com.dmdirc.plugins.PluginInfo:isLoaded()
    //#input(bool getState()): this
    //#input(bool getState()): this.pi
    //#input(bool getState()): this.toggle
    //#output(bool getState()): return_value
    //#pre[2] (bool getState()): this.pi != null
    //#pre[3] (bool getState()): init'ed(this.toggle)
    //#post(bool getState()): init'ed(return_value)
    //#PluginInfoToggle.java:65: end of method: bool com.dmdirc.addons.ui_swing.components.pluginpanel.PluginInfoToggle.getState()
    }

    /**
     * Retrieves the PluginInfo object associated with this toggle.
     * 
     * @return This toggle's PluginInfo object.
     */
    public PluginInfo getPluginInfo() {
        return pi;
    //#PluginInfoToggle.java:74: method: PluginInfo com.dmdirc.addons.ui_swing.components.pluginpanel.PluginInfoToggle.getPluginInfo()
    //#input(PluginInfo getPluginInfo()): this
    //#input(PluginInfo getPluginInfo()): this.pi
    //#output(PluginInfo getPluginInfo()): return_value
    //#post(PluginInfo getPluginInfo()): return_value == this.pi
    //#post(PluginInfo getPluginInfo()): init'ed(return_value)
    //#PluginInfoToggle.java:74: end of method: PluginInfo com.dmdirc.addons.ui_swing.components.pluginpanel.PluginInfoToggle.getPluginInfo()
    }
    
    /**
     * Applies the changes to the PluginInfo, if any.
     */
    public void apply() {
        if (toggle) {
    //#PluginInfoToggle.java:81: method: void com.dmdirc.addons.ui_swing.components.pluginpanel.PluginInfoToggle.apply()
    //#input(void apply()): this
    //#input(void apply()): this.pi
    //#input(void apply()): this.toggle
    //#pre[3] (void apply()): init'ed(this.toggle)
    //#pre[2] (void apply()): (soft) this.pi != null
    //#presumption(void apply()): com.dmdirc.plugins.PluginManager:getPluginManager(...)@88 != null
    //#test_vector(void apply()): this.toggle: {0}, {1}
    //#test_vector(void apply()): com.dmdirc.plugins.PluginInfo:isLoaded(...)@82: {0}, {1}
            if (pi.isLoaded()) {
    //#PluginInfoToggle.java:82: Warning: method not available - call not analyzed
    //#    call on bool com.dmdirc.plugins.PluginInfo:isLoaded()
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.ui_swing.components.pluginpanel.PluginInfoToggle
    //#    method: void apply()
    //#    unanalyzed callee: bool com.dmdirc.plugins.PluginInfo:isLoaded()
                pi.unloadPlugin();
    //#PluginInfoToggle.java:83: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.plugins.PluginInfo:unloadPlugin()
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.ui_swing.components.pluginpanel.PluginInfoToggle
    //#    method: void apply()
    //#    unanalyzed callee: void com.dmdirc.plugins.PluginInfo:unloadPlugin()
            } else {
                pi.loadPlugin();
    //#PluginInfoToggle.java:85: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.plugins.PluginInfo:loadPlugin()
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.ui_swing.components.pluginpanel.PluginInfoToggle
    //#    method: void apply()
    //#    unanalyzed callee: void com.dmdirc.plugins.PluginInfo:loadPlugin()
            }
            
            PluginManager.getPluginManager().updateAutoLoad(pi);
    //#PluginInfoToggle.java:88: Warning: method not available - call not analyzed
    //#    call on PluginManager com.dmdirc.plugins.PluginManager:getPluginManager()
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.ui_swing.components.pluginpanel.PluginInfoToggle
    //#    method: void apply()
    //#    unanalyzed callee: PluginManager com.dmdirc.plugins.PluginManager:getPluginManager()
    //#PluginInfoToggle.java:88: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.plugins.PluginManager:updateAutoLoad(PluginInfo)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.ui_swing.components.pluginpanel.PluginInfoToggle
    //#    method: void apply()
    //#    unanalyzed callee: void com.dmdirc.plugins.PluginManager:updateAutoLoad(PluginInfo)
        }
    }
    //#PluginInfoToggle.java:90: end of method: void com.dmdirc.addons.ui_swing.components.pluginpanel.PluginInfoToggle.apply()

}
    //#output(com.dmdirc.addons.ui_swing.components.pluginpanel.PluginInfoToggle__static_init): __Descendant_Table[com/dmdirc/addons/ui_swing/components/pluginpanel/PluginInfoToggle]
    //#output(com.dmdirc.addons.ui_swing.components.pluginpanel.PluginInfoToggle__static_init): __Dispatch_Table.apply()V
    //#output(com.dmdirc.addons.ui_swing.components.pluginpanel.PluginInfoToggle__static_init): __Dispatch_Table.getPluginInfo()Lcom/dmdirc/plugins/PluginInfo;
    //#output(com.dmdirc.addons.ui_swing.components.pluginpanel.PluginInfoToggle__static_init): __Dispatch_Table.getState()Z
    //#output(com.dmdirc.addons.ui_swing.components.pluginpanel.PluginInfoToggle__static_init): __Dispatch_Table.toggle()V
    //#post(com.dmdirc.addons.ui_swing.components.pluginpanel.PluginInfoToggle__static_init): __Descendant_Table[com/dmdirc/addons/ui_swing/components/pluginpanel/PluginInfoToggle] == &__Dispatch_Table
    //#post(com.dmdirc.addons.ui_swing.components.pluginpanel.PluginInfoToggle__static_init): __Dispatch_Table.apply()V == &apply
    //#post(com.dmdirc.addons.ui_swing.components.pluginpanel.PluginInfoToggle__static_init): __Dispatch_Table.getPluginInfo()Lcom/dmdirc/plugins/PluginInfo; == &getPluginInfo
    //#post(com.dmdirc.addons.ui_swing.components.pluginpanel.PluginInfoToggle__static_init): __Dispatch_Table.getState()Z == &getState
    //#post(com.dmdirc.addons.ui_swing.components.pluginpanel.PluginInfoToggle__static_init): __Dispatch_Table.toggle()V == &toggle
    //#PluginInfoToggle.java:: end of method: com.dmdirc.addons.ui_swing.components.pluginpanel.PluginInfoToggle.com.dmdirc.addons.ui_swing.components.pluginpanel.PluginInfoToggle__static_init
    //#PluginInfoToggle.java:: end of class: com.dmdirc.addons.ui_swing.components.pluginpanel.PluginInfoToggle
