4 * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
7 * GiWoong Kim <giwoong.kim@samsung.com>
8 * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
30 package org.tizen.emulator.skin.dialog;
32 import java.io.IOException;
33 import java.io.InputStream;
34 import java.util.Properties;
35 import java.util.logging.Level;
36 import java.util.logging.Logger;
38 import org.eclipse.swt.SWT;
39 import org.eclipse.swt.events.SelectionAdapter;
40 import org.eclipse.swt.events.SelectionEvent;
41 import org.eclipse.swt.events.SelectionListener;
42 import org.eclipse.swt.graphics.Color;
43 import org.eclipse.swt.graphics.Image;
44 import org.eclipse.swt.layout.FillLayout;
45 import org.eclipse.swt.layout.GridData;
46 import org.eclipse.swt.layout.GridLayout;
47 import org.eclipse.swt.program.Program;
48 import org.eclipse.swt.widgets.Button;
49 import org.eclipse.swt.widgets.Composite;
50 import org.eclipse.swt.widgets.Display;
51 import org.eclipse.swt.widgets.Label;
52 import org.eclipse.swt.widgets.Link;
53 import org.eclipse.swt.widgets.Shell;
54 import org.eclipse.swt.widgets.Text;
55 import org.tizen.emulator.skin.config.EmulatorConfig;
56 import org.tizen.emulator.skin.log.SkinLogger;
57 import org.tizen.emulator.skin.util.IOUtil;
58 import org.tizen.emulator.skin.util.StringUtil;
59 import org.tizen.emulator.skin.util.SwtUtil;
61 public class AboutDialog extends SkinDialog {
63 public static final String ABOUT_PROP_FILENAME = "about.properties";
65 public static final String PROP_KEY_VERSION = "version";
66 public static final String PROP_KEY_BUILD_TIME = "build_time";
67 public static final String PROP_KEY_GIT_VERSION = "build_git_commit";
69 public static final String URL_TIZEN_ORG = "https://developer.tizen.org";
71 private Logger logger =
72 SkinLogger.getSkinLogger(AboutDialog.class).getLogger();
74 private Image aboutImage;
75 private EmulatorConfig config;
78 public AboutDialog(Shell parent, EmulatorConfig config) {
79 super(parent, "About Tizen Emulator", SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
84 private GridLayout getNopaddedGridLayout(int numColumns, boolean makeColumnEqualWidth) {
85 GridLayout layout = new GridLayout(numColumns, makeColumnEqualWidth);
86 layout.marginLeft = layout.marginRight = 0;
87 layout.marginTop = layout.marginBottom = 0;
88 layout.marginWidth = layout.marginHeight = 0;
89 layout.horizontalSpacing = layout.verticalSpacing = 0;
95 protected void createComposite() {
96 Composite parent = new Composite(shell, SWT.NONE);
97 parent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
98 GridLayout gridLayout = getNopaddedGridLayout(1, true);
99 parent.setLayout(gridLayout);
101 Composite area = createArea(parent);
107 buttonComposite = new Composite(parent, SWT.NONE);
108 buttonComposite.setLayoutData(new GridData(SWT.RIGHT, SWT.BOTTOM, true, true));
109 buttonComposite.setLayout(new GridLayout(1, false));
111 createButtons(buttonComposite);
115 protected Composite createArea(Composite parent) {
116 Composite composite = displayInfo(parent);
120 private Composite displayInfo(Composite parent) {
121 Composite compositeBase = new Composite(parent, SWT.BORDER);
122 compositeBase.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
123 compositeBase.setLayout(getNopaddedGridLayout(2, false));
124 Color white = Display.getCurrent().getSystemColor(SWT.COLOR_WHITE);
125 compositeBase.setBackground(white);
128 Composite compositeLeft = new Composite(compositeBase, SWT.BORDER);
129 compositeLeft.setLayout(getNopaddedGridLayout(1, false));
131 Label imageLabel = new Label(compositeLeft, SWT.NONE);
132 aboutImage = new Image(shell.getDisplay(),
133 this.getClass().getClassLoader().getResourceAsStream("images/about_Tizen_SDK.png"));
134 imageLabel.setImage(aboutImage);
137 Composite compositeRight = new Composite(compositeBase, SWT.NONE);
138 compositeRight.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
139 GridLayout layout = getNopaddedGridLayout(1, true);
140 layout.marginLeft = layout.marginRight = 6;
141 compositeRight.setLayout(layout);
142 compositeRight.setBackground(white);
145 Label titleLabel = new Label(compositeRight, SWT.NONE);
146 /*GridData gridData = new GridData();
147 gridData.grabExcessHorizontalSpace = true;
148 gridData.horizontalAlignment = SWT.CENTER;
149 titleLabel.setLayoutData(gridData);*/
150 titleLabel.setText("\nTizen SDK\n");
151 /*Font systemFont = shell.getDisplay().getSystemFont();
152 FontData[] fontData = systemFont.getFontData();
153 fontData[0].setStyle(SWT.BOLD);
154 fontData[0].setHeight(16);
155 Font font = new Font(shell.getDisplay(), fontData[0]);
156 titleLabel.setFont(font);
158 titleLabel.setBackground(white);
160 if (SwtUtil.isWindowsPlatform()) {
161 Label space = new Label(compositeRight, SWT.NONE);
165 Properties properties = getProperties();
168 Text versionText = new Text(compositeRight, SWT.NONE);
169 /*String version = getValue(properties, PROP_KEY_VERSION);
170 if (version.isEmpty()) {
171 version = "Not identified";
173 String version = config.getSkinProperty(
174 EmulatorConfig.SkinInfoConstants.SDK_VERSION_NAME);
176 versionText.setText("Version : " + version);
177 versionText.setEditable(false);
178 versionText.setBackground(white);
181 Text buildText = new Text(compositeRight, SWT.NONE);
182 String time = getValue(properties, PROP_KEY_BUILD_TIME);
183 if (time.isEmpty()) {
184 time = "Not identified";
186 buildText.setText("Build id : " + time);
187 buildText.setEditable(false);
188 buildText.setBackground(white);
190 /*Text gitText = new Text(compositeRight, SWT.NONE);
191 String gitVersion = getValue(properties, PROP_KEY_GIT_VERSION);
192 gitText.setText("Git version" + " : " + gitVersion);
193 gitText.setEditable(false);
194 gitText.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));*/
197 Link visit = new Link(compositeRight, SWT.NONE);
198 visit.setText("\n\n Visit <a>" + URL_TIZEN_ORG + "</a>");
199 visit.setBackground(white);
200 visit.addSelectionListener(new SelectionListener() {
202 public void widgetDefaultSelected(SelectionEvent arg0) {
207 public void widgetSelected(SelectionEvent arg0) {
209 Program.launch(URL_TIZEN_ORG);
210 } catch (Throwable e) {
218 return compositeBase;
221 private String getValue(Properties properties, String key) {
222 if (null != properties) {
224 String property = properties.getProperty(key);
226 if (!StringUtil.isEmpty(property)) {
228 if (!property.contains(key)) {
231 // ex) '${build_git_commit}' is default
232 // expression in build.xml
233 return "Not identified";
237 return "Not identified";
241 return "Not identified";
246 protected void createButtons(Composite parent) {
247 super.createButtons(parent);
249 Composite composite = new Composite(parent, SWT.NONE);
250 FillLayout fillLayout = new FillLayout(SWT.HORIZONTAL);
251 composite.setLayout(fillLayout);
254 Button licenseButton = createButton(composite, "License");
256 licenseButton.addSelectionListener(new SelectionAdapter() {
257 private boolean isOpen;
260 public void widgetSelected(SelectionEvent e) {
263 LicenseDialog licenseDialog = new LicenseDialog(shell, "License");
264 licenseDialog.open();
271 createOKButton(composite, true);
274 private Properties getProperties() {
275 InputStream is = null;
276 Properties properties = null;
279 is = this.getClass().getClassLoader().getResourceAsStream(ABOUT_PROP_FILENAME);
281 logger.severe("about properties file is null.");
285 properties = new Properties();
288 } catch (IOException e) {
289 logger.log(Level.SEVERE, e.getMessage(), e);
298 protected void setShellSize() {
299 shell.setSize(436, shell.getSize().y);
302 protected void close() {
303 logger.info("close the about dialog");
304 aboutImage.dispose();