37 |
37 |
38 import java.io.InputStream; |
38 import java.io.InputStream; |
39 import java.io.IOException; |
39 import java.io.IOException; |
40 import java.util.Hashtable; |
40 import java.util.Hashtable; |
41 |
41 |
|
42 import org.eclipse.ercp.swt.midp.UIThreadSupport; |
42 import org.eclipse.swt.SWT; |
43 import org.eclipse.swt.SWT; |
43 import org.eclipse.swt.events.ControlEvent; |
44 import org.eclipse.swt.events.ControlEvent; |
44 import org.eclipse.swt.events.ControlListener; |
45 import org.eclipse.swt.events.ControlListener; |
45 import org.eclipse.swt.graphics.Font; |
46 import org.eclipse.swt.graphics.Font; |
46 import org.eclipse.swt.graphics.FontData; |
47 import org.eclipse.swt.graphics.FontData; |
53 import org.eclipse.swt.widgets.Display; |
54 import org.eclipse.swt.widgets.Display; |
54 import org.eclipse.swt.widgets.Event; |
55 import org.eclipse.swt.widgets.Event; |
55 import org.eclipse.swt.widgets.Composite; |
56 import org.eclipse.swt.widgets.Composite; |
56 import org.eclipse.swt.widgets.Listener; |
57 import org.eclipse.swt.widgets.Listener; |
57 import org.eclipse.swt.widgets.Shell; |
58 import org.eclipse.swt.widgets.Shell; |
58 //import org.eclipse.swt.widgets.MessageBox; |
|
59 |
59 |
60 /** |
60 /** |
61 * JavaInstaller eSWT UI. |
61 * JavaInstaller eSWT UI. |
62 */ |
62 */ |
63 public class InstallerUiEswt extends InstallerUi |
63 public class InstallerUiEswt extends InstallerUi |
70 private Shell iDialog = null; |
70 private Shell iDialog = null; |
71 private ProgressView iProgressView = null; |
71 private ProgressView iProgressView = null; |
72 private ProgressView iDlProgressView = null; |
72 private ProgressView iDlProgressView = null; |
73 private ProgressView iOcspProgressView = null; |
73 private ProgressView iOcspProgressView = null; |
74 private InstallConfirmationView iInstallConfirmationView = null; |
74 private InstallConfirmationView iInstallConfirmationView = null; |
75 private UninstallConfirmationView iUninstallConfirmationView = null; |
|
76 private PermissionConfirmationView iPermissionConfirmationView = null; |
75 private PermissionConfirmationView iPermissionConfirmationView = null; |
77 private UsernamePasswordView iUsernamePasswordView = null; |
76 private UsernamePasswordView iUsernamePasswordView = null; |
78 private LaunchAppQueryView iLaunchAppQueryView = null; |
77 private LaunchAppQueryView iLaunchAppQueryView = null; |
79 private ErrorView iErrorView = null; |
78 private ErrorView iErrorView = null; |
80 private ErrorDetailsView iErrorDetailsView = null; |
79 private ErrorDetailsView iErrorDetailsView = null; |
135 InstallerRuntimeUi.init(this); |
134 InstallerRuntimeUi.init(this); |
136 // Create a hashtable for icons. |
135 // Create a hashtable for icons. |
137 iImageTable = new Hashtable(); |
136 iImageTable = new Hashtable(); |
138 // Create a new thread to be the UI main thread. |
137 // Create a new thread to be the UI main thread. |
139 iUiThreadExists = true; |
138 iUiThreadExists = true; |
140 new Thread(new Runnable() |
139 UIThreadSupport.startInUIThread(new Runnable() |
141 { |
140 { |
142 public void run() |
141 public void run() |
143 { |
142 { |
144 uiMain(); |
143 uiMain(); |
145 } |
144 } |
146 }, "InstallerUiMainThread").start(); |
145 }); |
147 // To wait InstallerUi to be ready before installer main thread |
146 // To wait InstallerUi to be ready before installer main thread |
148 // continues, uncomment the following line. |
147 // continues, uncomment the following line. |
149 //waitForUi(); |
148 //waitForUi(); |
150 } |
149 } |
151 |
150 |
255 super.cancelConfirmations(); |
254 super.cancelConfirmations(); |
256 if (iInstallConfirmationView != null) |
255 if (iInstallConfirmationView != null) |
257 { |
256 { |
258 iInstallConfirmationView.confirmCancel(); |
257 iInstallConfirmationView.confirmCancel(); |
259 } |
258 } |
260 if (iUninstallConfirmationView != null) |
|
261 { |
|
262 iUninstallConfirmationView.confirmCancel(); |
|
263 } |
|
264 if (iPermissionConfirmationView != null) |
259 if (iPermissionConfirmationView != null) |
265 { |
260 { |
266 iPermissionConfirmationView.confirmCancel(); |
261 iPermissionConfirmationView.confirmCancel(); |
267 } |
262 } |
268 if (iUsernamePasswordView != null) |
263 if (iUsernamePasswordView != null) |
330 StartUpTrace.doTrace("InstallerUiEswt confirm"); |
325 StartUpTrace.doTrace("InstallerUiEswt confirm"); |
331 if (iInstallConfirmationView == null) |
326 if (iInstallConfirmationView == null) |
332 { |
327 { |
333 final Display display = iParent.getDisplay(); |
328 final Display display = iParent.getDisplay(); |
334 final InstallerUiEswt self = this; |
329 final InstallerUiEswt self = this; |
335 display.syncExec |
330 display.syncExec(new Runnable() |
336 (new Runnable() |
|
337 { |
331 { |
338 public void run() |
332 public void run() |
339 { |
333 { |
340 iInstallConfirmationView = |
334 iInstallConfirmationView = |
341 new InstallConfirmationView(self, iDialog); |
335 new InstallConfirmationView(self, iDialog); |
413 } |
406 } |
414 if (iPermissionConfirmationView == null) |
407 if (iPermissionConfirmationView == null) |
415 { |
408 { |
416 final Display display = iParent.getDisplay(); |
409 final Display display = iParent.getDisplay(); |
417 final InstallerUiEswt self = this; |
410 final InstallerUiEswt self = this; |
418 display.syncExec |
411 display.syncExec(new Runnable() |
419 (new Runnable() |
|
420 { |
412 { |
421 public void run() |
413 public void run() |
422 { |
414 { |
423 iPermissionConfirmationView = |
415 iPermissionConfirmationView = |
424 new PermissionConfirmationView(self, iDialog); |
416 new PermissionConfirmationView(self, iDialog); |
444 * @param aUninstallInfo uninstallation information |
436 * @param aUninstallInfo uninstallation information |
445 * @return true if user has accepted uninstallation, false otherwise |
437 * @return true if user has accepted uninstallation, false otherwise |
446 */ |
438 */ |
447 public boolean confirm(UninstallInfo aUninstallInfo) |
439 public boolean confirm(UninstallInfo aUninstallInfo) |
448 { |
440 { |
449 super.confirm(aUninstallInfo); |
441 return super.confirm(aUninstallInfo); |
450 |
|
451 waitForUi(); |
|
452 boolean result = true; |
|
453 if (!isUiReady()) |
|
454 { |
|
455 result = false; |
|
456 if (iMinimalUiEnabled) |
|
457 { |
|
458 result = MinimalUi.confirmStatic(aUninstallInfo); |
|
459 log("MinimalUi uninstallation confirmation returns " + result); |
|
460 return result; |
|
461 } |
|
462 else |
|
463 { |
|
464 // If UI is not ready by the time confirmation is requested, |
|
465 // throw an exception. |
|
466 throw new RuntimeException("JavaInstallerUi not ready"); |
|
467 } |
|
468 } |
|
469 if (result) |
|
470 { |
|
471 StartUpTrace.doTrace("InstallerUiEswt confirm"); |
|
472 if (iUninstallConfirmationView == null) |
|
473 { |
|
474 final Display display = iParent.getDisplay(); |
|
475 final InstallerUiEswt self = this; |
|
476 display.syncExec |
|
477 (new Runnable() |
|
478 { |
|
479 public void run() |
|
480 { |
|
481 iUninstallConfirmationView = |
|
482 new UninstallConfirmationView(self, iDialog); |
|
483 } |
|
484 }); |
|
485 } |
|
486 result = iUninstallConfirmationView.confirm(aUninstallInfo); |
|
487 iUninstallConfirmationView.dispose(); |
|
488 iUninstallConfirmationView = null; |
|
489 } |
|
490 if (result) |
|
491 { |
|
492 iDisplayProgress = true; |
|
493 } |
|
494 else |
|
495 { |
|
496 // The uninstall confirmation has been rejected, |
|
497 // nothing to display anymore. |
|
498 iParent.getDisplay().syncExec |
|
499 (new Runnable() |
|
500 { |
|
501 public void run() |
|
502 { |
|
503 iParent.dispose(); |
|
504 } |
|
505 }); |
|
506 } |
|
507 log("Uninstallation confirmation returns " + result); |
|
508 return result; |
|
509 } |
442 } |
510 |
443 |
511 /** |
444 /** |
512 * This method is used to notify UI that installation or |
445 * This method is used to notify UI that installation or |
513 * uninstallation has started. Upon this call UI could |
446 * uninstallation has started. Upon this call UI could |
731 if (aOn) |
663 if (aOn) |
732 { |
664 { |
733 if (iOcspProgressView == null) |
665 if (iOcspProgressView == null) |
734 { |
666 { |
735 final InstallerUiEswt self = this; |
667 final InstallerUiEswt self = this; |
736 iParent.getDisplay().syncExec |
668 iParent.getDisplay().syncExec(new Runnable() |
737 (new Runnable() |
|
738 { |
669 { |
739 public void run() |
670 public void run() |
740 { |
671 { |
741 iOcspProgressView = new ProgressView(self, iDialog, |
672 iOcspProgressView = new ProgressView(self, iDialog, |
742 InstallerUiTexts.get(InstallerUiTexts.OCSP_CHECK_PROGRESS), |
673 InstallerUiTexts.get(InstallerUiTexts.OCSP_CHECK_PROGRESS), |
871 /** |
801 /** |
872 * Notify user that an error has occurred using RuntimeUI. |
802 * Notify user that an error has occurred using RuntimeUI. |
873 * |
803 * |
874 * @param aInstallerException exception indicating the error reason |
804 * @param aInstallerException exception indicating the error reason |
875 */ |
805 */ |
|
806 /* |
876 private void showRuntimeUiError(InstallerExceptionBase aInstallerException) |
807 private void showRuntimeUiError(InstallerExceptionBase aInstallerException) |
877 { |
808 { |
878 boolean identified = false; |
809 boolean identified = false; |
879 if (iInstallInfo != null) |
810 if (iInstallInfo != null) |
880 { |
811 { |
888 if (iUninstallInfo.getCertificates() != null) |
819 if (iUninstallInfo.getCertificates() != null) |
889 { |
820 { |
890 identified = true; |
821 identified = true; |
891 } |
822 } |
892 } |
823 } |
893 String tmpTitle = ""; |
824 String tmpTitle = InstallerUiTexts.get(InstallerUiTexts.INSTALL_FAILED); |
894 if (iMode == MODE_INSTALL) |
|
895 { |
|
896 tmpTitle = InstallerUiTexts.get(InstallerUiTexts.INSTALL_FAILED); |
|
897 } |
|
898 else if (iMode == MODE_UNINSTALL) |
|
899 { |
|
900 tmpTitle = InstallerUiTexts.get(InstallerUiTexts.UNINSTALL_FAILED); |
|
901 } |
|
902 |
825 |
903 // Ensure that no confirmations are being displayed. |
826 // Ensure that no confirmations are being displayed. |
904 cancelConfirmations(); |
827 cancelConfirmations(); |
905 // Hide progress view before displaying error message. |
828 // Hide progress view before displaying error message. |
906 if (iProgressView != null) |
829 if (iProgressView != null) |
910 // Use RuntimeUi to display uninstallation error message. |
833 // Use RuntimeUi to display uninstallation error message. |
911 RuntimeUi runtimeUi = RuntimeUiFactory.getRuntimeUi(identified); |
834 RuntimeUi runtimeUi = RuntimeUiFactory.getRuntimeUi(identified); |
912 runtimeUi.error(tmpTitle, aInstallerException); |
835 runtimeUi.error(tmpTitle, aInstallerException); |
913 runtimeUi.destroy(); |
836 runtimeUi.destroy(); |
914 } |
837 } |
|
838 */ |
915 |
839 |
916 /** |
840 /** |
917 * Seeks confirmation from the user. |
841 * Seeks confirmation from the user. |
918 * |
842 * |
919 * @param aAppName the name of the application on behalf of which the |
843 * @param aAppName the name of the application on behalf of which the |
1057 /** |
979 /** |
1058 * Hides or unhides InstallerUi. |
980 * Hides or unhides InstallerUi. |
1059 */ |
981 */ |
1060 public void hide(boolean aHide) |
982 public void hide(boolean aHide) |
1061 { |
983 { |
1062 iParent.setMinimized(aHide); |
984 final boolean hide = aHide; |
|
985 if (iParent != null) |
|
986 { |
|
987 iParent.getDisplay().syncExec(new Runnable() |
|
988 { |
|
989 public void run() |
|
990 { |
|
991 iParent.setMinimized(hide); |
|
992 } |
|
993 }); |
|
994 } |
|
995 super.hide(aHide); |
|
996 } |
|
997 |
|
998 /** |
|
999 * Unhides the UI if it has been hidden. |
|
1000 */ |
|
1001 protected void unhide() |
|
1002 { |
|
1003 if (iHidden) |
|
1004 { |
|
1005 hide(false); |
|
1006 } |
1063 } |
1007 } |
1064 |
1008 |
1065 /** |
1009 /** |
1066 * Returns string title basing on mode of this InstallerUi. |
1010 * Returns string title basing on mode of this InstallerUi. |
1067 */ |
1011 */ |
1072 { |
1016 { |
1073 result = InstallerUiTexts.get(InstallerUiTexts.INSTALLING); |
1017 result = InstallerUiTexts.get(InstallerUiTexts.INSTALLING); |
1074 } |
1018 } |
1075 else if (iMode == MODE_UNINSTALL) |
1019 else if (iMode == MODE_UNINSTALL) |
1076 { |
1020 { |
1077 result = InstallerUiTexts.get(InstallerUiTexts.UNINSTALLING); |
1021 result = InstallerUiTexts.get("Uninstalling"); |
1078 } |
1022 } |
1079 else if (iMode == MODE_APP_CONVERSION) |
1023 else if (iMode == MODE_APP_CONVERSION) |
1080 { |
1024 { |
1081 result = InstallerUiTexts.get( |
1025 result = InstallerUiTexts.get( |
1082 InstallerUiTexts.APP_CONVERSION_PROGRESS, |
1026 "Converting data for application " + |
1083 new Object[] { new Integer(iAppConversionCurrent), |
1027 iAppConversionCurrent + "/" + iAppConversionTotal); |
1084 new Integer(iAppConversionTotal) |
|
1085 }); |
|
1086 } |
1028 } |
1087 return result; |
1029 return result; |
1088 } |
1030 } |
1089 |
1031 |
1090 /** |
1032 /** |