/*
 * Copyright (c) 2006-2013 DMDirc Developers
 *
 * 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.activewindow;

import com.dmdirc.addons.ui_swing.SwingController;
import com.dmdirc.interfaces.CommandController;
import com.dmdirc.messages.MessageSinkManager;
import com.dmdirc.plugins.implementations.BaseCommandPlugin;

/** Plugin to provide an active window command to the Swing UI. */
public final class ActiveWindowPlugin extends BaseCommandPlugin {

    /** The message sink to register and unregister. */
    private final ActiveWindowMessageSink sink;

    /**
     * Creates a new instance of this plugin.
     *
     * @param controller The controller to use to find active windows
     * @param commandController Command controller to register commands
     */
    public ActiveWindowPlugin(final SwingController controller,
            final CommandController commandController) {
        super(commandController);

        sink = new ActiveWindowMessageSink(controller.getMainFrame());

        registerCommand(new ActiveCommand(commandController, controller.getMainFrame()),
                ActiveCommand.INFO);
    }

    /** {@inheritDoc} */
    @Override
    public void onLoad() {
        super.onLoad();

        MessageSinkManager.getManager().addSink(sink);
    }

    /** {@inheritDoc} */
    @Override
    public void onUnload() {
        super.onUnload();

        MessageSinkManager.getManager().removeSink(sink);
    }
}

@@ -1444,22 +1444,16 @@
 %0Apublic 
-final 
 class Ac
@@ -1603,16 +1603,123 @@
  sink;%0A%0A
+    /** The manager to add and remove the sink from. */%0A    private final MessageSinkManager sinkManager;%0A%0A
     /**%0A
@@ -1913,16 +1913,70 @@
 ommands%0A
+     * @param sinkManager The manager to add sinks to%0A
      */%0A
@@ -2005,16 +2005,29 @@
 wPlugin(
+%0A            
 final Sw
@@ -2109,44 +2109,135 @@
 ller
-) %7B%0A        super(commandController)
+,%0A            final MessageSinkManager sinkManager) %7B%0A        super(commandController);%0A%0A        this.sinkManager = sinkManager
 ;%0A%0A 
@@ -2535,32 +2535,25 @@
 );%0A%0A        
-MessageS
+s
 inkManager.g
@@ -2551,29 +2551,16 @@
 Manager.
-getManager().
 addSink(
@@ -2676,24 +2676,17 @@
         
-MessageS
+s
 inkManag
@@ -2692,21 +2692,8 @@
 ger.
-getManager().
 remo

Remove static call to MessageSinkManager.