Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.framework / org.gvsig.andami / src / main / java / org / gvsig / andami / ui / mdiManager / MDIManager.java @ 44173

History | View | Annotate | Download (12 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.andami.ui.mdiManager;
25

    
26
import java.awt.Dialog;
27
import java.awt.GridBagConstraints;
28
import java.awt.Window;
29
import java.awt.image.BufferedImage;
30
import java.beans.PropertyVetoException;
31
import java.util.Locale;
32

    
33
import javax.swing.ImageIcon;
34
import javax.swing.JPanel;
35

    
36
import org.gvsig.andami.ui.mdiFrame.MDIFrame;
37
import org.gvsig.tools.swing.api.windowmanager.WindowManager;
38
import org.gvsig.tools.swing.api.windowmanager.WindowManager.MODE;
39

    
40

    
41

    
42
/**
43
 * <p>
44
 * This interface acts as window manager. It is the place to create
45
 * new windows, close existing ones or modify their properties
46
 * (size, position, etc).
47
 * </p>
48
 * <p>
49
 * Any class extending from JPanel and implementing the {@link IWindow}
50
 * interface may become an Andami window. Andami will create a real
51
 * window (normally a JInternalFrame) and put the JPanel inside the
52
 * real window. In order to differentiate the contents (panels
53
 * extending JPanel and implementing IWindow) from the real window
54
 * (normally JInternalFrames or JDialogs), we will use
55
 * <i>window</i> to refer to the contents and <i>frame</i>
56
 * to refer to the real window.
57
 * </p>
58
 * <p>
59
 * This class is implemented by the Andami Skin (currently libCorePlugin),
60
 * which will decide the final implementation of frames. A different frame
61
 * implementation could be used by switching the Skin.
62
 * </p>
63
 *
64
 * @see IWindow
65
 * @see WindowInfo
66
 * @see SingletonWindow
67
 *
68
 */
69
public interface MDIManager {
70

    
71
    /**
72
     * Initializes the MDIFrame. It must be called before starting
73
     * to use it. It receives the application's main frame
74
     * (MDIFrame) as parameter.
75
     *
76
     * @param f Application's main frame.
77
     */
78
    public void init(MDIFrame f);
79

    
80
    /**
81
     * <p>
82
     * Creates a new frame with the provided contents, and shows this
83
     * new window. The new frame's properties are set according to
84
     * the WindowInfo object from IWindow's <code>getWindowInfo()</code>
85
     * method.
86
     * The new frame is disposed when closed.
87
     * </p>
88
     * <p>
89
     * If the provided IWindow also implements SingletonWindow, and
90
     * another SingletonWindow already exists and uses the same
91
     * model, this later window will be sent to the foreground
92
     * and no new window will be created.
93
     * </p>
94
     *
95
     * @param p Panel with the contents of the new window.
96
     *
97
     * @return Returns the added IWindow, or in case it is a
98
     * SingletonWindow and there is another SingletonWindow with
99
     * the same model that it is already shown, returns this
100
     * later SingletonWindow.
101
     */
102
    public IWindow addWindow(IWindow p) throws SingletonDialogAlreadyShownException;
103

    
104

    
105
    /*
106
     * Constants used by the method showWindow
107
     */
108
    public final MODE WINDOW = WindowManager.MODE.WINDOW;
109
    public final MODE TOOL = WindowManager.MODE.TOOL;
110
    public final MODE DIALOG = WindowManager.MODE.DIALOG;
111

    
112
    /**
113
     * Useful method to simplify the presentation of a window.
114
     * For more precise control over the behavior of the window
115
     * use addWindow
116
     *
117
     * This methos
118
     * @param panel to show as a window
119
     * @param title title of the window
120
     * @param mode type of the window to create
121
     */
122
    public void showWindow(JPanel panel, String title, MODE mode);
123

    
124
    /**
125
     * Return the window associated to the SingletonWindow class and the model
126
     * specified. If not exists any singleton window associated to this
127
     * null is returned.
128
     *
129
     * @param windowClass, the class that implement SingletonWindow
130
     * @param model, the model associated to the SingletonWindow
131
     * @return the requested window or null.
132
     */
133
    public SingletonWindow getSingletonWindow(Class windowClass, Object model) ;
134

    
135
    /**
136
     * <p>
137
     * Creates a new frame with the provided contents, and shows this
138
     * new window. The new frame will be centered, regardless the
139
     * position specified in the WindowInfo object from IWindow's
140
     * <code>getWindowInfo()</code> method.
141
     * The new frame is disposed when closed.
142
     * </p>
143
     * <p>
144
     * If the provided IWindow also implements SingletonWindow, and
145
     * another SingletonWindow already exists and uses the same
146
     * model, this later window will be sent to the foreground
147
     * and no new window will be created.
148
     * </p>
149
     *
150
     * @param p Panel with the contents of the new window.
151
     *
152
     * @return Returns the added IWindow, or in case it is a
153
     * SingletonWindow and there is another SingletonWindow with
154
     * the same model that it is already shown, returns this
155
     * later SingletonWindow.
156
     *
157
     * @author Pablo Piqueras Bartolom?
158
     */
159
    public IWindow addCentredWindow(IWindow p) throws SingletonDialogAlreadyShownException;
160

    
161
    public static final int ALIGN_FIRST_LINE_START = GridBagConstraints.FIRST_LINE_START;
162
    public static final int ALIGN_PAGE_START = GridBagConstraints.PAGE_START;
163
    public static final int ALIGN_FIRST_LINE_END = GridBagConstraints.FIRST_LINE_END;
164
    public static final int ALIGN_FIRST_LINE_END_CASCADE = GridBagConstraints.FIRST_LINE_END + GridBagConstraints.BELOW_BASELINE;
165
    public static final int ALIGN_LINE_START = GridBagConstraints.LINE_START;
166
    public static final int ALIGN_LINE_END = GridBagConstraints.LINE_END;
167
    public static final int ALIGN_LAST_LINE_START = GridBagConstraints.LAST_LINE_START;
168
    public static final int ALIGN_PAGE_END = GridBagConstraints.PAGE_END;
169
    public static final int ALIGN_LAST_LINE_END = GridBagConstraints.LAST_LINE_END;
170
    public static final int ALIGN_CENTER = GridBagConstraints.CENTER;
171

    
172
    public IWindow addWindow(IWindow p, int align) throws SingletonDialogAlreadyShownException;
173

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

    
190
    /**
191
     * <p>
192
     * Returns the currently focused window, excluding the modal windows.
193
     * If the currently focused window is modal,
194
     * the previous non-modal focused window is returned.
195
     * </p>
196
     *
197
     * @return A reference to the focused window, or null if there is no
198
     * focused window
199
     */
200
    public IWindow getFocusWindow();
201

    
202
    public void moveToFrom(IWindow win);
203

    
204
    /**
205
     * Gets all the open windows. Minimized and maximized windows are
206
     * included. The application's main frame is excluded; it can be
207
     * accessed using <code>PluginServices.getMainFrame()</code>.
208
     *
209
     * @return An IWindow array containing all the open windows.
210
     */
211
    public IWindow[] getAllWindows();
212

    
213
    /**
214
     * Gets all the open windows (as {@link #getAllWindows()}),
215
     * but in this method the windows are returned in the same
216
     * deepness order that they have in the application.
217
     *
218
     * @return   An ordered array containing all the panels in the application.
219
     * The first element of the array is the topmost (foreground) window in the
220
     * application. The last element is the bottom (background) window.
221
     */
222
    public IWindow[] getOrderedWindows();
223

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

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

    
246
    /**
247
     * Close the provided window.
248
     * If the window is openend with the WindowManager, use setVisible(false) in
249
     * the JPanel to close it.
250
     *
251
     * @param p window to be closed
252
     */
253
    public void closeWindow(IWindow p);
254

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

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

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

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

    
285
    /**
286
     * Maximizes or restores the provided window
287
     *
288
     * @param v The window to be maximized or restored
289
     * @param bMaximum If true, the window will be maximized,
290
     *  if false, it will be restored
291
     * @throws PropertyVetoException
292
     */
293
    public void setMaximum(IWindow v, boolean bMaximum) throws PropertyVetoException;
294

    
295
    /**
296
     * Updates the window properties (size, location, etc) according to the
297
     * provided WindowInfo object.
298
     *
299
     * @param v The window whose properties are to be changed
300
     * @param vi The WindowInfo object containing the new properties to be set
301
     */
302
    public void changeWindowInfo(IWindow v, WindowInfo vi);
303

    
304
    /**
305
     * Forces a window to be repainted. Normally, this is not necessary,
306
     * as windows are refreshed when necessary.
307
     *
308
     * @param win The window to be refreshed.
309
     */
310
    public void refresh(IWindow win);
311

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

    
324
    public void setLocale(Locale locale);
325

    
326
    /**
327
     * Change the position of the speficied window.
328
     *
329
     * @param window
330
     * @param x
331
     * @param y
332
     */
333
    public void move(IWindow window, int x, int y);
334

    
335
    /**
336
     * Gets the associated IWindow to the panel shown with showWindow method.
337
     * Also panel shown with the tools WindowManager.
338
     *
339
     * @param panel
340
     * @return
341
     */
342
    public IWindow getWindow(JPanel panel);
343
    
344
    public BufferedImage getImagePreview();
345

    
346
    public boolean isModalDialogShowing();
347
}