--- a/javamanager/javainstaller/installerui/javasrc/com/nokia/mj/impl/installer/ui/eswt2/InstallerUiEswt.java Wed Sep 15 12:05:25 2010 +0300
+++ b/javamanager/javainstaller/installerui/javasrc/com/nokia/mj/impl/installer/ui/eswt2/InstallerUiEswt.java Wed Oct 13 14:23:59 2010 +0300
@@ -27,6 +27,7 @@
import com.nokia.mj.impl.installer.ui.LaunchAppInfo;
import com.nokia.mj.impl.installer.ui.PermissionInfo;
import com.nokia.mj.impl.installer.ui.UninstallInfo;
+import com.nokia.mj.impl.installer.ui.eswt.MinimalUi;
import com.nokia.mj.impl.rt.ui.ConfirmData;
import com.nokia.mj.impl.rt.ui.RuntimeUi;
import com.nokia.mj.impl.rt.ui.RuntimeUiFactory;
@@ -36,7 +37,6 @@
import java.io.InputStream;
import java.io.IOException;
-import java.util.Enumeration;
import java.util.Hashtable;
import org.eclipse.ercp.swt.midp.UIThreadSupport;
@@ -47,10 +47,10 @@
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData;
+import org.eclipse.swt.graphics.ImageLoader;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.internal.extension.DisplayExtension;
-import org.eclipse.swt.internal.qt.BaseCSSEngine;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Composite;
@@ -62,15 +62,10 @@
*/
public class InstallerUiEswt extends InstallerUi
{
- /** Disable UI temporarily. */
- private static final boolean DISABLE_UI =
- (System.getProperty("com.nokia.mj.impl.installer.ui.disableui")
- == null? false: true);
/** Default shell style. */
private static final int SHELL_STYLE =
SWT.BORDER | SWT.APPLICATION_MODAL | SWT.ON_TOP;
- private BaseCSSEngine iCssEngine = null;
private Shell iParent = null;
private Shell iDialog = null;
private ProgressView iProgressView = null;
@@ -103,9 +98,8 @@
private boolean iDisplayProgress = false;
/** Flag telling if the first progress bar update has been traced. */
private boolean iProgressBarUpdateTraced = false;
-
- /** Certificate details view, owned by the view where it was opened. */
- private CertificateDetailsView iCertificateDetailsView = null;
+ /** Flag telling if MinimalUi should be used if UI creation fails. */
+ private boolean iMinimalUiEnabled = true;
/** Hashtable for storing the loaded icons. */
private static Hashtable iImageTable = null;
@@ -141,6 +135,7 @@
// Create a hashtable for icons.
iImageTable = new Hashtable();
// Create a new thread to be the UI main thread.
+ iUiThreadExists = true;
UIThreadSupport.startInUIThread(new Runnable()
{
public void run()
@@ -159,14 +154,12 @@
private void uiMain()
{
log("uiMain: thread started");
- iUiThreadExists = true;
try
{
// Create the necessary views.
DisplayExtension display = new DisplayExtension();
StartUpTrace.doTrace("InstallerUiEswt display created");
display.setAppName(""); // Remove display title.
- iCssEngine = new BaseCSSEngine(display);
iParent = new Shell(display);
iDialog = new Shell(iParent, SHELL_STYLE);
iDefaultShellBounds = iDialog.internal_getDefaultBounds();
@@ -189,10 +182,10 @@
});
// Initialize best icon size.
- //iBestIconSize = new Point(
- // display.getBestImageWidth(DisplayExtension.ALERT),
- // display.getBestImageHeight(DisplayExtension.ALERT));
- //log("Best icon size: " + iBestIconSize);
+ iBestIconSize = new Point(
+ display.getBestImageWidth(DisplayExtension.ALERT),
+ display.getBestImageHeight(DisplayExtension.ALERT));
+ log("Best icon size: " + iBestIconSize);
synchronized (iInitWaitObject)
{
@@ -223,7 +216,10 @@
display.sleep();
}
}
- disposeResources();
+ if (iBoldFont != null && !iBoldFont.isDisposed())
+ {
+ iBoldFont.dispose();
+ }
display.dispose();
log("uiMain: display disposed");
synchronized (iExitWaitObject)
@@ -256,10 +252,6 @@
public void cancelConfirmations()
{
super.cancelConfirmations();
- if (iCertificateDetailsView != null)
- {
- iCertificateDetailsView.confirmCancel();
- }
if (iInstallConfirmationView != null)
{
iInstallConfirmationView.confirmCancel();
@@ -310,14 +302,24 @@
super.confirm(aInstallInfo);
waitForUi();
+ boolean result = true;
if (!isUiReady())
{
- // If UI is not ready by the time confirmation is requested,
- // throw an exception.
- throw new RuntimeException("JavaInstallerUi not ready");
+ result = false;
+ if (iMinimalUiEnabled)
+ {
+ result = MinimalUi.confirmStatic(aInstallInfo);
+ log("MinimalUi installation confirmation returns " + result);
+ return result;
+ }
+ else
+ {
+ // If UI is not ready by the time confirmation is requested,
+ // throw an exception.
+ throw new RuntimeException("JavaInstallerUi not ready");
+ }
}
- boolean result = true;
if (result)
{
StartUpTrace.doTrace("InstallerUiEswt confirm");
@@ -397,9 +399,6 @@
return true;
}
- // Ensure that UI is visible when this prompt is displayed.
- unhide();
-
synchronized (iProgressSyncObject)
{
// Do not display progress bar during dialog.
@@ -464,7 +463,6 @@
public void updateProgress(int aProgress)
{
super.updateProgress(aProgress);
- if (DISABLE_UI) return; // Disable UI temporarily.
if (!isUiReady())
{
return;
@@ -475,14 +473,7 @@
// updating it.
synchronized (iProgressSyncObject)
{
- if (iDlProgressView != null && iDlProgressView.isVisible())
- {
- // If download progress is being displayed,
- // do not display installation progress.
- return;
- }
- if (iDisplayProgress && !iProgressView.isVisible() &&
- iCertificateDetailsView == null)
+ if (iDisplayProgress && !iProgressView.isVisible())
{
// Re-create iProgressView here so that it gets
// application info that was set when confirm()
@@ -518,7 +509,6 @@
public void ended()
{
super.ended();
- if (DISABLE_UI) return; // Disable UI temporarily.
if (!isUiReady())
{
return;
@@ -563,7 +553,6 @@
public void started(DownloadInfo aDownloadInfo)
{
super.started(aDownloadInfo);
- if (DISABLE_UI) return; // Disable UI temporarily.
if (!isUiReady())
{
return;
@@ -590,7 +579,6 @@
public void updateProgress(DownloadInfo aDownloadInfo)
{
super.updateProgress(aDownloadInfo);
- if (DISABLE_UI) return; // Disable UI temporarily.
if (!isUiReady())
{
return;
@@ -616,8 +604,7 @@
synchronized (iProgressSyncObject)
{
- if (iDisplayProgress && !iDlProgressView.isVisible() &&
- iCertificateDetailsView == null)
+ if (iDisplayProgress && !iDlProgressView.isVisible())
{
iDlProgressView.setVisible(true);
}
@@ -641,7 +628,6 @@
public void ended(DownloadInfo aDownloadInfo)
{
super.ended(aDownloadInfo);
- if (DISABLE_UI) return; // Disable UI temporarily.
if (!isUiReady())
{
return;
@@ -653,8 +639,7 @@
}
synchronized (iProgressSyncObject)
{
- if (iDisplayProgress && !iProgressView.isVisible() &&
- iCertificateDetailsView == null)
+ if (iDisplayProgress && !iProgressView.isVisible())
{
iProgressView.setVisible(true);
}
@@ -669,7 +654,6 @@
public void setOcspIndicator(boolean aOn)
{
super.setOcspIndicator(aOn);
- if (DISABLE_UI) return; // Disable UI temporarily.
waitForUi();
if (!isUiReady())
{
@@ -685,18 +669,16 @@
{
public void run()
{
- iOcspProgressView = new ProgressView(
- self, iDialog,
- InstallerUiTexts.get(InstallerUiTexts.OCSP_CHECK_PROGRESS),
- true);
+ iOcspProgressView = new ProgressView(self, iDialog,
+ InstallerUiTexts.get(InstallerUiTexts.OCSP_CHECK_PROGRESS),
+ true);
}
});
iOcspProgressView.addCancelCommand();
}
if (iOcspProgressView != null)
{
- if (!iOcspProgressView.isVisible() &&
- iCertificateDetailsView == null)
+ if (!iOcspProgressView.isVisible())
{
iOcspProgressView.setVisible(true);
}
@@ -772,11 +754,9 @@
public void error(InstallerExceptionBase aInstallerException)
{
super.error(aInstallerException);
- if (DISABLE_UI) return; // Disable UI temporarily.
waitForUi();
- waitForCertificateDetailsView();
- if (!isUiReady() || iHidden || iConfirmationsCanceled) {
+ if (!isUiReady()) {
return;
}
@@ -819,6 +799,45 @@
}
/**
+ * Notify user that an error has occurred using RuntimeUI.
+ *
+ * @param aInstallerException exception indicating the error reason
+ */
+ /*
+ private void showRuntimeUiError(InstallerExceptionBase aInstallerException)
+ {
+ boolean identified = false;
+ if (iInstallInfo != null)
+ {
+ if (iInstallInfo.getCertificates() != null)
+ {
+ identified = true;
+ }
+ }
+ else if (iUninstallInfo != null)
+ {
+ if (iUninstallInfo.getCertificates() != null)
+ {
+ identified = true;
+ }
+ }
+ String tmpTitle = InstallerUiTexts.get(InstallerUiTexts.INSTALL_FAILED);
+
+ // Ensure that no confirmations are being displayed.
+ cancelConfirmations();
+ // Hide progress view before displaying error message.
+ if (iProgressView != null)
+ {
+ iProgressView.setVisible(false);
+ }
+ // Use RuntimeUi to display uninstallation error message.
+ RuntimeUi runtimeUi = RuntimeUiFactory.getRuntimeUi(identified);
+ runtimeUi.error(tmpTitle, aInstallerException);
+ runtimeUi.destroy();
+ }
+ */
+
+ /**
* Seeks confirmation from the user.
*
* @param aAppName the name of the application on behalf of which the
@@ -831,19 +850,10 @@
*/
public boolean confirm(String aAppName, ConfirmData aConfirmData)
{
- if (DISABLE_UI) return true; // Disable UI temporarily.
waitForUi();
if (!isUiReady()) {
return true;
}
- waitForCertificateDetailsView();
- if (iConfirmationsCanceled)
- {
- return false;
- }
-
- // Ensure that UI is visible when this prompt is displayed.
- unhide();
if (iRuntimeConfirmationView == null)
{
@@ -878,17 +888,12 @@
*/
public String[] getUsernamePassword(String aUrl)
{
- if (DISABLE_UI) return new String[] { "", "" }; // Disable UI temporarily.
waitForUi();
- waitForCertificateDetailsView();
- if (!isUiReady() || iConfirmationsCanceled)
+ if (!isUiReady())
{
return null;
}
- // Ensure that UI is visible when this prompt is displayed.
- unhide();
-
synchronized (iProgressSyncObject)
{
// Do not display progress bar during dialog.
@@ -938,15 +943,11 @@
*/
public boolean launchAppQuery(LaunchAppInfo aLaunchAppInfo)
{
- if (DISABLE_UI) return false; // Disable UI temporarily.
waitForUi();
- waitForCertificateDetailsView();
- if (!isUiReady() || iConfirmationsCanceled ||
- iHidden || getInstallInfo() == null)
+ if (!isUiReady() || iConfirmationsCanceled || getInstallInfo() == null)
{
- // Either UI is not yet ready, user has cancelled
- // installation or UI is hidden; in all these cases
- // do nothing.
+ // Either UI is not yet ready, or user has cancelled
+ // installation, in both cases do nothing.
return false;
}
@@ -963,46 +964,31 @@
});
}
boolean result = iLaunchAppQueryView.launchAppQuery(aLaunchAppInfo);
- iLaunchAppQueryView.dispose();
- iLaunchAppQueryView = null;
- if (!result)
+ iParent.getDisplay().syncExec(new Runnable()
{
- iParent.getDisplay().syncExec(new Runnable()
+ public void run()
{
- public void run()
- {
- iParent.dispose();
- }
- });
- }
+ iParent.dispose();
+ }
+ });
+ iLaunchAppQueryView = null;
log("LaunchAppQuery returns " + result + " for " + aLaunchAppInfo);
return result;
}
/**
- * Executes given Runnable synchronously in the UI thread.
- */
- public void syncExec(Runnable aRunnable)
- {
- if (!iParent.getDisplay().isDisposed())
- {
- iParent.getDisplay().syncExec(aRunnable);
- }
- }
-
- /**
* Hides or unhides InstallerUi.
*/
public void hide(boolean aHide)
{
- iHidden = aHide;
- if (iDialog != null)
+ final boolean hide = aHide;
+ if (iParent != null)
{
- iDialog.getDisplay().syncExec(new Runnable()
+ iParent.getDisplay().syncExec(new Runnable()
{
public void run()
{
- iDialog.setMinimized(iHidden);
+ iParent.setMinimized(hide);
}
});
}
@@ -1021,66 +1007,24 @@
}
/**
- * Sets flag telling if certificate details view is open.
- */
- protected void setCertificateDetailsView(CertificateDetailsView aView)
- {
- if (iCertificateDetailsView != null && aView == null)
- {
- // Certificate details view has been closed,
- // notify possible waiters.
- synchronized (iCertificateDetailsView)
- {
- iCertificateDetailsView.notify();
- }
- }
- iCertificateDetailsView = aView;
- }
-
- /**
- * Waits until certificate details view is closed.
- */
- protected void waitForCertificateDetailsView()
- {
- if (iCertificateDetailsView != null)
- {
- // If certificate details view is open, wait until
- // user closes it.
- synchronized (iCertificateDetailsView)
- {
- try
- {
- iCertificateDetailsView.wait();
- }
- catch (InterruptedException ie)
- {
- }
- }
- }
- }
-
- /**
* Returns string title basing on mode of this InstallerUi.
*/
protected String getTitle()
{
- String result = super.getTitle();
- if (isUiReady())
+ String result = null;
+ if (iMode == MODE_INSTALL)
+ {
+ result = InstallerUiTexts.get(InstallerUiTexts.INSTALLING);
+ }
+ else if (iMode == MODE_UNINSTALL)
{
- if (iMode == MODE_INSTALL)
- {
- result = InstallerUiTexts.get(InstallerUiTexts.INSTALLING);
- }
- else if (iMode == MODE_UNINSTALL)
- {
- result = InstallerUiTexts.get("Uninstalling");
- }
- else if (iMode == MODE_APP_CONVERSION)
- {
- result = InstallerUiTexts.get(
- "Converting data for application " +
- iAppConversionCurrent + "/" + iAppConversionTotal);
- }
+ result = InstallerUiTexts.get("Uninstalling");
+ }
+ else if (iMode == MODE_APP_CONVERSION)
+ {
+ result = InstallerUiTexts.get(
+ "Converting data for application " +
+ iAppConversionCurrent + "/" + iAppConversionTotal);
}
return result;
}
@@ -1100,24 +1044,16 @@
{
return iSecurityIcon;
}
- String iconFilename = "java_3_untrusted.png";
+ String iconFilename = ResourceUtil.UNTRUSTED_ICON_NAME;
if (aIdentified)
{
- iconFilename = "java_3_trusted.png";
+ iconFilename = ResourceUtil.TRUSTED_ICON_NAME;
}
- try
+ String resourceDir = ResourceUtil.getResourceDir(0);
+ for (int i = 1; iSecurityIcon == null && resourceDir != null; i++)
{
- String resourceDir = ResourceUtil.getResourceDir(0);
- for (int i = 1; iSecurityIcon == null && resourceDir != null; i++)
- {
- iSecurityIcon = loadImage(
- aDisplay, resourceDir + iconFilename, false);
- resourceDir = ResourceUtil.getResourceDir(i);
- }
- }
- catch (Throwable t)
- {
- log("Can not load security icon: " + t);
+ iSecurityIcon = loadImage(aDisplay, resourceDir + iconFilename, false);
+ resourceDir = ResourceUtil.getResourceDir(i);
}
return iSecurityIcon;
}
@@ -1208,21 +1144,19 @@
try
{
long startTime = System.currentTimeMillis();
- Image image = new Image(aDisplay, aInputStream);
- ImageData imageData = image.getImageData();
+ ImageData[] imageDatas = new ImageLoader().load(aInputStream);
+ ImageData imageData = imageDatas[0];
if (aScaleImage)
{
Point bestSize = getBestImageSize(
- imageData.width, imageData.height);
+ imageData.width, imageData.height);
if (bestSize.x != imageData.width ||
bestSize.y != imageData.height)
{
- Point oldSize =
- new Point(imageData.width, imageData.height);
imageData = imageData.scaledTo(bestSize.x, bestSize.y);
log("Image " + aImageName + " scaled from " +
- oldSize.x + "x" + oldSize.y + " to " +
- bestSize.x + "x" + bestSize.y);
+ imageDatas[0].width + "x" + imageDatas[0].height +
+ " to " + bestSize.x + "x" + bestSize.y);
}
}
result = new Image(aDisplay, imageData);
@@ -1244,8 +1178,8 @@
*/
private static Point getBestImageSize(int aWidth, int aHeight)
{
- final int MAX_WIDTH = (iBestIconSize == null? 50: iBestIconSize.x);
- final int MAX_HEIGHT = (iBestIconSize == null? 50: iBestIconSize.y);
+ final int MAX_WIDTH = iBestIconSize.x;
+ final int MAX_HEIGHT = iBestIconSize.y;
Point result = new Point(aWidth, aHeight);
if (result.x > MAX_WIDTH || result.y > MAX_HEIGHT)
{
@@ -1373,57 +1307,4 @@
{
return iActiveView;
}
-
- /**
- * Loads JavaInstaller UI stylesheet.
- */
- void loadCss()
- {
- String cssFilename = "javaapplicationinstaller.css";
- String cssPath = null;
- try
- {
- if (iCssEngine != null)
- {
- boolean loaded = false;
- String resourceDir = ResourceUtil.getResourceDir(0);
- for (int i = 1; !loaded && resourceDir != null; i++)
- {
- cssPath = resourceDir + cssFilename;
- FileUtility cssFile = new FileUtility(cssPath);
- if (cssFile.exists())
- {
- iCssEngine.loadCSS(cssPath);
- log("CSS loaded from " + cssPath);
- break;
- }
- resourceDir = ResourceUtil.getResourceDir(i);
- }
- }
- }
- catch (Throwable t)
- {
- logError("Loading CSS from " + cssPath + " failed", t);
- }
- }
-
- private void disposeResources() {
- if (iBoldFont != null && !iBoldFont.isDisposed())
- {
- iBoldFont.dispose();
- }
- if (iSecurityIcon != null && !iSecurityIcon.isDisposed())
- {
- iSecurityIcon.dispose();
- }
- Enumeration e = iImageTable.elements();
- while (e.hasMoreElements())
- {
- Image img = (Image)e.nextElement();
- if (img != null && !img.isDisposed())
- {
- img.dispose();
- }
- }
- }
}