Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / frameworks / _fwAndami / src / org / gvsig / andami / ui / mdiManager / MDIManager.java @ 38564

History | View | Annotate | Download (10.7 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004-2007 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41
package org.gvsig.andami.ui.mdiManager;
42

    
43
import java.beans.PropertyVetoException;
44

    
45
import javax.swing.ImageIcon;
46
import javax.swing.JPanel;
47

    
48
import org.gvsig.andami.ui.mdiFrame.MDIFrame;
49
import org.gvsig.tools.swing.api.windowmanager.WindowManager;
50
import org.gvsig.tools.swing.api.windowmanager.WindowManager.MODE;
51

    
52

    
53

    
54
/**
55
 * <p>
56
 * This interface acts as window manager. It is the place to create
57
 * new windows, close existing ones or modify their properties
58
 * (size, position, etc).
59
 * </p>
60
 * <p>
61
 * Any class extending from JPanel and implementing the {@link IWindow}
62
 * interface may become an Andami window. Andami will create a real
63
 * window (normally a JInternalFrame) and put the JPanel inside the
64
 * real window. In order to differentiate the contents (panels
65
 * extending JPanel and implementing IWindow) from the real window
66
 * (normally JInternalFrames or JDialogs), we will use
67
 * <i>window</i> to refer to the contents and <i>frame</i>
68
 * to refer to the real window.
69
 * </p>
70
 * <p>
71
 * This class is implemented by the Andami Skin (currently libCorePlugin),
72
 * which will decide the final implementation of frames. A different frame
73
 * implementation could be used by switching the Skin.
74
 * </p>
75
 * 
76
 * @see IWindow
77
 * @see WindowInfo
78
 * @see SingletonWindow
79
 * @see com.iver.core.mdiManager.NewSkin
80
 *
81
 * @author Fernando Gonz?lez Cort?s
82
 */
83
public interface MDIManager {
84
        
85
    /**
86
     * Initializes the MDIFrame. It must be called before starting
87
     * to use it. It receives the application's main frame
88
     * (MDIFrame) as parameter.  
89
     *
90
     * @param f Application's main frame.
91
     */
92
    public void init(MDIFrame f);
93

    
94
    /**
95
     * <p>
96
     * Creates a new frame with the provided contents, and shows this
97
     * new window. The new frame's properties are set according to
98
     * the WindowInfo object from IWindow's <code>getWindowInfo()</code>
99
     * method.
100
     * The new frame is disposed when closed. 
101
     * </p>
102
     * <p>
103
     * If the provided IWindow also implements SingletonWindow, and
104
     * another SingletonWindow already exists and uses the same
105
     * model, this later window will be sent to the foreground
106
     * and no new window will be created.
107
     * </p>
108
     *
109
     * @param p Panel with the contents of the new window.
110
     *
111
     * @return Returns the added IWindow, or in case it is a
112
     * SingletonWindow and there is another SingletonWindow with
113
     * the same model that it is already shown, returns this 
114
     * later SingletonWindow.
115
     */
116
    public IWindow addWindow(IWindow p) throws SingletonDialogAlreadyShownException;
117

    
118
    
119
    /*
120
     * Constants used by the method showWindow 
121
     */
122
    public final MODE WINDOW = WindowManager.MODE.WINDOW;
123
    public final MODE TOOL = WindowManager.MODE.TOOL;
124
    public final MODE DIALOG = WindowManager.MODE.DIALOG;
125
    
126
    /**
127
     * Useful method to simplify the presentation of a window. 
128
     * For more precise control over the behavior of the window 
129
     * use addWindow
130
     * 
131
     * This methos 
132
     * @param panel to show as a window
133
     * @param title title of the window
134
     * @param mode type of the window to create
135
     */
136
    public void showWindow(JPanel panel, String title, MODE mode);
137

    
138
    /**
139
     * Return the window associated to the SingletonWindow class and the model
140
     * specified. If not exists any singleton window associated to this
141
     * null is returned.
142
     * 
143
     * @param windowClass, the class that implement SingletonWindow
144
     * @param model, the model associated to the SingletonWindow
145
     * @return the requested window or null.
146
     */
147
    public SingletonWindow getSingletonWindow(Class windowClass, Object model) ;
148
    
149
    /**
150
     * <p>
151
     * Creates a new frame with the provided contents, and shows this
152
     * new window. The new frame will be centered, regardless the
153
     * position specified in the WindowInfo object from IWindow's
154
     * <code>getWindowInfo()</code> method.
155
     * The new frame is disposed when closed. 
156
     * </p>
157
     * <p>
158
     * If the provided IWindow also implements SingletonWindow, and
159
     * another SingletonWindow already exists and uses the same
160
     * model, this later window will be sent to the foreground
161
     * and no new window will be created.
162
     * </p>
163
     *
164
     * @param p Panel with the contents of the new window.
165
     *
166
     * @return Returns the added IWindow, or in case it is a
167
     * SingletonWindow and there is another SingletonWindow with
168
     * the same model that it is already shown, returns this 
169
     * later SingletonWindow.
170
     * 
171
     * @author Pablo Piqueras Bartolom?
172
     */
173
    public IWindow addCentredWindow(IWindow p) throws SingletonDialogAlreadyShownException;
174

    
175
    public IWindow addWindow(IWindow p, int align) throws SingletonDialogAlreadyShownException;
176

    
177
    /**
178
     * <p>
179
     * Returns the currently active window, excluding the modal windows and the
180
     * PALETTE windows. If the currently active window is modal or PALETTE type,
181
     * the previous non-modal and non-PALETTE active window is returned.
182
     * </p>
183
     * <p>
184
     * Modal windows and PALETTE windows are considered to be auxiliary windows,
185
     * that is the reason why they are not returned.
186
     * </p> 
187
     *
188
     * @return A reference to the active window, or null if there is no
189
     * active window
190
     */
191
    public IWindow getActiveWindow();
192

    
193
    /**
194
     * <p>
195
     * Returns the currently focused window, excluding the modal windows.
196
     * If the currently focused window is modal,
197
     * the previous non-modal focused window is returned.
198
     * </p>
199
     *
200
     * @return A reference to the focused window, or null if there is no
201
     * focused window
202
     */
203
    public IWindow getFocusWindow();
204
    
205
    /**
206
     * Gets all the open windows. Minimized and maximized windows are
207
     * included. The application's main frame is excluded; it can be
208
     * accessed using <code>PluginServices.getMainFrame()</code>.
209
     *
210
     * @return An IWindow array containing all the open windows.
211
     */
212
    public IWindow[] getAllWindows();
213
    
214
    /**
215
     * Gets all the open windows (as {@link #getAllWindows()}),
216
     * but in this method the windows are returned in the same
217
     * deepness order that they have in the application.
218
     *
219
     * @return   An ordered array containing all the panels in the application.
220
     * The first element of the array is the topmost (foreground) window in the
221
     * application. The last element is the bottom (background) window.
222
     */
223
    public IWindow[] getOrderedWindows();
224

    
225
    /**
226
     * Close the SingletonWindow whose class and model are provided as
227
     * parameters.
228
     * 
229
     * @param viewClass Class of the window which is to be closed
230
     * @param model Model of the window which is to be closed
231
     *
232
     * @return true if there is an open window whose class and model
233
     *         match the provided parameteres, false otherwise.
234
     */
235
    public boolean closeSingletonWindow(Class viewClass, Object model);
236

    
237
    /**
238
     * Close the SingletonWindow whose model is provided as parameter.
239
     *
240
     * @param model Model of the window which is to be closed
241
     *
242
     * @return true if there is an open window whose model matchs
243
     *         the provided one, false otherwise.
244
     */
245
    public boolean closeSingletonWindow(Object model);
246

    
247
    /**
248
     * Close the provided window.
249
     *
250
     * @param p window to be closed
251
     */
252
    public void closeWindow(IWindow p);
253

    
254
    /**
255
     * Close all the currently open windows
256
     */
257
    public void closeAllWindows();
258

    
259
    /**
260
     * Gets the WindowInfo object associated with the provided window.
261
     *
262
     * @param v window whose information is to be retrieved
263
     *
264
     * @return WindowInfo The WindowInfo object containing the information
265
     * about the provided window 
266
     * 
267
     * @see WindowInfo
268
     */
269
    public WindowInfo getWindowInfo(IWindow v);
270

    
271
    /**
272
     * Shows the wait cursor and blocks all the events from main window until
273
     * {@link #restoreCursor()} is called.
274
     */
275
    public void setWaitCursor();
276

    
277
    /**
278
     * Sets the normal cursor and unblocks events from main window.
279
     * 
280
     * @see #setWaitCursor()
281
     */
282
    public void restoreCursor();
283

    
284
    /**
285
     * Maximizes or restores the provided window
286
     * 
287
     * @param v The window to be maximized or restored 
288
     * @param bMaximum If true, the window will be maximized,
289
     *  if false, it will be restored
290
     * @throws PropertyVetoException
291
     */
292
    public void setMaximum(IWindow v, boolean bMaximum) throws PropertyVetoException;
293
    
294
    /**
295
     * Updates the window properties (size, location, etc) according to the
296
     * provided WindowInfo object.
297
     * 
298
     * @param v The window whose properties are to be changed
299
     * @param vi The WindowInfo object containing the new properties to be set
300
     */
301
    public void changeWindowInfo(IWindow v, WindowInfo vi);
302
    
303
    /**
304
     * Forces a window to be repainted. Normally, this is not necessary,
305
     * as windows are refreshed when necessary.
306
     * 
307
     * @param win The window to be refreshed.
308
     */
309
    public void refresh(IWindow win);
310

    
311
    /**
312
     * Sets the provided image as background image in the main window. The image
313
     * will be centered, set in mosaic or expanded to fill the full window,
314
     * depending on the <code>typeDesktop</code> argument.
315
     * 
316
     * @param image The image to be set as background image
317
     * @param typeDesktop Decides whether the image should be centered, set
318
     * in mosaic or expanded. Accepted values are: Theme.CENTERED,
319
     * Theme.MOSAIC and Theme.EXPAND.
320
     */
321
        public void setBackgroundImage(ImageIcon image, String typeDesktop);
322
}