|
1 /* |
|
2 * Copyright (c) 2009 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 package com.nokia.s60ct.gui.views; |
|
18 |
|
19 import java.net.URL; |
|
20 |
|
21 import org.eclipse.core.runtime.IProduct; |
|
22 import org.eclipse.core.runtime.Platform; |
|
23 import org.eclipse.jface.resource.ImageDescriptor; |
|
24 import org.eclipse.jface.resource.JFaceColors; |
|
25 import org.eclipse.swt.SWT; |
|
26 import org.eclipse.swt.custom.StyledText; |
|
27 import org.eclipse.swt.events.DisposeEvent; |
|
28 import org.eclipse.swt.events.DisposeListener; |
|
29 import org.eclipse.swt.graphics.Color; |
|
30 import org.eclipse.swt.graphics.Cursor; |
|
31 import org.eclipse.swt.graphics.Image; |
|
32 import org.eclipse.swt.layout.GridData; |
|
33 import org.eclipse.swt.layout.GridLayout; |
|
34 import org.eclipse.swt.widgets.Composite; |
|
35 import org.eclipse.swt.widgets.Control; |
|
36 import org.eclipse.swt.widgets.Label; |
|
37 import org.eclipse.swt.widgets.Shell; |
|
38 import org.eclipse.ui.internal.ProductProperties; |
|
39 |
|
40 import com.nokia.s60ct.gui.S60CtEditorPlugin; |
|
41 |
|
42 public class AboutDialog extends org.eclipse.ui.internal.dialogs.AboutDialog |
|
43 { |
|
44 private IProduct product; |
|
45 |
|
46 private StyledText text; |
|
47 |
|
48 private static final String pluginID = "com.nokia.S60CT.gui"; |
|
49 |
|
50 public AboutDialog(Shell parentShell) |
|
51 { |
|
52 super(parentShell); |
|
53 |
|
54 product = Platform.getProduct(); |
|
55 |
|
56 } |
|
57 |
|
58 protected Control createDialogArea(Composite parent) |
|
59 { |
|
60 |
|
61 final Cursor hand = new Cursor(parent.getDisplay(), SWT.CURSOR_HAND); |
|
62 final Cursor busy = new Cursor(parent.getDisplay(), SWT.CURSOR_WAIT); |
|
63 setHandCursor(hand); |
|
64 setBusyCursor(busy); |
|
65 getShell().addDisposeListener(new DisposeListener() { |
|
66 public void widgetDisposed(DisposeEvent e) { |
|
67 setHandCursor(null); |
|
68 hand.dispose(); |
|
69 setBusyCursor(null); |
|
70 busy.dispose(); |
|
71 } |
|
72 }); |
|
73 |
|
74 Image aboutImage = null; |
|
75 |
|
76 if (product != null) |
|
77 { |
|
78 ImageDescriptor imageDescriptor = ProductProperties.getAboutImage(product); |
|
79 if (imageDescriptor != null) |
|
80 { |
|
81 aboutImage = imageDescriptor.createImage(); |
|
82 } |
|
83 } |
|
84 else //no product. maybe run from Eclipse |
|
85 { |
|
86 try |
|
87 { |
|
88 URL url = S60CtEditorPlugin.class.getResource("/about.PNG"); |
|
89 ImageDescriptor imageDescriptor = ImageDescriptor.createFromURL(url); |
|
90 aboutImage = imageDescriptor.createImage(); |
|
91 |
|
92 } |
|
93 catch (Exception e) |
|
94 { |
|
95 } |
|
96 } |
|
97 |
|
98 Composite workArea = new Composite(parent, SWT.NONE); |
|
99 GridLayout workLayout = new GridLayout(2, false); |
|
100 workLayout.marginHeight = 0; |
|
101 workLayout.marginWidth = 0; |
|
102 workLayout.verticalSpacing = 0; |
|
103 workLayout.horizontalSpacing = 0; |
|
104 workArea.setLayout(workLayout); |
|
105 workArea.setLayoutData(new GridData(GridData.FILL_BOTH)); |
|
106 |
|
107 // page group |
|
108 Color background = JFaceColors.getBannerBackground(parent.getDisplay()); |
|
109 Color foreground = JFaceColors.getBannerForeground(parent.getDisplay()); |
|
110 |
|
111 workArea.setBackground(background); |
|
112 workArea.setForeground(foreground); |
|
113 |
|
114 //image on left side of dialog |
|
115 if (aboutImage != null) { |
|
116 Label imageLabel = new Label(workArea, SWT.NONE); |
|
117 imageLabel.setBackground(background); |
|
118 imageLabel.setForeground(foreground); |
|
119 |
|
120 GridData data = new GridData(); |
|
121 data.horizontalAlignment = GridData.FILL; |
|
122 data.verticalAlignment = GridData.BEGINNING; |
|
123 data.grabExcessHorizontalSpace = false; |
|
124 imageLabel.setLayoutData(data); |
|
125 imageLabel.setImage(aboutImage); |
|
126 } |
|
127 |
|
128 |
|
129 // text on the right |
|
130 text = new StyledText(workArea, SWT.MULTI | SWT.READ_ONLY); |
|
131 text.setCaret(null); |
|
132 text.setFont(parent.getFont()); |
|
133 GridData data = new GridData(); |
|
134 data.horizontalAlignment = GridData.FILL; |
|
135 data.verticalAlignment = GridData.BEGINNING; |
|
136 data.verticalIndent = 12; |
|
137 data.grabExcessHorizontalSpace = true; |
|
138 data.grabExcessVerticalSpace = true; |
|
139 |
|
140 text.setText(getAboutText()); |
|
141 text.setLayoutData(data); |
|
142 text.setCursor(null); |
|
143 text.setBackground(background); |
|
144 text.setForeground(foreground); |
|
145 |
|
146 if (aboutImage != null) |
|
147 { |
|
148 // horizontal bar |
|
149 Label bar = new Label(workArea, SWT.HORIZONTAL | SWT.SEPARATOR); |
|
150 data = new GridData(); |
|
151 data.horizontalAlignment = GridData.FILL; |
|
152 bar.setLayoutData(data); |
|
153 |
|
154 Label bar2 = new Label(workArea, SWT.HORIZONTAL | SWT.SEPARATOR); |
|
155 bar2.setLayoutData(data); |
|
156 } |
|
157 |
|
158 return workArea; |
|
159 } |
|
160 |
|
161 private String getAboutText() |
|
162 { |
|
163 String toolName=(String)Platform.getBundle(pluginID).getHeaders().get("Bundle-ToolName"); |
|
164 String pluginVersion=(String)Platform.getBundle(pluginID).getHeaders().get("Bundle-ReleaseVersion"); |
|
165 String pluginDate=(String)Platform.getBundle(pluginID).getHeaders().get("Bundle-Date"); |
|
166 String pluginRepositoryVersion=(String)Platform.getBundle(pluginID).getHeaders().get("Bundle-RepositoryVersion"); |
|
167 String legalText ="Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).\n" + |
|
168 "All rights reserved.\n" + |
|
169 "This component and the accompanying materials are made available \n" + |
|
170 "under the terms of the License \"Symbian Foundation License v1.0\"\n" + |
|
171 "which accompanies this distribution, and is available at the URL \n" + |
|
172 "\"http://www.symbianfoundation.org/legal/sfl-v10.html\"."; |
|
173 |
|
174 return "\n"+toolName+"\n\n"+pluginVersion+"\n"+pluginDate+" rev."+pluginRepositoryVersion+"\n\n"+legalText; |
|
175 } |
|
176 |
|
177 } |