javamanager/javainstaller/installerui/javasrc/com/nokia/mj/impl/installer/ui/eswt2/ViewBase.java
changeset 80 d6dafc5d983f
parent 72 1f0034e370aa
child 87 1627c337e51e
equal deleted inserted replaced
78:71ad690e91f5 80:d6dafc5d983f
    66     private ScrolledComposite iAppInfoScrolledComposite = null;
    66     private ScrolledComposite iAppInfoScrolledComposite = null;
    67     /** Composite to which application info is added. */
    67     /** Composite to which application info is added. */
    68     private Composite iAppInfoComposite = null;
    68     private Composite iAppInfoComposite = null;
    69     /** Composite to which command buttons are added. */
    69     /** Composite to which command buttons are added. */
    70     private Composite iCommandComposite = null;
    70     private Composite iCommandComposite = null;
    71     /** Application suite icon */
       
    72     protected Image iSuiteIcon = null;
       
    73     /** InstallerUi owning this view. */
    71     /** InstallerUi owning this view. */
    74     protected InstallerUiEswt iInstallerUi = null;
    72     protected InstallerUiEswt iInstallerUi = null;
    75     /** True if this view is visible. */
    73     /** True if this view is visible. */
    76     private boolean iVisible = false;
    74     private boolean iVisible = false;
    77     /** Number of columns for this view's GridLayout. */
    75     /** Number of columns for this view's GridLayout. */
    81     /** Certificate details view. */
    79     /** Certificate details view. */
    82     private CertificateDetailsView iCertificateDetailsView = null;
    80     private CertificateDetailsView iCertificateDetailsView = null;
    83     /** Certificates for this application. */
    81     /** Certificates for this application. */
    84     protected SigningCertificate[] iCertificates = null;
    82     protected SigningCertificate[] iCertificates = null;
    85 
    83 
       
    84     /** Application suite icon */
       
    85     protected Image iSuiteIcon = null;
       
    86     /** Label for application suite icon */
       
    87     protected Label iSuiteIconLabel = null;
       
    88     /** InputStream for application suite icon */
       
    89     private InputStream iSuiteIconInputStream = null;
       
    90     /** Path for application suite icon */
       
    91     private String iSuiteIconPath = null;
       
    92 
    86     /** Constructor */
    93     /** Constructor */
    87     protected ViewBase()
    94     protected ViewBase()
    88     {
    95     {
    89     }
    96     }
    90 
    97 
   171     public Composite getComposite()
   178     public Composite getComposite()
   172     {
   179     {
   173         return iComposite;
   180         return iComposite;
   174     }
   181     }
   175 
   182 
   176     /** Returns ScrolledComposite for Composite. */
   183     /** Returns ScrolledComposite for this view. */
   177     public ScrolledComposite getScrolledComposite()
   184     public ScrolledComposite getScrolledComposite()
   178     {
   185     {
       
   186         if (iAppInfoScrolledComposite != null)
       
   187         {
       
   188             return iAppInfoScrolledComposite;
       
   189         }
   179         return iScrolledComposite;
   190         return iScrolledComposite;
   180     }
   191     }
   181 
   192 
   182     /** Returns composite for application info widgets. */
   193     /** Returns composite for application info widgets. */
   183     public Composite getAppInfoComposite()
   194     public Composite getAppInfoComposite()
   319     protected void updateSize()
   330     protected void updateSize()
   320     {
   331     {
   321         getShell().setRedraw(false);
   332         getShell().setRedraw(false);
   322         // First calculate size without vertical scrollbar.
   333         // First calculate size without vertical scrollbar.
   323         doUpdateSize(false);
   334         doUpdateSize(false);
       
   335         // After layout has been calculated, load and set the
       
   336         // suite icon with correct size.
       
   337         setSuiteIcon();
       
   338         if (getScrolledComposite() != null &&
       
   339             getScrolledComposite().getVerticalBar() != null)
       
   340         {
       
   341             log("updateSize: getScrolledComposite().getVerticalBar().getVisible()="
       
   342                 + getScrolledComposite().getVerticalBar().getVisible());
       
   343         }
   324         if (getScrolledComposite() != null &&
   344         if (getScrolledComposite() != null &&
   325                 getScrolledComposite().getVerticalBar() != null &&
   345                 getScrolledComposite().getVerticalBar() != null &&
   326                 getScrolledComposite().getVerticalBar().getVisible())
   346                 getScrolledComposite().getVerticalBar().getVisible())
   327         {
   347         {
   328             // If scrollbar is visible recalculate size with scrollbar.
   348             // If scrollbar is visible recalculate size with scrollbar.
   339         Composite cmdComp = getCommandComposite();
   359         Composite cmdComp = getCommandComposite();
   340 
   360 
   341         if (getAppInfoComposite() != null)
   361         if (getAppInfoComposite() != null)
   342         {
   362         {
   343             // Recalculate the size of the app info composite.
   363             // Recalculate the size of the app info composite.
   344             getAppInfoComposite().setSize(
   364             if (aVerticalScrollBarVisible)
   345                 getAppInfoComposite().computeSize(
   365             {
   346                     SWT.DEFAULT, SWT.DEFAULT));
   366                 int contentWidth = getAppInfoComposite().getSize().x -
       
   367                     getScrolledComposite().getVerticalBar().getSize().x;
       
   368                 getAppInfoComposite().setSize(
       
   369                     getAppInfoComposite().computeSize(
       
   370                         contentWidth, SWT.DEFAULT));
       
   371             }
       
   372             else
       
   373             {
       
   374                 getAppInfoComposite().setSize(
       
   375                     getAppInfoComposite().computeSize(
       
   376                         SWT.DEFAULT, SWT.DEFAULT));
       
   377             }
   347         }
   378         }
   348 
   379 
   349         int contentWidth = iDefaultContentSize.x * MAX_VIEW_WIDTH / 100;
   380         int contentWidth = iDefaultContentSize.x * MAX_VIEW_WIDTH / 100;
   350         if (aVerticalScrollBarVisible)
   381         if (aVerticalScrollBarVisible)
   351         {
   382         {
   493         {
   524         {
   494             // Add security icon.
   525             // Add security icon.
   495             createSecurityLabel(iCertificates != null);
   526             createSecurityLabel(iCertificates != null);
   496         }
   527         }
   497 
   528 
   498         // Add suite icon.
   529         // Init suite icon data.
   499         InputStream iconInputStream = null;
       
   500         String iconPath = null;
       
   501         if (aInstallInfo != null)
   530         if (aInstallInfo != null)
   502         {
   531         {
   503             iconInputStream = aInstallInfo.getIconInputStream();
   532             iSuiteIconInputStream = aInstallInfo.getIconInputStream();
   504             iconPath = aInstallInfo.getIconPath();
   533             iSuiteIconPath = aInstallInfo.getIconPath();
   505         }
   534         }
   506         if (aUninstallInfo != null)
   535         if (aUninstallInfo != null)
   507         {
   536         {
   508             iconInputStream = aUninstallInfo.getIconInputStream();
   537             iSuiteIconInputStream = aUninstallInfo.getIconInputStream();
   509             iconPath = aUninstallInfo.getIconPath();
   538             iSuiteIconPath = aUninstallInfo.getIconPath();
   510         }
       
   511         if (iSuiteIcon == null && iconInputStream != null)
       
   512         {
       
   513             iSuiteIcon = InstallerUiEswt.loadImage(
       
   514                              getComposite().getDisplay(), iconInputStream, iconPath);
       
   515         }
   539         }
   516         int iconColumns = 0;
   540         int iconColumns = 0;
   517         if (iSuiteIcon != null)
   541         if (iSuiteIconInputStream != null)
   518         {
   542         {
   519             iconColumns = 2;
   543             iconColumns = 2;
   520             Label iconLabel = createLabel(iSuiteIcon, iconColumns, SWT.NONE);
   544             iSuiteIconLabel = createLabel((Image)null, iconColumns, SWT.NONE);
   521             setCssId(iconLabel, "contentIcon");
   545             setCssId(iSuiteIconLabel, "contentIcon");
   522         }
   546         }
   523 
   547 
   524         // Create a Composite for displaying application info.
   548         // Create a Composite for displaying application info.
   525         iAppInfoScrolledComposite =
   549         iAppInfoScrolledComposite =
   526             new ScrolledComposite(getComposite(), SWT.V_SCROLL);
   550             new ScrolledComposite(getComposite(), SWT.V_SCROLL);
   695      * @return label that was added to this view
   719      * @return label that was added to this view
   696      */
   720      */
   697     protected Label createAppInfoLabel(String aText)
   721     protected Label createAppInfoLabel(String aText)
   698     {
   722     {
   699         Label label = new Label(getAppInfoComposite(), SWT.WRAP);
   723         Label label = new Label(getAppInfoComposite(), SWT.WRAP);
       
   724         setCssId(label, "appInfoLabel");
   700         label.setText(aText);
   725         label.setText(aText);
   701         GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
   726         GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
   702         gridData.horizontalSpan = 1;
   727         gridData.horizontalSpan = 1;
   703         label.setLayoutData(gridData);
   728         label.setLayoutData(gridData);
   704         return label;
   729         return label;
   766             {
   791             {
   767                 openCertsView(iCertificates, (iCertificates != null? 0: -1));
   792                 openCertsView(iCertificates, (iCertificates != null? 0: -1));
   768             }
   793             }
   769         });
   794         });
   770         return button;
   795         return button;
       
   796     }
       
   797 
       
   798     protected void setSuiteIcon()
       
   799     {
       
   800         if (iSuiteIcon == null &&
       
   801             iSuiteIconInputStream != null &&
       
   802             iSuiteIconLabel != null)
       
   803         {
       
   804             //Rectangle rect = iSuiteIconLabel.getBounds();
       
   805             //log("iSuiteIconLabel bounds: " + rect);
       
   806             iSuiteIcon = InstallerUiEswt.loadImage(
       
   807                 getComposite().getDisplay(), iSuiteIconInputStream,
       
   808                 iSuiteIconPath, new Point(54, 54)); // new Point(rect.width, rect.height));
       
   809         }
       
   810         if (iSuiteIcon != null)
       
   811         {
       
   812             //log("iSuiteIcon bounds: " + iSuiteIcon.getBounds());
       
   813             iSuiteIconLabel.setImage(iSuiteIcon);
       
   814         }
   771     }
   815     }
   772 
   816 
   773     /**
   817     /**
   774      * Sets margins and spacing for the given layout to zero.
   818      * Sets margins and spacing for the given layout to zero.
   775      */
   819      */