Revision 7345 branches/v10/frameworks/_fwAndami/src/com/iver/andami/ui/mdiManager/WindowInfo.java
WindowInfo.java | ||
---|---|---|
44 | 44 |
import java.beans.PropertyChangeListener; |
45 | 45 |
import java.beans.PropertyChangeSupport; |
46 | 46 |
|
47 |
import com.iver.andami.PluginServices; |
|
48 |
import com.iver.utiles.XMLEntity; |
|
47 | 49 |
|
50 |
|
|
48 | 51 |
/** |
49 | 52 |
* DOCUMENT ME! |
50 | 53 |
* |
... | ... | |
78 | 81 |
/** DOCUMENT ME! */ |
79 | 82 |
private boolean modal = false; |
80 | 83 |
private boolean modeless = false; |
84 |
|
|
85 |
/** |
|
86 |
* Do we want to persist the geometry of this window in the project file? |
|
87 |
*/ |
|
88 |
private boolean persistWindow = true; |
|
81 | 89 |
|
82 | 90 |
/** |
83 | 91 |
* Se usa para poner una ventana de tipo paleta, por |
... | ... | |
136 | 144 |
public void setX(int x) { |
137 | 145 |
support.firePropertyChange("x", this.x, x); |
138 | 146 |
this.x = x; |
147 |
if (!isMaximized) |
|
148 |
this.normalX = x; |
|
139 | 149 |
} |
140 | 150 |
|
141 | 151 |
/** |
... | ... | |
155 | 165 |
public void setY(int y) { |
156 | 166 |
support.firePropertyChange("y", this.y, y); |
157 | 167 |
this.y = y; |
168 |
if (!isMaximized) |
|
169 |
this.normalY = y; |
|
158 | 170 |
} |
159 | 171 |
|
160 | 172 |
/** |
... | ... | |
261 | 273 |
/** |
262 | 274 |
* establece la propiedad altura |
263 | 275 |
* |
264 |
* @param i
|
|
276 |
* @param h
|
|
265 | 277 |
*/ |
266 |
public void setHeight(int i) { |
|
267 |
support.firePropertyChange("height", this.height, i); |
|
268 |
height = i; |
|
278 |
public void setHeight(int h) { |
|
279 |
support.firePropertyChange("height", this.height, h); |
|
280 |
height = h; |
|
281 |
if (!isMaximized) |
|
282 |
this.normalHeight = h; |
|
269 | 283 |
} |
270 | 284 |
|
271 | 285 |
/** |
... | ... | |
273 | 287 |
* |
274 | 288 |
* @param i |
275 | 289 |
*/ |
276 |
public void setWidth(int i) { |
|
277 |
support.firePropertyChange("width", this.width, i); |
|
278 |
width = i; |
|
290 |
public void setWidth(int w) { |
|
291 |
support.firePropertyChange("width", this.width, w); |
|
292 |
width = w; |
|
293 |
if (!isMaximized) |
|
294 |
this.width = w; |
|
279 | 295 |
} |
280 | 296 |
|
281 | 297 |
/** |
... | ... | |
341 | 357 |
this.visible = vi.visible; |
342 | 358 |
this.title = vi.title; |
343 | 359 |
this.id = vi.id; |
360 |
this.normalHeight = vi.normalHeight; |
|
361 |
this.normalWidth = vi.normalWidth; |
|
362 |
this.normalX = vi.normalX; |
|
363 |
this.normalY = vi.normalY; |
|
364 |
this.isClosed = vi.isClosed; |
|
365 |
this.persistWindow = vi.persistWindow; |
|
344 | 366 |
} |
345 | 367 |
public void toPalette(boolean b){ |
346 | 368 |
this.palette=b; |
... | ... | |
362 | 384 |
|
363 | 385 |
/* Specifies whether a view is open (showing) or closed */ |
364 | 386 |
public void setClosed(boolean closed) { |
387 |
support.firePropertyChange("closed", this.isClosed, closed); |
|
365 | 388 |
this.isClosed = closed; |
366 | 389 |
} |
367 | 390 |
|
368 | 391 |
public void setNormalX(int normalX) { |
392 |
support.firePropertyChange("normalX", this.normalX, normalX); |
|
369 | 393 |
this.normalX = normalX; |
370 | 394 |
} |
371 | 395 |
|
372 | 396 |
public void setNormalY(int normalY) { |
397 |
support.firePropertyChange("normalY", this.normalY, normalY); |
|
373 | 398 |
this.normalY = normalY; |
374 | 399 |
} |
375 | 400 |
|
376 | 401 |
public void setNormalHeight(int normalHeight) { |
402 |
support.firePropertyChange("normalHeight", this.normalHeight, normalHeight); |
|
377 | 403 |
this.normalHeight = normalHeight; |
378 | 404 |
} |
379 | 405 |
|
380 | 406 |
public void setNormalWidth(int normalWidth) { |
407 |
support.firePropertyChange("normalWidth", this.normalWidth, normalWidth); |
|
381 | 408 |
this.normalWidth = normalWidth; |
382 | 409 |
} |
383 | 410 |
|
384 | 411 |
|
385 | 412 |
public void setMaximized(boolean maximized) { |
413 |
support.firePropertyChange("maximized", this.isMaximized, maximized); |
|
386 | 414 |
this.isMaximized = maximized; |
387 | 415 |
} |
388 | 416 |
|
389 | 417 |
private void setBounds(int x, int y, int width, int height) { |
418 |
support.firePropertyChange("x", this.height, x); |
|
390 | 419 |
this.x = x; |
420 |
support.firePropertyChange("y", this.height, y); |
|
391 | 421 |
this.y = y; |
422 |
support.firePropertyChange("width", this.width, width); |
|
392 | 423 |
this.width = width; |
424 |
support.firePropertyChange("height", this.height, height); |
|
393 | 425 |
this.height = height; |
394 | 426 |
} |
395 | 427 |
|
396 | 428 |
public void setNormalBounds(int x, int y, int width, int height) { |
429 |
support.firePropertyChange("normalX", this.normalX, x); |
|
397 | 430 |
this.normalX = x; |
431 |
support.firePropertyChange("normalY", this.normalY, y); |
|
398 | 432 |
this.normalY = y; |
433 |
support.firePropertyChange("width", this.width, width); |
|
399 | 434 |
this.normalWidth = width; |
435 |
support.firePropertyChange("height", this.height, height); |
|
400 | 436 |
this.normalHeight = height; |
401 | 437 |
} |
402 | 438 |
|
... | ... | |
405 | 441 |
} |
406 | 442 |
|
407 | 443 |
public void setNormalBounds(Rectangle normalBounds) { |
444 |
support.firePropertyChange("normalX", this.normalX, normalBounds.x); |
|
408 | 445 |
normalX = normalBounds.x; |
446 |
support.firePropertyChange("normalY", this.normalY, normalBounds.y); |
|
409 | 447 |
normalY = normalBounds.y; |
448 |
support.firePropertyChange("normalHeight", this.normalHeight, normalBounds.height); |
|
410 | 449 |
normalHeight = normalBounds.height; |
450 |
support.firePropertyChange("normalWidth", this.normalWidth, normalBounds.width); |
|
411 | 451 |
normalWidth = normalBounds.width; |
412 | 452 |
} |
413 | 453 |
|
414 | 454 |
public void setBounds(Rectangle bounds) { |
455 |
support.firePropertyChange("x", this.x, bounds.x); |
|
415 | 456 |
x = bounds.x; |
457 |
support.firePropertyChange("y", this.y, bounds.y); |
|
416 | 458 |
y = bounds.y; |
459 |
support.firePropertyChange("height", this.height, bounds.height); |
|
417 | 460 |
height = bounds.height; |
461 |
support.firePropertyChange("width", this.width, bounds.width); |
|
418 | 462 |
width = bounds.width; |
419 | 463 |
} |
420 | 464 |
|
... | ... | |
453 | 497 |
public boolean isMaximized() { |
454 | 498 |
return this.isMaximized; |
455 | 499 |
} |
500 |
|
|
501 |
/** |
|
502 |
* Checks if the geometry of this window should be persisted in the |
|
503 |
* project file. This is set by the persistWindow(boolean) method, |
|
504 |
* and the default value is true. |
|
505 |
* |
|
506 |
* @return True if the geometry of this window should be persisted |
|
507 |
* in the project files, false otherwise. |
|
508 |
*/ |
|
509 |
public boolean checkPersistence() { |
|
510 |
return this.persistWindow; |
|
511 |
} |
|
512 |
|
|
513 |
/** |
|
514 |
* Set whether the geometry of this window should be persisted in the |
|
515 |
* project files. |
|
516 |
* |
|
517 |
* @param persist |
|
518 |
*/ |
|
519 |
public void setPersistence(boolean persist) { |
|
520 |
this.persistWindow = persist; |
|
521 |
} |
|
522 |
|
|
523 |
/** |
|
524 |
* Gets the window properties in an XMLEntity object, suitable |
|
525 |
* for persistence. |
|
526 |
* |
|
527 |
* @return An XMLEntity object containing the window properties, or null if the window was set as |
|
528 |
* not persistent |
|
529 |
* @throws SaveException |
|
530 |
* @throws XMLException |
|
531 |
* @throws SaveException |
|
532 |
*/ |
|
533 |
public XMLEntity getXMLEntity() { |
|
534 |
|
|
535 |
if (!checkPersistence()) // if the windows was set as not persistent, return null (we don't want to save this window) |
|
536 |
return null; |
|
537 |
|
|
538 |
XMLEntity xml = new XMLEntity(); |
|
539 |
xml.setName("ViewInfoProperties"); |
|
540 |
xml.putProperty("X", this.getX()); |
|
541 |
xml.putProperty("Y", this.getY()); |
|
542 |
xml.putProperty("Width", this.getWidth()); |
|
543 |
xml.putProperty("Height", this.getHeight()); |
|
544 |
xml.putProperty("isVisible", this.isVisible()); |
|
545 |
xml.putProperty("isResizable", this.isResizable()); |
|
546 |
xml.putProperty("isMaximizable", this.isMaximizable()); |
|
547 |
xml.putProperty("isModal", this.isModal()); |
|
548 |
xml.putProperty("isModeless", this.isModeless()); |
|
549 |
xml.putProperty("isClosed", this.isClosed()); |
|
550 |
if (this.isMaximized()==true) { |
|
551 |
xml.putProperty("isMaximized", this.isMaximized()); |
|
552 |
xml.putProperty("normalX", this.getNormalX()); |
|
553 |
xml.putProperty("normalY", this.getNormalY()); |
|
554 |
xml.putProperty("normalWidth", this.getNormalWidth()); |
|
555 |
xml.putProperty("normalHeight", this.getNormalHeight()); |
|
556 |
} |
|
557 |
return xml; |
|
558 |
} |
|
559 |
|
|
560 |
|
|
561 |
public static WindowInfo createFromXMLEntity(XMLEntity xml) |
|
562 |
{ |
|
563 |
WindowInfo result = new WindowInfo(); |
|
564 |
result.setX(xml.getIntProperty("X")); |
|
565 |
result.setY(xml.getIntProperty("Y")); |
|
566 |
result.setHeight(xml.getIntProperty("Height")); |
|
567 |
result.setWidth(xml.getIntProperty("Width")); |
|
568 |
result.setClosed(xml.getBooleanProperty("isClosed")); |
|
569 |
if (xml.contains("isMaximized")) { |
|
570 |
boolean maximized = xml.getBooleanProperty("isMaximized"); |
|
571 |
result.setMaximized(maximized); |
|
572 |
if (maximized==true) { |
|
573 |
result.setNormalBounds(xml.getIntProperty("normalX"), xml.getIntProperty("normalY"), xml.getIntProperty("normalWidth"), xml.getIntProperty("normalHeight")); |
|
574 |
} |
|
575 |
else { |
|
576 |
result.setNormalBounds(result.getBounds()); |
|
577 |
} |
|
578 |
} |
|
579 |
|
|
580 |
return result; |
|
581 |
} |
|
582 |
|
|
583 |
public void getPropertiesFromXMLEntity(XMLEntity xml) |
|
584 |
{ |
|
585 |
this.x = xml.getIntProperty("X"); |
|
586 |
this.y = xml.getIntProperty("Y"); |
|
587 |
this.height = xml.getIntProperty("Height"); |
|
588 |
this.width = xml.getIntProperty("Width"); |
|
589 |
this.isClosed = xml.getBooleanProperty("isClosed"); |
|
590 |
if (xml.contains("isMaximized")) { |
|
591 |
boolean maximized = xml.getBooleanProperty("isMaximized"); |
|
592 |
this.isMaximized = maximized; |
|
593 |
if (maximized==true) { |
|
594 |
this.setNormalBounds(xml.getIntProperty("normalX"), xml.getIntProperty("normalY"), xml.getIntProperty("normalWidth"), xml.getIntProperty("normalHeight")); |
|
595 |
} |
|
596 |
} |
|
597 |
} |
|
456 | 598 |
} |
Also available in: Unified diff