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

History | View | Annotate | Download (11.8 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.beans.PropertyVetoException;
28
import java.util.Locale;
29

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

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

    
37

    
38

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

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

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

    
101

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

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

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

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

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

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

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

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

    
199
    public void moveToFrom(IWindow win);
200

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

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

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

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

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

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

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

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

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

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

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

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

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

    
321
    public void setLocale(Locale locale);
322

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

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