javamanager/javainstaller/installerui/javasrc/com/nokia/mj/impl/installer/ui/eswt2/ViewBase.java
changeset 35 85266cc22c7f
parent 26 dc7c549001d5
child 47 f40128debb5d
child 49 35baca0e7a2e
--- a/javamanager/javainstaller/installerui/javasrc/com/nokia/mj/impl/installer/ui/eswt2/ViewBase.java	Thu May 27 12:49:31 2010 +0300
+++ b/javamanager/javainstaller/installerui/javasrc/com/nokia/mj/impl/installer/ui/eswt2/ViewBase.java	Fri Jun 11 13:33:44 2010 +0300
@@ -50,6 +50,8 @@
 {
     /** Maximum view height in percentage from display client area height. */
     protected static final int MAX_VIEW_HEIGHT = 80;
+    /** Maximum view width in percentage from display client area width. */
+    protected static final int MAX_VIEW_WIDTH = 90;
     /** Parent shell for this view. */
     protected Shell iParent = null;
     /** Container for the contents of the view */
@@ -341,12 +343,12 @@
                     SWT.DEFAULT, SWT.DEFAULT));
         }
 
-        int contentWidth = iDefaultContentSize.x;
+        int contentWidth = iDefaultContentSize.x * MAX_VIEW_WIDTH / 100;
         if (aVerticalScrollBarVisible)
         {
             int verticalScrollBarWidth =
                 getScrolledComposite().getVerticalBar().getSize().x;
-            contentWidth = iDefaultContentSize.x - verticalScrollBarWidth;
+            contentWidth -= verticalScrollBarWidth;
         }
 
         // Recalculate the size of the content.
@@ -355,7 +357,7 @@
         Point cmdContentSize = cmdComp.computeSize(iDefaultContentSize.x, SWT.DEFAULT);
         cmdComp.setSize(cmdContentSize);
 
-        // Adjust Shell height. The Shell never changes the x position, nor the width.
+        // Adjust Shell height and width.
         Rectangle dispRect = shell.getDisplay().getClientArea();
         int offset = iDefaultContentSize.y - contentSize.y - cmdContentSize.y;
 
@@ -368,18 +370,20 @@
             offset -= maxHeight - newHeight;
             newHeight = maxHeight;
         }
+        int newWidth = defShellBounds.width;
+        int maxWidth = dispRect.width * MAX_VIEW_WIDTH / 100;
+        if (newWidth > maxWidth)
+        {
+            newWidth = maxWidth;
+        }
 
+        // Always center horizontally and vertically.
         Rectangle dispBounds = shell.getDisplay().getBounds();
+        int x = dispBounds.width - newWidth;
         int y = dispBounds.height - newHeight;
-        // Always center vertically.
+        x /= 2;
         y /= 2;
-        // For landscape orientation center vertically
-        //if (dispRect.width > dispRect.height)
-        //{
-        //    y /= 2;
-        //}
-        // Set bounds when command Buttons are in use.
-        shell.setBounds(defShellBounds.x, y, defShellBounds.width, newHeight);
+        shell.setBounds(x, y, newWidth, newHeight);
         Rectangle clientArea = shell.getClientArea();
         iContainer.setSize(clientArea.width, clientArea.height);
         iContainer.layout(true);
@@ -558,10 +562,20 @@
         }
         if (size > 0)
         {
-            createAppInfoLabel(
-                InstallerUiTexts.get(
-                    InstallerUiTexts.SIZE_KB,
-                    new String[] { Long.toString(1 + size/1024) }));
+            if (size > 1024*1024)
+            {
+                createAppInfoLabel(
+                    InstallerUiTexts.get(
+                        InstallerUiTexts.SIZE_MB,
+                        new String[] { Long.toString(1 + size/(1024*1024)) }));
+            }
+            else
+            {
+                createAppInfoLabel(
+                    InstallerUiTexts.get(
+                        InstallerUiTexts.SIZE_KB,
+                        new String[] { Long.toString(1 + size/1024) }));
+            }
         }
         if (aFull)
         {