23 import com.nokia.mj.impl.installer.ui.UninstallInfo; |
23 import com.nokia.mj.impl.installer.ui.UninstallInfo; |
24 import com.nokia.mj.impl.security.midp.common.SigningCertificate; |
24 import com.nokia.mj.impl.security.midp.common.SigningCertificate; |
25 |
25 |
26 import java.io.InputStream; |
26 import java.io.InputStream; |
27 |
27 |
|
28 import org.eclipse.ercp.swt.mobile.MobileDevice; |
|
29 import org.eclipse.ercp.swt.mobile.Screen; |
28 import org.eclipse.swt.SWT; |
30 import org.eclipse.swt.SWT; |
29 import org.eclipse.swt.custom.ScrolledComposite; |
31 import org.eclipse.swt.custom.ScrolledComposite; |
30 import org.eclipse.swt.events.SelectionEvent; |
32 import org.eclipse.swt.events.SelectionEvent; |
31 import org.eclipse.swt.events.SelectionListener; |
33 import org.eclipse.swt.events.SelectionListener; |
32 import org.eclipse.swt.graphics.Image; |
34 import org.eclipse.swt.graphics.Image; |
73 /** Default content size. */ |
75 /** Default content size. */ |
74 private Point iDefaultContentSize = null; |
76 private Point iDefaultContentSize = null; |
75 /** Certificate details view. */ |
77 /** Certificate details view. */ |
76 private CertificateDetailsView iCertificateDetailsView = null; |
78 private CertificateDetailsView iCertificateDetailsView = null; |
77 /** Certificates for this application. */ |
79 /** Certificates for this application. */ |
78 private SigningCertificate[] iCertificates = null; |
80 protected SigningCertificate[] iCertificates = null; |
79 |
81 |
80 /** Constructor */ |
82 /** Constructor */ |
81 protected ViewBase() |
83 protected ViewBase() |
82 { |
84 { |
83 } |
85 } |
84 |
86 |
85 /** Constructor */ |
87 /** Constructor */ |
86 protected ViewBase(InstallerUiEswt aInstaller, Composite aParent, int aColumns) |
88 protected ViewBase(InstallerUiEswt aInstallerUi, Composite aParent, int aColumns) |
87 { |
89 { |
88 this(aInstaller, aParent, aColumns, false); |
90 this(aInstallerUi, aParent, aColumns, false); |
89 } |
91 } |
90 |
92 |
91 /** Constructor */ |
93 /** Constructor */ |
92 protected ViewBase(InstallerUiEswt aInstaller, Composite aParent, int aColumns, boolean aScrollable) |
94 protected ViewBase(InstallerUiEswt aInstallerUi, Composite aParent, int aColumns, boolean aScrollable) |
93 { |
95 { |
94 iInstallerUi = aInstaller; |
96 iInstallerUi = aInstallerUi; |
95 |
97 |
96 // Each view gets a shell to be used as a parameter. |
98 // Each view gets a shell to be used as a parameter. |
97 iParent = (Shell)aParent; |
99 iParent = (Shell)aParent; |
98 |
100 |
99 iContainer = new Composite(iParent, 0); |
101 iContainer = new Composite(iParent, 0); |
384 { |
392 { |
385 updateSize(); |
393 updateSize(); |
386 } |
394 } |
387 |
395 |
388 /** |
396 /** |
|
397 * Forces screen orientation. Valid values are |
|
398 * Screen.PORTRAIT, Screen.LANDSCAPE, and SWT.DEFAULT. |
|
399 */ |
|
400 protected void forceScreenOrientation(int aOrientation) |
|
401 { |
|
402 Screen[] screens = MobileDevice.getMobileDevice().getScreens(); |
|
403 for (int i = 0; i < screens.length; i++) |
|
404 { |
|
405 screens[i].setOrientation(aOrientation); |
|
406 } |
|
407 log(this.toString() + ": screen orientation set to " + aOrientation); |
|
408 } |
|
409 |
|
410 /** |
389 * Returns true if the View should have focus after it has been opened. |
411 * Returns true if the View should have focus after it has been opened. |
390 */ |
412 */ |
391 protected boolean forceFocusToView() |
413 protected boolean forceFocusToView() |
392 { |
414 { |
393 return true; |
415 return true; |
410 { |
432 { |
411 return iColumns; |
433 return iColumns; |
412 } |
434 } |
413 |
435 |
414 /** |
436 /** |
415 * Adds header used in installation and uninstallation views. |
437 * Adds header used in installation views. |
416 */ |
438 */ |
417 protected void addHeader( |
439 protected void addHeader( |
418 String aTitle, InstallInfo aInstallInfo, UninstallInfo aUninstallInfo) |
440 String aTitle, InstallInfo aInstallInfo, UninstallInfo aUninstallInfo) |
|
441 { |
|
442 addHeader(aTitle, aInstallInfo, aUninstallInfo, true); |
|
443 } |
|
444 |
|
445 /** |
|
446 * Adds header used in installation views. |
|
447 */ |
|
448 protected void addHeader( |
|
449 String aTitle, InstallInfo aInstallInfo, UninstallInfo aUninstallInfo, |
|
450 boolean aSecurityButton) |
419 { |
451 { |
420 // Add title. |
452 // Add title. |
421 String title = "Install?"; |
453 String title = "Install?"; |
422 if (aInstallInfo != null) |
454 if (aInstallInfo != null) |
423 { |
455 { |
433 iCertificates = aUninstallInfo.getCertificates(); |
465 iCertificates = aUninstallInfo.getCertificates(); |
434 } |
466 } |
435 Label titleLabel = createLabel(aTitle, getColumns() - 1, SWT.WRAP); |
467 Label titleLabel = createLabel(aTitle, getColumns() - 1, SWT.WRAP); |
436 titleLabel.setFont(iInstallerUi.getBoldFont()); |
468 titleLabel.setFont(iInstallerUi.getBoldFont()); |
437 |
469 |
438 // Add security icon. |
470 if (aSecurityButton) |
439 createSecurityButton(); |
471 { |
|
472 // Add security icon. |
|
473 createSecurityButton(); |
|
474 } |
|
475 else |
|
476 { |
|
477 // Add security icon. |
|
478 createSecurityLabel(iCertificates != null); |
|
479 } |
440 |
480 |
441 // Add suite icon. |
481 // Add suite icon. |
442 InputStream iconInputStream = null; |
482 InputStream iconInputStream = null; |
443 String iconPath = null; |
483 String iconPath = null; |
444 if (aInstallInfo != null) |
484 if (aInstallInfo != null) |
626 */ |
666 */ |
627 protected Label createSecurityLabel(boolean aIdentified) |
667 protected Label createSecurityLabel(boolean aIdentified) |
628 { |
668 { |
629 Label label = createLabel((Image)null, 1, SWT.NONE); |
669 Label label = createLabel((Image)null, 1, SWT.NONE); |
630 Image securityIcon = null; |
670 Image securityIcon = null; |
631 if (iInstallerUi instanceof InstallerUiEswt) |
671 if (iInstallerUi != null) |
632 { |
672 { |
633 securityIcon = ((InstallerUiEswt)iInstallerUi).getSecurityIcon |
673 securityIcon = iInstallerUi.getSecurityIcon( |
634 (getDisplay(), aIdentified); |
674 getDisplay(), aIdentified); |
635 } |
675 } |
636 if (securityIcon != null) |
676 if (securityIcon != null) |
637 { |
677 { |
638 label.setImage(securityIcon); |
678 label.setImage(securityIcon); |
639 } |
679 } |
652 gridData.horizontalSpan = 1; |
692 gridData.horizontalSpan = 1; |
653 gridData.horizontalAlignment = SWT.CENTER; |
693 gridData.horizontalAlignment = SWT.CENTER; |
654 gridData.verticalAlignment = SWT.CENTER; |
694 gridData.verticalAlignment = SWT.CENTER; |
655 button.setLayoutData(gridData); |
695 button.setLayoutData(gridData); |
656 Image securityIcon = null; |
696 Image securityIcon = null; |
657 if (iInstallerUi instanceof InstallerUiEswt) |
697 if (iInstallerUi != null) |
658 { |
698 { |
659 securityIcon = |
699 securityIcon = iInstallerUi.getSecurityIcon( |
660 ((InstallerUiEswt)iInstallerUi).getSecurityIcon( |
700 getDisplay(), iCertificates != null); |
661 getDisplay(), iCertificates != null); |
|
662 } |
701 } |
663 if (securityIcon != null) |
702 if (securityIcon != null) |
664 { |
703 { |
665 button.setImage(securityIcon); |
704 button.setImage(securityIcon); |
666 } |
705 } |