Source code: org/geotools/resources/InternalWindowListener.java
1 /*
2 * -*- mode: java; c-basic-indent: 4; indent-tabs-mode: nil -*-
3 * :indentSize=4:noTabs=true:tabSize=4:indentOnTab=true:indentOnEnter=true:mode=java:
4 * ex: set tabstop=4 expandtab:
5 *
6 * MrPostman - webmail <-> email gateway
7 * Copyright (C) 2002-2003 MrPostman Development Group
8 * Projectpage: http://mrbook.org/mrpostman/
9 *
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 * In particular, this implies that users are responsible for
21 * using MrPostman after reading the terms and conditions given
22 * by their web-mail provider.
23 *
24 * You should have received a copy of the GNU General Public License
25 * Named LICENSE in the base directory of this distribution,
26 * if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28 */
29
30 /*
31 * Geotools - OpenSource mapping toolkit
32 * (C) 2002, Centre for Computational Geography
33 * (C) 2002, Institut de Recherche pour le Développement
34 *
35 * This library is free software; you can redistribute it and/or
36 * modify it under the terms of the GNU Lesser General Public
37 * License as published by the Free Software Foundation; either
38 * version 2.1 of the License, or (at your option) any later version.
39 *
40 * This library is distributed in the hope that it will be useful,
41 * but WITHOUT ANY WARRANTY; without even the implied warranty of
42 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
43 * Lesser General Public License for more details.
44 *
45 * You should have received a copy of the GNU Lesser General Public
46 * License along with this library; if not, write to the Free Software
47 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
48 *
49 *
50 * Contacts:
51 * UNITED KINGDOM: James Macgill
52 * mailto:j.macgill@geog.leeds.ac.uk
53 *
54 * FRANCE: Surveillance de l'Environnement Assistée par Satellite
55 * Institut de Recherche pour le Développement / US-Espace
56 * mailto:seasnet@teledetection.fr
57 *
58 * CANADA: Observatoire du Saint-Laurent
59 * Institut Maurice-Lamontagne
60 * mailto:osl@osl.gc.ca
61 */
62 package org.geotools.resources;
63
64 import java.awt.event.WindowListener;
65
66 import javax.swing.event.InternalFrameEvent;
67 import javax.swing.event.InternalFrameListener;
68
69
70 /**
71 * Wrap a {@link WindowListener} into an {@link InternalFrameListener}. This is used
72 * by {@link SwingUtilities} in order to have the same methods working seemless on both
73 * {@link Frame} and {@link JInternalFrame}.
74 *
75 * @version $Id: InternalWindowListener.java,v 1.5 2003/02/09 23:38:11 lbruand Exp $
76 * @author Martin Desruisseaux
77 */
78 final class InternalWindowListener implements InternalFrameListener {
79 public static final String CVSID = "$Id: InternalWindowListener.java,v 1.5 2003/02/09 23:38:11 lbruand Exp $";
80
81 /**
82 * The underlying {@link WindowListener}.
83 */
84 private final WindowListener listener;
85
86 /**
87 * Construct a new {@link InternalFrameListener}
88 * wrapping the specified {@link WindowListener}.
89 */
90 private InternalWindowListener(final WindowListener listener) {
91 this.listener = listener;
92 }
93
94 /**
95 * Wrap the specified {@link WindowListener} into an {@link InternalFrameListener}.
96 * If the specified object is already an {@link InternalFrameListener}, then it is
97 * returned as-is.
98 */
99 public static InternalFrameListener wrap(final WindowListener listener) {
100 if (listener == null) {
101 return null;
102 }
103
104 if (listener instanceof InternalFrameListener) {
105 return (InternalFrameListener) listener;
106 }
107 return new InternalWindowListener(listener);
108 }
109
110 /**
111 * Invoked when a internal frame has been opened.
112 */
113 public void internalFrameOpened(InternalFrameEvent event) {
114 listener.windowOpened(null);
115 }
116
117 /**
118 * Invoked when an internal frame is in the process of being closed.
119 * The close operation can be overridden at this point.
120 */
121 public void internalFrameClosing(InternalFrameEvent event) {
122 listener.windowClosing(null);
123 }
124
125 /**
126 * Invoked when an internal frame has been closed.
127 */
128 public void internalFrameClosed(InternalFrameEvent event) {
129 listener.windowClosed(null);
130 }
131
132 /**
133 * Invoked when an internal frame is iconified.
134 */
135 public void internalFrameIconified(InternalFrameEvent event) {
136 listener.windowIconified(null);
137 }
138
139 /**
140 * Invoked when an internal frame is de-iconified.
141 */
142 public void internalFrameDeiconified(InternalFrameEvent event) {
143 listener.windowDeiconified(null);
144 }
145
146 /**
147 * Invoked when an internal frame is activated.
148 */
149 public void internalFrameActivated(InternalFrameEvent event) {
150 listener.windowActivated(null);
151 }
152
153 /**
154 * Invoked when an internal frame is de-activated.
155 */
156 public void internalFrameDeactivated(InternalFrameEvent event) {
157 listener.windowDeactivated(null);
158 }
159 }