[Title] Introduce initial "about dialog"
authorsyeon.hwang <syeon.hwang@samsung.com>
Mon, 19 Mar 2012 09:14:47 +0000 (18:14 +0900)
committersyeon.hwang <syeon.hwang@samsung.com>
Mon, 19 Mar 2012 09:14:47 +0000 (18:14 +0900)
[Type]
[Module] Emulator/
[Priority]
[CQ#]
[Redmine#]
[Problem]
[Cause]
[Solution]
[TestCase]

tizen/src/VERSION [new file with mode: 0644]
tizen/src/skin/client/build.xml
tizen/src/skin/client/src/about.properties [new file with mode: 0644]
tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java
tizen/src/skin/client/src/org/tizen/emulator/skin/dialog/AboutDialog.java [new file with mode: 0644]

diff --git a/tizen/src/VERSION b/tizen/src/VERSION
new file mode 100644 (file)
index 0000000..5320adc
--- /dev/null
@@ -0,0 +1 @@
+0.21
index b9e71fb..41e9533 100644 (file)
@@ -3,7 +3,7 @@
     
     <property name="jar.file" value="emulator-skin.jar" />
     <property name="mainclass" value="org.tizen.emulator.skin.EmulatorSkinMain" />
-
+       
     <property name="swt.file" value="swt.jar" />
 
     <path id="linux-classpath">
         <delete file="${jar.file}" />
     </target>
 
-    <target name="linux-compile" depends="clean">
+       <target name="make-properties">
+       <echo message="Make properties..." />
+               <tstamp>
+                       <format property="build_time" pattern="MM/dd/yyyy hh:mm aa" timezone="GMT" locale="en" />
+               </tstamp>
+               <exec executable="cat" outputproperty="version">
+                       <arg value="../../VERSION" />
+               </exec>
+               <exec executable="git" outputproperty="build_git_commit">
+                       <arg value="rev-parse" />
+                       <arg value="--short" />
+                       <arg value="HEAD" />
+               </exec>
+               
+               <propertyfile file="src/about.properties"
+                       comment="Auto-generated properties - DO NOT EDIT">
+                       <entry key="version" value="${version}" />
+                       <entry key="build_time" value="${build_time}" />
+                       <entry key="build_git_commit" value="${build_git_commit}" />
+               </propertyfile>
+       </target>
+       
+    <target name="linux-compile" depends="make-properties, clean">
         <echo message="compiling..." />
         <mkdir dir="bin" />
         <javac encoding="UTF-8" fork="true" srcdir="src" destdir="bin" debug="on" memorymaximumsize="128m">
@@ -30,7 +52,7 @@
         </javac>
     </target>
 
-    <target name="windows-compile" depends="clean">
+    <target name="windows-compile" depends="make-properties, clean">
         <echo message="compiling..." />
         <mkdir dir="bin" />
         <javac encoding="UTF-8" fork="true" srcdir="src" destdir="bin" debug="on" memorymaximumsize="128m">
@@ -38,7 +60,7 @@
         </javac>
     </target>
 
-    <target name="mac-compile" depends="clean">
+    <target name="mac-compile" depends="make-properties, clean">
         <echo message="compiling..." />
         <mkdir dir="bin" />
         <javac encoding="UTF-8" fork="true" srcdir="src" destdir="bin" debug="on" memorymaximumsize="128m">
@@ -49,6 +71,7 @@
     <target name="linux-jar" depends="linux-compile">
         <echo message="creating jar..." />
         <jar jarfile="${jar.file}" basedir="bin" duplicate="add">
+                       <fileset file="src/about.properties" />
             <manifest>
                 <attribute name="Main-Class" value="${mainclass}"/>
                 <attribute name="Class-path" value="lib/swt/gtk-linux/${swt.file}"/>
diff --git a/tizen/src/skin/client/src/about.properties b/tizen/src/skin/client/src/about.properties
new file mode 100644 (file)
index 0000000..40b48b5
--- /dev/null
@@ -0,0 +1,6 @@
+#Auto-generated properties - DO NOT EDIT
+#Mon, 19 Mar 2012 18:12:58 +0900
+
+version=0.21
+build_time=03/19/2012 09\:12 AM
+build_git_commit=4919ac4
index bc1a627..a0d5a02 100644 (file)
@@ -88,6 +88,7 @@ import org.tizen.emulator.skin.dbi.LcdType;
 import org.tizen.emulator.skin.dbi.RegionType;
 import org.tizen.emulator.skin.dbi.RgbType;
 import org.tizen.emulator.skin.dbi.RotationType;
+import org.tizen.emulator.skin.dialog.AboutDialog;
 import org.tizen.emulator.skin.image.ImageRegistry;
 import org.tizen.emulator.skin.image.ImageRegistry.ImageType;
 import org.tizen.emulator.skin.log.SkinLogger;
@@ -1038,11 +1039,12 @@ public class EmulatorSkin {
 
                final MenuItem aboutItem = new MenuItem( menu, SWT.PUSH );
                aboutItem.setText( "About" );
-               aboutItem.setEnabled( false );
+               aboutItem.setEnabled( true );
                aboutItem.addSelectionListener( new SelectionAdapter() {
                        @Override
                        public void widgetSelected( SelectionEvent e ) {
-                               // TODO
+                               AboutDialog dialog = new AboutDialog(shell);
+                               dialog.open();
                        }
                } );
 
diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/dialog/AboutDialog.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/dialog/AboutDialog.java
new file mode 100644 (file)
index 0000000..6b6d376
--- /dev/null
@@ -0,0 +1,53 @@
+package org.tizen.emulator.skin.dialog;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.swt.widgets.Shell;
+
+public class AboutDialog {
+       MessageBox messageBox;
+       Properties properties;
+       
+       public AboutDialog(Shell shell) {
+               if(!getProperties())
+                       return;
+               
+               messageBox = new MessageBox(shell);
+               messageBox.setText("About");
+               
+               String message = makeMessage();
+               messageBox.setMessage(message);
+       }
+
+       private String makeMessage() {
+               String version = "Version : " + properties.getProperty("version");
+               String buildTime = "Build time : " + properties.getProperty("build_time");
+               String gitCommit = "Git : " + properties.getProperty("build_git_commit");
+               
+               return version + "\n" + buildTime + "\n" + gitCommit;
+       }
+
+       private boolean getProperties() {
+               InputStream is = this.getClass().getClassLoader().getResourceAsStream("about.properties");
+               if(is == null)
+                       return false;
+               
+               properties = new Properties();
+               try {
+                       properties.load(is);
+               } catch (IOException e) {
+                       e.printStackTrace();
+                       
+                       return false;
+               }
+               
+               return true;
+       }
+
+       public void open() {
+               messageBox.open();
+       }
+}