Statistics
| Revision:

root / branches / v2_0_0_prep / frameworks / _fwAndami / src / org / gvsig / andami / ui / mdiManager / MDIManager.java @ 38608

History | View | Annotate | Download (11.6 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.awt.GridBagConstraints;
44
import java.beans.PropertyVetoException;
45

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

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

    
53

    
54

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

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

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

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

    
176
    public static final int ALIGN_FIRST_LINE_START = GridBagConstraints.FIRST_LINE_START;
177
    public static final int ALIGN_PAGE_START = GridBagConstraints.PAGE_START;
178
    public static final int ALIGN_FIRST_LINE_END = GridBagConstraints.FIRST_LINE_END;
179
    public static final int ALIGN_FIRST_LINE_END_CASCADE = GridBagConstraints.FIRST_LINE_END + GridBagConstraints.BELOW_BASELINE;
180
    public static final int ALIGN_LINE_START = GridBagConstraints.LINE_START;
181
    public static final int ALIGN_LINE_END = GridBagConstraints.LINE_END;
182
    public static final int ALIGN_LAST_LINE_START = GridBagConstraints.LAST_LINE_START;
183
    public static final int ALIGN_PAGE_END = GridBagConstraints.PAGE_END;
184
    public static final int ALIGN_LAST_LINE_END = GridBagConstraints.LAST_LINE_END;
185
    public static final int ALIGN_CENTER = GridBagConstraints.CENTER;
186
    
187
    public IWindow addWindow(IWindow p, int align) throws SingletonDialogAlreadyShownException;
188

    
189
    /**
190
     * <p>
191
     * Returns the currently active window, excluding the modal windows and the
192
     * PALETTE windows. If the currently active window is modal or PALETTE type,
193
     * the previous non-modal and non-PALETTE active window is returned.
194
     * </p>
195
     * <p>
196
     * Modal windows and PALETTE windows are considered to be auxiliary windows,
197
     * that is the reason why they are not returned.
198
     * </p> 
199
     *
200
     * @return A reference to the active window, or null if there is no
201
     * active window
202
     */
203
    public IWindow getActiveWindow();
204

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

    
237
    /**
238
     * Close the SingletonWindow whose class and model are provided as
239
     * parameters.
240
     * 
241
     * @param viewClass Class of the window which is to be closed
242
     * @param model Model of the window which is to be closed
243
     *
244
     * @return true if there is an open window whose class and model
245
     *         match the provided parameteres, false otherwise.
246
     */
247
    public boolean closeSingletonWindow(Class viewClass, Object model);
248

    
249
    /**
250
     * Close the SingletonWindow whose model is provided as parameter.
251
     *
252
     * @param model Model of the window which is to be closed
253
     *
254
     * @return true if there is an open window whose model matchs
255
     *         the provided one, false otherwise.
256
     */
257
    public boolean closeSingletonWindow(Object model);
258

    
259
    /**
260
     * Close the provided window.
261
     *
262
     * @param p window to be closed
263
     */
264
    public void closeWindow(IWindow p);
265

    
266
    /**
267
     * Close all the currently open windows
268
     */
269
    public void closeAllWindows();
270

    
271
    /**
272
     * Gets the WindowInfo object associated with the provided window.
273
     *
274
     * @param v window whose information is to be retrieved
275
     *
276
     * @return WindowInfo The WindowInfo object containing the information
277
     * about the provided window 
278
     * 
279
     * @see WindowInfo
280
     */
281
    public WindowInfo getWindowInfo(IWindow v);
282

    
283
    /**
284
     * Shows the wait cursor and blocks all the events from main window until
285
     * {@link #restoreCursor()} is called.
286
     */
287
    public void setWaitCursor();
288

    
289
    /**
290
     * Sets the normal cursor and unblocks events from main window.
291
     * 
292
     * @see #setWaitCursor()
293
     */
294
    public void restoreCursor();
295

    
296
    /**
297
     * Maximizes or restores the provided window
298
     * 
299
     * @param v The window to be maximized or restored 
300
     * @param bMaximum If true, the window will be maximized,
301
     *  if false, it will be restored
302
     * @throws PropertyVetoException
303
     */
304
    public void setMaximum(IWindow v, boolean bMaximum) throws PropertyVetoException;
305
    
306
    /**
307
     * Updates the window properties (size, location, etc) according to the
308
     * provided WindowInfo object.
309
     * 
310
     * @param v The window whose properties are to be changed
311
     * @param vi The WindowInfo object containing the new properties to be set
312
     */
313
    public void changeWindowInfo(IWindow v, WindowInfo vi);
314
    
315
    /**
316
     * Forces a window to be repainted. Normally, this is not necessary,
317
     * as windows are refreshed when necessary.
318
     * 
319
     * @param win The window to be refreshed.
320
     */
321
    public void refresh(IWindow win);
322

    
323
    /**
324
     * Sets the provided image as background image in the main window. The image
325
     * will be centered, set in mosaic or expanded to fill the full window,
326
     * depending on the <code>typeDesktop</code> argument.
327
     * 
328
     * @param image The image to be set as background image
329
     * @param typeDesktop Decides whether the image should be centered, set
330
     * in mosaic or expanded. Accepted values are: Theme.CENTERED,
331
     * Theme.MOSAIC and Theme.EXPAND.
332
     */
333
        public void setBackgroundImage(ImageIcon image, String typeDesktop);
334
}