1 /*
2 * Copyright 2006-2016 The JGUIraffe Team.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License")
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package net.sf.jguiraffe.gui.builder.window;
17
18 /**
19 * <p>
20 * Definition of an interface used to control whether a window can be closed.
21 * </p>
22 * <p>
23 * A <code>{@link Window}</code> object can be passed an implementation of
24 * this interface. Whenever the user wants to close the window (by clicking the
25 * close button or using a similar mechanism) the <code>canClose()</code>
26 * method will be invoked to check if closing the window is allowed. If this
27 * method returns <b>false</code> the close operation will be aborted.
28 * </p>
29 * <p>
30 * A typical use case for this interface is displaying a confirmation message if
31 * there is unsaved data: Only if the user confirms that changed data can be
32 * thrown away, the window will be closed.
33 * </p>
34 *
35 * @author Oliver Heger
36 * @version $Id: WindowClosingStrategy.java 205 2012-01-29 18:29:57Z oheger $
37 */
38 public interface WindowClosingStrategy
39 {
40 /**
41 * Checks if the window can be closed. An implementation can perform any
42 * necessary operation to find out if closing the window at this moment is
43 * allowed. Only if <b>true</b> is returned, the window will be closed;
44 * otherwise it will remain open.
45 *
46 * @param window a reference to the associated window
47 * @return a flag whether the window can be closed
48 */
49 boolean canClose(Window window);
50 }