javamanager/javainstaller/installerui/javasrc/com/nokia/mj/impl/installer/ui/eswt2/ViewBase.java
branchRCL_3
changeset 60 6c158198356e
parent 59 e5618cc85d74
child 77 7cee158cb8cd
--- a/javamanager/javainstaller/installerui/javasrc/com/nokia/mj/impl/installer/ui/eswt2/ViewBase.java	Thu Jul 15 18:31:06 2010 +0300
+++ b/javamanager/javainstaller/installerui/javasrc/com/nokia/mj/impl/installer/ui/eswt2/ViewBase.java	Thu Aug 19 09:48:13 2010 +0300
@@ -34,6 +34,7 @@
 import org.eclipse.swt.graphics.Image;
 import org.eclipse.swt.graphics.Point;
 import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.internal.qt.WidgetConstant;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Button;
@@ -42,6 +43,7 @@
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Widget;
 
 /**
  * Base class for different InstallerUi views.
@@ -50,6 +52,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 */
@@ -99,6 +103,7 @@
         iParent = (Shell)aParent;
 
         iContainer = new Composite(iParent, 0);
+        setCssId(iContainer, "dialogArea");
         iContainer.setVisible(false);
 
         iColumns = aColumns;
@@ -216,7 +221,7 @@
     /** Set title for this view. */
     public void setTitle(String aTitle)
     {
-        // Dialog shells have no title anymore
+        // Dialog shells have no title.
     }
 
     /** Disposes this view. */
@@ -341,12 +346,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 +360,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 +373,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);
@@ -434,6 +441,14 @@
     }
 
     /**
+     * Sets CSS id for given widget.
+     */
+    protected void setCssId(Widget aWidget, String aCssId)
+    {
+        aWidget.setData(WidgetConstant.CSS_ID, aCssId);
+    }
+
+    /**
      * Adds header used in installation views.
      */
     protected void addHeader(
@@ -450,26 +465,28 @@
         boolean aSecurityButton)
     {
         // Add title.
-        String title = InstallerUiTexts.get(InstallerUiTexts.INSTALL_QUERY);
+        if (aTitle == null)
+        {
+            aTitle = InstallerUiTexts.get(InstallerUiTexts.INSTALL_QUERY);
+            if (aInstallInfo != null && aInstallInfo.getOldVersion() != null)
+            {
+                aTitle = InstallerUiTexts.get(InstallerUiTexts.UPDATE_QUERY);
+            }
+        }
+        Label titleLabel = createLabel(aTitle, getColumns() - 1, SWT.WRAP);
+        setCssId(titleLabel, "heading");
+
         if (aInstallInfo != null)
         {
-            if (aInstallInfo.getOldVersion() != null)
-            {
-                title = InstallerUiTexts.get(InstallerUiTexts.UPDATE_QUERY);
-            }
             iCertificates = aInstallInfo.getCertificates();
         }
-        if (aUninstallInfo != null)
+        else if (aUninstallInfo != null)
         {
-            title = "Uninstall?";
             iCertificates = aUninstallInfo.getCertificates();
         }
-        Label titleLabel = createLabel(aTitle, getColumns() - 1, SWT.WRAP);
-        titleLabel.setFont(iInstallerUi.getBoldFont());
-
         if (aSecurityButton)
         {
-            // Add security icon.
+            // Add security button.
             createSecurityButton();
         }
         else
@@ -501,11 +518,12 @@
         {
             iconColumns = 2;
             Label iconLabel = createLabel(iSuiteIcon, iconColumns, SWT.NONE);
+            setCssId(iconLabel, "contentIcon");
         }
 
         // Create a Composite for displaying application info.
         iAppInfoScrolledComposite =
-            new ScrolledComposite(getComposite(), SWT.H_SCROLL | SWT.V_SCROLL);
+            new ScrolledComposite(getComposite(), SWT.V_SCROLL);
         iAppInfoScrolledComposite.setAlwaysShowScrollBars(false);
         iAppInfoScrolledComposite.setExpandHorizontal(true);
         GridData gridData = new GridData(GridData.FILL_BOTH);
@@ -514,6 +532,7 @@
         iAppInfoComposite = new Composite(iAppInfoScrolledComposite, SWT.NONE);
         iAppInfoComposite.setLayout(new GridLayout(1, true));
         iAppInfoScrolledComposite.setContent(iAppInfoComposite);
+        setCssId(iAppInfoScrolledComposite, "appInfoArea");
     }
 
     /**
@@ -530,7 +549,7 @@
         // Add suite name and version.
         createAppInfoLabel(
             InstallerUiTexts.get(
-                InstallerUiTexts.SUITE_NAME,
+                InstallerUiTexts.SUITE_NAME_VERSION,
                 new String[] { aInstallInfo.getName(),
                                aInstallInfo.getVersion() }));
         if (aFull)
@@ -553,10 +572,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 Object[] { new Integer((int)(1 + size/(1024*1024))) }));
+            }
+            else
+            {
+                createAppInfoLabel(
+                    InstallerUiTexts.get(
+                        InstallerUiTexts.SIZE_KB,
+                        new Object[] { new Integer((int)(1 + size/1024)) }));
+            }
         }
         if (aFull)
         {
@@ -639,7 +668,7 @@
         GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
         gridData.horizontalSpan = aColumns;
         gridData.horizontalAlignment = SWT.CENTER;
-        gridData.verticalAlignment = SWT.CENTER;
+        gridData.verticalAlignment = SWT.TOP;
         label.setLayoutData(gridData);
         return label;
     }
@@ -671,6 +700,7 @@
     protected Label createSecurityLabel(boolean aIdentified)
     {
         Label label = createLabel((Image)null, 1, SWT.NONE);
+        setCssId(label, "securityLabel");
         Image securityIcon = null;
         if (iInstallerUi != null)
         {
@@ -691,6 +721,7 @@
     protected Button createSecurityButton()
     {
         Button button = new Button(getComposite(), SWT.PUSH);
+        setCssId(button, "securityButton");
         GridData gridData = new GridData(
             GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL);
         gridData.horizontalSpan = 1;