javamanager/javainstaller/installerui/javasrc/com/nokia/mj/impl/installer/ui/eswt2/ViewBase.java
changeset 48 e0d6e9bd3ca7
parent 47 f40128debb5d
child 61 bf7ee68962da
equal deleted inserted replaced
47:f40128debb5d 48:e0d6e9bd3ca7
    32 import org.eclipse.swt.events.SelectionEvent;
    32 import org.eclipse.swt.events.SelectionEvent;
    33 import org.eclipse.swt.events.SelectionListener;
    33 import org.eclipse.swt.events.SelectionListener;
    34 import org.eclipse.swt.graphics.Image;
    34 import org.eclipse.swt.graphics.Image;
    35 import org.eclipse.swt.graphics.Point;
    35 import org.eclipse.swt.graphics.Point;
    36 import org.eclipse.swt.graphics.Rectangle;
    36 import org.eclipse.swt.graphics.Rectangle;
       
    37 import org.eclipse.swt.internal.qt.WidgetConstant;
    37 import org.eclipse.swt.layout.GridData;
    38 import org.eclipse.swt.layout.GridData;
    38 import org.eclipse.swt.layout.GridLayout;
    39 import org.eclipse.swt.layout.GridLayout;
    39 import org.eclipse.swt.widgets.Button;
    40 import org.eclipse.swt.widgets.Button;
    40 import org.eclipse.swt.widgets.Composite;
    41 import org.eclipse.swt.widgets.Composite;
    41 import org.eclipse.swt.widgets.Control;
    42 import org.eclipse.swt.widgets.Control;
    42 import org.eclipse.swt.widgets.Display;
    43 import org.eclipse.swt.widgets.Display;
    43 import org.eclipse.swt.widgets.Label;
    44 import org.eclipse.swt.widgets.Label;
    44 import org.eclipse.swt.widgets.Shell;
    45 import org.eclipse.swt.widgets.Shell;
       
    46 import org.eclipse.swt.widgets.Widget;
    45 
    47 
    46 /**
    48 /**
    47  * Base class for different InstallerUi views.
    49  * Base class for different InstallerUi views.
    48  */
    50  */
    49 abstract public class ViewBase
    51 abstract public class ViewBase
    99 
   101 
   100         // Each view gets a shell to be used as a parameter.
   102         // Each view gets a shell to be used as a parameter.
   101         iParent = (Shell)aParent;
   103         iParent = (Shell)aParent;
   102 
   104 
   103         iContainer = new Composite(iParent, 0);
   105         iContainer = new Composite(iParent, 0);
       
   106         setCssId(iContainer, "dialogArea");
   104         iContainer.setVisible(false);
   107         iContainer.setVisible(false);
   105 
   108 
   106         iColumns = aColumns;
   109         iColumns = aColumns;
   107 
   110 
   108         // Store the default bounds for later height adjustments.
   111         // Store the default bounds for later height adjustments.
   436     {
   439     {
   437         return iColumns;
   440         return iColumns;
   438     }
   441     }
   439 
   442 
   440     /**
   443     /**
       
   444      * Sets CSS id for given widget.
       
   445      */
       
   446     protected void setCssId(Widget aWidget, String aCssId)
       
   447     {
       
   448         aWidget.setData(WidgetConstant.CSS_ID, aCssId);
       
   449     }
       
   450 
       
   451     /**
   441      * Adds header used in installation views.
   452      * Adds header used in installation views.
   442      */
   453      */
   443     protected void addHeader(
   454     protected void addHeader(
   444         String aTitle, InstallInfo aInstallInfo, UninstallInfo aUninstallInfo)
   455         String aTitle, InstallInfo aInstallInfo, UninstallInfo aUninstallInfo)
   445     {
   456     {
   452     protected void addHeader(
   463     protected void addHeader(
   453         String aTitle, InstallInfo aInstallInfo, UninstallInfo aUninstallInfo,
   464         String aTitle, InstallInfo aInstallInfo, UninstallInfo aUninstallInfo,
   454         boolean aSecurityButton)
   465         boolean aSecurityButton)
   455     {
   466     {
   456         // Add title.
   467         // Add title.
   457         String title = InstallerUiTexts.get(InstallerUiTexts.INSTALL_QUERY);
   468         if (aTitle == null)
       
   469         {
       
   470             aTitle = InstallerUiTexts.get(InstallerUiTexts.INSTALL_QUERY);
       
   471             if (aInstallInfo != null && aInstallInfo.getOldVersion() != null)
       
   472             {
       
   473                 aTitle = InstallerUiTexts.get(InstallerUiTexts.UPDATE_QUERY);
       
   474             }
       
   475         }
       
   476         Label titleLabel = createLabel(aTitle, getColumns() - 1, SWT.WRAP);
       
   477         setCssId(titleLabel, "heading");
       
   478 
   458         if (aInstallInfo != null)
   479         if (aInstallInfo != null)
   459         {
   480         {
   460             if (aInstallInfo.getOldVersion() != null)
       
   461             {
       
   462                 title = InstallerUiTexts.get(InstallerUiTexts.UPDATE_QUERY);
       
   463             }
       
   464             iCertificates = aInstallInfo.getCertificates();
   481             iCertificates = aInstallInfo.getCertificates();
   465         }
   482         }
   466         if (aUninstallInfo != null)
   483         else if (aUninstallInfo != null)
   467         {
   484         {
   468             title = "Uninstall?";
       
   469             iCertificates = aUninstallInfo.getCertificates();
   485             iCertificates = aUninstallInfo.getCertificates();
   470         }
   486         }
   471         Label titleLabel = createLabel(aTitle, getColumns() - 1, SWT.WRAP);
       
   472         titleLabel.setFont(iInstallerUi.getBoldFont());
       
   473 
       
   474         if (aSecurityButton)
   487         if (aSecurityButton)
   475         {
   488         {
   476             // Add security icon.
   489             // Add security button.
   477             createSecurityButton();
   490             createSecurityButton();
   478         }
   491         }
   479         else
   492         else
   480         {
   493         {
   481             // Add security icon.
   494             // Add security icon.
   503         int iconColumns = 0;
   516         int iconColumns = 0;
   504         if (iSuiteIcon != null)
   517         if (iSuiteIcon != null)
   505         {
   518         {
   506             iconColumns = 2;
   519             iconColumns = 2;
   507             Label iconLabel = createLabel(iSuiteIcon, iconColumns, SWT.NONE);
   520             Label iconLabel = createLabel(iSuiteIcon, iconColumns, SWT.NONE);
       
   521             setCssId(iconLabel, "contentIcon");
   508         }
   522         }
   509 
   523 
   510         // Create a Composite for displaying application info.
   524         // Create a Composite for displaying application info.
   511         iAppInfoScrolledComposite =
   525         iAppInfoScrolledComposite =
   512             new ScrolledComposite(getComposite(), SWT.H_SCROLL | SWT.V_SCROLL);
   526             new ScrolledComposite(getComposite(), SWT.V_SCROLL);
   513         iAppInfoScrolledComposite.setAlwaysShowScrollBars(false);
   527         iAppInfoScrolledComposite.setAlwaysShowScrollBars(false);
   514         iAppInfoScrolledComposite.setExpandHorizontal(true);
   528         iAppInfoScrolledComposite.setExpandHorizontal(true);
   515         GridData gridData = new GridData(GridData.FILL_BOTH);
   529         GridData gridData = new GridData(GridData.FILL_BOTH);
   516         gridData.horizontalSpan = getColumns() - iconColumns;
   530         gridData.horizontalSpan = getColumns() - iconColumns;
   517         iAppInfoScrolledComposite.setLayoutData(gridData);
   531         iAppInfoScrolledComposite.setLayoutData(gridData);
   518         iAppInfoComposite = new Composite(iAppInfoScrolledComposite, SWT.NONE);
   532         iAppInfoComposite = new Composite(iAppInfoScrolledComposite, SWT.NONE);
   519         iAppInfoComposite.setLayout(new GridLayout(1, true));
   533         iAppInfoComposite.setLayout(new GridLayout(1, true));
   520         iAppInfoScrolledComposite.setContent(iAppInfoComposite);
   534         iAppInfoScrolledComposite.setContent(iAppInfoComposite);
       
   535         setCssId(iAppInfoScrolledComposite, "appInfoArea");
   521     }
   536     }
   522 
   537 
   523     /**
   538     /**
   524      * Adds application information to the header.
   539      * Adds application information to the header.
   525      */
   540      */
   538                 new String[] { aInstallInfo.getName(),
   553                 new String[] { aInstallInfo.getName(),
   539                                aInstallInfo.getVersion() }));
   554                                aInstallInfo.getVersion() }));
   540         if (aFull)
   555         if (aFull)
   541         {
   556         {
   542             // Add vendor.
   557             // Add vendor.
   543             if (aInstallInfo.getCertificates() != null)
   558             createAppInfoLabel(
   544             {
   559                 InstallerUiTexts.get(
   545                 // Vendor information must be displayed only for
   560                     InstallerUiTexts.SUITE_VENDOR,
   546                 // identified applications.
   561                     new String[] { aInstallInfo.getVendor() }));
   547                 createAppInfoLabel(
       
   548                     InstallerUiTexts.get(
       
   549                         InstallerUiTexts.SUITE_VENDOR,
       
   550                         new String[] { aInstallInfo.getVendor() }));
       
   551             }
       
   552         }
   562         }
   553         // Add size.
   563         // Add size.
   554         long size = 0;
   564         long size = 0;
   555         if (aInstallInfo.getJarSize() > 0)
   565         if (aInstallInfo.getJarSize() > 0)
   556         {
   566         {
   688      * @return label that was added to this view
   698      * @return label that was added to this view
   689      */
   699      */
   690     protected Label createSecurityLabel(boolean aIdentified)
   700     protected Label createSecurityLabel(boolean aIdentified)
   691     {
   701     {
   692         Label label = createLabel((Image)null, 1, SWT.NONE);
   702         Label label = createLabel((Image)null, 1, SWT.NONE);
       
   703         setCssId(label, "securityLabel");
   693         Image securityIcon = null;
   704         Image securityIcon = null;
   694         if (iInstallerUi != null)
   705         if (iInstallerUi != null)
   695         {
   706         {
   696             securityIcon = iInstallerUi.getSecurityIcon(
   707             securityIcon = iInstallerUi.getSecurityIcon(
   697                 getDisplay(), aIdentified);
   708                 getDisplay(), aIdentified);
   708     }
   719     }
   709 
   720 
   710     protected Button createSecurityButton()
   721     protected Button createSecurityButton()
   711     {
   722     {
   712         Button button = new Button(getComposite(), SWT.PUSH);
   723         Button button = new Button(getComposite(), SWT.PUSH);
       
   724         setCssId(button, "securityButton");
   713         GridData gridData = new GridData(
   725         GridData gridData = new GridData(
   714             GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL);
   726             GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL);
   715         gridData.horizontalSpan = 1;
   727         gridData.horizontalSpan = 1;
   716         gridData.horizontalAlignment = SWT.CENTER;
   728         gridData.horizontalAlignment = SWT.CENTER;
   717         gridData.verticalAlignment = SWT.CENTER;
   729         gridData.verticalAlignment = SWT.CENTER;