restore dialog size with respect to location, to fit to the right screen

This commit is contained in:
Kirill Kalishev
2011-12-05 16:30:41 +03:00
parent 9ba6f76c53
commit 0dd83518ef
@@ -560,10 +560,14 @@ public class DialogWrapperPeerImpl extends DialogWrapperPeer implements FocusTra
}
public void setSize(int width, int height) {
Point location = getLocation();
_setSizeForLocation(width, height, null);
}
private void _setSizeForLocation(int width, int height, @Nullable Point initial) {
Point location = initial != null ? initial : getLocation();
Rectangle rect = new Rectangle(location.x, location.y, width, height);
ScreenUtil.fitToScreen(rect);
if (location.x != rect.x || location.y != rect.y) {
if (initial != null || location.x != rect.x || location.y != rect.y) {
setLocation(rect.x, rect.y);
}
@@ -609,7 +613,7 @@ public class DialogWrapperPeerImpl extends DialogWrapperPeer implements FocusTra
Dimension size = DimensionService.getInstance().getSize(myDimensionServiceKey, projectGuess);
if (size != null) {
myInitialSize = (Dimension)size.clone();
setSize(myInitialSize);
_setSizeForLocation(myInitialSize.width, myInitialSize.height, location);
}
}