001/**
002 * 
003 */
004package icy.common.listener.weak;
005
006import icy.gui.main.ActiveViewerListener;
007import icy.gui.viewer.Viewer;
008import icy.gui.viewer.ViewerEvent;
009import icy.main.Icy;
010
011/**
012 * @author Stephane
013 */
014public class WeakActiveViewerListener extends WeakListener<ActiveViewerListener> implements ActiveViewerListener
015{
016    public WeakActiveViewerListener(ActiveViewerListener listener)
017    {
018        super(listener);
019    }
020
021    @Override
022    public void removeListener(Object source)
023    {
024        Icy.getMainInterface().removeActiveViewerListener(this);
025    }
026
027    @Override
028    public void viewerActivated(Viewer viewer)
029    {
030        final ActiveViewerListener listener = getListener(null);
031
032        if (listener != null)
033            listener.viewerActivated(viewer);
034    }
035
036    @Override
037    public void viewerDeactivated(Viewer viewer)
038    {
039        final ActiveViewerListener listener = getListener(null);
040
041        if (listener != null)
042            listener.viewerDeactivated(viewer);
043    }
044
045    @Override
046    public void activeViewerChanged(ViewerEvent event)
047    {
048        final ActiveViewerListener listener = getListener(null);
049
050        if (listener != null)
051            listener.activeViewerChanged(event);
052    }
053}