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