25 import com.nokia.mj.impl.installer.ui.InstallerUiListener; |
25 import com.nokia.mj.impl.installer.ui.InstallerUiListener; |
26 import com.nokia.mj.impl.installer.ui.InstallInfo; |
26 import com.nokia.mj.impl.installer.ui.InstallInfo; |
27 import com.nokia.mj.impl.installer.ui.LaunchAppInfo; |
27 import com.nokia.mj.impl.installer.ui.LaunchAppInfo; |
28 import com.nokia.mj.impl.installer.ui.PermissionInfo; |
28 import com.nokia.mj.impl.installer.ui.PermissionInfo; |
29 import com.nokia.mj.impl.installer.ui.UninstallInfo; |
29 import com.nokia.mj.impl.installer.ui.UninstallInfo; |
|
30 import com.nokia.mj.impl.installer.ui.eswt.MinimalUi; |
30 import com.nokia.mj.impl.rt.ui.ConfirmData; |
31 import com.nokia.mj.impl.rt.ui.ConfirmData; |
31 import com.nokia.mj.impl.rt.ui.RuntimeUi; |
32 import com.nokia.mj.impl.rt.ui.RuntimeUi; |
32 import com.nokia.mj.impl.rt.ui.RuntimeUiFactory; |
33 import com.nokia.mj.impl.rt.ui.RuntimeUiFactory; |
33 import com.nokia.mj.impl.utils.ResourceUtil; |
34 import com.nokia.mj.impl.utils.ResourceUtil; |
34 import com.nokia.mj.impl.utils.StartUpTrace; |
35 import com.nokia.mj.impl.utils.StartUpTrace; |
35 import com.nokia.mj.impl.utils.exception.InstallerExceptionBase; |
36 import com.nokia.mj.impl.utils.exception.InstallerExceptionBase; |
36 |
37 |
37 import java.io.InputStream; |
38 import java.io.InputStream; |
38 import java.io.IOException; |
39 import java.io.IOException; |
39 import java.util.Enumeration; |
|
40 import java.util.Hashtable; |
40 import java.util.Hashtable; |
41 |
41 |
42 import org.eclipse.ercp.swt.midp.UIThreadSupport; |
42 import org.eclipse.ercp.swt.midp.UIThreadSupport; |
43 import org.eclipse.swt.SWT; |
43 import org.eclipse.swt.SWT; |
44 import org.eclipse.swt.events.ControlEvent; |
44 import org.eclipse.swt.events.ControlEvent; |
45 import org.eclipse.swt.events.ControlListener; |
45 import org.eclipse.swt.events.ControlListener; |
46 import org.eclipse.swt.graphics.Font; |
46 import org.eclipse.swt.graphics.Font; |
47 import org.eclipse.swt.graphics.FontData; |
47 import org.eclipse.swt.graphics.FontData; |
48 import org.eclipse.swt.graphics.Image; |
48 import org.eclipse.swt.graphics.Image; |
49 import org.eclipse.swt.graphics.ImageData; |
49 import org.eclipse.swt.graphics.ImageData; |
|
50 import org.eclipse.swt.graphics.ImageLoader; |
50 import org.eclipse.swt.graphics.Point; |
51 import org.eclipse.swt.graphics.Point; |
51 import org.eclipse.swt.graphics.Rectangle; |
52 import org.eclipse.swt.graphics.Rectangle; |
52 import org.eclipse.swt.internal.extension.DisplayExtension; |
53 import org.eclipse.swt.internal.extension.DisplayExtension; |
53 import org.eclipse.swt.internal.qt.BaseCSSEngine; |
|
54 import org.eclipse.swt.widgets.Display; |
54 import org.eclipse.swt.widgets.Display; |
55 import org.eclipse.swt.widgets.Event; |
55 import org.eclipse.swt.widgets.Event; |
56 import org.eclipse.swt.widgets.Composite; |
56 import org.eclipse.swt.widgets.Composite; |
57 import org.eclipse.swt.widgets.Listener; |
57 import org.eclipse.swt.widgets.Listener; |
58 import org.eclipse.swt.widgets.Shell; |
58 import org.eclipse.swt.widgets.Shell; |
60 /** |
60 /** |
61 * JavaInstaller eSWT UI. |
61 * JavaInstaller eSWT UI. |
62 */ |
62 */ |
63 public class InstallerUiEswt extends InstallerUi |
63 public class InstallerUiEswt extends InstallerUi |
64 { |
64 { |
65 /** Disable UI temporarily. */ |
|
66 private static final boolean DISABLE_UI = |
|
67 (System.getProperty("com.nokia.mj.impl.installer.ui.disableui") |
|
68 == null? false: true); |
|
69 /** Default shell style. */ |
65 /** Default shell style. */ |
70 private static final int SHELL_STYLE = |
66 private static final int SHELL_STYLE = |
71 SWT.BORDER | SWT.APPLICATION_MODAL | SWT.ON_TOP; |
67 SWT.BORDER | SWT.APPLICATION_MODAL | SWT.ON_TOP; |
72 |
68 |
73 private BaseCSSEngine iCssEngine = null; |
|
74 private Shell iParent = null; |
69 private Shell iParent = null; |
75 private Shell iDialog = null; |
70 private Shell iDialog = null; |
76 private ProgressView iProgressView = null; |
71 private ProgressView iProgressView = null; |
77 private ProgressView iDlProgressView = null; |
72 private ProgressView iDlProgressView = null; |
78 private ProgressView iOcspProgressView = null; |
73 private ProgressView iOcspProgressView = null; |
101 private Image iSecurityIcon = null; |
96 private Image iSecurityIcon = null; |
102 /** Flag telling if progress bar should be displayed. */ |
97 /** Flag telling if progress bar should be displayed. */ |
103 private boolean iDisplayProgress = false; |
98 private boolean iDisplayProgress = false; |
104 /** Flag telling if the first progress bar update has been traced. */ |
99 /** Flag telling if the first progress bar update has been traced. */ |
105 private boolean iProgressBarUpdateTraced = false; |
100 private boolean iProgressBarUpdateTraced = false; |
106 |
101 /** Flag telling if MinimalUi should be used if UI creation fails. */ |
107 /** Certificate details view, owned by the view where it was opened. */ |
102 private boolean iMinimalUiEnabled = true; |
108 private CertificateDetailsView iCertificateDetailsView = null; |
|
109 |
103 |
110 /** Hashtable for storing the loaded icons. */ |
104 /** Hashtable for storing the loaded icons. */ |
111 private static Hashtable iImageTable = null; |
105 private static Hashtable iImageTable = null; |
112 /** Best size for application icon. */ |
106 /** Best size for application icon. */ |
113 private static Point iBestIconSize = null; |
107 private static Point iBestIconSize = null; |
157 * This method is executed in UI main thread. |
152 * This method is executed in UI main thread. |
158 */ |
153 */ |
159 private void uiMain() |
154 private void uiMain() |
160 { |
155 { |
161 log("uiMain: thread started"); |
156 log("uiMain: thread started"); |
162 iUiThreadExists = true; |
|
163 try |
157 try |
164 { |
158 { |
165 // Create the necessary views. |
159 // Create the necessary views. |
166 DisplayExtension display = new DisplayExtension(); |
160 DisplayExtension display = new DisplayExtension(); |
167 StartUpTrace.doTrace("InstallerUiEswt display created"); |
161 StartUpTrace.doTrace("InstallerUiEswt display created"); |
168 display.setAppName(""); // Remove display title. |
162 display.setAppName(""); // Remove display title. |
169 iCssEngine = new BaseCSSEngine(display); |
|
170 iParent = new Shell(display); |
163 iParent = new Shell(display); |
171 iDialog = new Shell(iParent, SHELL_STYLE); |
164 iDialog = new Shell(iParent, SHELL_STYLE); |
172 iDefaultShellBounds = iDialog.internal_getDefaultBounds(); |
165 iDefaultShellBounds = iDialog.internal_getDefaultBounds(); |
173 iDefaultShellClientBounds = iDialog.getClientArea(); |
166 iDefaultShellClientBounds = iDialog.getClientArea(); |
174 iBoldFont = getBoldFont(); |
167 iBoldFont = getBoldFont(); |
187 //aEvent.doit = false; |
180 //aEvent.doit = false; |
188 } |
181 } |
189 }); |
182 }); |
190 |
183 |
191 // Initialize best icon size. |
184 // Initialize best icon size. |
192 //iBestIconSize = new Point( |
185 iBestIconSize = new Point( |
193 // display.getBestImageWidth(DisplayExtension.ALERT), |
186 display.getBestImageWidth(DisplayExtension.ALERT), |
194 // display.getBestImageHeight(DisplayExtension.ALERT)); |
187 display.getBestImageHeight(DisplayExtension.ALERT)); |
195 //log("Best icon size: " + iBestIconSize); |
188 log("Best icon size: " + iBestIconSize); |
196 |
189 |
197 synchronized (iInitWaitObject) |
190 synchronized (iInitWaitObject) |
198 { |
191 { |
199 // Notify that UI is now ready. |
192 // Notify that UI is now ready. |
200 iInitWaitObject.notify(); |
193 iInitWaitObject.notify(); |
254 * Cancels all confirmation views that are currently displayed. |
250 * Cancels all confirmation views that are currently displayed. |
255 */ |
251 */ |
256 public void cancelConfirmations() |
252 public void cancelConfirmations() |
257 { |
253 { |
258 super.cancelConfirmations(); |
254 super.cancelConfirmations(); |
259 if (iCertificateDetailsView != null) |
|
260 { |
|
261 iCertificateDetailsView.confirmCancel(); |
|
262 } |
|
263 if (iInstallConfirmationView != null) |
255 if (iInstallConfirmationView != null) |
264 { |
256 { |
265 iInstallConfirmationView.confirmCancel(); |
257 iInstallConfirmationView.confirmCancel(); |
266 } |
258 } |
267 if (iPermissionConfirmationView != null) |
259 if (iPermissionConfirmationView != null) |
308 public boolean confirm(InstallInfo aInstallInfo) |
300 public boolean confirm(InstallInfo aInstallInfo) |
309 { |
301 { |
310 super.confirm(aInstallInfo); |
302 super.confirm(aInstallInfo); |
311 |
303 |
312 waitForUi(); |
304 waitForUi(); |
|
305 boolean result = true; |
313 if (!isUiReady()) |
306 if (!isUiReady()) |
314 { |
307 { |
315 // If UI is not ready by the time confirmation is requested, |
308 result = false; |
316 // throw an exception. |
309 if (iMinimalUiEnabled) |
317 throw new RuntimeException("JavaInstallerUi not ready"); |
310 { |
318 } |
311 result = MinimalUi.confirmStatic(aInstallInfo); |
319 |
312 log("MinimalUi installation confirmation returns " + result); |
320 boolean result = true; |
313 return result; |
|
314 } |
|
315 else |
|
316 { |
|
317 // If UI is not ready by the time confirmation is requested, |
|
318 // throw an exception. |
|
319 throw new RuntimeException("JavaInstallerUi not ready"); |
|
320 } |
|
321 } |
|
322 |
321 if (result) |
323 if (result) |
322 { |
324 { |
323 StartUpTrace.doTrace("InstallerUiEswt confirm"); |
325 StartUpTrace.doTrace("InstallerUiEswt confirm"); |
324 if (iInstallConfirmationView == null) |
326 if (iInstallConfirmationView == null) |
325 { |
327 { |
462 * @param aProgress progress value between 0 and 100 |
461 * @param aProgress progress value between 0 and 100 |
463 */ |
462 */ |
464 public void updateProgress(int aProgress) |
463 public void updateProgress(int aProgress) |
465 { |
464 { |
466 super.updateProgress(aProgress); |
465 super.updateProgress(aProgress); |
467 if (DISABLE_UI) return; // Disable UI temporarily. |
|
468 if (!isUiReady()) |
466 if (!isUiReady()) |
469 { |
467 { |
470 return; |
468 return; |
471 } |
469 } |
472 // UI is created asynchronously, so it might be that |
470 // UI is created asynchronously, so it might be that |
473 // UI was not yet ready when started() was called. |
471 // UI was not yet ready when started() was called. |
474 // Ensure that iProgressView has been opened before |
472 // Ensure that iProgressView has been opened before |
475 // updating it. |
473 // updating it. |
476 synchronized (iProgressSyncObject) |
474 synchronized (iProgressSyncObject) |
477 { |
475 { |
478 if (iDlProgressView != null && iDlProgressView.isVisible()) |
476 if (iDisplayProgress && !iProgressView.isVisible()) |
479 { |
|
480 // If download progress is being displayed, |
|
481 // do not display installation progress. |
|
482 return; |
|
483 } |
|
484 if (iDisplayProgress && !iProgressView.isVisible() && |
|
485 iCertificateDetailsView == null) |
|
486 { |
477 { |
487 // Re-create iProgressView here so that it gets |
478 // Re-create iProgressView here so that it gets |
488 // application info that was set when confirm() |
479 // application info that was set when confirm() |
489 // was called. |
480 // was called. |
490 final InstallerUiEswt self = this; |
481 final InstallerUiEswt self = this; |
683 final InstallerUiEswt self = this; |
667 final InstallerUiEswt self = this; |
684 iParent.getDisplay().syncExec(new Runnable() |
668 iParent.getDisplay().syncExec(new Runnable() |
685 { |
669 { |
686 public void run() |
670 public void run() |
687 { |
671 { |
688 iOcspProgressView = new ProgressView( |
672 iOcspProgressView = new ProgressView(self, iDialog, |
689 self, iDialog, |
673 InstallerUiTexts.get(InstallerUiTexts.OCSP_CHECK_PROGRESS), |
690 InstallerUiTexts.get(InstallerUiTexts.OCSP_CHECK_PROGRESS), |
674 true); |
691 true); |
|
692 } |
675 } |
693 }); |
676 }); |
694 iOcspProgressView.addCancelCommand(); |
677 iOcspProgressView.addCancelCommand(); |
695 } |
678 } |
696 if (iOcspProgressView != null) |
679 if (iOcspProgressView != null) |
697 { |
680 { |
698 if (!iOcspProgressView.isVisible() && |
681 if (!iOcspProgressView.isVisible()) |
699 iCertificateDetailsView == null) |
|
700 { |
682 { |
701 iOcspProgressView.setVisible(true); |
683 iOcspProgressView.setVisible(true); |
702 } |
684 } |
703 } |
685 } |
704 } |
686 } |
815 result = iErrorDetailsView.error(aInstallerException); |
795 result = iErrorDetailsView.error(aInstallerException); |
816 iErrorDetailsView.dispose(); |
796 iErrorDetailsView.dispose(); |
817 iErrorDetailsView = null; |
797 iErrorDetailsView = null; |
818 } |
798 } |
819 } |
799 } |
|
800 |
|
801 /** |
|
802 * Notify user that an error has occurred using RuntimeUI. |
|
803 * |
|
804 * @param aInstallerException exception indicating the error reason |
|
805 */ |
|
806 /* |
|
807 private void showRuntimeUiError(InstallerExceptionBase aInstallerException) |
|
808 { |
|
809 boolean identified = false; |
|
810 if (iInstallInfo != null) |
|
811 { |
|
812 if (iInstallInfo.getCertificates() != null) |
|
813 { |
|
814 identified = true; |
|
815 } |
|
816 } |
|
817 else if (iUninstallInfo != null) |
|
818 { |
|
819 if (iUninstallInfo.getCertificates() != null) |
|
820 { |
|
821 identified = true; |
|
822 } |
|
823 } |
|
824 String tmpTitle = InstallerUiTexts.get(InstallerUiTexts.INSTALL_FAILED); |
|
825 |
|
826 // Ensure that no confirmations are being displayed. |
|
827 cancelConfirmations(); |
|
828 // Hide progress view before displaying error message. |
|
829 if (iProgressView != null) |
|
830 { |
|
831 iProgressView.setVisible(false); |
|
832 } |
|
833 // Use RuntimeUi to display uninstallation error message. |
|
834 RuntimeUi runtimeUi = RuntimeUiFactory.getRuntimeUi(identified); |
|
835 runtimeUi.error(tmpTitle, aInstallerException); |
|
836 runtimeUi.destroy(); |
|
837 } |
|
838 */ |
820 |
839 |
821 /** |
840 /** |
822 * Seeks confirmation from the user. |
841 * Seeks confirmation from the user. |
823 * |
842 * |
824 * @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 |
829 * @return true if the user has answered, false if the user has |
848 * @return true if the user has answered, false if the user has |
830 * canceled the confirmation |
849 * canceled the confirmation |
831 */ |
850 */ |
832 public boolean confirm(String aAppName, ConfirmData aConfirmData) |
851 public boolean confirm(String aAppName, ConfirmData aConfirmData) |
833 { |
852 { |
834 if (DISABLE_UI) return true; // Disable UI temporarily. |
|
835 waitForUi(); |
853 waitForUi(); |
836 if (!isUiReady()) { |
854 if (!isUiReady()) { |
837 return true; |
855 return true; |
838 } |
856 } |
839 waitForCertificateDetailsView(); |
|
840 if (iConfirmationsCanceled) |
|
841 { |
|
842 return false; |
|
843 } |
|
844 |
|
845 // Ensure that UI is visible when this prompt is displayed. |
|
846 unhide(); |
|
847 |
857 |
848 if (iRuntimeConfirmationView == null) |
858 if (iRuntimeConfirmationView == null) |
849 { |
859 { |
850 final Display display = iParent.getDisplay(); |
860 final Display display = iParent.getDisplay(); |
851 final InstallerUiEswt self = this; |
861 final InstallerUiEswt self = this; |
876 * and second being password. If username and password |
886 * and second being password. If username and password |
877 * cannot be obtained, this method returns null. |
887 * cannot be obtained, this method returns null. |
878 */ |
888 */ |
879 public String[] getUsernamePassword(String aUrl) |
889 public String[] getUsernamePassword(String aUrl) |
880 { |
890 { |
881 if (DISABLE_UI) return new String[] { "", "" }; // Disable UI temporarily. |
|
882 waitForUi(); |
891 waitForUi(); |
883 waitForCertificateDetailsView(); |
892 if (!isUiReady()) |
884 if (!isUiReady() || iConfirmationsCanceled) |
|
885 { |
893 { |
886 return null; |
894 return null; |
887 } |
895 } |
888 |
|
889 // Ensure that UI is visible when this prompt is displayed. |
|
890 unhide(); |
|
891 |
896 |
892 synchronized (iProgressSyncObject) |
897 synchronized (iProgressSyncObject) |
893 { |
898 { |
894 // Do not display progress bar during dialog. |
899 // Do not display progress bar during dialog. |
895 iDisplayProgress = false; |
900 iDisplayProgress = false; |
936 * @return true if the user has chosen to launch the application, |
941 * @return true if the user has chosen to launch the application, |
937 * false if the user has canceled the query |
942 * false if the user has canceled the query |
938 */ |
943 */ |
939 public boolean launchAppQuery(LaunchAppInfo aLaunchAppInfo) |
944 public boolean launchAppQuery(LaunchAppInfo aLaunchAppInfo) |
940 { |
945 { |
941 if (DISABLE_UI) return false; // Disable UI temporarily. |
|
942 waitForUi(); |
946 waitForUi(); |
943 waitForCertificateDetailsView(); |
947 if (!isUiReady() || iConfirmationsCanceled || getInstallInfo() == null) |
944 if (!isUiReady() || iConfirmationsCanceled || |
948 { |
945 iHidden || getInstallInfo() == null) |
949 // Either UI is not yet ready, or user has cancelled |
946 { |
950 // installation, in both cases do nothing. |
947 // Either UI is not yet ready, user has cancelled |
|
948 // installation or UI is hidden; in all these cases |
|
949 // do nothing. |
|
950 return false; |
951 return false; |
951 } |
952 } |
952 |
953 |
953 if (iLaunchAppQueryView == null) |
954 if (iLaunchAppQueryView == null) |
954 { |
955 { |
961 iLaunchAppQueryView = new LaunchAppQueryView(self, iDialog); |
962 iLaunchAppQueryView = new LaunchAppQueryView(self, iDialog); |
962 } |
963 } |
963 }); |
964 }); |
964 } |
965 } |
965 boolean result = iLaunchAppQueryView.launchAppQuery(aLaunchAppInfo); |
966 boolean result = iLaunchAppQueryView.launchAppQuery(aLaunchAppInfo); |
966 iLaunchAppQueryView.dispose(); |
967 iParent.getDisplay().syncExec(new Runnable() |
|
968 { |
|
969 public void run() |
|
970 { |
|
971 iParent.dispose(); |
|
972 } |
|
973 }); |
967 iLaunchAppQueryView = null; |
974 iLaunchAppQueryView = null; |
968 if (!result) |
|
969 { |
|
970 iParent.getDisplay().syncExec(new Runnable() |
|
971 { |
|
972 public void run() |
|
973 { |
|
974 iParent.dispose(); |
|
975 } |
|
976 }); |
|
977 } |
|
978 log("LaunchAppQuery returns " + result + " for " + aLaunchAppInfo); |
975 log("LaunchAppQuery returns " + result + " for " + aLaunchAppInfo); |
979 return result; |
976 return result; |
980 } |
977 } |
981 |
978 |
982 /** |
979 /** |
983 * Executes given Runnable synchronously in the UI thread. |
|
984 */ |
|
985 public void syncExec(Runnable aRunnable) |
|
986 { |
|
987 if (!iParent.getDisplay().isDisposed()) |
|
988 { |
|
989 iParent.getDisplay().syncExec(aRunnable); |
|
990 } |
|
991 } |
|
992 |
|
993 /** |
|
994 * Hides or unhides InstallerUi. |
980 * Hides or unhides InstallerUi. |
995 */ |
981 */ |
996 public void hide(boolean aHide) |
982 public void hide(boolean aHide) |
997 { |
983 { |
998 iHidden = aHide; |
984 final boolean hide = aHide; |
999 if (iDialog != null) |
985 if (iParent != null) |
1000 { |
986 { |
1001 iDialog.getDisplay().syncExec(new Runnable() |
987 iParent.getDisplay().syncExec(new Runnable() |
1002 { |
988 { |
1003 public void run() |
989 public void run() |
1004 { |
990 { |
1005 iDialog.setMinimized(iHidden); |
991 iParent.setMinimized(hide); |
1006 } |
992 } |
1007 }); |
993 }); |
1008 } |
994 } |
1009 super.hide(aHide); |
995 super.hide(aHide); |
1010 } |
996 } |
1019 hide(false); |
1005 hide(false); |
1020 } |
1006 } |
1021 } |
1007 } |
1022 |
1008 |
1023 /** |
1009 /** |
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 } |
|
1059 } |
|
1060 } |
|
1061 |
|
1062 /** |
|
1063 * Returns string title basing on mode of this InstallerUi. |
1010 * Returns string title basing on mode of this InstallerUi. |
1064 */ |
1011 */ |
1065 protected String getTitle() |
1012 protected String getTitle() |
1066 { |
1013 { |
1067 String result = super.getTitle(); |
1014 String result = null; |
1068 if (isUiReady()) |
1015 if (iMode == MODE_INSTALL) |
1069 { |
1016 { |
1070 if (iMode == MODE_INSTALL) |
1017 result = InstallerUiTexts.get(InstallerUiTexts.INSTALLING); |
1071 { |
1018 } |
1072 result = InstallerUiTexts.get(InstallerUiTexts.INSTALLING); |
1019 else if (iMode == MODE_UNINSTALL) |
1073 } |
1020 { |
1074 else if (iMode == MODE_UNINSTALL) |
1021 result = InstallerUiTexts.get("Uninstalling"); |
1075 { |
1022 } |
1076 result = InstallerUiTexts.get("Uninstalling"); |
1023 else if (iMode == MODE_APP_CONVERSION) |
1077 } |
1024 { |
1078 else if (iMode == MODE_APP_CONVERSION) |
1025 result = InstallerUiTexts.get( |
1079 { |
1026 "Converting data for application " + |
1080 result = InstallerUiTexts.get( |
1027 iAppConversionCurrent + "/" + iAppConversionTotal); |
1081 "Converting data for application " + |
|
1082 iAppConversionCurrent + "/" + iAppConversionTotal); |
|
1083 } |
|
1084 } |
1028 } |
1085 return result; |
1029 return result; |
1086 } |
1030 } |
1087 |
1031 |
1088 /** |
1032 /** |
1098 { |
1042 { |
1099 if (iSecurityIcon != null) |
1043 if (iSecurityIcon != null) |
1100 { |
1044 { |
1101 return iSecurityIcon; |
1045 return iSecurityIcon; |
1102 } |
1046 } |
1103 String iconFilename = "java_3_untrusted.png"; |
1047 String iconFilename = ResourceUtil.UNTRUSTED_ICON_NAME; |
1104 if (aIdentified) |
1048 if (aIdentified) |
1105 { |
1049 { |
1106 iconFilename = "java_3_trusted.png"; |
1050 iconFilename = ResourceUtil.TRUSTED_ICON_NAME; |
1107 } |
1051 } |
1108 try |
1052 String resourceDir = ResourceUtil.getResourceDir(0); |
1109 { |
1053 for (int i = 1; iSecurityIcon == null && resourceDir != null; i++) |
1110 String resourceDir = ResourceUtil.getResourceDir(0); |
1054 { |
1111 for (int i = 1; iSecurityIcon == null && resourceDir != null; i++) |
1055 iSecurityIcon = loadImage(aDisplay, resourceDir + iconFilename, false); |
1112 { |
1056 resourceDir = ResourceUtil.getResourceDir(i); |
1113 iSecurityIcon = loadImage( |
|
1114 aDisplay, resourceDir + iconFilename, false); |
|
1115 resourceDir = ResourceUtil.getResourceDir(i); |
|
1116 } |
|
1117 } |
|
1118 catch (Throwable t) |
|
1119 { |
|
1120 log("Can not load security icon: " + t); |
|
1121 } |
1057 } |
1122 return iSecurityIcon; |
1058 return iSecurityIcon; |
1123 } |
1059 } |
1124 |
1060 |
1125 /** |
1061 /** |
1206 return result; |
1142 return result; |
1207 } |
1143 } |
1208 try |
1144 try |
1209 { |
1145 { |
1210 long startTime = System.currentTimeMillis(); |
1146 long startTime = System.currentTimeMillis(); |
1211 Image image = new Image(aDisplay, aInputStream); |
1147 ImageData[] imageDatas = new ImageLoader().load(aInputStream); |
1212 ImageData imageData = image.getImageData(); |
1148 ImageData imageData = imageDatas[0]; |
1213 if (aScaleImage) |
1149 if (aScaleImage) |
1214 { |
1150 { |
1215 Point bestSize = getBestImageSize( |
1151 Point bestSize = getBestImageSize( |
1216 imageData.width, imageData.height); |
1152 imageData.width, imageData.height); |
1217 if (bestSize.x != imageData.width || |
1153 if (bestSize.x != imageData.width || |
1218 bestSize.y != imageData.height) |
1154 bestSize.y != imageData.height) |
1219 { |
1155 { |
1220 Point oldSize = |
|
1221 new Point(imageData.width, imageData.height); |
|
1222 imageData = imageData.scaledTo(bestSize.x, bestSize.y); |
1156 imageData = imageData.scaledTo(bestSize.x, bestSize.y); |
1223 log("Image " + aImageName + " scaled from " + |
1157 log("Image " + aImageName + " scaled from " + |
1224 oldSize.x + "x" + oldSize.y + " to " + |
1158 imageDatas[0].width + "x" + imageDatas[0].height + |
1225 bestSize.x + "x" + bestSize.y); |
1159 " to " + bestSize.x + "x" + bestSize.y); |
1226 } |
1160 } |
1227 } |
1161 } |
1228 result = new Image(aDisplay, imageData); |
1162 result = new Image(aDisplay, imageData); |
1229 long endTime = System.currentTimeMillis(); |
1163 long endTime = System.currentTimeMillis(); |
1230 log("Loaded image " + aImageName + " (load time " + |
1164 log("Loaded image " + aImageName + " (load time " + |
1242 /** |
1176 /** |
1243 * Determines the best image size for the image of given size. |
1177 * Determines the best image size for the image of given size. |
1244 */ |
1178 */ |
1245 private static Point getBestImageSize(int aWidth, int aHeight) |
1179 private static Point getBestImageSize(int aWidth, int aHeight) |
1246 { |
1180 { |
1247 final int MAX_WIDTH = (iBestIconSize == null? 50: iBestIconSize.x); |
1181 final int MAX_WIDTH = iBestIconSize.x; |
1248 final int MAX_HEIGHT = (iBestIconSize == null? 50: iBestIconSize.y); |
1182 final int MAX_HEIGHT = iBestIconSize.y; |
1249 Point result = new Point(aWidth, aHeight); |
1183 Point result = new Point(aWidth, aHeight); |
1250 if (result.x > MAX_WIDTH || result.y > MAX_HEIGHT) |
1184 if (result.x > MAX_WIDTH || result.y > MAX_HEIGHT) |
1251 { |
1185 { |
1252 if (result.x >= MAX_WIDTH) |
1186 if (result.x >= MAX_WIDTH) |
1253 { |
1187 { |
1371 |
1305 |
1372 ViewBase getActiveView() |
1306 ViewBase getActiveView() |
1373 { |
1307 { |
1374 return iActiveView; |
1308 return iActiveView; |
1375 } |
1309 } |
1376 |
|
1377 /** |
|
1378 * Loads JavaInstaller UI stylesheet. |
|
1379 */ |
|
1380 void loadCss() |
|
1381 { |
|
1382 String cssFilename = "javaapplicationinstaller.css"; |
|
1383 String cssPath = null; |
|
1384 try |
|
1385 { |
|
1386 if (iCssEngine != null) |
|
1387 { |
|
1388 boolean loaded = false; |
|
1389 String resourceDir = ResourceUtil.getResourceDir(0); |
|
1390 for (int i = 1; !loaded && resourceDir != null; i++) |
|
1391 { |
|
1392 cssPath = resourceDir + cssFilename; |
|
1393 FileUtility cssFile = new FileUtility(cssPath); |
|
1394 if (cssFile.exists()) |
|
1395 { |
|
1396 iCssEngine.loadCSS(cssPath); |
|
1397 log("CSS loaded from " + cssPath); |
|
1398 break; |
|
1399 } |
|
1400 resourceDir = ResourceUtil.getResourceDir(i); |
|
1401 } |
|
1402 } |
|
1403 } |
|
1404 catch (Throwable t) |
|
1405 { |
|
1406 logError("Loading CSS from " + cssPath + " failed", t); |
|
1407 } |
|
1408 } |
|
1409 |
|
1410 private void disposeResources() { |
|
1411 if (iBoldFont != null && !iBoldFont.isDisposed()) |
|
1412 { |
|
1413 iBoldFont.dispose(); |
|
1414 } |
|
1415 if (iSecurityIcon != null && !iSecurityIcon.isDisposed()) |
|
1416 { |
|
1417 iSecurityIcon.dispose(); |
|
1418 } |
|
1419 Enumeration e = iImageTable.elements(); |
|
1420 while (e.hasMoreElements()) |
|
1421 { |
|
1422 Image img = (Image)e.nextElement(); |
|
1423 if (img != null && !img.isDisposed()) |
|
1424 { |
|
1425 img.dispose(); |
|
1426 } |
|
1427 } |
|
1428 } |
|
1429 } |
1310 } |