root / branches / v2_0_0_prep / frameworks / _fwAndami / src / org / gvsig / andami / ui / mdiManager / WindowInfo.java @ 38608
History | View | Annotate | Download (37.8 KB)
1 | 6880 | cesar | /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|---|---|
2 | *
|
||
3 | 11992 | cesar | * Copyright (C) 2004-2007 IVER T.I. and Generalitat Valenciana.
|
4 | 6880 | cesar | *
|
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 | 6880 | cesar | |
43 | 9994 | cesar | import java.awt.Dimension; |
44 | 6880 | cesar | import java.awt.Rectangle; |
45 | import java.beans.PropertyChangeListener; |
||
46 | import java.beans.PropertyChangeSupport; |
||
47 | 10643 | cesar | import java.util.HashMap; |
48 | 34833 | fdiaz | import java.util.Map; |
49 | 6880 | cesar | |
50 | 9750 | jaume | import org.exolab.castor.xml.XMLException; |
51 | 29593 | jpiera | import org.gvsig.andami.PluginServices; |
52 | 34833 | fdiaz | import org.gvsig.tools.ToolsLocator; |
53 | import org.gvsig.tools.dynobject.DynStruct; |
||
54 | import org.gvsig.tools.persistence.PersistenceManager; |
||
55 | import org.gvsig.tools.persistence.Persistent; |
||
56 | import org.gvsig.tools.persistence.PersistentState; |
||
57 | import org.gvsig.tools.persistence.exception.PersistenceException; |
||
58 | import org.gvsig.tools.util.Callable; |
||
59 | 29593 | jpiera | import org.gvsig.utils.XMLEntity; |
60 | 9750 | jaume | |
61 | 6880 | cesar | |
62 | 7447 | cesar | |
63 | 6880 | cesar | /**
|
64 | 9963 | cesar | * This class represents the state of the associated window.
|
65 | * The <code>set</code> methods (<code>setX</code>, <code>setY</code>,
|
||
66 | 11992 | cesar | * <code>setHeight</code>, etc) are immediately reflected on the
|
67 | 9963 | cesar | * window.
|
68 | 25519 | vcaballero | *
|
69 | 9963 | cesar | * The <code>update</code> methods doesn't update the window, because
|
70 | * they are used to update the WindowInfo object when the associated
|
||
71 | * window was modified by user interaction.
|
||
72 | 6880 | cesar | *
|
73 | * @author Fernando Gonz?lez Cort?s
|
||
74 | */
|
||
75 | 34833 | fdiaz | public class WindowInfo implements Persistent{ |
76 | |||
77 | public static final String PERSISTENCE_DEFINITION_NAME = "WindowInfo"; |
||
78 | |||
79 | 11992 | cesar | /** Specifies that the window is resizable */
|
80 | 6880 | cesar | public static final int RESIZABLE = 1; |
81 | |||
82 | 9963 | cesar | /** Specifies that the window is maximizable */
|
83 | 6880 | cesar | public static final int MAXIMIZABLE = 2; |
84 | |||
85 | 9963 | cesar | /** Specifies that the window is iconifiable */
|
86 | 6880 | cesar | public static final int ICONIFIABLE = 4; |
87 | |||
88 | 9963 | cesar | /** Specifies that the window is modal */
|
89 | 6880 | cesar | public static final int MODALDIALOG = 8; |
90 | 11992 | cesar | /** Specifies that the window is modeless (it's on the top but doesn't block any other window) */
|
91 | 6880 | cesar | public static final int MODELESSDIALOG = 16; |
92 | 11992 | cesar | /** Specifies that the window may be docked inside another window */
|
93 | 6880 | cesar | public static final int PALETTE = 32; |
94 | 29752 | nbrodin | /** Specifies that the window may be closed */
|
95 | public static final int NOTCLOSABLE = 64; |
||
96 | 26449 | jmvivo | |
97 | |||
98 | /** Specifies that this window has an editor profile */
|
||
99 | public static final Integer EDITOR_PROFILE = new Integer(1); |
||
100 | /** Specifies that this window has an editor profile */
|
||
101 | public static final Integer TOOL_PROFILE = new Integer(2); |
||
102 | /** Specifies that this window has an editor profile */
|
||
103 | public static final Integer PROJECT_PROFILE = new Integer(3); |
||
104 | /** Specifies that this window has an editor profile */
|
||
105 | public static final Integer PROPERTIES_PROFILE = new Integer(4); |
||
106 | /** Specifies that this window has an editor profile */
|
||
107 | public static final Integer DIALOG_PROFILE = new Integer(5); |
||
108 | |||
109 | 6880 | cesar | private PropertyChangeSupport support = new PropertyChangeSupport(this); |
110 | |||
111 | /** DOCUMENT ME! */
|
||
112 | private boolean resizable = false; |
||
113 | |||
114 | /** DOCUMENT ME! */
|
||
115 | private boolean maximizable = false; |
||
116 | |||
117 | /** DOCUMENT ME! */
|
||
118 | private boolean iconifiable = false; |
||
119 | |||
120 | /** DOCUMENT ME! */
|
||
121 | private boolean modal = false; |
||
122 | private boolean modeless = false; |
||
123 | 29752 | nbrodin | private boolean notclosable = false; |
124 | |||
125 | 7447 | cesar | /**
|
126 | * Do we want to persist the geometry of this window in the project file?
|
||
127 | */
|
||
128 | private boolean persistWindow = true; |
||
129 | 6880 | cesar | |
130 | /**
|
||
131 | * Se usa para poner una ventana de tipo paleta, por
|
||
132 | * encima de las dem?s. Equivale a poner usar
|
||
133 | * JDesktopPane.PALETTE_LAYER
|
||
134 | */
|
||
135 | private boolean palette = false; |
||
136 | 25519 | vcaballero | |
137 | 12224 | nacho | private String additionalInfo = null; |
138 | 6880 | cesar | |
139 | /** These properties store the dimension and position of the frame */
|
||
140 | private int width = -1; |
||
141 | private int height = -1; |
||
142 | 11826 | cesar | private int x = -1; |
143 | private int y = -1; |
||
144 | 6880 | cesar | /**
|
145 | * These properties store the position and dimension of the frame when it is not maximized
|
||
146 | * (so that it can be restored to its original size). They are equal to the not-normal properties
|
||
147 | * when the frame is not maximized, and different when the frame is maximized.
|
||
148 | */
|
||
149 | private int normalX = 0; |
||
150 | private int normalY = 0; |
||
151 | 8374 | cesar | private int normalHeight = -1; |
152 | private int normalWidth = -1; |
||
153 | 25519 | vcaballero | |
154 | 9994 | cesar | /** The minimum allowed size for this window. */
|
155 | private Dimension minSize = null; |
||
156 | 25519 | vcaballero | |
157 | 6880 | cesar | /* Whether the window is maximized */
|
158 | private boolean isMaximized = false; |
||
159 | private boolean visible = true; |
||
160 | /* Whether the window is closed */
|
||
161 | private boolean isClosed = false; |
||
162 | |||
163 | |||
164 | /** DOCUMENT ME! */
|
||
165 | private String title; |
||
166 | |||
167 | private int id; |
||
168 | |||
169 | /**
|
||
170 | * ActionCommand del tool seleccionado. Lo usamos
|
||
171 | * para activar el tool que estaba seleccionado en
|
||
172 | * la vista, cuando volvemos a ella.
|
||
173 | */
|
||
174 | 34833 | fdiaz | @SuppressWarnings("rawtypes") |
175 | private Map selectedTools = null; |
||
176 | 10643 | cesar | // this should be the same value defined at plugin-config.xsd
|
177 | private String defaultGroup = "unico"; |
||
178 | 6880 | cesar | |
179 | /**
|
||
180 | 11992 | cesar | * Adds a PropertyChangeListener to the listener list. The listener will be
|
181 | * notified about changes in this object.
|
||
182 | 6880 | cesar | *
|
183 | * @param listener
|
||
184 | */
|
||
185 | public void addPropertyChangeListener(PropertyChangeListener listener) { |
||
186 | support.addPropertyChangeListener(listener); |
||
187 | } |
||
188 | |||
189 | /**
|
||
190 | 11992 | cesar | * Remove a PropertyChangeListener from the listener list. The listener will
|
191 | * not be notified anymore about changes in this object.
|
||
192 | 6880 | cesar | *
|
193 | * @param listener
|
||
194 | */
|
||
195 | public void removePropertyChangeListener(PropertyChangeListener listener) { |
||
196 | support.removePropertyChangeListener(listener); |
||
197 | } |
||
198 | |||
199 | /**
|
||
200 | 11992 | cesar | * Creates a new WindowInfo object with the provided properties.
|
201 | * Valid properties include:
|
||
202 | * <ul>
|
||
203 | * <li>WindowInfo.MODALDIALOG</li>
|
||
204 | * <li>WindowInfo.MODELESSDIALOG</li>
|
||
205 | * <li>WindowInfo.PALETTE</li>
|
||
206 | * <li>WindowInfo.ICONIFIABLE</li>
|
||
207 | * <li>WindowInfo.RESIZABLE</li>
|
||
208 | * <li>WindowInfo.MAXIMIZABLE</li>
|
||
209 | 25519 | vcaballero | *
|
210 | 11992 | cesar | * <p>Properties can be set together by using the binary OR operator
|
211 | * "<b>|</b>". For example:</p>
|
||
212 | 25519 | vcaballero | *
|
213 | * <p><code>WindowInfo wi = new WindowInfo(WindowInfo.MODELESSDIALOG
|
||
214 | 11992 | cesar | * |WindowInfo.ICONIFIABLE|WindowInfo.RESIZABLE).</code></p>
|
215 | 25519 | vcaballero | *
|
216 | 11992 | cesar | * <p>The WindowInfo.MODELESSDIALOG and WindowInfo.MODALDIALOG properties
|
217 | 25519 | vcaballero | * cannot be set at the same time</p>
|
218 | 6880 | cesar | *
|
219 | 11992 | cesar | * @param code Bit-or of the window properties.
|
220 | 6880 | cesar | *
|
221 | 11992 | cesar | * @throws IllegalStateException If incompatible properties are set together,
|
222 | * for example, if MODALDIALOG and MODELESSDIALGO are set together.
|
||
223 | 6880 | cesar | */
|
224 | public WindowInfo(int code) { |
||
225 | resizable = (code % 2) > 0; |
||
226 | code = code / 2;
|
||
227 | maximizable = (code % 2) > 0; |
||
228 | code = code / 2;
|
||
229 | iconifiable = (code % 2) > 0; |
||
230 | code = code / 2;
|
||
231 | modal = (code % 2) > 0; |
||
232 | code = code / 2;
|
||
233 | modeless = (code % 2) > 0; |
||
234 | code = code / 2;
|
||
235 | palette = (code % 2) > 0; |
||
236 | 29752 | nbrodin | code = code / 2;
|
237 | notclosable = (code % 2) > 0; |
||
238 | 6880 | cesar | |
239 | if (modal && modeless) {
|
||
240 | throw new IllegalStateException("modal && modeless"); |
||
241 | } |
||
242 | } |
||
243 | |||
244 | 11992 | cesar | /**
|
245 | * Creates a new WindowInfo object with the default properties:
|
||
246 | * <ul>
|
||
247 | * <li>not resizable</li>
|
||
248 | * <li>not maximizable</li>
|
||
249 | * <li>not iconifiable</li>
|
||
250 | * <li>not modal</li>
|
||
251 | * <li>not modeless</li>
|
||
252 | * <li>not palette</li>
|
||
253 | * </uil>
|
||
254 | *
|
||
255 | */
|
||
256 | 6880 | cesar | public WindowInfo(){
|
257 | |||
258 | } |
||
259 | 25519 | vcaballero | |
260 | 9963 | cesar | /**
|
261 | 11992 | cesar | * Returns the current x coordinate of the window's origin
|
262 | * (left-upper corner of the window).
|
||
263 | 9963 | cesar | *
|
264 | * @return Returns the value (in pixels) of the x coordinate
|
||
265 | * of the window's origin.
|
||
266 | */
|
||
267 | public int getX() { |
||
268 | return x;
|
||
269 | } |
||
270 | 6880 | cesar | |
271 | /**
|
||
272 | 11992 | cesar | * Sets the x coordinate of the window's origin
|
273 | * (left-upper corner of the window).
|
||
274 | 9963 | cesar | *
|
275 | * @param x The value (in pixels) of the x coordinate to set.
|
||
276 | */
|
||
277 | public void setX(int x) { |
||
278 | support.firePropertyChange("x", this.x, x); |
||
279 | this.x = x;
|
||
280 | if (!isMaximized)
|
||
281 | this.normalX = x;
|
||
282 | } |
||
283 | 25519 | vcaballero | |
284 | 9963 | cesar | /**
|
285 | * Updates the value of the x coordinate for this WindowInfo
|
||
286 | * object. It doesn't get reflected on the window (use
|
||
287 | * setX for that).
|
||
288 | 25519 | vcaballero | *
|
289 | 9963 | cesar | * @param x The value (in pixels) of the x coordinate
|
290 | */
|
||
291 | public void updateX(int x) { |
||
292 | this.x = x;
|
||
293 | if (!isMaximized)
|
||
294 | this.normalX = x;
|
||
295 | } |
||
296 | |||
297 | /**
|
||
298 | 11992 | cesar | * Gets the value of the y coordinate for the origin
|
299 | * (left-upper corner of the window) of the associated
|
||
300 | 9994 | cesar | * window.
|
301 | 25519 | vcaballero | *
|
302 | 9994 | cesar | * @return Returns the y coordinate (in pixels).
|
303 | 9963 | cesar | */
|
304 | public int getY() { |
||
305 | return y;
|
||
306 | } |
||
307 | |||
308 | /**
|
||
309 | 11992 | cesar | * Sets the value of the y coordinate for the origin
|
310 | * (left-upper corner of the window) of the associated
|
||
311 | 9994 | cesar | * window.
|
312 | 25519 | vcaballero | *
|
313 | 9994 | cesar | * @param y The value (in pixels) of the y coordinate
|
314 | 9963 | cesar | */
|
315 | public void setY(int y) { |
||
316 | support.firePropertyChange("y", this.y, y); |
||
317 | this.y = y;
|
||
318 | if (!isMaximized)
|
||
319 | this.normalY = y;
|
||
320 | } |
||
321 | 25519 | vcaballero | |
322 | 9963 | cesar | /**
|
323 | 9994 | cesar | * Updates the value of the y coordinate for this WindowInfo
|
324 | 9963 | cesar | * object. It doesn't get reflected on the window (use
|
325 | * setY for that).
|
||
326 | 25519 | vcaballero | *
|
327 | 9963 | cesar | * @param y The value (in pixels) of the y coordinate
|
328 | */
|
||
329 | public void updateY(int y) { |
||
330 | this.y = y;
|
||
331 | if (!isMaximized)
|
||
332 | this.normalY = y;
|
||
333 | } |
||
334 | |||
335 | /**
|
||
336 | 11992 | cesar | * Determines whether the associated window is iconifiable or not
|
337 | 6880 | cesar | *
|
338 | * @return
|
||
339 | */
|
||
340 | public boolean isIconifiable() { |
||
341 | return iconifiable;
|
||
342 | } |
||
343 | |||
344 | /**
|
||
345 | 11992 | cesar | * Determines whether the associated window is maximizable or not
|
346 | 6880 | cesar | *
|
347 | * @return
|
||
348 | */
|
||
349 | public boolean isMaximizable() { |
||
350 | return maximizable;
|
||
351 | } |
||
352 | |||
353 | /**
|
||
354 | 11992 | cesar | * Determines whether the associated window is resizable or not
|
355 | 6880 | cesar | *
|
356 | * @return
|
||
357 | */
|
||
358 | public boolean isResizable() { |
||
359 | return resizable;
|
||
360 | } |
||
361 | |||
362 | /**
|
||
363 | 11992 | cesar | * Determines whether the associated window is modal or not
|
364 | 6880 | cesar | *
|
365 | * @return
|
||
366 | */
|
||
367 | public boolean isModal() { |
||
368 | return modal;
|
||
369 | } |
||
370 | |||
371 | /**
|
||
372 | 9994 | cesar | * Gets the window height.
|
373 | 6880 | cesar | *
|
374 | 9994 | cesar | * @return The window height (in pixels).
|
375 | 6880 | cesar | */
|
376 | public int getHeight() { |
||
377 | return height;
|
||
378 | } |
||
379 | |||
380 | /**
|
||
381 | 9994 | cesar | * Gets the window width.
|
382 | 6880 | cesar | *
|
383 | 9994 | cesar | * @return The window width (in pixels).
|
384 | 6880 | cesar | */
|
385 | public int getWidth() { |
||
386 | return width;
|
||
387 | } |
||
388 | |||
389 | /**
|
||
390 | 9994 | cesar | * Sets the window height.
|
391 | 6880 | cesar | *
|
392 | 9994 | cesar | * @param The window height (in pixels)
|
393 | 6880 | cesar | */
|
394 | 9963 | cesar | public void setHeight(int height) { |
395 | if (height!=-1) |
||
396 | support.firePropertyChange("height", this.height, height); |
||
397 | this.height = height;
|
||
398 | 7447 | cesar | if (!isMaximized)
|
399 | 9963 | cesar | this.normalHeight = height;
|
400 | 6880 | cesar | } |
401 | 25519 | vcaballero | |
402 | 9963 | cesar | /**
|
403 | * Updates the height property for this WindowInfo
|
||
404 | * object. It doesn't get reflected on the window (use
|
||
405 | * <code>setHeight</code> for that).
|
||
406 | 25519 | vcaballero | *
|
407 | 9963 | cesar | * @param height The height value for this WindowInfo object
|
408 | */
|
||
409 | public void updateHeight(int height) { |
||
410 | this.height = height;
|
||
411 | if (!isMaximized)
|
||
412 | this.normalHeight = height;
|
||
413 | } |
||
414 | 6880 | cesar | |
415 | /**
|
||
416 | 9963 | cesar | * Sets the width property for the associated Window.
|
417 | 6880 | cesar | *
|
418 | 9963 | cesar | * @param w The new width.
|
419 | 6880 | cesar | */
|
420 | 7447 | cesar | public void setWidth(int w) { |
421 | 8374 | cesar | if (w!=-1) |
422 | support.firePropertyChange("width", this.width, w); |
||
423 | 7447 | cesar | width = w; |
424 | if (!isMaximized)
|
||
425 | 9963 | cesar | this.normalWidth = w;
|
426 | 6880 | cesar | } |
427 | 25519 | vcaballero | |
428 | 9963 | cesar | /**
|
429 | * Updates the width property for for this WindowInfo
|
||
430 | * object. It doesn't get reflected on the window (use
|
||
431 | * <code>setWidth</code> for that).
|
||
432 | 25519 | vcaballero | *
|
433 | 9963 | cesar | * @param height The height value for this WindowInfo object
|
434 | */
|
||
435 | public void updateWidth(int width) { |
||
436 | this.width = width;
|
||
437 | if (!isMaximized)
|
||
438 | this.normalWidth = width;
|
||
439 | } |
||
440 | 6880 | cesar | |
441 | /**
|
||
442 | 9963 | cesar | * Gets the title property
|
443 | 6880 | cesar | *
|
444 | * @return
|
||
445 | */
|
||
446 | public String getTitle() { |
||
447 | return title;
|
||
448 | } |
||
449 | |||
450 | /**
|
||
451 | 9963 | cesar | * Sets the title property.
|
452 | 6880 | cesar | *
|
453 | 9963 | cesar | * @param title The new title.
|
454 | 6880 | cesar | */
|
455 | 9963 | cesar | public void setTitle(String title) { |
456 | support.firePropertyChange("title", this.title, title); |
||
457 | this.title = title;
|
||
458 | 6880 | cesar | } |
459 | 25519 | vcaballero | |
460 | 9963 | cesar | /**
|
461 | * Updates the title property for for this WindowInfo
|
||
462 | * object. It doesn't get reflected on the window (use
|
||
463 | * <code>setTitle</code> for that).
|
||
464 | 25519 | vcaballero | *
|
465 | 9963 | cesar | * @param title The title value for this WindowInfo object
|
466 | */
|
||
467 | public void updateTitle(String title) { |
||
468 | this.title = title;
|
||
469 | } |
||
470 | 6880 | cesar | |
471 | /**
|
||
472 | 11992 | cesar | * Determines whether the associated window is modeless
|
473 | * (it is on the top but does not block any other window)
|
||
474 | 6880 | cesar | *
|
475 | * @return
|
||
476 | */
|
||
477 | public boolean isModeless() { |
||
478 | return modeless;
|
||
479 | } |
||
480 | 29752 | nbrodin | |
481 | /**
|
||
482 | * Determines whether the associated window is closable or not
|
||
483 | *
|
||
484 | * @return
|
||
485 | */
|
||
486 | public boolean isNotClosable() { |
||
487 | return notclosable;
|
||
488 | } |
||
489 | |||
490 | /**
|
||
491 | * Sets notclosable property
|
||
492 | *
|
||
493 | * @return
|
||
494 | */
|
||
495 | public void setNotClosable(boolean b) { |
||
496 | notclosable = b; |
||
497 | } |
||
498 | 6880 | cesar | |
499 | 11992 | cesar | /**
|
500 | * Determines whether the associated window is visible
|
||
501 | *
|
||
502 | * @return true if the associated window is visible, false
|
||
503 | * if it is hidden
|
||
504 | */
|
||
505 | 6880 | cesar | public boolean isVisible() { |
506 | return visible;
|
||
507 | } |
||
508 | |||
509 | 11992 | cesar | /**
|
510 | * Determines whether the associated dockable window is
|
||
511 | * currently in palette status or docked.
|
||
512 | *
|
||
513 | * @return true if the window is currently in palette status,
|
||
514 | * false if it is docked in another window
|
||
515 | */
|
||
516 | 6880 | cesar | public boolean isPalette() |
517 | { |
||
518 | return palette;
|
||
519 | } |
||
520 | |||
521 | 11992 | cesar | /**
|
522 | * Sets the window's ID.
|
||
523 | 25519 | vcaballero | *
|
524 | 11992 | cesar | * @param id An integer to identify the window. Different
|
525 | * windows must have different IDs.
|
||
526 | */
|
||
527 | 6880 | cesar | public void setId(int id){ |
528 | this.id = id;
|
||
529 | } |
||
530 | |||
531 | 11992 | cesar | /**
|
532 | * Gets the window ID.
|
||
533 | 25519 | vcaballero | *
|
534 | 11992 | cesar | * @return id An integer to identify the window. Different
|
535 | * windows must have different IDs.
|
||
536 | */
|
||
537 | 6880 | cesar | public int getId(){ |
538 | return id;
|
||
539 | } |
||
540 | |||
541 | 11992 | cesar | /**
|
542 | * Updates all the properties in this object so that
|
||
543 | * they match the properties of the provided
|
||
544 | * <code>wi</code> object. The changes are not reflected on the
|
||
545 | * window, just the WindowInfo object is updated.
|
||
546 | 25519 | vcaballero | *
|
547 | 11992 | cesar | * @param vi A WindowInfo object containing the new
|
548 | * properties of the window.
|
||
549 | */
|
||
550 | 6880 | cesar | public void setWindowInfo(WindowInfo vi){ |
551 | this.resizable = vi.resizable;
|
||
552 | this.maximizable = vi.maximizable;
|
||
553 | 8321 | cesar | this.isMaximized = vi.isMaximized;
|
554 | 6880 | cesar | this.iconifiable = vi.iconifiable;
|
555 | 12224 | nacho | this.additionalInfo = vi.additionalInfo;
|
556 | 6880 | cesar | this.modal = vi.modal;
|
557 | this.modeless = vi.modeless;
|
||
558 | 29752 | nbrodin | this.notclosable = vi.notclosable;
|
559 | 8374 | cesar | if (vi.width!=-1) |
560 | this.width = vi.width;
|
||
561 | if (vi.height!=-1) |
||
562 | this.height = vi.height;
|
||
563 | 6880 | cesar | this.x = vi.x;
|
564 | this.y = vi.y;
|
||
565 | this.visible = vi.visible;
|
||
566 | this.title = vi.title;
|
||
567 | this.id = vi.id;
|
||
568 | 8374 | cesar | if (vi.normalHeight!=-1) |
569 | this.normalHeight = vi.normalHeight;
|
||
570 | if (vi.normalWidth!=-1) |
||
571 | this.normalWidth = vi.normalWidth;
|
||
572 | 7447 | cesar | this.normalX = vi.normalX;
|
573 | this.normalY = vi.normalY;
|
||
574 | this.isClosed = vi.isClosed;
|
||
575 | this.persistWindow = vi.persistWindow;
|
||
576 | 6880 | cesar | } |
577 | 25519 | vcaballero | |
578 | 11992 | cesar | /**
|
579 | 25519 | vcaballero | * Sets whether the window is in palette mode or is in docked mode.
|
580 | 11992 | cesar | * This method <b>does not</b> update the window status, it just
|
581 | * updates the WindowInfo object. Use the IWindowTransform interface
|
||
582 | * to actually change the window status.
|
||
583 | 25519 | vcaballero | *
|
584 | 11992 | cesar | * @param b
|
585 | */
|
||
586 | 6880 | cesar | public void toPalette(boolean b){ |
587 | this.palette=b;
|
||
588 | } |
||
589 | |||
590 | 11992 | cesar | /**
|
591 | * Gets the list of selected tools for this window.
|
||
592 | 25519 | vcaballero | *
|
593 | 11992 | cesar | * @return A HashMap containing pairs (group, actionCommand), which
|
594 | 25519 | vcaballero | * are the selected tools for this window.
|
595 | 11992 | cesar | */
|
596 | 34833 | fdiaz | @SuppressWarnings("rawtypes") |
597 | public Map getSelectedTools() { |
||
598 | 10643 | cesar | return selectedTools;
|
599 | 6880 | cesar | } |
600 | |||
601 | 10643 | cesar | /**
|
602 | 25519 | vcaballero | * Use {@link setSelectedTools(HashMap selectedTool)}
|
603 | *
|
||
604 | 10643 | cesar | * @param selectedTool
|
605 | * @deprecated
|
||
606 | */
|
||
607 | 34833 | fdiaz | @SuppressWarnings("unchecked") |
608 | public void setSelectedTool(String selectedTool) { |
||
609 | 6880 | cesar | if (selectedTool != null) |
610 | 10643 | cesar | selectedTools.put(defaultGroup ,selectedTool); |
611 | 6880 | cesar | } |
612 | 25519 | vcaballero | |
613 | 11992 | cesar | /**
|
614 | * Sets the list of selected tools for this window.
|
||
615 | |||
616 | * @param selectedTools A HashMap containing pairs
|
||
617 | * (group, actionCommand), which will be set as the selected tools
|
||
618 | 25519 | vcaballero | * for this window.
|
619 | 11992 | cesar | */
|
620 | 34833 | fdiaz | @SuppressWarnings("rawtypes") |
621 | public void setSelectedTools(Map selectedTools) { |
||
622 | 10643 | cesar | if (selectedTools != null) |
623 | this.selectedTools = selectedTools;
|
||
624 | } |
||
625 | 6880 | cesar | |
626 | 9994 | cesar | /** Finds out whether a view is open (showing) or closed */
|
627 | 6880 | cesar | public boolean isClosed() { |
628 | return isClosed;
|
||
629 | } |
||
630 | 29752 | nbrodin | |
631 | 9994 | cesar | /** Specifies whether a view is open (showing) or closed */
|
632 | 6880 | cesar | public void setClosed(boolean closed) { |
633 | 7447 | cesar | support.firePropertyChange("closed", this.isClosed, closed); |
634 | 6880 | cesar | this.isClosed = closed;
|
635 | } |
||
636 | |||
637 | 9963 | cesar | /**
|
638 | * Updates the closed property for this WindowInfo
|
||
639 | * object. It doesn't get reflected on the window (use
|
||
640 | * <code>setClosed</code> for that).
|
||
641 | 25519 | vcaballero | *
|
642 | 9963 | cesar | * @param closed The new closed property for this WindowInfo object
|
643 | */
|
||
644 | public void updateClosed(boolean closed) { |
||
645 | this.isClosed = closed;
|
||
646 | } |
||
647 | 25519 | vcaballero | |
648 | 9963 | cesar | /**
|
649 | * Sets the normalX property for this WindowInfo object. This sets the X
|
||
650 | * position that the window would have when it gets restored from the
|
||
651 | * maximized state.
|
||
652 | 25519 | vcaballero | *
|
653 | 9963 | cesar | * @param normalX The new normalX property for this WindowInfo object
|
654 | */
|
||
655 | 6880 | cesar | public void setNormalX(int normalX) { |
656 | 9963 | cesar | if (!isMaximized()) {
|
657 | setX(normalX); |
||
658 | } |
||
659 | else {
|
||
660 | support.firePropertyChange("normalX", this.normalX, normalX); |
||
661 | this.normalX = normalX;
|
||
662 | } |
||
663 | } |
||
664 | 25519 | vcaballero | |
665 | 9963 | cesar | /**
|
666 | * Updates the normalX property for this WindowInfo
|
||
667 | * object. It doesn't get reflected on the window (use
|
||
668 | * <code>setNormalX</code> for that).
|
||
669 | 25519 | vcaballero | *
|
670 | 9963 | cesar | * @param normalX The new normalX property for this WindowInfo object
|
671 | */
|
||
672 | public void updateNormalX(int normalX) { |
||
673 | 6880 | cesar | this.normalX = normalX;
|
674 | 9963 | cesar | if (!isMaximized())
|
675 | x = normalX; |
||
676 | 6880 | cesar | } |
677 | |||
678 | 9963 | cesar | /**
|
679 | * Sets the normalY property for this WindowInfo object. This sets the Y
|
||
680 | * position that the window would have when it gets restored from the
|
||
681 | * maximized state.
|
||
682 | 25519 | vcaballero | *
|
683 | 9963 | cesar | * @param normalY The new normalY property for this WindowInfo object
|
684 | */
|
||
685 | 6880 | cesar | public void setNormalY(int normalY) { |
686 | 9963 | cesar | if (!isMaximized()) {
|
687 | setY(normalY); |
||
688 | } |
||
689 | else {
|
||
690 | support.firePropertyChange("normalY", this.normalY, normalY); |
||
691 | this.normalY = normalY;
|
||
692 | } |
||
693 | } |
||
694 | 25519 | vcaballero | |
695 | 9963 | cesar | /**
|
696 | * Updates the normalY property for this WindowInfo
|
||
697 | * object. It doesn't get reflected on the window (use
|
||
698 | * <code>setNormalY</code> for that).
|
||
699 | 25519 | vcaballero | *
|
700 | 9963 | cesar | * @param normalY The new normalY property for this WindowInfo object
|
701 | */
|
||
702 | public void updateNormalY(int normalY) { |
||
703 | 6880 | cesar | this.normalY = normalY;
|
704 | 9963 | cesar | if (!isMaximized())
|
705 | y = normalY; |
||
706 | 6880 | cesar | } |
707 | |||
708 | 9963 | cesar | /**
|
709 | * Sets the normalHeight property for this WindowInfo object. This sets the height
|
||
710 | * position that the window would have when it gets restored from the
|
||
711 | * maximized state.
|
||
712 | 25519 | vcaballero | *
|
713 | 9963 | cesar | * @param normalY The new normalHeight property for this WindowInfo object
|
714 | */
|
||
715 | 6880 | cesar | public void setNormalHeight(int normalHeight) { |
716 | 9963 | cesar | if (!isMaximized) {
|
717 | setHeight(normalHeight); |
||
718 | } |
||
719 | else {
|
||
720 | support.firePropertyChange("normalHeight", this.normalHeight, normalHeight); |
||
721 | this.normalHeight = normalHeight;
|
||
722 | } |
||
723 | } |
||
724 | 25519 | vcaballero | |
725 | 9963 | cesar | /**
|
726 | * Updates the normalHeight property for this WindowInfo
|
||
727 | * object. It doesn't get reflected on the window (use
|
||
728 | * <code>setNormalHeight</code> for that).
|
||
729 | 25519 | vcaballero | *
|
730 | 9963 | cesar | * @param normalHeight The new normalHeight property for this WindowInfo object
|
731 | */
|
||
732 | public void updateNormalHeight(int normalHeight) { |
||
733 | 6880 | cesar | this.normalHeight = normalHeight;
|
734 | 9963 | cesar | if (!isMaximized) {
|
735 | this.height = normalHeight;
|
||
736 | } |
||
737 | 6880 | cesar | } |
738 | |||
739 | 9963 | cesar | /**
|
740 | * Sets the normalWidth property for this WindowInfo object. This sets the width
|
||
741 | * position that the window would have when it gets restored from the
|
||
742 | * maximized state.
|
||
743 | 25519 | vcaballero | *
|
744 | 9963 | cesar | * @param normalY The new normalWidth property for this WindowInfo object
|
745 | */
|
||
746 | 6880 | cesar | public void setNormalWidth(int normalWidth) { |
747 | 9963 | cesar | if (!isMaximized()) {
|
748 | setWidth(normalWidth); |
||
749 | } |
||
750 | else {
|
||
751 | support.firePropertyChange("normalWidth", this.normalWidth, normalWidth); |
||
752 | this.normalWidth = normalWidth;
|
||
753 | } |
||
754 | } |
||
755 | 25519 | vcaballero | |
756 | 9994 | cesar | /**
|
757 | * Sets the minimum allowed size for the associated window. If null is provided,
|
||
758 | * the minimum size is disabled (and thus
|
||
759 | * the window can be resized to any size).
|
||
760 | 25519 | vcaballero | *
|
761 | 9994 | cesar | * @param minSize The minimum allowed size for the associated window.
|
762 | */
|
||
763 | public void setMinimumSize(Dimension minSize) { |
||
764 | support.firePropertyChange("minimumSize", this.minSize, minSize); |
||
765 | this.minSize = minSize;
|
||
766 | } |
||
767 | 9963 | cesar | |
768 | /**
|
||
769 | 9994 | cesar | * Updates the minimum allowed size for the associated window. It doesn't
|
770 | * get reflected on the window (use <code>setMinimumSize</code> for that).
|
||
771 | 25519 | vcaballero | *
|
772 | 9994 | cesar | * @param minSize The minimum allowed size for the associated window.
|
773 | */
|
||
774 | public void updateMinimumSize(Dimension minSize) { |
||
775 | this.minSize = minSize;
|
||
776 | } |
||
777 | 25519 | vcaballero | |
778 | 9994 | cesar | /**
|
779 | * Gets the minimum allowed size for the associated window.
|
||
780 | 25519 | vcaballero | *
|
781 | 9994 | cesar | * @return minSize The minimum allowed size for the associated window.
|
782 | */
|
||
783 | public Dimension getMinimumSize() { |
||
784 | return minSize;
|
||
785 | } |
||
786 | 25519 | vcaballero | |
787 | 9994 | cesar | /**
|
788 | 9963 | cesar | * Updates the normalWidth property for this WindowInfo
|
789 | * object. It doesn't get reflected on the window (use
|
||
790 | * <code>setNormalWidth</code> for that).
|
||
791 | 25519 | vcaballero | *
|
792 | 9963 | cesar | * @param normalWidth The new normalHeight property for this WindowInfo object
|
793 | */
|
||
794 | public void updateNormalWidth(int normalWidth) { |
||
795 | 6880 | cesar | this.normalWidth = normalWidth;
|
796 | 9963 | cesar | if (!isMaximized())
|
797 | this.width = normalWidth;
|
||
798 | 6880 | cesar | } |
799 | |||
800 | 9963 | cesar | /**
|
801 | * Maximize the associated window
|
||
802 | 25519 | vcaballero | *
|
803 | 9963 | cesar | * @param maximized
|
804 | */
|
||
805 | 6880 | cesar | public void setMaximized(boolean maximized) { |
806 | 7447 | cesar | support.firePropertyChange("maximized", this.isMaximized, maximized); |
807 | 6880 | cesar | this.isMaximized = maximized;
|
808 | } |
||
809 | 25519 | vcaballero | |
810 | 9963 | cesar | /**
|
811 | * Updates the maximized property for this WindowInfo
|
||
812 | * object. It doesn't get reflected on the window (use
|
||
813 | * <code>setMaximized</code> for that).
|
||
814 | 25519 | vcaballero | *
|
815 | 9963 | cesar | * @param maximized The new maximized property for this WindowInfo object
|
816 | */
|
||
817 | public void updateMaximized(boolean maximized) { |
||
818 | this.isMaximized = maximized;
|
||
819 | } |
||
820 | 9750 | jaume | |
821 | 7397 | maquerol | public void setMaximizable(boolean maximizable) { |
822 | this.maximizable = maximizable;
|
||
823 | } |
||
824 | 6880 | cesar | |
825 | 9994 | cesar | /**
|
826 | * Sets the bounds of the associated window.
|
||
827 | 25519 | vcaballero | *
|
828 | 9994 | cesar | * @param x
|
829 | * @param y
|
||
830 | * @param width
|
||
831 | * @param height
|
||
832 | */
|
||
833 | 6880 | cesar | private void setBounds(int x, int y, int width, int height) { |
834 | 9963 | cesar | setX(x); |
835 | setY(y); |
||
836 | setWidth(width); |
||
837 | setHeight(height); |
||
838 | } |
||
839 | 25519 | vcaballero | |
840 | 9963 | cesar | /**
|
841 | * Updates the bounds for this WindowInfo object. It doesn't get reflected
|
||
842 | 9994 | cesar | * on the window (use <code>setBounds</code> for that).
|
843 | 25519 | vcaballero | *
|
844 | 9963 | cesar | * @param x
|
845 | * @param y
|
||
846 | * @param width
|
||
847 | * @param height
|
||
848 | */
|
||
849 | public void updateBounds(int x, int y, int width, int height) { |
||
850 | 6880 | cesar | this.x = x;
|
851 | this.y = y;
|
||
852 | this.width = width;
|
||
853 | this.height = height;
|
||
854 | 9963 | cesar | if (!isMaximized()) {
|
855 | this.normalX = x;
|
||
856 | this.normalY = y;
|
||
857 | this.normalWidth = width;
|
||
858 | this.normalHeight = height;
|
||
859 | } |
||
860 | 6880 | cesar | } |
861 | |||
862 | 9994 | cesar | /**
|
863 | * Sets the normal bounds of the associated window. This sets the bounds
|
||
864 | * that the window would have when it gets restored from the
|
||
865 | * maximized state.
|
||
866 | 25519 | vcaballero | *
|
867 | 9994 | cesar | * @param x
|
868 | * @param y
|
||
869 | * @param width
|
||
870 | * @param height
|
||
871 | */
|
||
872 | 6880 | cesar | public void setNormalBounds(int x, int y, int width, int height) { |
873 | 9963 | cesar | setNormalX(x); |
874 | setNormalY(y); |
||
875 | setNormalWidth(width); |
||
876 | setNormalHeight(height); |
||
877 | 6880 | cesar | } |
878 | 25519 | vcaballero | |
879 | 9963 | cesar | /**
|
880 | * Updates the normal bounds for this WindowInfo object. It doesn't get
|
||
881 | 9994 | cesar | * reflected on the window (use <code>setNormalBounds</code> for that).
|
882 | 25519 | vcaballero | *
|
883 | 9963 | cesar | * @param x
|
884 | * @param y
|
||
885 | * @param width
|
||
886 | * @param height
|
||
887 | */
|
||
888 | public void updateNormalBounds(int x, int y, int width, int height) { |
||
889 | this.normalX = x;
|
||
890 | this.normalY = y;
|
||
891 | this.normalWidth = width;
|
||
892 | this.normalHeight = height;
|
||
893 | if (!isMaximized()) {
|
||
894 | this.x = x;
|
||
895 | this.y = y;
|
||
896 | this.width = width;
|
||
897 | this.height = height;
|
||
898 | } |
||
899 | } |
||
900 | 6880 | cesar | |
901 | 9994 | cesar | /**
|
902 | * Gets the normal bounds of the associated window. This gets the bounds
|
||
903 | * that the window would have when it gets restored from the
|
||
904 | * maximized state.
|
||
905 | 25519 | vcaballero | *
|
906 | 9994 | cesar | * @return The normal bounds of the associated window.
|
907 | */
|
||
908 | 6880 | cesar | public Rectangle getNormalBounds() { |
909 | return new Rectangle(getNormalX(), getNormalY(), getNormalWidth(), getNormalHeight()); |
||
910 | } |
||
911 | |||
912 | 9994 | cesar | /**
|
913 | * Sets the normal bounds of the associated window. This sets the bounds
|
||
914 | * that the window would have when it gets restored from the
|
||
915 | * maximized state.
|
||
916 | 25519 | vcaballero | *
|
917 | 9994 | cesar | * @param normalBounds
|
918 | */
|
||
919 | 6880 | cesar | public void setNormalBounds(Rectangle normalBounds) { |
920 | 9963 | cesar | setNormalBounds(normalBounds.x, normalBounds.y, normalBounds.width, normalBounds.height); |
921 | 6880 | cesar | } |
922 | 25519 | vcaballero | |
923 | 9994 | cesar | /**
|
924 | * Updates the normal bounds for this WindowInfo object. It doesn't get
|
||
925 | * reflected on the window (use <code>setNormalBounds</code> for that).
|
||
926 | 25519 | vcaballero | *
|
927 | 9994 | cesar | * @param normalBounds
|
928 | */
|
||
929 | 9963 | cesar | public void updateNormalBounds(Rectangle normalBounds) { |
930 | updateNormalBounds(normalBounds.x, normalBounds.y, normalBounds.width, normalBounds.height); |
||
931 | } |
||
932 | 25519 | vcaballero | |
933 | 9994 | cesar | /**
|
934 | * Sets the bounds of the associated window.
|
||
935 | 25519 | vcaballero | *
|
936 | 9994 | cesar | * @param bounds
|
937 | */
|
||
938 | 6880 | cesar | public void setBounds(Rectangle bounds) { |
939 | 9963 | cesar | setBounds(bounds.x, bounds.y, bounds.width, bounds.height); |
940 | 6880 | cesar | } |
941 | 25519 | vcaballero | |
942 | 9994 | cesar | /**
|
943 | * Updates the bounds for this WindowInfo object. It doesn't get reflected
|
||
944 | * on the window (use <code>setBounds</code> for that).
|
||
945 | 25519 | vcaballero | *
|
946 | 9994 | cesar | * @param bounds
|
947 | */
|
||
948 | 9963 | cesar | public void updateBounds(Rectangle bounds) { |
949 | updateBounds(bounds.x, bounds.y, bounds.width, bounds.height); |
||
950 | } |
||
951 | 6880 | cesar | |
952 | 9994 | cesar | /**
|
953 | * Gets the bounds of the associated window.
|
||
954 | 25519 | vcaballero | *
|
955 | 9994 | cesar | * @return The bounds of the associated window.
|
956 | */
|
||
957 | 6880 | cesar | public Rectangle getBounds() { |
958 | return new Rectangle(x, y, width, height); |
||
959 | } |
||
960 | |||
961 | public int getNormalX() { |
||
962 | if (normalX!=0) |
||
963 | return this.normalX; |
||
964 | else
|
||
965 | return x;
|
||
966 | } |
||
967 | |||
968 | 11992 | cesar | /**
|
969 | * Gets the x coordinate of the window's origin when the window is not
|
||
970 | * maximized. When the window is maximized, gets the y coordinate that
|
||
971 | * it will have when it gets restored
|
||
972 | 25519 | vcaballero | *
|
973 | 11992 | cesar | * @return the normal y coordinate of the window's origin
|
974 | */
|
||
975 | 6880 | cesar | public int getNormalY() { |
976 | if (normalY!=0) |
||
977 | return this.normalY; |
||
978 | else
|
||
979 | return y;
|
||
980 | } |
||
981 | |||
982 | 11992 | cesar | /**
|
983 | * Gets the height of the window's origin when the window is not
|
||
984 | * maximized. When the window is maximized, gets the height that
|
||
985 | * it will have when it gets restored
|
||
986 | 25519 | vcaballero | *
|
987 | 11992 | cesar | * @return the normal height of the window
|
988 | */
|
||
989 | 6880 | cesar | public int getNormalHeight() { |
990 | if (normalHeight!=0) |
||
991 | return this.normalHeight; |
||
992 | else
|
||
993 | return height;
|
||
994 | } |
||
995 | |||
996 | 11992 | cesar | /**
|
997 | * Gets the width of the window's origin when the window is not
|
||
998 | * maximized. When the window is maximized, gets the width that
|
||
999 | * it will have when it gets restored
|
||
1000 | 25519 | vcaballero | *
|
1001 | 11992 | cesar | * @return the normal width of the window
|
1002 | */
|
||
1003 | 6880 | cesar | public int getNormalWidth() { |
1004 | if (normalWidth!=0) |
||
1005 | return this.normalWidth; |
||
1006 | else
|
||
1007 | return width;
|
||
1008 | } |
||
1009 | |||
1010 | 11992 | cesar | /**
|
1011 | * Determines whether the window is maximized or not
|
||
1012 | 25519 | vcaballero | *
|
1013 | 11992 | cesar | * @return true if the window is maximized, false otherwise
|
1014 | */
|
||
1015 | 6880 | cesar | public boolean isMaximized() { |
1016 | return this.isMaximized; |
||
1017 | } |
||
1018 | 9750 | jaume | |
1019 | 7447 | cesar | /**
|
1020 | * Checks if the geometry of this window should be persisted in the
|
||
1021 | * project file. This is set by the persistWindow(boolean) method,
|
||
1022 | * and the default value is true.
|
||
1023 | 9750 | jaume | *
|
1024 | 7447 | cesar | * @return True if the geometry of this window should be persisted
|
1025 | * in the project files, false otherwise.
|
||
1026 | */
|
||
1027 | public boolean checkPersistence() { |
||
1028 | return this.persistWindow; |
||
1029 | } |
||
1030 | 9750 | jaume | |
1031 | 7447 | cesar | /**
|
1032 | * Set whether the geometry of this window should be persisted in the
|
||
1033 | * project files.
|
||
1034 | 9750 | jaume | *
|
1035 | 7447 | cesar | * @param persist
|
1036 | */
|
||
1037 | public void setPersistence(boolean persist) { |
||
1038 | this.persistWindow = persist;
|
||
1039 | } |
||
1040 | 9750 | jaume | |
1041 | 7447 | cesar | /**
|
1042 | * Gets the window properties in an XMLEntity object, suitable
|
||
1043 | * for persistence.
|
||
1044 | *
|
||
1045 | 11992 | cesar | * @return An XMLEntity object containing the window properties,
|
1046 | * or null if the window was set as not persistent
|
||
1047 | 7447 | cesar | * @throws SaveException
|
1048 | * @throws XMLException
|
||
1049 | */
|
||
1050 | public XMLEntity getXMLEntity() {
|
||
1051 | 11992 | cesar | if (checkPersistence()==false) { |
1052 | return null; |
||
1053 | } |
||
1054 | 7447 | cesar | XMLEntity xml = new XMLEntity();
|
1055 | xml.setName("ViewInfoProperties");
|
||
1056 | 10621 | cesar | xml.putProperty("X", this.getX(), false); |
1057 | xml.putProperty("Y", this.getY(), false); |
||
1058 | xml.putProperty("Width", this.getWidth(), false); |
||
1059 | xml.putProperty("Height", this.getHeight(), false); |
||
1060 | xml.putProperty("isVisible", this.isVisible(), false); |
||
1061 | xml.putProperty("isResizable", this.isResizable(), false); |
||
1062 | xml.putProperty("isMaximizable", this.isMaximizable(), false); |
||
1063 | xml.putProperty("isModal", this.isModal(), false); |
||
1064 | xml.putProperty("isModeless", this.isModeless(), false); |
||
1065 | xml.putProperty("isClosed", this.isClosed(), false); |
||
1066 | 25519 | vcaballero | xml.putProperty("AdditionalInfo", this.getAdditionalInfo(), false); |
1067 | 29752 | nbrodin | xml.putProperty("isNotClosable", this.isNotClosable(), false); |
1068 | 7447 | cesar | if (this.isMaximized()==true) { |
1069 | 10621 | cesar | xml.putProperty("isMaximized", this.isMaximized(), false); |
1070 | xml.putProperty("normalX", this.getNormalX(), false); |
||
1071 | xml.putProperty("normalY", this.getNormalY(), false); |
||
1072 | xml.putProperty("normalWidth", this.getNormalWidth(), false); |
||
1073 | xml.putProperty("normalHeight", this.getNormalHeight(), false); |
||
1074 | 7447 | cesar | } |
1075 | return xml;
|
||
1076 | } |
||
1077 | 9750 | jaume | |
1078 | 11992 | cesar | /**
|
1079 | * Creates a WindowInfo object from an XMLEntity containing the
|
||
1080 | * window properties.
|
||
1081 | 25519 | vcaballero | *
|
1082 | 11992 | cesar | * @param xml An XMLEntity object containing the window properties
|
1083 | 25519 | vcaballero | *
|
1084 | 11992 | cesar | * @return A new WindowInfo object, containing the properties
|
1085 | 25519 | vcaballero | * specified in the XMLEntity parameters
|
1086 | 11992 | cesar | */
|
1087 | 7447 | cesar | public static WindowInfo createFromXMLEntity(XMLEntity xml) |
1088 | { |
||
1089 | WindowInfo result = new WindowInfo();
|
||
1090 | 9655 | cesar | try {
|
1091 | result.setX(xml.getIntProperty("X"));
|
||
1092 | result.setY(xml.getIntProperty("Y"));
|
||
1093 | result.setHeight(xml.getIntProperty("Height"));
|
||
1094 | result.setWidth(xml.getIntProperty("Width"));
|
||
1095 | result.setClosed(xml.getBooleanProperty("isClosed"));
|
||
1096 | 12224 | nacho | result.setAdditionalInfo(xml.getStringProperty("AdditionalInfo"));
|
1097 | 29752 | nbrodin | result.setNotClosable(xml.getBooleanProperty("isNotClosable"));
|
1098 | 9655 | cesar | if (xml.contains("isMaximized")) { |
1099 | boolean maximized = xml.getBooleanProperty("isMaximized"); |
||
1100 | result.setMaximized(maximized); |
||
1101 | if (maximized==true) { |
||
1102 | result.setNormalBounds(xml.getIntProperty("normalX"), xml.getIntProperty("normalY"), xml.getIntProperty("normalWidth"), xml.getIntProperty("normalHeight")); |
||
1103 | } |
||
1104 | else {
|
||
1105 | result.setNormalBounds(result.getBounds()); |
||
1106 | } |
||
1107 | 7447 | cesar | } |
1108 | } |
||
1109 | 29593 | jpiera | catch (org.gvsig.utils.NotExistInXMLEntity ex) {
|
1110 | 9655 | cesar | PluginServices.getLogger().warn(PluginServices.getText(null, "Window_properties_not_stored_correctly_Window_state_will_not_be_restored")); |
1111 | } |
||
1112 | 7447 | cesar | |
1113 | return result;
|
||
1114 | } |
||
1115 | 9750 | jaume | |
1116 | 11992 | cesar | /**
|
1117 | * Updates this WindowInfo object according to the properties
|
||
1118 | * provided by the XMLEntity parameter.
|
||
1119 | 25519 | vcaballero | *
|
1120 | 11992 | cesar | * @param xml An XMLEntity object containing the window properties
|
1121 | */
|
||
1122 | 7447 | cesar | public void getPropertiesFromXMLEntity(XMLEntity xml) |
1123 | { |
||
1124 | this.x = xml.getIntProperty("X"); |
||
1125 | this.y = xml.getIntProperty("Y"); |
||
1126 | this.height = xml.getIntProperty("Height"); |
||
1127 | this.width = xml.getIntProperty("Width"); |
||
1128 | this.isClosed = xml.getBooleanProperty("isClosed"); |
||
1129 | 12224 | nacho | this.additionalInfo = xml.getStringProperty("AdditionalInfo"); |
1130 | 29752 | nbrodin | this.notclosable = xml.getBooleanProperty("isNotClosable"); |
1131 | 7447 | cesar | if (xml.contains("isMaximized")) { |
1132 | boolean maximized = xml.getBooleanProperty("isMaximized"); |
||
1133 | this.isMaximized = maximized;
|
||
1134 | if (maximized==true) { |
||
1135 | this.setNormalBounds(xml.getIntProperty("normalX"), xml.getIntProperty("normalY"), xml.getIntProperty("normalWidth"), xml.getIntProperty("normalHeight")); |
||
1136 | } |
||
1137 | } |
||
1138 | } |
||
1139 | 12224 | nacho | |
1140 | /**
|
||
1141 | * Obtiene informaci?n adicional de la ventana. Esta etiqueta podr? llevar cualquier
|
||
1142 | * tipo de informaci?n que queramos almacenar.
|
||
1143 | * @return Informaci?n adicional
|
||
1144 | */
|
||
1145 | public String getAdditionalInfo() { |
||
1146 | return additionalInfo;
|
||
1147 | } |
||
1148 | |||
1149 | /**
|
||
1150 | * Asigna informaci?n adicional de la ventana. Esta etiqueta podr? llevar cualquier
|
||
1151 | * tipo de informaci?n que queramos almacenar.
|
||
1152 | * @return Informaci?n adicional
|
||
1153 | */
|
||
1154 | public void setAdditionalInfo(String additionalInfo) { |
||
1155 | this.additionalInfo = additionalInfo;
|
||
1156 | } |
||
1157 | |||
1158 | 34833 | fdiaz | public void saveToState(PersistentState state) throws PersistenceException { |
1159 | state.set("resizable", this.resizable); |
||
1160 | state.set("maximizable", this.maximizable); |
||
1161 | state.set("iconifiable", this.iconifiable); |
||
1162 | state.set("modal", this.modal); |
||
1163 | state.set("modeless", this.modeless); |
||
1164 | state.set("notclosable", this.notclosable); |
||
1165 | state.set("persistWindow", this.persistWindow); //OJO ?Obsoleto? |
||
1166 | state.set("palette", this.palette); |
||
1167 | state.set("additionalInfo", this.additionalInfo); |
||
1168 | state.set("width", this.width); |
||
1169 | state.set("height", this.height); |
||
1170 | state.set("x", this.x); |
||
1171 | state.set("y", this.y); |
||
1172 | state.set("normalX", this.normalX); |
||
1173 | state.set("normalY", this.normalY); |
||
1174 | state.set("normalHeight", this.normalHeight); |
||
1175 | state.set("normalWidth", this.normalWidth); |
||
1176 | state.set("minSize", this.minSize); |
||
1177 | state.set("isMaximized", this.isMaximized); |
||
1178 | state.set("visible", this.visible); |
||
1179 | state.set("isClosed", this.isClosed); |
||
1180 | state.set("title", this.title); |
||
1181 | state.set("id", this.id); //OJO |
||
1182 | state.set("selectedTools", this.selectedTools); //OJO |
||
1183 | state.set("defaultGroup", this.defaultGroup); //OJO |
||
1184 | } |
||
1185 | |||
1186 | @SuppressWarnings("rawtypes") |
||
1187 | public void loadFromState(PersistentState state) |
||
1188 | throws PersistenceException {
|
||
1189 | this.resizable = state.getBoolean("resizable"); |
||
1190 | this.maximizable = state.getBoolean("maximizable"); |
||
1191 | this.iconifiable = state.getBoolean("iconifiable"); |
||
1192 | this.modal = state.getBoolean("modal"); |
||
1193 | this.modeless = state.getBoolean("modeless"); |
||
1194 | this.notclosable = state.getBoolean("notclosable"); |
||
1195 | this.persistWindow = state.getBoolean("persistWindow"); //OJO ?Obsoleto? |
||
1196 | this.palette = state.getBoolean("palette"); |
||
1197 | this.additionalInfo = state.getString("additionalInfo"); |
||
1198 | this.width = state.getInt("width"); |
||
1199 | this.height = state.getInt("height"); |
||
1200 | this.x = state.getInt("x"); |
||
1201 | this.y = state.getInt("y"); |
||
1202 | this.normalX = state.getInt("normalX"); |
||
1203 | this.normalY = state.getInt("normalY"); |
||
1204 | this.normalHeight = state.getInt("normalHeight"); |
||
1205 | this.normalWidth = state.getInt("normalWidth"); |
||
1206 | this.minSize = (Dimension)state.get("minSize"); |
||
1207 | this.isMaximized = state.getBoolean("isMaximized"); |
||
1208 | this.visible = state.getBoolean("visible"); |
||
1209 | this.isClosed = state.getBoolean("isClosed"); |
||
1210 | this.title = state.getString("title"); |
||
1211 | this.id = state.getInt("id"); |
||
1212 | this.setSelectedTools(state.getMap("selectedTools")); |
||
1213 | this.defaultGroup = state.getString("defaultGroup"); //OJO |
||
1214 | } |
||
1215 | |||
1216 | |||
1217 | public static class RegisterPersistence implements Callable { |
||
1218 | |||
1219 | public Object call() throws Exception { |
||
1220 | PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
||
1221 | DynStruct definition = manager.getDefinition(PERSISTENCE_DEFINITION_NAME); |
||
1222 | if ( definition == null ){ |
||
1223 | definition = manager.addDefinition( |
||
1224 | WindowInfo.class, |
||
1225 | PERSISTENCE_DEFINITION_NAME, |
||
1226 | "WindowInfo persistence definition",
|
||
1227 | null,
|
||
1228 | null
|
||
1229 | ); |
||
1230 | definition.addDynFieldBoolean("resizable").setMandatory(true); |
||
1231 | definition.addDynFieldBoolean("maximizable").setMandatory(true); |
||
1232 | definition.addDynFieldBoolean("iconifiable").setMandatory(true); |
||
1233 | definition.addDynFieldBoolean("modal").setMandatory(true); |
||
1234 | definition.addDynFieldBoolean("modeless").setMandatory(true); |
||
1235 | definition.addDynFieldBoolean("notclosable").setMandatory(true); |
||
1236 | definition.addDynFieldBoolean("persistWindow").setMandatory(true); |
||
1237 | definition.addDynFieldBoolean("palette").setMandatory(true); |
||
1238 | definition.addDynFieldString("additionalInfo").setMandatory(false); |
||
1239 | definition.addDynFieldInt("width").setMandatory(true); |
||
1240 | definition.addDynFieldInt("height").setMandatory(true); |
||
1241 | definition.addDynFieldInt("x").setMandatory(true); |
||
1242 | definition.addDynFieldInt("y").setMandatory(true); |
||
1243 | definition.addDynFieldInt("normalX").setMandatory(true); |
||
1244 | definition.addDynFieldInt("normalY").setMandatory(true); |
||
1245 | definition.addDynFieldInt("normalHeight").setMandatory(true); |
||
1246 | definition.addDynFieldInt("normalWidth").setMandatory(true); |
||
1247 | definition.addDynFieldObject("minSize").setMandatory(false).setClassOfValue(Dimension.class); |
||
1248 | definition.addDynFieldBoolean("isMaximized").setMandatory(true); |
||
1249 | definition.addDynFieldBoolean("visible").setMandatory(true); |
||
1250 | definition.addDynFieldBoolean("isClosed").setMandatory(true); |
||
1251 | definition.addDynFieldString("title").setMandatory(true); |
||
1252 | definition.addDynFieldInt("id").setMandatory(true); |
||
1253 | definition.addDynFieldMap("selectedTools").setMandatory(false); |
||
1254 | definition.addDynFieldString("defaultGroup").setMandatory(true); |
||
1255 | } |
||
1256 | return Boolean.TRUE; |
||
1257 | } |
||
1258 | } |
||
1259 | 6880 | cesar | } |