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 @ 43911

History | View | Annotate | Download (11.9 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.GridBagConstraints;
27
import java.awt.image.BufferedImage;
28
import java.beans.PropertyVetoException;
29
import java.util.Locale;
30

    
31
import javax.swing.ImageIcon;
32
import javax.swing.JPanel;
33

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

    
38

    
39

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

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

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

    
102

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

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

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

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

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

    
170
    public IWindow addWindow(IWindow p, int align) throws SingletonDialogAlreadyShownException;
171

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

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

    
200
    public void moveToFrom(IWindow win);
201

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

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

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

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

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

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

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

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

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

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

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

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

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

    
322
    public void setLocale(Locale locale);
323

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

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