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 | 1104 | fjp | /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|---|---|
2 | *
|
||
3 | 11979 | cesar | * Copyright (C) 2004-2007 IVER T.I. and Generalitat Valenciana.
|
4 | 1104 | fjp | *
|
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 | 29593 | jpiera | package org.gvsig.andami.ui.mdiManager; |
42 | 598 | fernando | |
43 | 38608 | jjdelcerro | import java.awt.GridBagConstraints; |
44 | 3249 | fjp | import java.beans.PropertyVetoException; |
45 | |||
46 | 8971 | caballero | import javax.swing.ImageIcon; |
47 | 35190 | jjdelcerro | import javax.swing.JPanel; |
48 | 8971 | caballero | |
49 | 29593 | jpiera | import org.gvsig.andami.ui.mdiFrame.MDIFrame; |
50 | 35190 | jjdelcerro | import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
51 | import org.gvsig.tools.swing.api.windowmanager.WindowManager.MODE; |
||
52 | 598 | fernando | |
53 | |||
54 | 29593 | jpiera | |
55 | 598 | fernando | /**
|
56 | 11979 | cesar | * <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 | 598 | fernando | *
|
82 | * @author Fernando Gonz?lez Cort?s
|
||
83 | */
|
||
84 | public interface MDIManager { |
||
85 | 38078 | jjdelcerro | |
86 | 2553 | caballero | /**
|
87 | 11979 | cesar | * 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 | 2553 | caballero | *
|
91 | 11979 | cesar | * @param f Application's main frame.
|
92 | 2553 | caballero | */
|
93 | public void init(MDIFrame f); |
||
94 | 598 | fernando | |
95 | 2553 | caballero | /**
|
96 | 11979 | cesar | * <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 | 2553 | caballero | *
|
110 | 11979 | cesar | * @param p Panel with the contents of the new window.
|
111 | 2553 | caballero | *
|
112 | 11979 | cesar | * @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 | 2553 | caballero | */
|
117 | 6880 | cesar | public IWindow addWindow(IWindow p) throws SingletonDialogAlreadyShownException; |
118 | 598 | fernando | |
119 | 31339 | jjdelcerro | |
120 | 35190 | jjdelcerro | /*
|
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 | 2553 | caballero | /**
|
128 | 35190 | jjdelcerro | * 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 | 11979 | cesar | * <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 | 8923 | caballero | *
|
165 | 11979 | cesar | * @param p Panel with the contents of the new window.
|
166 | 6863 | ppiqueras | *
|
167 | 11979 | cesar | * @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 | 6863 | ppiqueras | */
|
174 | 6880 | cesar | public IWindow addCentredWindow(IWindow p) throws SingletonDialogAlreadyShownException; |
175 | 8923 | caballero | |
176 | 38608 | jjdelcerro | 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 | 34943 | jjdelcerro | public IWindow addWindow(IWindow p, int align) throws SingletonDialogAlreadyShownException; |
188 | |||
189 | 6863 | ppiqueras | /**
|
190 | 11979 | cesar | * <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 | 2553 | caballero | *
|
200 | 11979 | cesar | * @return A reference to the active window, or null if there is no
|
201 | * active window
|
||
202 | 2553 | caballero | */
|
203 | 6880 | cesar | public IWindow getActiveWindow();
|
204 | 11979 | cesar | |
205 | 2553 | caballero | /**
|
206 | 11979 | cesar | * <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 | 4726 | caballero | *
|
212 | 11979 | cesar | * @return A reference to the focused window, or null if there is no
|
213 | * focused window
|
||
214 | 4726 | caballero | */
|
215 | 6880 | cesar | public IWindow getFocusWindow();
|
216 | 11979 | cesar | |
217 | 4726 | caballero | /**
|
218 | 11979 | cesar | * 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 | 2553 | caballero | *
|
222 | 11979 | cesar | * @return An IWindow array containing all the open windows.
|
223 | 2553 | caballero | */
|
224 | 6880 | cesar | public IWindow[] getAllWindows(); |
225 | 11979 | cesar | |
226 | 7452 | cesar | /**
|
227 | 11979 | cesar | * 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 | 8923 | caballero | *
|
231 | 11979 | cesar | * @return An ordered array containing all the panels in the application.
|
232 | 7452 | cesar | * The first element of the array is the topmost (foreground) window in the
|
233 | 11979 | cesar | * application. The last element is the bottom (background) window.
|
234 | 7452 | cesar | */
|
235 | public IWindow[] getOrderedWindows(); |
||
236 | 598 | fernando | |
237 | 2553 | caballero | /**
|
238 | 11979 | cesar | * 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 | 2553 | caballero | *
|
244 | 11979 | cesar | * @return true if there is an open window whose class and model
|
245 | * match the provided parameteres, false otherwise.
|
||
246 | 2553 | caballero | */
|
247 | 6880 | cesar | public boolean closeSingletonWindow(Class viewClass, Object model); |
248 | 598 | fernando | |
249 | 2553 | caballero | /**
|
250 | 11979 | cesar | * Close the SingletonWindow whose model is provided as parameter.
|
251 | 2553 | caballero | *
|
252 | 11979 | cesar | * @param model Model of the window which is to be closed
|
253 | 2553 | caballero | *
|
254 | 11979 | cesar | * @return true if there is an open window whose model matchs
|
255 | * the provided one, false otherwise.
|
||
256 | 2553 | caballero | */
|
257 | 6880 | cesar | public boolean closeSingletonWindow(Object model); |
258 | 598 | fernando | |
259 | 2553 | caballero | /**
|
260 | 11979 | cesar | * Close the provided window.
|
261 | 2553 | caballero | *
|
262 | 11979 | cesar | * @param p window to be closed
|
263 | 2553 | caballero | */
|
264 | 6880 | cesar | public void closeWindow(IWindow p); |
265 | 598 | fernando | |
266 | 2553 | caballero | /**
|
267 | 11979 | cesar | * Close all the currently open windows
|
268 | 2553 | caballero | */
|
269 | 6880 | cesar | public void closeAllWindows(); |
270 | 1323 | fernando | |
271 | 2553 | caballero | /**
|
272 | 11979 | cesar | * Gets the WindowInfo object associated with the provided window.
|
273 | 2553 | caballero | *
|
274 | 11979 | cesar | * @param v window whose information is to be retrieved
|
275 | 2553 | caballero | *
|
276 | 11979 | cesar | * @return WindowInfo The WindowInfo object containing the information
|
277 | * about the provided window
|
||
278 | *
|
||
279 | * @see WindowInfo
|
||
280 | 2553 | caballero | */
|
281 | 6880 | cesar | public WindowInfo getWindowInfo(IWindow v);
|
282 | 1323 | fernando | |
283 | 2553 | caballero | /**
|
284 | 11979 | cesar | * Shows the wait cursor and blocks all the events from main window until
|
285 | * {@link #restoreCursor()} is called.
|
||
286 | 2553 | caballero | */
|
287 | public void setWaitCursor(); |
||
288 | |||
289 | /**
|
||
290 | 11979 | cesar | * Sets the normal cursor and unblocks events from main window.
|
291 | *
|
||
292 | * @see #setWaitCursor()
|
||
293 | 2553 | caballero | */
|
294 | public void restoreCursor(); |
||
295 | 4726 | caballero | |
296 | 3249 | fjp | /**
|
297 | 11979 | cesar | * 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 | 3249 | fjp | * @throws PropertyVetoException
|
303 | */
|
||
304 | 6877 | cesar | public void setMaximum(IWindow v, boolean bMaximum) throws PropertyVetoException; |
305 | 11979 | cesar | |
306 | 4726 | caballero | /**
|
307 | 11979 | cesar | * 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 | 4726 | caballero | */
|
313 | 6880 | cesar | public void changeWindowInfo(IWindow v, WindowInfo vi); |
314 | 11979 | cesar | |
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 | 8923 | caballero | |
323 | 11979 | cesar | /**
|
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 | 8971 | caballero | public void setBackgroundImage(ImageIcon image, String typeDesktop); |
334 | 598 | fernando | } |