svn-gvsig-desktop / trunk / frameworks / _fwAndami / src / com / iver / andami / ui / mdiManager / WindowInfo.java @ 9994
History | View | Annotate | Download (25 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
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 |
package com.iver.andami.ui.mdiManager; |
42 |
|
43 |
import java.awt.Dimension; |
44 |
import java.awt.Rectangle; |
45 |
import java.beans.PropertyChangeListener; |
46 |
import java.beans.PropertyChangeSupport; |
47 |
|
48 |
import org.exolab.castor.xml.XMLException; |
49 |
|
50 |
import com.iver.andami.PluginServices; |
51 |
import com.iver.utiles.XMLEntity; |
52 |
|
53 |
|
54 |
/**
|
55 |
* This class represents the state of the associated window.
|
56 |
* The <code>set</code> methods (<code>setX</code>, <code>setY</code>,
|
57 |
* <code>setHeight</code>, etc) are inmediately reflected on the
|
58 |
* window.
|
59 |
*
|
60 |
* The <code>update</code> methods doesn't update the window, because
|
61 |
* they are used to update the WindowInfo object when the associated
|
62 |
* window was modified by user interaction.
|
63 |
*
|
64 |
* @author Fernando Gonz?lez Cort?s
|
65 |
*/
|
66 |
public class WindowInfo { |
67 |
/** Specifies that the window is resizable */
|
68 |
public static final int RESIZABLE = 1; |
69 |
|
70 |
/** Specifies that the window is maximizable */
|
71 |
public static final int MAXIMIZABLE = 2; |
72 |
|
73 |
/** Specifies that the window is iconifiable */
|
74 |
public static final int ICONIFIABLE = 4; |
75 |
|
76 |
/** Specifies that the window is modal */
|
77 |
public static final int MODALDIALOG = 8; |
78 |
/** Specifies that the window is modeless (doesn't block any other window) */
|
79 |
public static final int MODELESSDIALOG = 16; |
80 |
/** Specifies that the window is semimodal */
|
81 |
public static final int PALETTE = 32; |
82 |
private PropertyChangeSupport support = new PropertyChangeSupport(this); |
83 |
|
84 |
/** DOCUMENT ME! */
|
85 |
private boolean resizable = false; |
86 |
|
87 |
/** DOCUMENT ME! */
|
88 |
private boolean maximizable = false; |
89 |
|
90 |
/** DOCUMENT ME! */
|
91 |
private boolean iconifiable = false; |
92 |
|
93 |
/** DOCUMENT ME! */
|
94 |
private boolean modal = false; |
95 |
private boolean modeless = false; |
96 |
|
97 |
/**
|
98 |
* Do we want to persist the geometry of this window in the project file?
|
99 |
*/
|
100 |
private boolean persistWindow = true; |
101 |
|
102 |
/**
|
103 |
* Se usa para poner una ventana de tipo paleta, por
|
104 |
* encima de las dem?s. Equivale a poner usar
|
105 |
* JDesktopPane.PALETTE_LAYER
|
106 |
*/
|
107 |
private boolean palette = false; |
108 |
|
109 |
/** These properties store the dimension and position of the frame */
|
110 |
private int width = -1; |
111 |
private int height = -1; |
112 |
private int x = 0; |
113 |
private int y = 0; |
114 |
/**
|
115 |
* These properties store the position and dimension of the frame when it is not maximized
|
116 |
* (so that it can be restored to its original size). They are equal to the not-normal properties
|
117 |
* when the frame is not maximized, and different when the frame is maximized.
|
118 |
*/
|
119 |
private int normalX = 0; |
120 |
private int normalY = 0; |
121 |
private int normalHeight = -1; |
122 |
private int normalWidth = -1; |
123 |
|
124 |
/** The minimum allowed size for this window. */
|
125 |
private Dimension minSize = null; |
126 |
|
127 |
/* Whether the window is maximized */
|
128 |
private boolean isMaximized = false; |
129 |
private boolean visible = true; |
130 |
/* Whether the window is closed */
|
131 |
private boolean isClosed = false; |
132 |
|
133 |
|
134 |
/** DOCUMENT ME! */
|
135 |
private String title; |
136 |
|
137 |
private int id; |
138 |
|
139 |
/**
|
140 |
* ActionCommand del tool seleccionado. Lo usamos
|
141 |
* para activar el tool que estaba seleccionado en
|
142 |
* la vista, cuando volvemos a ella.
|
143 |
*/
|
144 |
private String selectedTool; |
145 |
|
146 |
/**
|
147 |
* DOCUMENT ME!
|
148 |
*
|
149 |
* @param listener
|
150 |
*/
|
151 |
public void addPropertyChangeListener(PropertyChangeListener listener) { |
152 |
support.addPropertyChangeListener(listener); |
153 |
} |
154 |
|
155 |
/**
|
156 |
* DOCUMENT ME!
|
157 |
*
|
158 |
* @param listener
|
159 |
*/
|
160 |
public void removePropertyChangeListener(PropertyChangeListener listener) { |
161 |
support.removePropertyChangeListener(listener); |
162 |
} |
163 |
|
164 |
/**
|
165 |
* Establece las propiedades de la vista
|
166 |
*
|
167 |
* @param code Bit-or de las propiedades de la vista
|
168 |
*
|
169 |
* @throws IllegalStateException DOCUMENT ME!
|
170 |
*/
|
171 |
public WindowInfo(int code) { |
172 |
resizable = (code % 2) > 0; |
173 |
code = code / 2;
|
174 |
maximizable = (code % 2) > 0; |
175 |
code = code / 2;
|
176 |
iconifiable = (code % 2) > 0; |
177 |
code = code / 2;
|
178 |
modal = (code % 2) > 0; |
179 |
code = code / 2;
|
180 |
modeless = (code % 2) > 0; |
181 |
code = code / 2;
|
182 |
palette = (code % 2) > 0; |
183 |
|
184 |
if (modal && modeless) {
|
185 |
throw new IllegalStateException("modal && modeless"); |
186 |
} |
187 |
} |
188 |
|
189 |
public WindowInfo(){
|
190 |
|
191 |
} |
192 |
|
193 |
/**
|
194 |
* Returns the current x coordinate of the window's origin.
|
195 |
*
|
196 |
* @return Returns the value (in pixels) of the x coordinate
|
197 |
* of the window's origin.
|
198 |
*/
|
199 |
public int getX() { |
200 |
return x;
|
201 |
} |
202 |
|
203 |
/**
|
204 |
* Sets the x coordinate of the window's origin.
|
205 |
*
|
206 |
* @param x The value (in pixels) of the x coordinate to set.
|
207 |
*/
|
208 |
public void setX(int x) { |
209 |
support.firePropertyChange("x", this.x, x); |
210 |
this.x = x;
|
211 |
if (!isMaximized)
|
212 |
this.normalX = x;
|
213 |
} |
214 |
|
215 |
/**
|
216 |
* Updates the value of the x coordinate for this WindowInfo
|
217 |
* object. It doesn't get reflected on the window (use
|
218 |
* setX for that).
|
219 |
*
|
220 |
* @param x The value (in pixels) of the x coordinate
|
221 |
*/
|
222 |
public void updateX(int x) { |
223 |
this.x = x;
|
224 |
if (!isMaximized)
|
225 |
this.normalX = x;
|
226 |
} |
227 |
|
228 |
/**
|
229 |
* Gets the value of the y coordinate for the origin of the associated
|
230 |
* window.
|
231 |
*
|
232 |
* @return Returns the y coordinate (in pixels).
|
233 |
*/
|
234 |
public int getY() { |
235 |
return y;
|
236 |
} |
237 |
|
238 |
/**
|
239 |
* Sets the value of the y coordinate for the origin of the associated
|
240 |
* window.
|
241 |
*
|
242 |
* @param y The value (in pixels) of the y coordinate
|
243 |
*/
|
244 |
public void setY(int y) { |
245 |
support.firePropertyChange("y", this.y, y); |
246 |
this.y = y;
|
247 |
if (!isMaximized)
|
248 |
this.normalY = y;
|
249 |
} |
250 |
|
251 |
/**
|
252 |
* Updates the value of the y coordinate for this WindowInfo
|
253 |
* object. It doesn't get reflected on the window (use
|
254 |
* setY for that).
|
255 |
*
|
256 |
* @param y The value (in pixels) of the y coordinate
|
257 |
*/
|
258 |
public void updateY(int y) { |
259 |
this.y = y;
|
260 |
if (!isMaximized)
|
261 |
this.normalY = y;
|
262 |
} |
263 |
|
264 |
/**
|
265 |
* Si es iconificable
|
266 |
*
|
267 |
* @return
|
268 |
*/
|
269 |
public boolean isIconifiable() { |
270 |
return iconifiable;
|
271 |
} |
272 |
|
273 |
/**
|
274 |
* Si es maximizable
|
275 |
*
|
276 |
* @return
|
277 |
*/
|
278 |
public boolean isMaximizable() { |
279 |
return maximizable;
|
280 |
} |
281 |
|
282 |
/**
|
283 |
* Si es resizable
|
284 |
*
|
285 |
* @return
|
286 |
*/
|
287 |
public boolean isResizable() { |
288 |
return resizable;
|
289 |
} |
290 |
|
291 |
/**
|
292 |
* Devuelve si el di?logo es modal
|
293 |
*
|
294 |
* @return
|
295 |
*/
|
296 |
public boolean isModal() { |
297 |
return modal;
|
298 |
} |
299 |
|
300 |
/**
|
301 |
* Gets the window height.
|
302 |
*
|
303 |
* @return The window height (in pixels).
|
304 |
*/
|
305 |
public int getHeight() { |
306 |
return height;
|
307 |
} |
308 |
|
309 |
/**
|
310 |
* Gets the window width.
|
311 |
*
|
312 |
* @return The window width (in pixels).
|
313 |
*/
|
314 |
public int getWidth() { |
315 |
return width;
|
316 |
} |
317 |
|
318 |
/**
|
319 |
* Sets the window height.
|
320 |
*
|
321 |
* @param The window height (in pixels)
|
322 |
*/
|
323 |
public void setHeight(int height) { |
324 |
if (height!=-1) |
325 |
support.firePropertyChange("height", this.height, height); |
326 |
this.height = height;
|
327 |
if (!isMaximized)
|
328 |
this.normalHeight = height;
|
329 |
} |
330 |
|
331 |
/**
|
332 |
* Updates the height property for this WindowInfo
|
333 |
* object. It doesn't get reflected on the window (use
|
334 |
* <code>setHeight</code> for that).
|
335 |
*
|
336 |
* @param height The height value for this WindowInfo object
|
337 |
*/
|
338 |
public void updateHeight(int height) { |
339 |
this.height = height;
|
340 |
if (!isMaximized)
|
341 |
this.normalHeight = height;
|
342 |
} |
343 |
|
344 |
/**
|
345 |
* Sets the width property for the associated Window.
|
346 |
*
|
347 |
* @param w The new width.
|
348 |
*/
|
349 |
public void setWidth(int w) { |
350 |
if (w!=-1) |
351 |
support.firePropertyChange("width", this.width, w); |
352 |
width = w; |
353 |
if (!isMaximized)
|
354 |
this.normalWidth = w;
|
355 |
} |
356 |
|
357 |
/**
|
358 |
* Updates the width property for for this WindowInfo
|
359 |
* object. It doesn't get reflected on the window (use
|
360 |
* <code>setWidth</code> for that).
|
361 |
*
|
362 |
* @param height The height value for this WindowInfo object
|
363 |
*/
|
364 |
public void updateWidth(int width) { |
365 |
this.width = width;
|
366 |
if (!isMaximized)
|
367 |
this.normalWidth = width;
|
368 |
} |
369 |
|
370 |
/**
|
371 |
* Gets the title property
|
372 |
*
|
373 |
* @return
|
374 |
*/
|
375 |
public String getTitle() { |
376 |
return title;
|
377 |
} |
378 |
|
379 |
/**
|
380 |
* Sets the title property.
|
381 |
*
|
382 |
* @param title The new title.
|
383 |
*/
|
384 |
public void setTitle(String title) { |
385 |
support.firePropertyChange("title", this.title, title); |
386 |
this.title = title;
|
387 |
} |
388 |
|
389 |
/**
|
390 |
* Updates the title property for for this WindowInfo
|
391 |
* object. It doesn't get reflected on the window (use
|
392 |
* <code>setTitle</code> for that).
|
393 |
*
|
394 |
* @param title The title value for this WindowInfo object
|
395 |
*/
|
396 |
public void updateTitle(String title) { |
397 |
this.title = title;
|
398 |
} |
399 |
|
400 |
/**
|
401 |
* DOCUMENT ME!
|
402 |
*
|
403 |
* @return
|
404 |
*/
|
405 |
public boolean isModeless() { |
406 |
return modeless;
|
407 |
} |
408 |
|
409 |
/**
|
410 |
* DOCUMENT ME!
|
411 |
*
|
412 |
* @return
|
413 |
*/
|
414 |
public boolean isVisible() { |
415 |
return visible;
|
416 |
} |
417 |
|
418 |
public boolean isPalette() |
419 |
{ |
420 |
return palette;
|
421 |
} |
422 |
|
423 |
public void setId(int id){ |
424 |
this.id = id;
|
425 |
} |
426 |
|
427 |
public int getId(){ |
428 |
return id;
|
429 |
} |
430 |
|
431 |
public void setWindowInfo(WindowInfo vi){ |
432 |
this.resizable = vi.resizable;
|
433 |
this.maximizable = vi.maximizable;
|
434 |
this.isMaximized = vi.isMaximized;
|
435 |
this.iconifiable = vi.iconifiable;
|
436 |
this.modal = vi.modal;
|
437 |
this.modeless = vi.modeless;
|
438 |
if (vi.width!=-1) |
439 |
this.width = vi.width;
|
440 |
if (vi.height!=-1) |
441 |
this.height = vi.height;
|
442 |
this.x = vi.x;
|
443 |
this.y = vi.y;
|
444 |
this.visible = vi.visible;
|
445 |
this.title = vi.title;
|
446 |
this.id = vi.id;
|
447 |
if (vi.normalHeight!=-1) |
448 |
this.normalHeight = vi.normalHeight;
|
449 |
if (vi.normalWidth!=-1) |
450 |
this.normalWidth = vi.normalWidth;
|
451 |
this.normalX = vi.normalX;
|
452 |
this.normalY = vi.normalY;
|
453 |
this.isClosed = vi.isClosed;
|
454 |
this.persistWindow = vi.persistWindow;
|
455 |
} |
456 |
public void toPalette(boolean b){ |
457 |
this.palette=b;
|
458 |
} |
459 |
|
460 |
public String getSelectedTool() { |
461 |
return selectedTool;
|
462 |
} |
463 |
|
464 |
public void setSelectedTool(String selectedTool) { |
465 |
if (selectedTool != null) |
466 |
this.selectedTool = selectedTool;
|
467 |
} |
468 |
|
469 |
/** Finds out whether a view is open (showing) or closed */
|
470 |
public boolean isClosed() { |
471 |
return isClosed;
|
472 |
} |
473 |
|
474 |
/** Specifies whether a view is open (showing) or closed */
|
475 |
public void setClosed(boolean closed) { |
476 |
support.firePropertyChange("closed", this.isClosed, closed); |
477 |
this.isClosed = closed;
|
478 |
} |
479 |
|
480 |
/**
|
481 |
* Updates the closed property for this WindowInfo
|
482 |
* object. It doesn't get reflected on the window (use
|
483 |
* <code>setClosed</code> for that).
|
484 |
*
|
485 |
* @param closed The new closed property for this WindowInfo object
|
486 |
*/
|
487 |
public void updateClosed(boolean closed) { |
488 |
this.isClosed = closed;
|
489 |
} |
490 |
|
491 |
/**
|
492 |
* Sets the normalX property for this WindowInfo object. This sets the X
|
493 |
* position that the window would have when it gets restored from the
|
494 |
* maximized state.
|
495 |
*
|
496 |
* @param normalX The new normalX property for this WindowInfo object
|
497 |
*/
|
498 |
public void setNormalX(int normalX) { |
499 |
if (!isMaximized()) {
|
500 |
setX(normalX); |
501 |
} |
502 |
else {
|
503 |
support.firePropertyChange("normalX", this.normalX, normalX); |
504 |
this.normalX = normalX;
|
505 |
} |
506 |
} |
507 |
|
508 |
/**
|
509 |
* Updates the normalX property for this WindowInfo
|
510 |
* object. It doesn't get reflected on the window (use
|
511 |
* <code>setNormalX</code> for that).
|
512 |
*
|
513 |
* @param normalX The new normalX property for this WindowInfo object
|
514 |
*/
|
515 |
public void updateNormalX(int normalX) { |
516 |
this.normalX = normalX;
|
517 |
if (!isMaximized())
|
518 |
x = normalX; |
519 |
} |
520 |
|
521 |
/**
|
522 |
* Sets the normalY property for this WindowInfo object. This sets the Y
|
523 |
* position that the window would have when it gets restored from the
|
524 |
* maximized state.
|
525 |
*
|
526 |
* @param normalY The new normalY property for this WindowInfo object
|
527 |
*/
|
528 |
public void setNormalY(int normalY) { |
529 |
if (!isMaximized()) {
|
530 |
setY(normalY); |
531 |
} |
532 |
else {
|
533 |
support.firePropertyChange("normalY", this.normalY, normalY); |
534 |
this.normalY = normalY;
|
535 |
} |
536 |
} |
537 |
|
538 |
/**
|
539 |
* Updates the normalY property for this WindowInfo
|
540 |
* object. It doesn't get reflected on the window (use
|
541 |
* <code>setNormalY</code> for that).
|
542 |
*
|
543 |
* @param normalY The new normalY property for this WindowInfo object
|
544 |
*/
|
545 |
public void updateNormalY(int normalY) { |
546 |
this.normalY = normalY;
|
547 |
if (!isMaximized())
|
548 |
y = normalY; |
549 |
} |
550 |
|
551 |
/**
|
552 |
* Sets the normalHeight property for this WindowInfo object. This sets the height
|
553 |
* position that the window would have when it gets restored from the
|
554 |
* maximized state.
|
555 |
*
|
556 |
* @param normalY The new normalHeight property for this WindowInfo object
|
557 |
*/
|
558 |
public void setNormalHeight(int normalHeight) { |
559 |
if (!isMaximized) {
|
560 |
setHeight(normalHeight); |
561 |
} |
562 |
else {
|
563 |
support.firePropertyChange("normalHeight", this.normalHeight, normalHeight); |
564 |
this.normalHeight = normalHeight;
|
565 |
} |
566 |
} |
567 |
|
568 |
/**
|
569 |
* Updates the normalHeight property for this WindowInfo
|
570 |
* object. It doesn't get reflected on the window (use
|
571 |
* <code>setNormalHeight</code> for that).
|
572 |
*
|
573 |
* @param normalHeight The new normalHeight property for this WindowInfo object
|
574 |
*/
|
575 |
public void updateNormalHeight(int normalHeight) { |
576 |
this.normalHeight = normalHeight;
|
577 |
if (!isMaximized) {
|
578 |
this.height = normalHeight;
|
579 |
} |
580 |
} |
581 |
|
582 |
/**
|
583 |
* Sets the normalWidth property for this WindowInfo object. This sets the width
|
584 |
* position that the window would have when it gets restored from the
|
585 |
* maximized state.
|
586 |
*
|
587 |
* @param normalY The new normalWidth property for this WindowInfo object
|
588 |
*/
|
589 |
public void setNormalWidth(int normalWidth) { |
590 |
if (!isMaximized()) {
|
591 |
setWidth(normalWidth); |
592 |
} |
593 |
else {
|
594 |
support.firePropertyChange("normalWidth", this.normalWidth, normalWidth); |
595 |
this.normalWidth = normalWidth;
|
596 |
} |
597 |
} |
598 |
|
599 |
/**
|
600 |
* Sets the minimum allowed size for the associated window. If null is provided,
|
601 |
* the minimum size is disabled (and thus
|
602 |
* the window can be resized to any size).
|
603 |
*
|
604 |
* @param minSize The minimum allowed size for the associated window.
|
605 |
*/
|
606 |
public void setMinimumSize(Dimension minSize) { |
607 |
support.firePropertyChange("minimumSize", this.minSize, minSize); |
608 |
this.minSize = minSize;
|
609 |
} |
610 |
|
611 |
/**
|
612 |
* Updates the minimum allowed size for the associated window. It doesn't
|
613 |
* get reflected on the window (use <code>setMinimumSize</code> for that).
|
614 |
*
|
615 |
* @param minSize The minimum allowed size for the associated window.
|
616 |
*/
|
617 |
public void updateMinimumSize(Dimension minSize) { |
618 |
this.minSize = minSize;
|
619 |
} |
620 |
|
621 |
/**
|
622 |
* Gets the minimum allowed size for the associated window.
|
623 |
*
|
624 |
* @return minSize The minimum allowed size for the associated window.
|
625 |
*/
|
626 |
public Dimension getMinimumSize() { |
627 |
return minSize;
|
628 |
} |
629 |
|
630 |
/**
|
631 |
* Updates the normalWidth property for this WindowInfo
|
632 |
* object. It doesn't get reflected on the window (use
|
633 |
* <code>setNormalWidth</code> for that).
|
634 |
*
|
635 |
* @param normalWidth The new normalHeight property for this WindowInfo object
|
636 |
*/
|
637 |
public void updateNormalWidth(int normalWidth) { |
638 |
this.normalWidth = normalWidth;
|
639 |
if (!isMaximized())
|
640 |
this.width = normalWidth;
|
641 |
} |
642 |
|
643 |
/**
|
644 |
* Maximize the associated window
|
645 |
*
|
646 |
* @param maximized
|
647 |
*/
|
648 |
public void setMaximized(boolean maximized) { |
649 |
support.firePropertyChange("maximized", this.isMaximized, maximized); |
650 |
this.isMaximized = maximized;
|
651 |
} |
652 |
|
653 |
/**
|
654 |
* Updates the maximized property for this WindowInfo
|
655 |
* object. It doesn't get reflected on the window (use
|
656 |
* <code>setMaximized</code> for that).
|
657 |
*
|
658 |
* @param maximized The new maximized property for this WindowInfo object
|
659 |
*/
|
660 |
public void updateMaximized(boolean maximized) { |
661 |
this.isMaximized = maximized;
|
662 |
} |
663 |
|
664 |
public void setMaximizable(boolean maximizable) { |
665 |
this.maximizable = maximizable;
|
666 |
} |
667 |
|
668 |
/**
|
669 |
* Sets the bounds of the associated window.
|
670 |
*
|
671 |
* @param x
|
672 |
* @param y
|
673 |
* @param width
|
674 |
* @param height
|
675 |
*/
|
676 |
private void setBounds(int x, int y, int width, int height) { |
677 |
setX(x); |
678 |
setY(y); |
679 |
setWidth(width); |
680 |
setHeight(height); |
681 |
} |
682 |
|
683 |
/**
|
684 |
* Updates the bounds for this WindowInfo object. It doesn't get reflected
|
685 |
* on the window (use <code>setBounds</code> for that).
|
686 |
*
|
687 |
* @param x
|
688 |
* @param y
|
689 |
* @param width
|
690 |
* @param height
|
691 |
*/
|
692 |
public void updateBounds(int x, int y, int width, int height) { |
693 |
this.x = x;
|
694 |
this.y = y;
|
695 |
this.width = width;
|
696 |
this.height = height;
|
697 |
if (!isMaximized()) {
|
698 |
this.normalX = x;
|
699 |
this.normalY = y;
|
700 |
this.normalWidth = width;
|
701 |
this.normalHeight = height;
|
702 |
} |
703 |
} |
704 |
|
705 |
/**
|
706 |
* Sets the normal bounds of the associated window. This sets the bounds
|
707 |
* that the window would have when it gets restored from the
|
708 |
* maximized state.
|
709 |
*
|
710 |
* @param x
|
711 |
* @param y
|
712 |
* @param width
|
713 |
* @param height
|
714 |
*/
|
715 |
public void setNormalBounds(int x, int y, int width, int height) { |
716 |
setNormalX(x); |
717 |
setNormalY(y); |
718 |
setNormalWidth(width); |
719 |
setNormalHeight(height); |
720 |
} |
721 |
|
722 |
/**
|
723 |
* Updates the normal bounds for this WindowInfo object. It doesn't get
|
724 |
* reflected on the window (use <code>setNormalBounds</code> for that).
|
725 |
*
|
726 |
* @param x
|
727 |
* @param y
|
728 |
* @param width
|
729 |
* @param height
|
730 |
*/
|
731 |
public void updateNormalBounds(int x, int y, int width, int height) { |
732 |
this.normalX = x;
|
733 |
this.normalY = y;
|
734 |
this.normalWidth = width;
|
735 |
this.normalHeight = height;
|
736 |
if (!isMaximized()) {
|
737 |
this.x = x;
|
738 |
this.y = y;
|
739 |
this.width = width;
|
740 |
this.height = height;
|
741 |
} |
742 |
} |
743 |
|
744 |
/**
|
745 |
* Gets the normal bounds of the associated window. This gets the bounds
|
746 |
* that the window would have when it gets restored from the
|
747 |
* maximized state.
|
748 |
*
|
749 |
* @return The normal bounds of the associated window.
|
750 |
*/
|
751 |
public Rectangle getNormalBounds() { |
752 |
return new Rectangle(getNormalX(), getNormalY(), getNormalWidth(), getNormalHeight()); |
753 |
} |
754 |
|
755 |
/**
|
756 |
* Sets the normal bounds of the associated window. This sets the bounds
|
757 |
* that the window would have when it gets restored from the
|
758 |
* maximized state.
|
759 |
*
|
760 |
* @param normalBounds
|
761 |
*/
|
762 |
public void setNormalBounds(Rectangle normalBounds) { |
763 |
setNormalBounds(normalBounds.x, normalBounds.y, normalBounds.width, normalBounds.height); |
764 |
} |
765 |
|
766 |
/**
|
767 |
* Updates the normal bounds for this WindowInfo object. It doesn't get
|
768 |
* reflected on the window (use <code>setNormalBounds</code> for that).
|
769 |
*
|
770 |
* @param normalBounds
|
771 |
*/
|
772 |
public void updateNormalBounds(Rectangle normalBounds) { |
773 |
updateNormalBounds(normalBounds.x, normalBounds.y, normalBounds.width, normalBounds.height); |
774 |
} |
775 |
|
776 |
/**
|
777 |
* Sets the bounds of the associated window.
|
778 |
*
|
779 |
* @param bounds
|
780 |
*/
|
781 |
public void setBounds(Rectangle bounds) { |
782 |
setBounds(bounds.x, bounds.y, bounds.width, bounds.height); |
783 |
} |
784 |
|
785 |
/**
|
786 |
* Updates the bounds for this WindowInfo object. It doesn't get reflected
|
787 |
* on the window (use <code>setBounds</code> for that).
|
788 |
*
|
789 |
* @param bounds
|
790 |
*/
|
791 |
public void updateBounds(Rectangle bounds) { |
792 |
updateBounds(bounds.x, bounds.y, bounds.width, bounds.height); |
793 |
} |
794 |
|
795 |
/**
|
796 |
* Gets the bounds of the associated window.
|
797 |
*
|
798 |
* @return The bounds of the associated window.
|
799 |
*/
|
800 |
public Rectangle getBounds() { |
801 |
return new Rectangle(x, y, width, height); |
802 |
} |
803 |
|
804 |
public int getNormalX() { |
805 |
if (normalX!=0) |
806 |
return this.normalX; |
807 |
else
|
808 |
return x;
|
809 |
} |
810 |
|
811 |
public int getNormalY() { |
812 |
if (normalY!=0) |
813 |
return this.normalY; |
814 |
else
|
815 |
return y;
|
816 |
} |
817 |
|
818 |
public int getNormalHeight() { |
819 |
if (normalHeight!=0) |
820 |
return this.normalHeight; |
821 |
else
|
822 |
return height;
|
823 |
} |
824 |
|
825 |
public int getNormalWidth() { |
826 |
if (normalWidth!=0) |
827 |
return this.normalWidth; |
828 |
else
|
829 |
return width;
|
830 |
} |
831 |
|
832 |
public boolean isMaximized() { |
833 |
return this.isMaximized; |
834 |
} |
835 |
|
836 |
/**
|
837 |
* Checks if the geometry of this window should be persisted in the
|
838 |
* project file. This is set by the persistWindow(boolean) method,
|
839 |
* and the default value is true.
|
840 |
*
|
841 |
* @return True if the geometry of this window should be persisted
|
842 |
* in the project files, false otherwise.
|
843 |
*/
|
844 |
public boolean checkPersistence() { |
845 |
return this.persistWindow; |
846 |
} |
847 |
|
848 |
/**
|
849 |
* Set whether the geometry of this window should be persisted in the
|
850 |
* project files.
|
851 |
*
|
852 |
* @param persist
|
853 |
*/
|
854 |
public void setPersistence(boolean persist) { |
855 |
this.persistWindow = persist;
|
856 |
} |
857 |
|
858 |
/**
|
859 |
* Gets the window properties in an XMLEntity object, suitable
|
860 |
* for persistence.
|
861 |
*
|
862 |
* @return An XMLEntity object containing the window properties, or null if the window was set as
|
863 |
* not persistent
|
864 |
* @throws SaveException
|
865 |
* @throws XMLException
|
866 |
* @throws SaveException
|
867 |
*/
|
868 |
public XMLEntity getXMLEntity() {
|
869 |
XMLEntity xml = new XMLEntity();
|
870 |
xml.setName("ViewInfoProperties");
|
871 |
xml.putProperty("X", this.getX()); |
872 |
xml.putProperty("Y", this.getY()); |
873 |
xml.putProperty("Width", this.getWidth()); |
874 |
xml.putProperty("Height", this.getHeight()); |
875 |
xml.putProperty("isVisible", this.isVisible()); |
876 |
xml.putProperty("isResizable", this.isResizable()); |
877 |
xml.putProperty("isMaximizable", this.isMaximizable()); |
878 |
xml.putProperty("isModal", this.isModal()); |
879 |
xml.putProperty("isModeless", this.isModeless()); |
880 |
xml.putProperty("isClosed", this.isClosed()); |
881 |
if (this.isMaximized()==true) { |
882 |
xml.putProperty("isMaximized", this.isMaximized()); |
883 |
xml.putProperty("normalX", this.getNormalX()); |
884 |
xml.putProperty("normalY", this.getNormalY()); |
885 |
xml.putProperty("normalWidth", this.getNormalWidth()); |
886 |
xml.putProperty("normalHeight", this.getNormalHeight()); |
887 |
} |
888 |
return xml;
|
889 |
} |
890 |
|
891 |
|
892 |
public static WindowInfo createFromXMLEntity(XMLEntity xml) |
893 |
{ |
894 |
WindowInfo result = new WindowInfo();
|
895 |
try {
|
896 |
result.setX(xml.getIntProperty("X"));
|
897 |
result.setY(xml.getIntProperty("Y"));
|
898 |
result.setHeight(xml.getIntProperty("Height"));
|
899 |
result.setWidth(xml.getIntProperty("Width"));
|
900 |
result.setClosed(xml.getBooleanProperty("isClosed"));
|
901 |
if (xml.contains("isMaximized")) { |
902 |
boolean maximized = xml.getBooleanProperty("isMaximized"); |
903 |
result.setMaximized(maximized); |
904 |
if (maximized==true) { |
905 |
result.setNormalBounds(xml.getIntProperty("normalX"), xml.getIntProperty("normalY"), xml.getIntProperty("normalWidth"), xml.getIntProperty("normalHeight")); |
906 |
} |
907 |
else {
|
908 |
result.setNormalBounds(result.getBounds()); |
909 |
} |
910 |
} |
911 |
} |
912 |
catch (com.iver.utiles.NotExistInXMLEntity ex) {
|
913 |
PluginServices.getLogger().warn(PluginServices.getText(null, "Window_properties_not_stored_correctly_Window_state_will_not_be_restored")); |
914 |
} |
915 |
|
916 |
return result;
|
917 |
} |
918 |
|
919 |
public void getPropertiesFromXMLEntity(XMLEntity xml) |
920 |
{ |
921 |
this.x = xml.getIntProperty("X"); |
922 |
this.y = xml.getIntProperty("Y"); |
923 |
this.height = xml.getIntProperty("Height"); |
924 |
this.width = xml.getIntProperty("Width"); |
925 |
this.isClosed = xml.getBooleanProperty("isClosed"); |
926 |
if (xml.contains("isMaximized")) { |
927 |
boolean maximized = xml.getBooleanProperty("isMaximized"); |
928 |
this.isMaximized = maximized;
|
929 |
if (maximized==true) { |
930 |
this.setNormalBounds(xml.getIntProperty("normalX"), xml.getIntProperty("normalY"), xml.getIntProperty("normalWidth"), xml.getIntProperty("normalHeight")); |
931 |
} |
932 |
} |
933 |
} |
934 |
} |