Device Template: setting device template value using new device configuration
authorjihye424.kim <jihye424.kim@samsung.com>
Thu, 15 Oct 2015 07:15:51 +0000 (16:15 +0900)
committerJiHye Kim <jihye424.kim@samsung.com>
Thu, 15 Oct 2015 08:10:57 +0000 (17:10 +0900)
- add setting DPI value routine when calling setting display value function

Change-Id: I2e14a0c80326840d865f255e6aa9931bff9a5b0b
Signed-off-by: jihye424.kim <jihye424.kim@samsung.com>
src/org/tizen/emulator/manager/devices/DeviceTemplate.java
src/org/tizen/emulator/manager/devices/DeviceTemplateValue.java

index fc284dc..a9e20a9 100644 (file)
@@ -128,18 +128,12 @@ public class DeviceTemplate {
                        return;
                }
 
-               DeviceConfiguration newConf = settingConfiguration(newValue);
-               if (newConf != null) {
-                       if (DeviceTemplateList.saveDeviceConfiguration(newConf, templateFile)) {
-                               this.conf = newConf;
-                               this.value = newValue;
-                       } else {
-                               throw new DeviceWorkerException("Failed to modfiy device template"
-                                               + StringResources.NEW_LINE
-                                               + "Check emulator manager log file: "
-                                               + StringResources.NEW_LINE
-                                               + FilePathResources.getTizenVmsPath());
-                       }
+               if (!saveDeviceConfiguration(newValue)) {
+                       throw new DeviceWorkerException("Failed to modfiy device template"
+                                       + StringResources.NEW_LINE
+                                       + "Check emulator manager log file: "
+                                       + StringResources.NEW_LINE
+                                       + FilePathResources.getTizenVmsPath());
                }
                // lock.release
        }
@@ -150,29 +144,41 @@ public class DeviceTemplate {
                        return;
                }
 
+               if (saveDeviceConfiguration(newValue)) {
+                       // TODO
+                       Profile profile = ProfileList.getProfile(value.getProfile());
+                       profile.addDeviceTemplate(this);
+               } else {
+                       throw new DeviceWorkerException("Failed to create device template"
+                                       + StringResources.NEW_LINE
+                                       + "Check emulator manager log file: "
+                                       + StringResources.NEW_LINE
+                                       + FilePathResources.getTizenVmsPath());
+               }
+               // lock.release
+       }
+
+       private boolean saveDeviceConfiguration(DeviceTemplateValue newValue) {
                DeviceConfiguration newConf = settingConfiguration(newValue);
-               if (newConf != null) {
-                       if (templateFile == null) {
-                               String filePath = FilePathResources.getTizenSdkDataDevicePath()
-                                               + File.separator + newValue.getName() + ".xml";
-                               templateFile = new File(filePath);
-                       }
+               if (newConf == null) {
+                       return false;
+               }
 
-                       if (DeviceTemplateList.saveDeviceConfiguration(newConf, templateFile)) {
-                               this.conf = newConf;
-                               this.value = newValue;
-                               // TODO
-                               Profile profile = ProfileList.getProfile(value.getProfile());
-                               profile.addDeviceTemplate(this);
-                       } else {
-                               throw new DeviceWorkerException("Failed to create device template"
-                                               + StringResources.NEW_LINE
-                                               + "Check emulator manager log file: "
-                                               + StringResources.NEW_LINE
-                                               + FilePathResources.getTizenVmsPath());
-                       }
+               if (templateFile == null) {
+                       String filePath = FilePathResources.getTizenSdkDataDevicePath()
+                                       + File.separator + newValue.getName() + ".xml";
+                       templateFile = new File(filePath);
+               }
+
+               if (DeviceTemplateList.saveDeviceConfiguration(newConf, templateFile)) {
+                       conf = newConf;
+                       value = newValue;
+                       value.settingConfigure(this);
+                       lastModified = templateFile.lastModified();
+                       return true;
+               } else {
+                       return false;
                }
-               // lock.release
        }
 
        private DeviceConfiguration settingConfiguration(DeviceTemplateValue value) {
index 4656178..0fd1b01 100644 (file)
@@ -301,6 +301,9 @@ public class DeviceTemplateValue implements Cloneable {
 
        public void setResolution(RESOLUTION resolution) {
                this.resolution = resolution;
+               displayWidth = resolution.getResolution().getWidth();
+               displayHeight = resolution.getResolution().getHeight();
+               displayDPI = calculatorDPI();
        }
 
        public int getDisplayWidth() {
@@ -309,6 +312,7 @@ public class DeviceTemplateValue implements Cloneable {
 
        public void setDisplayWidth(int displayWidth) {
                this.displayWidth = displayWidth;
+               displayDPI = calculatorDPI();
        }
 
        public int getDisplayHeight() {
@@ -317,6 +321,7 @@ public class DeviceTemplateValue implements Cloneable {
 
        public void setDisplayHeight(int displayHeight) {
                this.displayHeight = displayHeight;
+               displayDPI = calculatorDPI();
        }
 
        public double getDisplaySize() {
@@ -325,6 +330,7 @@ public class DeviceTemplateValue implements Cloneable {
 
        public void setDisplaySize(double displaySize) {
                this.displaySize = displaySize;
+               displayDPI = calculatorDPI();
        }
 
        public String getDisplaySizeUnit() {