|
1 /* |
|
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 package com.nokia.mj.impl.installer.ui.eswt2; |
|
20 |
|
21 import com.nokia.mj.impl.utils.exception.ExceptionBase; |
|
22 |
|
23 import org.eclipse.swt.SWT; |
|
24 import org.eclipse.swt.widgets.Composite; |
|
25 import org.eclipse.swt.widgets.Label; |
|
26 |
|
27 /** |
|
28 * Displays error message. |
|
29 */ |
|
30 public class ErrorView extends ConfirmationViewBase |
|
31 { |
|
32 private ExceptionBase iException = null; |
|
33 |
|
34 /** Constructor */ |
|
35 protected ErrorView() |
|
36 { |
|
37 super(); |
|
38 } |
|
39 |
|
40 /** Constructor */ |
|
41 protected ErrorView(InstallerUiEswt aInstallerUi, Composite aParent) |
|
42 { |
|
43 super(aInstallerUi, aParent, 8); |
|
44 setTitle(InstallerUiTexts.get(InstallerUiTexts.INSTALL_FAILED)); |
|
45 setCommands("Show", |
|
46 InstallerUiTexts.get(InstallerUiTexts.CLOSE)); |
|
47 } |
|
48 |
|
49 /** |
|
50 * Synchoronous method for displaying error message. |
|
51 */ |
|
52 public boolean error(ExceptionBase aException) |
|
53 { |
|
54 iException = aException; |
|
55 boolean result = confirm(); |
|
56 if (result) |
|
57 { |
|
58 log("ErrorView confirmed"); |
|
59 } |
|
60 else |
|
61 { |
|
62 log("ErrorView cancelled"); |
|
63 } |
|
64 return result; |
|
65 } |
|
66 |
|
67 /** |
|
68 * This method is called once before view is opened. |
|
69 */ |
|
70 protected void createView() |
|
71 { |
|
72 // Add header. |
|
73 //String title = InstallerUiTexts.get(InstallerUiTexts.INSTALL_FAILED); |
|
74 String title = "Installation failed"; |
|
75 if (iInstallerUi.getInstallInfo() != null) |
|
76 { |
|
77 if (iInstallerUi.getInstallInfo().getOldVersion() != null) |
|
78 { |
|
79 title = "Update failed"; |
|
80 } |
|
81 addHeader(title, iInstallerUi.getInstallInfo(), null); |
|
82 } |
|
83 else |
|
84 { |
|
85 Label titleLabel = createLabel(title, getColumns(), SWT.WRAP); |
|
86 titleLabel.setFont(iInstallerUi.getBoldFont()); |
|
87 } |
|
88 |
|
89 int horizontalSpan = getColumns(); |
|
90 int labelStyle = SWT.WRAP; |
|
91 |
|
92 // Begin widgets creation. |
|
93 Label errorLabel = createLabel( |
|
94 iException.getShortMessage(), horizontalSpan, labelStyle); |
|
95 // End of widgets creation. |
|
96 |
|
97 if (iInstallerUi.getInstallInfo() != null) |
|
98 { |
|
99 // After other widgets have been added, add content to |
|
100 // application info Composite. |
|
101 addAppInfo(iInstallerUi.getInstallInfo(), true); |
|
102 } |
|
103 } |
|
104 |
|
105 /** |
|
106 * This method is called after user has answered |
|
107 * to confirmation. |
|
108 * Inheriting class must implement this method. |
|
109 */ |
|
110 protected void getDataFromView() |
|
111 { |
|
112 // nop |
|
113 } |
|
114 |
|
115 /** |
|
116 * Returns SWT style for this view. |
|
117 */ |
|
118 protected int getStyle() |
|
119 { |
|
120 return SWT.V_SCROLL; |
|
121 } |
|
122 } |