javamanager/javainstaller/installerui/javasrc/com/nokia/mj/impl/installer/ui/eswt/UninstallConfirmationView.java
branchRCL_3
changeset 14 04becd199f91
child 23 e5618cc85d74
equal deleted inserted replaced
13:f5050f1da672 14:04becd199f91
       
     1 /*
       
     2 * Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 package com.nokia.mj.impl.installer.ui.eswt;
       
    20 
       
    21 import com.nokia.mj.impl.installer.ui.ApplicationInfo;
       
    22 import com.nokia.mj.impl.installer.ui.UninstallInfo;
       
    23 
       
    24 import java.io.InputStream;
       
    25 
       
    26 import org.eclipse.swt.SWT;
       
    27 import org.eclipse.swt.SWTException;
       
    28 import org.eclipse.swt.graphics.Image;
       
    29 import org.eclipse.swt.layout.GridData;
       
    30 import org.eclipse.swt.widgets.Combo;
       
    31 import org.eclipse.swt.widgets.Composite;
       
    32 import org.eclipse.swt.widgets.Label;
       
    33 
       
    34 /**
       
    35  * UninstallConfirmationView asks uninstallation confirmation
       
    36  * from the user.
       
    37  */
       
    38 public class UninstallConfirmationView extends ConfirmationViewBase
       
    39 {
       
    40     private UninstallInfo iUninstallInfo = null;
       
    41 
       
    42     /** Constructor */
       
    43     protected UninstallConfirmationView()
       
    44     {
       
    45         super();
       
    46     }
       
    47 
       
    48     /** Constructor */
       
    49     protected UninstallConfirmationView(InstallerUiEswt aInstaller, Composite aParent)
       
    50     {
       
    51         super(aInstaller, aParent, 8);
       
    52         setTitle(InstallerUiTexts.get(InstallerUiTexts.UNINSTALL));
       
    53         setCommands(InstallerUiTexts.get(InstallerUiTexts.OK),
       
    54                     InstallerUiTexts.get(InstallerUiTexts.CANCEL));
       
    55     }
       
    56 
       
    57     /**
       
    58      * Synchoronous method for asking user confirmation.
       
    59      */
       
    60     public boolean confirm(UninstallInfo aUninstallInfo)
       
    61     {
       
    62         iUninstallInfo = aUninstallInfo;
       
    63         boolean result = confirm();
       
    64         if (result)
       
    65         {
       
    66             log("uninstallConfirmationView confirmed");
       
    67         }
       
    68         else
       
    69         {
       
    70             log("uninstallConfirmationView cancelled");
       
    71         }
       
    72         return result;
       
    73     }
       
    74 
       
    75     /**
       
    76      * This method is called once before view is opened.
       
    77      * Inheriting class must implement this method.
       
    78      */
       
    79     protected void createView()
       
    80     {
       
    81         GridData gridData = null;
       
    82         int horizontalSpan = getColumns() - 1;
       
    83         int labelStyle = SWT.WRAP;
       
    84 
       
    85         InputStream iconInputStream = iUninstallInfo.getIconInputStream();
       
    86         if (iconInputStream != null)
       
    87         {
       
    88             Image image = InstallerUiEswt.loadImage
       
    89                           (getComposite().getDisplay(), iconInputStream,
       
    90                            iUninstallInfo.getIconPath());
       
    91             if (image != null)
       
    92             {
       
    93                 Label iconLabel = createLabel(image, 2, SWT.NONE);
       
    94                 horizontalSpan = getColumns() - 3;
       
    95             }
       
    96             else
       
    97             {
       
    98                 horizontalSpan = getColumns() - 1;
       
    99             }
       
   100         }
       
   101 
       
   102         // Add title.
       
   103         Label titleLabel = createLabel
       
   104                            (InstallerUiTexts.get
       
   105                             (InstallerUiTexts.UNINSTALL_QUERY,
       
   106                              new String[] { iUninstallInfo.getName() }),
       
   107                             horizontalSpan, labelStyle);
       
   108         titleLabel.setFont(iInstallerUi.getBoldFont());
       
   109 
       
   110         // Add security icon.
       
   111         boolean identified = (iUninstallInfo.getCertificates() != null);
       
   112         Label securityIconLabel = createSecurityLabel(identified);
       
   113 
       
   114         horizontalSpan = getColumns();
       
   115 
       
   116         Label nameLabel = createLabel
       
   117                           (InstallerUiTexts.get
       
   118                            (InstallerUiTexts.NAME,
       
   119                             new String[] { iUninstallInfo.getName() }),
       
   120                            horizontalSpan, labelStyle);
       
   121 
       
   122         if (identified)
       
   123         {
       
   124             // Vendor information must be displayed only for
       
   125             // identified applications.
       
   126             Label vendorLabel = createLabel
       
   127                                 (InstallerUiTexts.get
       
   128                                  (InstallerUiTexts.VENDOR,
       
   129                                   new String[] { iUninstallInfo.getVendor() }),
       
   130                                  horizontalSpan, labelStyle);
       
   131         }
       
   132 
       
   133         Label versionLabel = createLabel
       
   134                              (InstallerUiTexts.get
       
   135                               (InstallerUiTexts.VERSION,
       
   136                                new String[] { iUninstallInfo.getVersion() }),
       
   137                               horizontalSpan, labelStyle);
       
   138 
       
   139         ApplicationInfo[] apps = iUninstallInfo.getApplications();
       
   140         if (apps != null && apps.length > 0)
       
   141         {
       
   142             if (apps.length > 1 ||
       
   143                     !iUninstallInfo.getName().equals(apps[0].getName()))
       
   144             {
       
   145                 Label appsLabel = createLabel
       
   146                                   (InstallerUiTexts.get
       
   147                                    (InstallerUiTexts.APPLICATIONS),
       
   148                                    horizontalSpan, labelStyle);
       
   149 
       
   150                 for (int i = 0; i < apps.length; i++)
       
   151                 {
       
   152                     Label appLabel = createLabel
       
   153                                      (InstallerUiTexts.get
       
   154                                       (InstallerUiTexts.APP_NAME,
       
   155                                        new String[] { apps[i].getName() }),
       
   156                                       horizontalSpan, labelStyle);
       
   157                 }
       
   158             }
       
   159         }
       
   160 
       
   161         String deleteConfirm = iUninstallInfo.getDeleteConfirm();
       
   162         if (deleteConfirm != null)
       
   163         {
       
   164             Label deleteConfirmLabel = createLabel
       
   165                                        (deleteConfirm, horizontalSpan, labelStyle);
       
   166         }
       
   167     }
       
   168 
       
   169     /**
       
   170      * This method is called after user has answered
       
   171      * to confirmation.
       
   172      * Inheriting class must implement this method.
       
   173      */
       
   174     protected void getDataFromView()
       
   175     {
       
   176         // No data to get from uninstallation confirmation.
       
   177     }
       
   178 
       
   179     /**
       
   180      * Returns SWT style for this view.
       
   181      */
       
   182     protected int getStyle()
       
   183     {
       
   184         return SWT.V_SCROLL;
       
   185     }
       
   186 }