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.common.listener.weak; 020 021import icy.gui.frame.IcyFrame; 022import icy.gui.frame.IcyFrameEvent; 023import icy.gui.frame.IcyFrameListener; 024 025/** 026 * Weak wrapper for IcyFrameListener. 027 * 028 * @author Stephane 029 */ 030public class WeakIcyFrameListener extends WeakListener<IcyFrameListener> implements IcyFrameListener 031{ 032 public WeakIcyFrameListener(IcyFrameListener listener) 033 { 034 super(listener); 035 } 036 037 @Override 038 public void removeListener(Object source) 039 { 040 if (source != null) 041 ((IcyFrame) source).removeFrameListener(this); 042 } 043 044 @Override 045 public void icyFrameOpened(IcyFrameEvent e) 046 { 047 final IcyFrameListener listener = getListener(e.getFrame()); 048 049 if (listener != null) 050 listener.icyFrameOpened(e); 051 } 052 053 @Override 054 public void icyFrameClosing(IcyFrameEvent e) 055 { 056 final IcyFrameListener listener = getListener(e.getFrame()); 057 058 if (listener != null) 059 listener.icyFrameClosing(e); 060 } 061 062 @Override 063 public void icyFrameClosed(IcyFrameEvent e) 064 { 065 final IcyFrameListener listener = getListener(e.getFrame()); 066 067 if (listener != null) 068 listener.icyFrameClosed(e); 069 } 070 071 @Override 072 public void icyFrameIconified(IcyFrameEvent e) 073 { 074 final IcyFrameListener listener = getListener(e.getFrame()); 075 076 if (listener != null) 077 listener.icyFrameIconified(e); 078 } 079 080 @Override 081 public void icyFrameDeiconified(IcyFrameEvent e) 082 { 083 final IcyFrameListener listener = getListener(e.getFrame()); 084 085 if (listener != null) 086 listener.icyFrameDeiconified(e); 087 } 088 089 @Override 090 public void icyFrameActivated(IcyFrameEvent e) 091 { 092 final IcyFrameListener listener = getListener(e.getFrame()); 093 094 if (listener != null) 095 listener.icyFrameActivated(e); 096 } 097 098 @Override 099 public void icyFrameDeactivated(IcyFrameEvent e) 100 { 101 final IcyFrameListener listener = getListener(e.getFrame()); 102 103 if (listener != null) 104 listener.icyFrameDeactivated(e); 105 } 106 107 @Override 108 public void icyFrameInternalized(IcyFrameEvent e) 109 { 110 final IcyFrameListener listener = getListener(e.getFrame()); 111 112 if (listener != null) 113 listener.icyFrameInternalized(e); 114 } 115 116 @Override 117 public void icyFrameExternalized(IcyFrameEvent e) 118 { 119 final IcyFrameListener listener = getListener(e.getFrame()); 120 121 if (listener != null) 122 listener.icyFrameExternalized(e); 123 } 124}