|
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: Definitions for the class DbghelpDllVersionInfoDialog |
|
15 * |
|
16 */ |
|
17 |
|
18 package com.nokia.s60tools.analyzetool.ui; |
|
19 |
|
20 import java.net.MalformedURLException; |
|
21 import java.net.URL; |
|
22 |
|
23 import org.eclipse.jface.dialogs.Dialog; |
|
24 import org.eclipse.swt.SWT; |
|
25 import org.eclipse.swt.layout.GridData; |
|
26 import org.eclipse.swt.layout.GridLayout; |
|
27 import org.eclipse.swt.widgets.Composite; |
|
28 import org.eclipse.swt.widgets.Control; |
|
29 import org.eclipse.swt.widgets.Label; |
|
30 import org.eclipse.swt.widgets.Shell; |
|
31 import org.eclipse.ui.PartInitException; |
|
32 import org.eclipse.ui.browser.IWebBrowser; |
|
33 import org.eclipse.ui.browser.IWorkbenchBrowserSupport; |
|
34 import org.eclipse.ui.forms.events.HyperlinkEvent; |
|
35 import org.eclipse.ui.forms.events.IHyperlinkListener; |
|
36 import org.eclipse.ui.forms.widgets.FormToolkit; |
|
37 import org.eclipse.ui.forms.widgets.Hyperlink; |
|
38 |
|
39 import com.nokia.s60tools.analyzetool.Activator; |
|
40 import com.nokia.s60tools.analyzetool.global.Constants; |
|
41 |
|
42 /** |
|
43 * Custom dialog with clickable link and Ok and Cancel buttons for |
|
44 * displaying of dbghelp.dll version information. |
|
45 * |
|
46 * @author lukamil |
|
47 * |
|
48 */ |
|
49 public class DbghelpDllVersionInfoDialog extends Dialog { |
|
50 |
|
51 private String dbghelpDllVersionInfo; |
|
52 |
|
53 public DbghelpDllVersionInfoDialog(Shell shell, String dbghelpDllVersionInfo) { |
|
54 super(shell); |
|
55 this.dbghelpDllVersionInfo = dbghelpDllVersionInfo; |
|
56 } |
|
57 |
|
58 @Override |
|
59 protected void configureShell(Shell shell) { |
|
60 shell.setText(Constants.ANALYZE_TOOL_TITLE); |
|
61 super.configureShell(shell); |
|
62 } |
|
63 |
|
64 @Override |
|
65 protected Control createDialogArea(Composite parent) { |
|
66 |
|
67 final Composite container = (Composite) super.createDialogArea(parent); |
|
68 container.setLayout(new GridLayout(2, false)); |
|
69 |
|
70 Composite imageComposite = new Composite(container, SWT.NONE); |
|
71 imageComposite.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, |
|
72 false)); |
|
73 imageComposite.setLayout(new GridLayout()); |
|
74 |
|
75 Label imageLabel = new Label(imageComposite, SWT.NONE); |
|
76 imageLabel.setImage(getShell().getDisplay().getSystemImage( |
|
77 SWT.ICON_INFORMATION)); |
|
78 |
|
79 Composite infoComposite = new Composite(container, SWT.NONE); |
|
80 GridLayout gridLayout = new GridLayout(); |
|
81 gridLayout.verticalSpacing = 0; |
|
82 infoComposite.setLayout(gridLayout); |
|
83 |
|
84 String[] array = dbghelpDllVersionInfo.split("\n"); |
|
85 String info = ""; |
|
86 |
|
87 for (int i = 0; i < array.length - 1; i++) { |
|
88 info = info + array[i] + "\n"; |
|
89 } |
|
90 |
|
91 String link = array[array.length - 1]; |
|
92 |
|
93 Label infoLabel = new Label(infoComposite, SWT.NONE); |
|
94 infoLabel.setText(info); |
|
95 |
|
96 FormToolkit toolkit = new FormToolkit(getShell().getDisplay()); |
|
97 Hyperlink hyperlink = toolkit.createHyperlink(infoComposite, link, |
|
98 SWT.NONE); |
|
99 hyperlink.setBackground(getShell().getBackground()); |
|
100 hyperlink.setUnderlined(false); |
|
101 hyperlink.setHref(link); |
|
102 |
|
103 hyperlink.addHyperlinkListener(new IHyperlinkListener() { |
|
104 public void linkEntered(HyperlinkEvent event) { |
|
105 } |
|
106 |
|
107 public void linkExited(HyperlinkEvent event) { |
|
108 } |
|
109 |
|
110 public void linkActivated(HyperlinkEvent event) { |
|
111 IWorkbenchBrowserSupport browserSupport = Activator |
|
112 .getDefault().getWorkbench().getBrowserSupport(); |
|
113 |
|
114 try { |
|
115 IWebBrowser browser = browserSupport.getExternalBrowser(); |
|
116 browser.openURL(new URL(event.getHref().toString())); |
|
117 } catch (MalformedURLException e) { |
|
118 e.printStackTrace(); |
|
119 } catch (PartInitException e) { |
|
120 e.printStackTrace(); |
|
121 } |
|
122 } |
|
123 }); |
|
124 |
|
125 Label questionLabel = new Label(infoComposite, SWT.NONE); |
|
126 questionLabel.setText("Would you like to continue?"); |
|
127 |
|
128 return container; |
|
129 } |
|
130 } |