001/*
002 * Copyright 2010-2015 Institut Pasteur.
003 * 
004 * This file is part of Icy.
005 * 
006 * Icy is free software: you can redistribute it and/or modify
007 * it under the terms of the GNU General Public License as published by
008 * the Free Software Foundation, either version 3 of the License, or
009 * (at your option) any later version.
010 * 
011 * Icy is distributed in the hope that it will be useful,
012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
014 * GNU General Public License for more details.
015 * 
016 * You should have received a copy of the GNU General Public License
017 * along with Icy. If not, see <http://www.gnu.org/licenses/>.
018 */
019package icy.gui.main;
020
021import icy.common.listener.weak.WeakListener;
022import icy.main.Icy;
023
024/**
025 * Weak listener wrapper for MainListener.
026 * 
027 * @deprecated Use one of these interface instead:<br/>
028 *             {@link GlobalViewerListener}<br/>
029 *             {@link GlobalSequenceListener}<br/>
030 *             {@link GlobalROIListener}<br/>
031 *             {@link GlobalOverlayListener}<br/>
032 *             {@link GlobalPluginListener}
033 * @author Stephane
034 */
035@Deprecated
036public class WeakMainListener extends WeakListener<MainListener> implements MainListener
037{
038    public WeakMainListener(MainListener listener)
039    {
040        super(listener);
041    }
042
043    @Override
044    public void removeListener(Object source)
045    {
046        Icy.getMainInterface().removeListener(this);
047    }
048
049    @Override
050    public void pluginOpened(MainEvent event)
051    {
052        final MainListener listener = getListener();
053
054        if (listener != null)
055            listener.pluginOpened(event);
056    }
057
058    @Override
059    public void pluginClosed(MainEvent event)
060    {
061        final MainListener listener = getListener();
062
063        if (listener != null)
064            listener.pluginClosed(event);
065    }
066
067    @Override
068    public void viewerOpened(MainEvent event)
069    {
070        final MainListener listener = getListener();
071
072        if (listener != null)
073            listener.viewerOpened(event);
074    }
075
076    @Override
077    public void viewerFocused(MainEvent event)
078    {
079        final MainListener listener = getListener();
080
081        if (listener != null)
082            listener.viewerFocused(event);
083    }
084
085    @Override
086    public void viewerClosed(MainEvent event)
087    {
088        final MainListener listener = getListener();
089
090        if (listener != null)
091            listener.viewerClosed(event);
092    }
093
094    @Override
095    public void sequenceOpened(MainEvent event)
096    {
097        final MainListener listener = getListener();
098
099        if (listener != null)
100            listener.sequenceOpened(event);
101    }
102
103    @Override
104    public void sequenceFocused(MainEvent event)
105    {
106        final MainListener listener = getListener();
107
108        if (listener != null)
109            listener.sequenceFocused(event);
110    }
111
112    @Override
113    public void sequenceClosed(MainEvent event)
114    {
115        final MainListener listener = getListener();
116
117        if (listener != null)
118            listener.sequenceClosed(event);
119    }
120
121    @Override
122    public void roiAdded(MainEvent event)
123    {
124        final MainListener listener = getListener();
125
126        if (listener != null)
127            listener.roiAdded(event);
128    }
129
130    @Override
131    public void roiRemoved(MainEvent event)
132    {
133        final MainListener listener = getListener();
134
135        if (listener != null)
136            listener.roiRemoved(event);
137    }
138
139    @Override
140    public void painterAdded(MainEvent event)
141    {
142        final MainListener listener = getListener();
143
144        if (listener != null)
145            listener.painterAdded(event);
146    }
147
148    @Override
149    public void painterRemoved(MainEvent event)
150    {
151        final MainListener listener = getListener();
152
153        if (listener != null)
154            listener.painterRemoved(event);
155    }
156}