javamanager/javainstaller/installerui/javasrc/com/nokia/mj/impl/installer/ui/eswt2/InstallerUiEswt.java
branchRCL_3
changeset 77 7cee158cb8cd
parent 60 6c158198356e
child 83 26b2b12093af
equal deleted inserted replaced
71:d5e927d5853b 77:7cee158cb8cd
   102     /** Flag telling if progress bar should be displayed. */
   102     /** Flag telling if progress bar should be displayed. */
   103     private boolean iDisplayProgress = false;
   103     private boolean iDisplayProgress = false;
   104     /** Flag telling if the first progress bar update has been traced. */
   104     /** Flag telling if the first progress bar update has been traced. */
   105     private boolean iProgressBarUpdateTraced = false;
   105     private boolean iProgressBarUpdateTraced = false;
   106 
   106 
       
   107     /** Certificate details view, owned by the view where it was opened. */
       
   108     private CertificateDetailsView iCertificateDetailsView = null;
       
   109 
   107     /** Hashtable for storing the loaded icons. */
   110     /** Hashtable for storing the loaded icons. */
   108     private static Hashtable iImageTable = null;
   111     private static Hashtable iImageTable = null;
   109     /** Best size for application icon. */
   112     /** Best size for application icon. */
   110     private static Point iBestIconSize = null;
   113     private static Point iBestIconSize = null;
   111 
   114 
   251      * Cancels all confirmation views that are currently displayed.
   254      * Cancels all confirmation views that are currently displayed.
   252      */
   255      */
   253     public void cancelConfirmations()
   256     public void cancelConfirmations()
   254     {
   257     {
   255         super.cancelConfirmations();
   258         super.cancelConfirmations();
       
   259         if (iCertificateDetailsView != null)
       
   260         {
       
   261             iCertificateDetailsView.confirmCancel();
       
   262         }
   256         if (iInstallConfirmationView != null)
   263         if (iInstallConfirmationView != null)
   257         {
   264         {
   258             iInstallConfirmationView.confirmCancel();
   265             iInstallConfirmationView.confirmCancel();
   259         }
   266         }
   260         if (iPermissionConfirmationView != null)
   267         if (iPermissionConfirmationView != null)
   387         if (!isUiReady())
   394         if (!isUiReady())
   388         {
   395         {
   389             aPermissionInfo.setPermissionAllowed(false);
   396             aPermissionInfo.setPermissionAllowed(false);
   390             return true;
   397             return true;
   391         }
   398         }
       
   399 
       
   400         // Ensure that UI is visible when this prompt is displayed.
       
   401         unhide();
   392 
   402 
   393         synchronized (iProgressSyncObject)
   403         synchronized (iProgressSyncObject)
   394         {
   404         {
   395             // Do not display progress bar during dialog.
   405             // Do not display progress bar during dialog.
   396             iDisplayProgress = false;
   406             iDisplayProgress = false;
   469             {
   479             {
   470                 // If download progress is being displayed,
   480                 // If download progress is being displayed,
   471                 // do not display installation progress.
   481                 // do not display installation progress.
   472                 return;
   482                 return;
   473             }
   483             }
   474             if (iDisplayProgress && !iProgressView.isVisible())
   484             if (iDisplayProgress && !iProgressView.isVisible() &&
       
   485                 iCertificateDetailsView == null)
   475             {
   486             {
   476                 // Re-create iProgressView here so that it gets
   487                 // Re-create iProgressView here so that it gets
   477                 // application info that was set when confirm()
   488                 // application info that was set when confirm()
   478                 // was called.
   489                 // was called.
   479                 final InstallerUiEswt self = this;
   490                 final InstallerUiEswt self = this;
   603             iDlProgressView.addCancelCommand();
   614             iDlProgressView.addCancelCommand();
   604         }
   615         }
   605 
   616 
   606         synchronized (iProgressSyncObject)
   617         synchronized (iProgressSyncObject)
   607         {
   618         {
   608             if (iDisplayProgress && !iDlProgressView.isVisible())
   619             if (iDisplayProgress && !iDlProgressView.isVisible() &&
       
   620                 iCertificateDetailsView == null)
   609             {
   621             {
   610                 iDlProgressView.setVisible(true);
   622                 iDlProgressView.setVisible(true);
   611             }
   623             }
   612         }
   624         }
   613         if (aDownloadInfo.getTotalSize() > 0)
   625         if (aDownloadInfo.getTotalSize() > 0)
   639             iDlProgressView.dispose();
   651             iDlProgressView.dispose();
   640             iDlProgressView = null;
   652             iDlProgressView = null;
   641         }
   653         }
   642         synchronized (iProgressSyncObject)
   654         synchronized (iProgressSyncObject)
   643         {
   655         {
   644             if (iDisplayProgress && !iProgressView.isVisible())
   656             if (iDisplayProgress && !iProgressView.isVisible() &&
       
   657                 iCertificateDetailsView == null)
   645             {
   658             {
   646                 iProgressView.setVisible(true);
   659                 iProgressView.setVisible(true);
   647             }
   660             }
   648         }
   661         }
   649     }
   662     }
   680                 });
   693                 });
   681                 iOcspProgressView.addCancelCommand();
   694                 iOcspProgressView.addCancelCommand();
   682             }
   695             }
   683             if (iOcspProgressView != null)
   696             if (iOcspProgressView != null)
   684             {
   697             {
   685                 if (!iOcspProgressView.isVisible())
   698                 if (!iOcspProgressView.isVisible() &&
       
   699                     iCertificateDetailsView == null)
   686                 {
   700                 {
   687                     iOcspProgressView.setVisible(true);
   701                     iOcspProgressView.setVisible(true);
   688                 }
   702                 }
   689             }
   703             }
   690         }
   704         }
   759     {
   773     {
   760         super.error(aInstallerException);
   774         super.error(aInstallerException);
   761         if (DISABLE_UI) return; // Disable UI temporarily.
   775         if (DISABLE_UI) return; // Disable UI temporarily.
   762 
   776 
   763         waitForUi();
   777         waitForUi();
   764         if (!isUiReady()) {
   778         waitForCertificateDetailsView();
       
   779         if (!isUiReady() || iHidden || iConfirmationsCanceled) {
   765             return;
   780             return;
   766         }
   781         }
   767 
   782 
   768         // Use ErrorView to display error message.
   783         // Use ErrorView to display error message.
   769         if (iErrorView == null)
   784         if (iErrorView == null)
   819         if (DISABLE_UI) return true; // Disable UI temporarily.
   834         if (DISABLE_UI) return true; // Disable UI temporarily.
   820         waitForUi();
   835         waitForUi();
   821         if (!isUiReady()) {
   836         if (!isUiReady()) {
   822             return true;
   837             return true;
   823         }
   838         }
       
   839         waitForCertificateDetailsView();
       
   840         if (iConfirmationsCanceled)
       
   841         {
       
   842             return false;
       
   843         }
       
   844 
       
   845         // Ensure that UI is visible when this prompt is displayed.
       
   846         unhide();
   824 
   847 
   825         if (iRuntimeConfirmationView == null)
   848         if (iRuntimeConfirmationView == null)
   826         {
   849         {
   827             final Display display = iParent.getDisplay();
   850             final Display display = iParent.getDisplay();
   828             final InstallerUiEswt self = this;
   851             final InstallerUiEswt self = this;
   855      */
   878      */
   856     public String[] getUsernamePassword(String aUrl)
   879     public String[] getUsernamePassword(String aUrl)
   857     {
   880     {
   858         if (DISABLE_UI) return new String[] { "", "" }; // Disable UI temporarily.
   881         if (DISABLE_UI) return new String[] { "", "" }; // Disable UI temporarily.
   859         waitForUi();
   882         waitForUi();
   860         if (!isUiReady())
   883         waitForCertificateDetailsView();
       
   884         if (!isUiReady() || iConfirmationsCanceled)
   861         {
   885         {
   862             return null;
   886             return null;
   863         }
   887         }
       
   888 
       
   889         // Ensure that UI is visible when this prompt is displayed.
       
   890         unhide();
   864 
   891 
   865         synchronized (iProgressSyncObject)
   892         synchronized (iProgressSyncObject)
   866         {
   893         {
   867             // Do not display progress bar during dialog.
   894             // Do not display progress bar during dialog.
   868             iDisplayProgress = false;
   895             iDisplayProgress = false;
   911      */
   938      */
   912     public boolean launchAppQuery(LaunchAppInfo aLaunchAppInfo)
   939     public boolean launchAppQuery(LaunchAppInfo aLaunchAppInfo)
   913     {
   940     {
   914         if (DISABLE_UI) return false; // Disable UI temporarily.
   941         if (DISABLE_UI) return false; // Disable UI temporarily.
   915         waitForUi();
   942         waitForUi();
   916         if (!isUiReady() || iConfirmationsCanceled || getInstallInfo() == null)
   943         waitForCertificateDetailsView();
   917         {
   944         if (!isUiReady() || iConfirmationsCanceled ||
   918             // Either UI is not yet ready, or user has cancelled
   945             iHidden || getInstallInfo() == null)
   919             // installation, in both cases do nothing.
   946         {
       
   947             // Either UI is not yet ready, user has cancelled
       
   948             // installation or UI is hidden; in all these cases
       
   949             // do nothing.
   920             return false;
   950             return false;
   921         }
   951         }
   922 
   952 
   923         if (iLaunchAppQueryView == null)
   953         if (iLaunchAppQueryView == null)
   924         {
   954         {
   952     /**
   982     /**
   953      * Executes given Runnable synchronously in the UI thread.
   983      * Executes given Runnable synchronously in the UI thread.
   954      */
   984      */
   955     public void syncExec(Runnable aRunnable)
   985     public void syncExec(Runnable aRunnable)
   956     {
   986     {
   957         iParent.getDisplay().syncExec(aRunnable);
   987         if (!iParent.getDisplay().isDisposed())
       
   988         {
       
   989             iParent.getDisplay().syncExec(aRunnable);
       
   990         }
   958     }
   991     }
   959 
   992 
   960     /**
   993     /**
   961      * Hides or unhides InstallerUi.
   994      * Hides or unhides InstallerUi.
   962      */
   995      */
   963     public void hide(boolean aHide)
   996     public void hide(boolean aHide)
   964     {
   997     {
   965         final boolean hide = aHide;
   998         iHidden = aHide;
   966         if (iParent != null)
   999         if (iDialog != null)
   967         {
  1000         {
   968             iParent.getDisplay().syncExec(new Runnable()
  1001             iDialog.getDisplay().syncExec(new Runnable()
   969             {
  1002             {
   970                 public void run()
  1003                 public void run()
   971                 {
  1004                 {
   972                     iParent.setMinimized(hide);
  1005                     iDialog.setMinimized(iHidden);
   973                 }
  1006                 }
   974             });
  1007             });
   975         }
  1008         }
   976         super.hide(aHide);
  1009         super.hide(aHide);
   977     }
  1010     }
   982     protected void unhide()
  1015     protected void unhide()
   983     {
  1016     {
   984         if (iHidden)
  1017         if (iHidden)
   985         {
  1018         {
   986             hide(false);
  1019             hide(false);
       
  1020         }
       
  1021     }
       
  1022 
       
  1023     /**
       
  1024      * Sets flag telling if certificate details view is open.
       
  1025      */
       
  1026     protected void setCertificateDetailsView(CertificateDetailsView aView)
       
  1027     {
       
  1028         if (iCertificateDetailsView != null && aView == null)
       
  1029         {
       
  1030             // Certificate details view has been closed,
       
  1031             // notify possible waiters.
       
  1032             synchronized (iCertificateDetailsView)
       
  1033             {
       
  1034                 iCertificateDetailsView.notify();
       
  1035             }
       
  1036         }
       
  1037         iCertificateDetailsView = aView;
       
  1038     }
       
  1039 
       
  1040     /**
       
  1041      * Waits until certificate details view is closed.
       
  1042      */
       
  1043     protected void waitForCertificateDetailsView()
       
  1044     {
       
  1045         if (iCertificateDetailsView != null)
       
  1046         {
       
  1047             // If certificate details view is open, wait until
       
  1048             // user closes it.
       
  1049             synchronized (iCertificateDetailsView)
       
  1050             {
       
  1051                 try
       
  1052                 {
       
  1053                     iCertificateDetailsView.wait();
       
  1054                 }
       
  1055                 catch (InterruptedException ie)
       
  1056                 {
       
  1057                 }
       
  1058             }
   987         }
  1059         }
   988     }
  1060     }
   989 
  1061 
   990     /**
  1062     /**
   991      * Returns string title basing on mode of this InstallerUi.
  1063      * Returns string title basing on mode of this InstallerUi.