Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorElshad Seyidmammadov2016-04-22 09:39:30 -0400
committerElshad Seyidmammadov2016-04-22 16:18:11 -0400
commit890d14077fcded092a9bbebd32ef168e5b09afb3 (patch)
tree165c0ffeb418b54dbd9aa6832bdfc9f86b125305 /bundles
parent88dd4220dc29d7e5b3a187a3d43f1f457afe7bc7 (diff)
downloadorg.eclipse.rap-890d14077fcded092a9bbebd32ef168e5b09afb3.tar.gz
org.eclipse.rap-890d14077fcded092a9bbebd32ef168e5b09afb3.tar.xz
org.eclipse.rap-890d14077fcded092a9bbebd32ef168e5b09afb3.zip
Position SWT Dialogs in display center instead of parent shell center
When website-like scrolling enabled, usually the parent Shell size is bigger in height than the Display (browser window) height. To avoid opening of blocking shell (Dialog) outside viewport, the dialogs must be positioned in the middle of Display (viewport). Change-Id: I1abc4bd9b593070215185bf3972a11f2c7d12ef8 Signed-off-by: Elshad Seyidmammadov <elshad@eclipsesource.com>
Diffstat (limited to 'bundles')
-rw-r--r--bundles/org.eclipse.rap.filedialog/src/org/eclipse/swt/widgets/FileDialog.java6
-rw-r--r--bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/widgets/ColorDialog.java6
-rw-r--r--bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/widgets/FontDialog.java6
-rw-r--r--bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/widgets/MessageBox.java6
4 files changed, 12 insertions, 12 deletions
diff --git a/bundles/org.eclipse.rap.filedialog/src/org/eclipse/swt/widgets/FileDialog.java b/bundles/org.eclipse.rap.filedialog/src/org/eclipse/swt/widgets/FileDialog.java
index 038a7bd302..8ab8cf53d0 100644
--- a/bundles/org.eclipse.rap.filedialog/src/org/eclipse/swt/widgets/FileDialog.java
+++ b/bundles/org.eclipse.rap.filedialog/src/org/eclipse/swt/widgets/FileDialog.java
@@ -244,9 +244,9 @@ public class FileDialog extends Dialog {
prefSize.y += 165; // ensure space for five files
}
shell.setMinimumSize( prefSize );
- Rectangle parentSize = getParent().getBounds();
- int locationX = ( parentSize.width - prefSize.x ) / 2 + parentSize.x;
- int locationY = ( parentSize.height - prefSize.y ) / 2 + parentSize.y;
+ Rectangle displaySize = getParent().getDisplay().getBounds();
+ int locationX = ( displaySize.width - prefSize.x ) / 2 + displaySize.x;
+ int locationY = ( displaySize.height - prefSize.y ) / 2 + displaySize.y;
shell.setBounds( locationX, locationY, prefSize.x, prefSize.y );
// set spacer real layout data after shell prefer size calculation
spacer.setLayoutData( createHorizontalFillData() );
diff --git a/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/widgets/ColorDialog.java b/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/widgets/ColorDialog.java
index b47a92f71d..ddfab696c8 100644
--- a/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/widgets/ColorDialog.java
+++ b/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/widgets/ColorDialog.java
@@ -325,11 +325,11 @@ public class ColorDialog extends Dialog {
private void configureShell() {
shell.setText( title );
- Rectangle parentSize = parent.getBounds();
+ Rectangle displaySize = parent.getDisplay().getBounds();
Point prefSize = shell.computeSize( SWT.DEFAULT, SWT.DEFAULT );
shell.setSize( prefSize );
- int locationX = ( parentSize.width - prefSize.x ) / 2 + parentSize.x;
- int locationY = ( parentSize.height - prefSize.y ) / 2 + parentSize.y;
+ int locationX = ( displaySize.width - prefSize.x ) / 2 + displaySize.x;
+ int locationY = ( displaySize.height - prefSize.y ) / 2 + displaySize.y;
shell.setLocation( new Point( locationX, locationY ) );
shell.pack();
}
diff --git a/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/widgets/FontDialog.java b/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/widgets/FontDialog.java
index 074db92491..c657f51da8 100644
--- a/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/widgets/FontDialog.java
+++ b/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/widgets/FontDialog.java
@@ -254,9 +254,9 @@ public class FontDialog extends Dialog {
// leave some space in preview area for larger fonts
prefSize.y += 50;
shell.setSize( prefSize );
- Rectangle parentSize = parent.getBounds();
- int locationX = ( parentSize.width - prefSize.x ) / 2 + parentSize.x;
- int locationY = ( parentSize.height - prefSize.y ) / 2 + parentSize.y;
+ Rectangle displaySize = parent.getDisplay().getBounds();
+ int locationX = ( displaySize.width - prefSize.x ) / 2 + displaySize.x;
+ int locationY = ( displaySize.height - prefSize.y ) / 2 + displaySize.y;
shell.setLocation( locationX, locationY );
}
diff --git a/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/widgets/MessageBox.java b/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/widgets/MessageBox.java
index b4e3750b05..02a53156ea 100644
--- a/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/widgets/MessageBox.java
+++ b/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/widgets/MessageBox.java
@@ -192,9 +192,9 @@ public class MessageBox extends Dialog {
private Rectangle computeShellBounds() {
Rectangle result = new Rectangle( 0, 0, 0, 0 );
Point preferredSize = shell.computeSize( SWT.DEFAULT, SWT.DEFAULT );
- Rectangle parentSize = parent.getBounds();
- result.x = ( parentSize.width - preferredSize.x ) / 2 + parentSize.x;
- result.y = ( parentSize.height - preferredSize.y ) / 2 + parentSize.y;
+ Rectangle displaySize = parent.getDisplay().getBounds();
+ result.x = ( displaySize.width - preferredSize.x ) / 2 + displaySize.x;
+ result.y = ( displaySize.height - preferredSize.y ) / 2 + displaySize.y;
result.width = Math.min( preferredSize.x, MAX_WIDTH );
result.height = preferredSize.y;
return result;

Back to the top