|
1 /* |
|
2 * Copyright (c) 2008-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: Definitions for the class CustomErrorDialog |
|
15 * |
|
16 */ |
|
17 |
|
18 package com.nokia.s60tools.analyzetool.ui; |
|
19 |
|
20 import org.eclipse.jface.dialogs.Dialog; |
|
21 import org.eclipse.jface.dialogs.IDialogConstants; |
|
22 import org.eclipse.swt.SWT; |
|
23 import org.eclipse.swt.layout.GridData; |
|
24 import org.eclipse.swt.layout.GridLayout; |
|
25 import org.eclipse.swt.widgets.Composite; |
|
26 import org.eclipse.swt.widgets.Control; |
|
27 import org.eclipse.swt.widgets.Label; |
|
28 import org.eclipse.swt.widgets.Shell; |
|
29 import org.eclipse.ui.PlatformUI; |
|
30 |
|
31 import com.nokia.s60tools.analyzetool.AnalyzeToolHelpContextIDs; |
|
32 import com.nokia.s60tools.analyzetool.global.Util; |
|
33 |
|
34 public class CustomMessageDialog extends Dialog { |
|
35 |
|
36 private String title; |
|
37 private String message; |
|
38 private int icon; |
|
39 |
|
40 public CustomMessageDialog(Shell shell, String title, String message, |
|
41 int icon) { |
|
42 super(shell); |
|
43 this.title = title; |
|
44 this.message = message; |
|
45 this.icon = icon; |
|
46 } |
|
47 |
|
48 @Override |
|
49 protected void configureShell(Shell shell) { |
|
50 shell.setText(title); |
|
51 super.configureShell(shell); |
|
52 } |
|
53 |
|
54 @Override |
|
55 protected Control createDialogArea(Composite parent) { |
|
56 |
|
57 final Composite container = (Composite) super.createDialogArea(parent); |
|
58 container.setLayout(new GridLayout(2, false)); |
|
59 |
|
60 Composite imageComposite = new Composite(container, SWT.NONE); |
|
61 imageComposite.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, |
|
62 false)); |
|
63 imageComposite.setLayout(new GridLayout()); |
|
64 |
|
65 Label imageLabel = new Label(imageComposite, SWT.NONE); |
|
66 imageLabel.setImage(getShell().getDisplay().getSystemImage(icon)); |
|
67 |
|
68 Composite messageComposite = new Composite(container, SWT.NONE); |
|
69 GridLayout gridLayout = new GridLayout(); |
|
70 gridLayout.verticalSpacing = 0; |
|
71 messageComposite.setLayout(gridLayout); |
|
72 |
|
73 Label messageLabel = new Label(messageComposite, SWT.NONE); |
|
74 messageLabel.setText(message); |
|
75 |
|
76 PlatformUI.getWorkbench().getHelpSystem().setHelp(getShell(), |
|
77 AnalyzeToolHelpContextIDs.ANALYZE_TROUBLESHOOTING); |
|
78 |
|
79 return container; |
|
80 } |
|
81 |
|
82 @Override |
|
83 protected Control createButtonBar(Composite parent) { |
|
84 Composite composite = new Composite(parent, SWT.NONE); |
|
85 GridLayout layout = new GridLayout(); |
|
86 layout.marginWidth = 0; |
|
87 layout.marginHeight = 0; |
|
88 layout.horizontalSpacing = 0; |
|
89 composite.setLayout(layout); |
|
90 composite |
|
91 .setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); |
|
92 composite.setFont(parent.getFont()); |
|
93 |
|
94 Control helpControl = Util.createHelpControl(composite); |
|
95 ((GridData) helpControl.getLayoutData()).horizontalIndent = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); |
|
96 |
|
97 Control buttonSection = super.createButtonBar(composite); |
|
98 ((GridData) buttonSection.getLayoutData()).grabExcessHorizontalSpace = true; |
|
99 return composite; |
|
100 } |
|
101 |
|
102 @Override |
|
103 protected void createButtonsForButtonBar(Composite parent) { |
|
104 createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, |
|
105 true); |
|
106 } |
|
107 } |