VM property: create 'VMPropertyConfiguration' class
authorjihye424.kim <jihye424.kim@samsung.com>
Tue, 10 Nov 2015 05:00:05 +0000 (14:00 +0900)
committerSeokYeon Hwang <syeon.hwang@samsung.com>
Wed, 20 Jan 2016 05:05:47 +0000 (14:05 +0900)
- 'VMPropertyConfiguration' class replace 'EmulatorConfiguration' class
-- other class can not access 'EmualtorConfiguration' class that is auto generated class from jaxb.
- 'VMOption' and 'VMSubOption' class replace 'OptionType' and 'SubOptionType'
-- 'OptionType' and 'SubOptionType' class are auto generated from jaxb

Conflicts:
        src/org/tizen/emulator/manager/vms/Creator.java
        src/org/tizen/emulator/manager/vms/Modifier.java
        src/org/tizen/emulator/manager/vms/VMProperty.java
        src/org/tizen/emulator/manager/vms/VMPropertyValue.java

Change-Id: I9a63e27c2cc8e5688b2bcbaeac3662597698ae97
Signed-off-by: jihye424.kim <jihye424.kim@samsung.com>
(cherry picked from commit 8abedef8564568d4d5ba66dc9afd07d94be84dad)

src/org/tizen/emulator/manager/vms/Creator.java
src/org/tizen/emulator/manager/vms/EmulatorVMList.java
src/org/tizen/emulator/manager/vms/Modifier.java
src/org/tizen/emulator/manager/vms/VMLauncher.java
src/org/tizen/emulator/manager/vms/VMOption.java [new file with mode: 0644]
src/org/tizen/emulator/manager/vms/VMProperty.java
src/org/tizen/emulator/manager/vms/VMPropertyConfiguration.java [new file with mode: 0644]
src/org/tizen/emulator/manager/vms/VMPropertyValue.java
src/org/tizen/emulator/manager/vms/VMSubOption.java [new file with mode: 0644]

index a3f9d88..d314099 100644 (file)
@@ -50,8 +50,6 @@ import org.tizen.emulator.manager.vms.helper.VMCreatorException;
 import org.tizen.emulator.manager.vms.helper.VMWorkerException;
 import org.tizen.emulator.manager.vms.helper.WorkerLock;
 import org.tizen.emulator.manager.vms.option.LaunchConfig;
-import org.tizen.emulator.manager.vms.xml.EmulatorConfiguration;
-import org.tizen.emulator.manager.vms.xml.ObjectFactory;
 
 public class Creator {
        private VMProperty property;
@@ -271,127 +269,9 @@ public class Creator {
        private void createUsability() {}
 
        private void settingProperty() {
-               ObjectFactory factory = EmulatorVMList.getInstance().getObjectFactory();
-               EmulatorConfiguration ec = property.getConfiguration();
-               ec.setBaseInformation(factory.createBaseInformationType());
-               ec.setUsability(factory.createUsabilityType());
-               ec.setDevice(factory.createDeviceType());
-
-               ec.getBaseInformation().setName(newVM.vmsName);
-               ec.getBaseInformation().setArchitecture(newVM.baseImage.getCpu());
-               ec.getBaseInformation().setPlatform(newVM.baseImage.getPlatformName());
-
-               ec.getBaseInformation().setDiskImage(factory.createBaseInformationTypeDiskImage());
-               if (newVM.baseImage.isStandard()) {
-                       ec.getBaseInformation().getDiskImage().setType("standard"); //$NON-NLS-1$
-               } else {
-                       ec.getBaseInformation().getDiskImage().setType("custom"); //$NON-NLS-1$
-               }
-
-               if (newVM.baseImage.getVersion() != null) {
-                       ec.getBaseInformation().getDiskImage().setVersion(newVM.baseImage.getVersion());
-               } else {
-                       ec.getBaseInformation().getDiskImage().setVersion("Standard"); //$NON-NLS-1$
-               }
-               if (newVM.baseImage.getName() != null) {
-                       ec.getBaseInformation().getDiskImage().setBase(newVM.baseImage.getName());
-               }
-
-               //
-               ec.getBaseInformation().getDiskImage().setProfile(newVM.baseImage.getProfile());
-               ec.getBaseInformation().getDiskImage().setBaseDiskImage(factory.createDiskImageFormatType());
-               ec.getBaseInformation().getDiskImage().setCurrentDiskImage(factory.createDiskImageFormatType());
-               // TODO :
-               ec.getBaseInformation().getDiskImage().getBaseDiskImage().setFormat("qcow2"); //$NON-NLS-1$
-               ec.getBaseInformation().getDiskImage().getBaseDiskImage().setValue(newVM.baseImagePath);
-
-               if (newVM.baseImage.isStandard() && !newVM.baseImage.getBinaryVersion().isEmpty()) {
-                       ec.getBaseInformation().getDiskImage().getBaseDiskImage().setVersion(newVM.baseImage.getBinaryVersion());
-               }
-               ec.getBaseInformation().getDiskImage().getCurrentDiskImage().setFormat("qcow2"); //$NON-NLS-1$
-               //ec.getBaseInformation().getDiskImage().getCurrentDiskImage().setValue(
-               //              folder.getAbsolutePath() + File.separator + "emulimg-" +  newVM.imageName + "." + Architecture.x86.toString());
-               ec.getBaseInformation().getDiskImage().getCurrentDiskImage().setValue(customPath);
-
-               if (swapPath != null) {
-                       ec.getBaseInformation().getDiskImage().setSwapDiskImage(factory.createDiskImageFormatType());
-                       ec.getBaseInformation().getDiskImage().getSwapDiskImage().setFormat("qcow2"); //$NON-NLS-1$
-                       ec.getBaseInformation().getDiskImage().getSwapDiskImage().setValue(swapPath);
-               }
-
-               ec.getUsability().setLogging(factory.createUsabilityTypeLogging());
-               ec.getUsability().getLogging().setLevel("NONE"); //$NON-NLS-1$
-               ec.getUsability().setHwVirtualization(newVM.isHWVirtualization);
-                                                       /*&& CheckVirtualization.getInstance().isSupportVirtualization());*/
-               ec.getUsability().setHwGLAcceleration(newVM.isGLAcceleration);
-               ec.getUsability().setSupportSuspend(newVM.isSupportSuspend);
-
-               ec.getUsability().setFileSharing(factory.createUsabilityTypeFileSharing());
-               if (!newVM.fileSharePath.isEmpty()) {
-                       ec.getUsability().getFileSharing().setPath(newVM.fileSharePath);
-               }
-
-               ec.getDevice().setDisplay(factory.createDisplayType());
-               ec.getDevice().getDisplay().setResolution(factory.createDisplayTypeResolution());
-               ec.getDevice().getDisplay().getResolution().setWidth(newVM.resolution.getWidth());
-               ec.getDevice().getDisplay().getResolution().setHeight(newVM.resolution.getHeight());
-
-               ec.getDevice().getDisplay().setDensity(factory.createDisplayTypeDensity());
-               ec.getDevice().getDisplay().getDensity().setUnit("dpi"); //$NON-NLS-1$
-               ec.getDevice().getDisplay().getDensity().setValue(newVM.dpi);
-
-               ec.getDevice().getDisplay().setSkinPath(factory.createDisplayTypeSkinPath());
-               if (newVM.skin != null) {
-                       ec.getDevice().getDisplay().getSkinPath().setPath(newVM.skin.getPath());
-               } else if (newVM.skinPath != null) {
-                       ec.getDevice().getDisplay().getSkinPath().setPath(newVM.skinPath);
-               }
-
-               ////// CPU //////
-               ec.getDevice().setCPU(factory.createCpuType());
-               ec.getDevice().getCPU().setValue(factory.createCpuTypeValue());
-               ec.getDevice().getCPU().getValue().setUnit("cpu"); //$NON-NLS-1$
-               if (newVM.cpu == 0) {
-                       int max = CPU.getMaxCpuNum();
-                       newVM.cpu = max > 4 ? 4 : max;
-               }
-               ec.getDevice().getCPU().getValue().setValue(newVM.cpu);
-
-
-               ec.getDevice().setRAM(factory.createRamType());
-               ec.getDevice().getRAM().setSize(factory.createRamTypeSize());
-               ec.getDevice().getRAM().getSize().setUnit("MiB"); //$NON-NLS-1$
-               ec.getDevice().getRAM().getSize().setValue(newVM.ramSize);
-
-               if (newVM.maxTouchCount >= 0) {
-                       ec.getDevice().setTouch(factory.createTouchType());
-                       ec.getDevice().getTouch().setMaxTouchPoint(newVM.maxTouchCount);
-               }
-
-               if (newVM.addOptions != null) {
-                       ec.getUsability().setAdvancedOptions(newVM.addOptions);
-               }
-
-               if(newVM.ociOptions != null) {
-               //////OCI DEVICE//////
-                       ec.setOci(factory.createOciType());
-                       ec.getOci().setOciOptions(newVM.ociOptions);
-               }
-
-               // extended option
-               if (newVM.extendedOptions != null) {
-                       ec.getExtendedOption().addAll(newVM.extendedOptions);
-               }
-
-               // advanced option
-               if (newVM.advancedOptionList.size() > 0) {
-                       if (ec.getAdvancedOption() == null) {
-                               ec.setAdvancedOption(factory.createAdvancedOptionType());
-                       } else {
-                               ec.getAdvancedOption().getOption().clear();
-                       }
-                       ec.getAdvancedOption().getOption().addAll(newVM.advancedOptionList);
-               }
+               newVM.childImagePath = customPath;
+               newVM.swapImagePath = swapPath;
+               property.settingConfiguration();
        }
 
        public static VMProperty create(VMPropertyValue newVM) throws VMWorkerException {
index d631406..56cdd5c 100644 (file)
@@ -213,7 +213,7 @@ public class EmulatorVMList {
                        }
 
                        fos = new FileOutputStream(outputFile);
-                       marshaller.marshal(property.getConfiguration(), fos);
+                       marshaller.marshal(property.getVMConfiguration().getConfiguration(), fos);
                } catch (JAXBException e) {
                        e.printStackTrace();
                        return false;
@@ -236,6 +236,11 @@ public class EmulatorVMList {
                return true;
        }
 
+       /**
+        * Create 'VMProperty' that have empty emulator configuration
+        * @param name
+        * @return
+        */
        public VMProperty getNewProperty(String name) {
                String configDirectoryName = FilePathResources.getTizenVmsPath() + File.separator + name;
                String configFilename = configDirectoryName + File.separator + StringResources.PROPERTY_XML_NAME;
@@ -244,20 +249,6 @@ public class EmulatorVMList {
 
                EmulatorConfiguration ec = objectFactory.createEmulatorConfiguration();
 
-//             ec.setBaseInformation(objectFactory.createBaseInformationType());
-//             ec.setUsability(objectFactory.createUsabilityType());
-//             ec.setSkin(objectFactory.createSkinType());
-//
-//             ec.getBaseInformation().setName(name);
-//             ec.getBaseInformation().setArchitecture(arch.toString());
-//             ec.getBaseInformation().getDiskImage().setType("standard");
-//             ec.getBaseInformation().getDiskImage().setBaseDiskImage(objectFactory.createDiskImageFormatType());
-//             ec.getBaseInformation().getDiskImage().getBaseDiskImage().setFormat("qcow2");
-//             ec.getBaseInformation().getDiskImage().getBaseDiskImage().setValue("path");
-//             .
-//             .
-//             .
-
                return new VMProperty(configFile, ec);
        }
 }
index fea7e77..2eaf689 100644 (file)
@@ -33,8 +33,6 @@ package org.tizen.emulator.manager.vms;
 import org.tizen.emulator.manager.Messages;
 import org.tizen.emulator.manager.vms.helper.VMWorkerException;
 import org.tizen.emulator.manager.vms.option.LaunchConfig;
-import org.tizen.emulator.manager.vms.xml.EmulatorConfiguration;
-import org.tizen.emulator.manager.vms.xml.TouchType;
 
 public class Modifier {
        private Modifier() {}
@@ -45,136 +43,9 @@ public class Modifier {
                        throw new VMWorkerException(Messages.getString("Modifier.Error.0")); //$NON-NLS-1$
                }
                modifyFileShare(newVM);
-               if (!newVM.resolution.equals(oldVM.resolution)) {
-                       /*
-                       int i = newVM.resolution.indexOf('x');
-                       oldVM.resolutionType.setWidth(Integer.valueOf(newVM.resolution.substring(0,i)));
-                       oldVM.resolutionType.setHeight(Integer.valueOf(newVM.resolution.substring(i+1,newVM.resolution.length())));
-                       */
-                       property.getConfiguration().getDevice().getDisplay().getResolution().setWidth(newVM.resolution.getWidth());
-                       property.getConfiguration().getDevice().getDisplay().getResolution().setHeight(newVM.resolution.getHeight());
-                       /*
-                       if (newVM.keyType == 1) { // 1key
-                               newVM.skinPath = FilePath.getInstance().getDefaultSkinPath() + File.separator + "emul_" + newVM.resolution;
-                       } else if (newVM.keyType == 3){ // 3 key
-                               newVM.skinPath = FilePath.getInstance().getDefaultSkinPath() + File.separator + "emul_3keys_" + newVM.resolution;
-                       }
-                       */
-                       if (newVM.skin != null) {
-                               newVM.skinPath = newVM.skin.getPath();
-                               property.getConfiguration().getDevice().getDisplay().getSkinPath().setPath(newVM.skinPath);
-                       } else if (newVM.skinPath != null) {
-                               property.getConfiguration().getDevice().getDisplay().getSkinPath().setPath(newVM.skinPath);
-                       } else {
-                               newVM.skinPath = null;
-                       }
-               }
-               /* else {
-                       if (newVM.keyType != oldVM.keyType) {
-                               newVM.skinPath = newVM.getSkin().findSkinPath(newVM.resolution);
-                               property.getConfiguration().getDevice().getDisplay().getSkinPath().setPath(newVM.skinPath);
-                       }
-               }*/
-
-               if (newVM.dpi != oldVM.dpi) {
-                       property.getConfiguration().getDevice().getDisplay().getDensity().setValue(newVM.dpi);
-               }
-
-               if (newVM.skin != oldVM.skin) {
-                       if (newVM.skin != null) {
-                               property.getConfiguration().getDevice().getDisplay().getSkinPath().setPath(newVM.skin.getPath());
-                       } else {
-                               property.getConfiguration().getDevice().getDisplay().getSkinPath().setPath(null);
-                       }
-               }
-
-               if (newVM.cpu != oldVM.cpu) {
-                       property.setCPU(newVM.cpu, true);
-               }
-
-               if (newVM.ramSize != oldVM.ramSize) {
-                       property.getConfiguration().getDevice().getRAM().getSize().setValue(newVM.ramSize);
-               }
-
-               if (newVM.isFileShareSupport != oldVM.isFileShareSupport) {
-                       if (newVM.isFileShareSupport && !newVM.fileSharePath.isEmpty()) {
-                               property.getConfiguration().getUsability().getFileSharing().setPath(newVM.fileSharePath);
-                       } else {
-                               property.getConfiguration().getUsability().getFileSharing().setPath(null);
-                       }
-               } else if (newVM.isFileShareSupport && !newVM.fileSharePath.equals(oldVM.fileSharePath)) {
-                       property.getConfiguration().getUsability().getFileSharing().setPath(newVM.fileSharePath);
-               }
-
-               if (newVM.isHWVirtualization != oldVM.isHWVirtualization) {
-                       property.getConfiguration().getUsability().setHwVirtualization(newVM.isHWVirtualization);
-               }
-
-               if (newVM.isGLAcceleration != oldVM.isGLAcceleration) {
-                       property.getConfiguration().getUsability().setHwGLAcceleration(newVM.isGLAcceleration);
-               }
-
-               if (newVM.isSupportSuspend != oldVM.isSupportSuspend) {
-                       property.getConfiguration().getUsability().setSupportSuspend(newVM.isSupportSuspend);
-               }
-
-               TouchType touchType = property.getConfiguration().getDevice().getTouch();
-               if (newVM.maxTouchCount != oldVM.maxTouchCount) {
-                       if (touchType != null) {
-                               touchType.setMaxTouchPoint(newVM.maxTouchCount);
-                       } else {
-                               //else if (EmulatorManager.getInstance().getManagerMode().equals(ManagerModeType.INHOUSE_MODE)) {
-                               //touchType == null
-                               EmulatorConfiguration ec = property.getConfiguration();
-                               ec.getDevice().setTouch(EmulatorVMList.getInstance().getObjectFactory().createTouchType());
-                               ec.getDevice().getTouch().setMaxTouchPoint(newVM.maxTouchCount);
-                       }
-               }
-
-               if (newVM.baseImage != null) { // baseName can be modified only in Custom VM.
-                       if (!newVM.baseImage.getName().equals(oldVM.baseImage.getName())) {
-                               property.getConfiguration().getBaseInformation().getDiskImage().setBase(newVM.baseImage.getName());
-                       }
-               }
-
-               if (newVM.addOptions != null) {
-                       if (oldVM.addOptions == null || !newVM.addOptions.equals(oldVM.addOptions)) {
-                               property.getConfiguration().getUsability().setAdvancedOptions(newVM.addOptions);
-                       }
-               } else {
-                       if (oldVM.addOptions != null) {
-                               property.getConfiguration().getUsability().setAdvancedOptions(newVM.addOptions);
-                       }
-               }
-
-               if (newVM.ociOptions != null) {
-                       if (oldVM.ociOptions == null || !newVM.ociOptions.equals(oldVM.ociOptions)) {
-                               property.getConfiguration().getOci().setOciOptions(newVM.ociOptions);
-                       }
-               } else {
-                       if (oldVM.ociOptions != null) {
-                               property.getConfiguration().getOci().setOciOptions(newVM.ociOptions);
-                       }
-               }
-
-               // extended option
-               if (newVM.extendedOptions != null) {
-                       property.getConfiguration().getExtendedOption().clear();
-                       property.getConfiguration().getExtendedOption().addAll(newVM.extendedOptions);
-               }
-
-               // Advanced option
-               if (!newVM.isAdvancedOptionEquals(oldVM.advancedOptionList)) {
-                       if (property.getConfiguration().getAdvancedOption() == null) {
-                               property.getConfiguration().setAdvancedOption(
-                                               EmulatorVMList.getInstance().getObjectFactory().createAdvancedOptionType());
-                       } else {
-                               property.getConfiguration().getAdvancedOption().getOption().clear();
-                       }
-                       property.getConfiguration().getAdvancedOption().getOption().addAll(newVM.advancedOptionList);
-               }
 
                property.setPropertyValue(newVM);
+               property.settingConfiguration();
                LaunchConfig.createLaunchConfig(property);
                EmulatorVMList.getInstance().storeXML(property);
        }
index dae46f9..1771a45 100644 (file)
@@ -148,10 +148,8 @@ public class VMLauncher {
        private static void checkDiskImage(VMProperty property)
                        throws VMLauncherException {
                // check disk image
-               File child = new File(property.getConfiguration().getBaseInformation()
-                               .getDiskImage().getCurrentDiskImage().getValue());
-               File base = new File(property.getConfiguration().getBaseInformation()
-                               .getDiskImage().getBaseDiskImage().getValue());
+               File child = new File(property.getChildImagePath());
+               File base = new File(property.getBaseImagePath());
                if (!child.exists()) {
                        throw new VMLauncherException(Messages.getString("VMLauncher.ImageError.0") //$NON-NLS-1$
                                        + StringResources.NEW_LINE + child.getAbsolutePath(), true);
diff --git a/src/org/tizen/emulator/manager/vms/VMOption.java b/src/org/tizen/emulator/manager/vms/VMOption.java
new file mode 100644 (file)
index 0000000..bdf81a0
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * JiHye Kim <jihye424.kim@samsung.com>
+ * Minkee Lee <minkee.lee@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Sangho Park <sangho.p@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.emulator.manager.vms;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class VMOption {
+       private String name = "";
+       private String value = "";
+       private List<VMSubOption> subOptionList = new ArrayList<VMSubOption>();
+
+       public VMOption() {
+       }
+
+       public VMOption(String name) {
+               this.name = name;
+       }
+
+       public String getName() {
+               return name;
+       }
+
+       public void setName(String name) {
+               this.name = name;
+       }
+
+       public String getValue() {
+               return value;
+       }
+
+       public void setValue(String value) {
+               this.value = value;
+       }
+
+       public List<VMSubOption> getSubOptionList() {
+               return subOptionList;
+       }
+
+       public void setSubOptionList(List<VMSubOption> subOptionList) {
+               this.subOptionList = subOptionList;
+       }
+
+       public void addSubOption(VMSubOption subOption) {
+               if (subOption == null) {
+                       return;
+               }
+               subOptionList.add(subOption);
+       }
+}
index 0f835ef..05202e8 100644 (file)
@@ -37,7 +37,6 @@ import org.tizen.emulator.manager.plugin.EMPlugin;
 import org.tizen.emulator.manager.plugin.ExtensionItem;
 import org.tizen.emulator.manager.plugin.PluginStringResources;
 import org.tizen.emulator.manager.vms.xml.EmulatorConfiguration;
-import org.tizen.emulator.manager.vms.xml.ObjectFactory;
 
 public class VMProperty {
        public static final int MAX_NAME_LEN = 20;
@@ -46,7 +45,7 @@ public class VMProperty {
 
        private File propertyFile;
        private long lastModified;
-       private EmulatorConfiguration configuration;
+       private VMPropertyConfiguration configuration;
 
        private VMWorkerCommon worker;
        private VMPropertyValue value = null;
@@ -74,9 +73,9 @@ public class VMProperty {
         * @param element xml configuration of property file
         */
        public VMProperty(File propertyFile, EmulatorConfiguration element) {
+               configuration = new VMPropertyConfiguration(element);
                this.propertyFile = propertyFile;
                this.lastModified = propertyFile.lastModified();
-               this.configuration = element;
        }
 
        /**
@@ -111,7 +110,7 @@ public class VMProperty {
        }
 
        public void reloadProperty() {
-               this.configuration = EmulatorVMList.getInstance().parseXML(this);
+               this.configuration.setConfiguration(EmulatorVMList.getInstance().parseXML(this));
                this.lastModified = propertyFile.lastModified();
 
                this.value.settingConfigure(this);
@@ -151,112 +150,68 @@ public class VMProperty {
                this.isRunning = isRunning;
        }
 
+       // for plug-in source -> need to delete
+       @ Deprecated
        public EmulatorConfiguration getConfiguration() {
+               return configuration.getConfiguration();
+       }
+
+       public VMPropertyConfiguration getVMConfiguration() {
                return configuration;
        }
 
-       public String getName() {
-               if(configuration == null
-                               || configuration.getBaseInformation() == null) {
-                       return null;
+       public void settingConfiguration() {
+               if (value == null || configuration == null) {
+                       return;
                }
+               configuration.settingEmulatorConfiguration(value);
+       }
 
-               return configuration.getBaseInformation().getName();
+       public String getName() {
+               return configuration.getName();
        }
 
        public Architecture getArch() {
-               if(configuration == null
-                               || configuration.getBaseInformation() == null) {
-                       return null;
-               }
-               return Architecture.getDisplayType(configuration.getBaseInformation().getArchitecture());
+               return configuration.getArch();
        }
 
        public Architecture getArchInternal() {
-               if(configuration == null
-                               || configuration.getBaseInformation() == null) {
-                       return null;
-               }
-               return Architecture.getType(configuration.getBaseInformation().getArchitecture());
+               return configuration.getArchInternal();
        }
 
        public FSImageType getImageType() {
-               if(configuration == null
-                               || configuration.getBaseInformation() == null || configuration.getBaseInformation().getDiskImage() == null) {
-                       return null;
-               }
-
-               return FSImageType.standard.toString().equals(configuration.getBaseInformation().getDiskImage().getType()) ?
-                               FSImageType.standard : FSImageType.custom;
+               return configuration.getBaseImageType();
        }
 
        public String getBaseImageName() {
-               if(configuration == null
-                               || configuration.getBaseInformation() == null || configuration.getBaseInformation().getDiskImage() == null) {
-                       return ""; //$NON-NLS-1$
-               }
-
-               return configuration.getBaseInformation().getDiskImage().getBase();
+               return configuration.getBaseImageName();
        }
 
        public String getBaseImagePath() {
-               if (configuration == null
-                               || configuration.getBaseInformation() == null
-                               || configuration.getBaseInformation().getDiskImage() == null) {
-                       return ""; //$NON-NLS-1$
-               }
-
-               return configuration.getBaseInformation().getDiskImage().getBaseDiskImage().getValue();
+               return configuration.getBaseImagePath();
        }
        public String getChildImagePath() {
-               if(configuration == null
-                               || configuration.getBaseInformation() == null || configuration.getBaseInformation().getDiskImage() == null) {
-                       return ""; //$NON-NLS-1$
-               }
-
-               return configuration.getBaseInformation().getDiskImage().getCurrentDiskImage().getValue();
+               return configuration.getChildImagePath();
        }
 
-       public String getSwapImagePathTmp() { //tmp
-               if(configuration == null
-                               || configuration.getBaseInformation() == null || configuration.getBaseInformation().getDiskImage() == null) {
-                       return ""; //$NON-NLS-1$
-               }
-
-               return configuration.getBaseInformation().getDiskImage().getSwapDiskImage().getValue();
+       public String getSwapImagePath() {
+               return configuration.getSwapImagePath();
        }
 
-
        public String getImageVersion() {
-               if(configuration == null
-                               || configuration.getBaseInformation() == null || configuration.getBaseInformation().getDiskImage() == null) {
-                       return ""; //$NON-NLS-1$
-               }
-
-               return configuration.getBaseInformation().getDiskImage().getVersion();
+               return configuration.getBaseImageVersion();
        }
 
        public String getImageProfile() {
-               if(configuration == null
-                               || configuration.getBaseInformation() == null || configuration.getBaseInformation().getDiskImage() == null) {
-                       return ""; //$NON-NLS-1$
-               }
-
-               return configuration.getBaseInformation().getDiskImage().getProfile();
+               return configuration.getBaseImageProfile();
        }
 
        public String getImagePlatform() {
-               if (configuration != null && configuration.getBaseInformation() != null
-                               && configuration.getBaseInformation().getPlatform() != null) {
-                       return configuration.getBaseInformation().getPlatform();
-               } else {
-                       String version = getImageVersion();
-                       String profile = getImageProfile();
-                       if (version == null || profile == null) {
-                               return ""; //$NON-NLS-1$
-                       }
-                       return profile + "-" + version; //$NON-NLS-1$
-               }
+               return configuration.getBaseImagePlatform();
+       }
+
+       public String getBaseImageBinaryVersion() {
+               return configuration.getBaseImageBinaryVersion();
        }
 
        public boolean compareImage(BaseImage image) {
@@ -277,21 +232,6 @@ public class VMProperty {
                return true;
        }
 
-       public void setCPU(int cpu, boolean isCreateElement) {
-               if (configuration != null) {
-                       if (isCreateElement && configuration.getDevice().getCPU() == null) {
-                               ObjectFactory factory = EmulatorVMList.getInstance().getObjectFactory();
-                               configuration.getDevice().setCPU(factory.createCpuType());
-                               configuration.getDevice().getCPU().setValue(factory.createCpuTypeValue());
-                               configuration.getDevice().getCPU().getValue().setUnit("cpu"); //$NON-NLS-1$
-                       }
-
-                       if (configuration.getDevice().getCPU() != null) {
-                               configuration.getDevice().getCPU().getValue().setValue(cpu);
-                       }
-               }
-       }
-
        public boolean isAvailable() {
                return isAvailable;
        }
diff --git a/src/org/tizen/emulator/manager/vms/VMPropertyConfiguration.java b/src/org/tizen/emulator/manager/vms/VMPropertyConfiguration.java
new file mode 100644 (file)
index 0000000..f4ff8d1
--- /dev/null
@@ -0,0 +1,569 @@
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * JiHye Kim <jihye424.kim@samsung.com>
+ * Minkee Lee <minkee.lee@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Sangho Park <sangho.p@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.emulator.manager.vms;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.tizen.emulator.manager.resources.StringResources;
+import org.tizen.emulator.manager.vms.VMProperty.Architecture;
+import org.tizen.emulator.manager.vms.VMProperty.FSImageType;
+import org.tizen.emulator.manager.vms.xml.EmulatorConfiguration;
+import org.tizen.emulator.manager.vms.xml.ObjectFactory;
+import org.tizen.emulator.manager.vms.xml.OptionType;
+import org.tizen.emulator.manager.vms.xml.SubOptionType;
+
+public class VMPropertyConfiguration {
+       private EmulatorConfiguration configuration;
+       private List<VMOption> optionList = new ArrayList<VMOption>();
+
+       public VMPropertyConfiguration(EmulatorConfiguration configuration) {
+               this.configuration = configuration;
+       }
+
+       EmulatorConfiguration getConfiguration() {
+               return configuration;
+       }
+
+       public void setConfiguration(EmulatorConfiguration configuration) {
+               this.configuration = configuration;
+       }
+
+       public String getName() {
+               if(configuration == null
+                               || configuration.getBaseInformation() == null) {
+                       return null;
+               }
+
+               return configuration.getBaseInformation().getName();
+       }
+
+       public Architecture getArch() {
+               if(configuration == null
+                               || configuration.getBaseInformation() == null) {
+                       return null;
+               }
+               return Architecture.getDisplayType(configuration.getBaseInformation().getArchitecture());
+       }
+
+       public Architecture getArchInternal() {
+               if(configuration == null
+                               || configuration.getBaseInformation() == null) {
+                       return null;
+               }
+               return Architecture.getType(configuration.getBaseInformation().getArchitecture());
+       }
+
+       public String getPlatformName() {
+               if (configuration == null
+                               || configuration.getBaseInformation() == null) {
+                       return null;
+               }
+               return configuration.getBaseInformation().getPlatform();
+       }
+
+       public String getBaseImageName() {
+               if(configuration == null
+                               || configuration.getBaseInformation() == null || configuration.getBaseInformation().getDiskImage() == null) {
+                       return ""; //$NON-NLS-1$
+               }
+
+               return configuration.getBaseInformation().getDiskImage().getBase();
+       }
+
+//     public String getDeviceTemplatePath() {
+//             if (configuration == null
+//                             || configuration.getBaseInformation() == null
+//                             || configuration.getBaseInformation().getDeviceTemplate() == null) {
+//                     return null;
+//             }
+//
+//             return configuration.getBaseInformation().getDeviceTemplate().getPath();
+//     }
+
+       public FSImageType getBaseImageType() {
+               if(configuration == null
+                               || configuration.getBaseInformation() == null || configuration.getBaseInformation().getDiskImage() == null) {
+                       return null;
+               }
+
+               return FSImageType.standard.toString().equals(configuration.getBaseInformation().getDiskImage().getType()) ?
+                               FSImageType.standard : FSImageType.custom;
+       }
+
+       public String getBaseImageVersion() {
+               if(configuration == null
+                               || configuration.getBaseInformation() == null || configuration.getBaseInformation().getDiskImage() == null) {
+                       return ""; //$NON-NLS-1$
+               }
+
+               return configuration.getBaseInformation().getDiskImage().getVersion();
+       }
+
+       public String getBaseImageProfile() {
+               if(configuration == null
+                               || configuration.getBaseInformation() == null || configuration.getBaseInformation().getDiskImage() == null) {
+                       return ""; //$NON-NLS-1$
+               }
+
+               return configuration.getBaseInformation().getDiskImage().getProfile();
+       }
+
+       public String getBaseImagePlatform() {
+               if (configuration != null && configuration.getBaseInformation() != null
+                               && configuration.getBaseInformation().getPlatform() != null) {
+                       return configuration.getBaseInformation().getPlatform();
+               } else {
+                       String version = getBaseImageVersion();
+                       String profile = getBaseImageProfile();
+                       if (version == null || profile == null) {
+                               return ""; //$NON-NLS-1$
+                       }
+                       return profile + "-" + version; //$NON-NLS-1$
+               }
+       }
+
+       public String getBaseImageBinaryVersion() {
+               if (configuration == null
+                               || configuration.getBaseInformation() == null
+                               || configuration.getBaseInformation().getDiskImage() == null) {
+                       return ""; //$NON-NLS-1$
+               }
+
+               return configuration.getBaseInformation().getDiskImage().getBaseDiskImage().getVersion();
+       }
+
+       public String getBaseImagePath() {
+               if (configuration == null
+                               || configuration.getBaseInformation() == null
+                               || configuration.getBaseInformation().getDiskImage() == null) {
+                       return ""; //$NON-NLS-1$
+               }
+
+               return configuration.getBaseInformation().getDiskImage().getBaseDiskImage().getValue();
+       }
+
+       public String getChildImagePath() {
+               if(configuration == null
+                               || configuration.getBaseInformation() == null || configuration.getBaseInformation().getDiskImage() == null) {
+                       return ""; //$NON-NLS-1$
+               }
+
+               return configuration.getBaseInformation().getDiskImage().getCurrentDiskImage().getValue();
+       }
+
+       public String getSwapImagePath() {
+               if(configuration == null
+                               || configuration.getBaseInformation() == null || configuration.getBaseInformation().getDiskImage() == null) {
+                       return ""; //$NON-NLS-1$
+               }
+
+               return configuration.getBaseInformation().getDiskImage().getSwapDiskImage().getValue();
+       }
+
+       public String getLoggingLevel() {
+               if (configuration == null
+                               || configuration.getUsability() == null
+                               || configuration.getUsability().getLogging() == null) {
+                       return "";
+               }
+
+               return configuration.getUsability().getLogging().getLevel();
+       }
+
+       public String getFileSharingPath() {
+               if (configuration == null
+                               || configuration.getUsability() == null
+                               || configuration.getUsability().getFileSharing() == null) {
+                       return null;
+               }
+
+               return configuration.getUsability().getFileSharing().getPath();
+       }
+
+       public boolean supportHWVirtualization() {
+               if (configuration == null
+                               || configuration.getUsability() == null) {
+                       return false;
+               }
+               return configuration.getUsability().isHwVirtualization();
+       }
+
+       public boolean supporGLAcceleration() {
+               if (configuration == null
+                               || configuration.getUsability() == null) {
+                       return false;
+               }
+               return configuration.getUsability().isHwGLAcceleration();
+       }
+
+       public boolean supportSuspend() {
+               if (configuration == null
+                               || configuration.getUsability() == null) {
+                       return false;
+               }
+               return configuration.getUsability().isSupportSuspend();
+       }
+
+       public int getDisplayWidth() {
+               if (configuration == null
+                               || configuration.getDevice() == null
+                               || configuration.getDevice().getDisplay() == null
+                               || configuration.getDevice().getDisplay().getResolution() == null) {
+                       return 0;
+               }
+               return configuration.getDevice().getDisplay().getResolution().getWidth();
+       }
+
+       public int getDisplayHeight() {
+               if (configuration == null
+                               || configuration.getDevice() == null
+                               || configuration.getDevice().getDisplay() == null
+                               || configuration.getDevice().getDisplay().getResolution() == null) {
+                       return 0;
+               }
+               return configuration.getDevice().getDisplay().getResolution().getHeight();
+       }
+
+       public int getDisplayDPI() {
+               if (configuration == null
+                               || configuration.getDevice() == null
+                               || configuration.getDevice().getDisplay() == null
+                               || configuration.getDevice().getDisplay().getDensity() == null) {
+                       return 0;
+               }
+               return configuration.getDevice().getDisplay().getDensity().getValue();
+       }
+
+//     public double getDisplaySize() {
+//             if (configuration == null
+//                             || configuration.getDevice() == null
+//                             || configuration.getDevice().getDisplay() == null
+//                             || configuration.getDevice().getDisplay().getScreenSize() == null) {
+//                     return 0;
+//             }
+//             return configuration.getDevice().getDisplay().getScreenSize().getValue();
+//     }
+
+       public String getSkinPath() {
+               if (configuration == null
+                               || configuration.getDevice() == null
+                               || configuration.getDevice().getDisplay() == null
+                               || configuration.getDevice().getDisplay().getSkinPath() == null) {
+                       return null;
+               }
+
+               return configuration.getDevice().getDisplay().getSkinPath().getPath();
+       }
+
+       public int getCPUCount() {
+               if (configuration == null
+                               || configuration.getDevice() == null
+                               || configuration.getDevice().getCPU() == null
+                               || configuration.getDevice().getCPU().getValue() == null) {
+                       return 1;
+               }
+               return configuration.getDevice().getCPU().getValue().getValue();
+       }
+
+       public int getRamSize() {
+               if (configuration == null
+                               || configuration.getDevice() == null
+                               || configuration.getDevice().getRAM() == null
+                               || configuration.getDevice().getRAM().getSize() == null) {
+                       return 512;
+               }
+               return configuration.getDevice().getRAM().getSize().getValue();
+       }
+
+       public int getMaxTouchPoint() {
+               if (configuration == null
+                               || configuration.getDevice() == null
+                               || configuration.getDevice().getTouch() == null) {
+                       return 10;
+               }
+               return configuration.getDevice().getTouch().getMaxTouchPoint();
+       }
+
+       public String getOciOptions() {
+               if (configuration == null
+                               || configuration.getOci() == null) {
+                       return null;
+               }
+
+               return configuration.getOci().getOciOptions();
+       }
+
+       public List<VMOption> getAdvancedOptionList() {
+               if (configuration == null
+                               || configuration.getAdvancedOption() == null) {
+                       return null;
+               }
+               optionList.clear();
+
+               // make advanced option list
+               for (OptionType option : configuration.getAdvancedOption().getOption()) {
+                       VMOption o = new VMOption(option.getName());
+                       o.setValue(option.getValue());
+
+                       for (SubOptionType sub : option.getSubOption()) {
+                               VMSubOption s = new VMSubOption(sub.getName(), sub.getValue());
+                               o.addSubOption(s);
+                       }
+                       optionList.add(o);
+               }
+
+               return optionList;
+       }
+
+       public OptionType getAdvancedOption(String optionName) {
+               for (OptionType option : configuration.getAdvancedOption().getOption()) {
+                       if (option.getName().equals(optionName)) {
+                               return option;
+                       }
+               }
+               return null;
+       }
+
+       public void settingVMPropertyValue(VMPropertyValue property) {
+               if (property == null) {
+                       return;
+               }
+
+//             String devicePath = getDeviceTemplatePath();
+//             if (devicePath != null) {
+//                     property.device = DeviceTemplateList.findDeviceTemplate(devicePath);
+//             }
+
+               int width = getDisplayWidth();
+               int height = getDisplayHeight();
+               for (RESOLUTION d : RESOLUTION.values()) {
+                       if (d.getWidth() == width
+                                       && d.getHeight() == height) {
+                               property.resolution = d;
+                               break;
+                       }
+               }
+               property.dpi = getDisplayDPI();
+//             property.screenSize = getDisplaySize();
+
+               if (property.resolution == null) {
+                       if (width != 0 && height != 0) {
+                               property.resolution = new RESOLUTION(width, height, "", property.dpi);
+                       } else {
+                               property.resolution = RESOLUTION.HD;
+                       }
+               }
+
+               property.skinPath = getSkinPath();
+
+               property.fileSharePath = getFileSharingPath();
+               if (property.fileSharePath != null) {
+                       property.isFileShareSupport = true;
+                       property.fileSharePathName = property.fileSharePath.substring
+                                                       (property.fileSharePath.lastIndexOf(File.separator) + 1,
+                                                       property.fileSharePath.length());
+               } else {
+                       property.fileSharePath = ""; //$NON-NLS-1$
+                       property.fileSharePathName = StringResources.None;
+               }
+
+               property.ramSize = getRamSize();
+               property.cpu = getCPUCount();
+               property.isHWVirtualization = supportHWVirtualization();
+               property.isGLAcceleration = supporGLAcceleration();
+               property.isSupportSuspend = supportSuspend();
+
+               property.maxTouchCount = getMaxTouchPoint();
+
+               // OCI
+               // TODO
+               if (property.ociDevice == null) {
+                       OCIList.getInstance();
+               }
+
+               property.ociOptions = getOciOptions();
+
+               // advanced option
+               property.advancedVMOptionList = getAdvancedOptionList();
+       }
+
+       public void settingEmulatorConfiguration(VMPropertyValue newVM) {
+               ObjectFactory factory = EmulatorVMList.getInstance().getObjectFactory();
+               configuration.setBaseInformation(factory.createBaseInformationType());
+               configuration.setUsability(factory.createUsabilityType());
+               configuration.setDevice(factory.createDeviceType());
+
+               configuration.getBaseInformation().setName(newVM.vmsName);
+               configuration.getBaseInformation().setArchitecture(newVM.baseImage.getCpu());
+               configuration.getBaseInformation().setPlatform(newVM.baseImage.getPlatformName());
+
+//             if (newVM.device != null) {
+//                     DeviceTemplateType device = new DeviceTemplateType();
+//                     device.setName(newVM.device.getValue().getName());
+//                     device.setVersion(newVM.device.getValue().getVersion());
+//                     device.setPath(newVM.device.getTemplateFile().getAbsolutePath());
+//                     configuration.getBaseInformation().setDeviceTemplate(device);
+//             }
+
+               configuration.getBaseInformation().setDiskImage(factory.createBaseInformationTypeDiskImage());
+               if (newVM.baseImage.isStandard()) {
+                       configuration.getBaseInformation().getDiskImage().setType("standard"); //$NON-NLS-1$
+               } else {
+                       configuration.getBaseInformation().getDiskImage().setType("custom"); //$NON-NLS-1$
+               }
+
+               if (newVM.baseImage.getVersion() != null) {
+                       configuration.getBaseInformation().getDiskImage().setVersion(newVM.baseImage.getVersion());
+               } else {
+                       configuration.getBaseInformation().getDiskImage().setVersion("Standard"); //$NON-NLS-1$
+               }
+               if (newVM.baseImage.getName() != null) {
+                       configuration.getBaseInformation().getDiskImage().setBase(newVM.baseImage.getName());
+               }
+
+               //
+               configuration.getBaseInformation().getDiskImage().setProfile(newVM.baseImage.getProfile());
+               configuration.getBaseInformation().getDiskImage().setBaseDiskImage(factory.createDiskImageFormatType());
+               configuration.getBaseInformation().getDiskImage().setCurrentDiskImage(factory.createDiskImageFormatType());
+               // TODO :
+               configuration.getBaseInformation().getDiskImage().getBaseDiskImage().setFormat("qcow2"); //$NON-NLS-1$
+               configuration.getBaseInformation().getDiskImage().getBaseDiskImage().setValue(newVM.baseImagePath);
+
+               if (!newVM.baseImage.getBinaryVersion().isEmpty()) {
+                       configuration.getBaseInformation().getDiskImage().getBaseDiskImage().setVersion(newVM.baseImage.getBinaryVersion());
+               }
+               configuration.getBaseInformation().getDiskImage().getCurrentDiskImage().setFormat("qcow2"); //$NON-NLS-1$
+               //ec.getBaseInformation().getDiskImage().getCurrentDiskImage().setValue(
+               //              folder.getAbsolutePath() + File.separator + "emulimg-" +  newVM.imageName + "." + Architecture.x86.toString());
+               configuration.getBaseInformation().getDiskImage().getCurrentDiskImage().setValue(newVM.childImagePath);
+
+               if (newVM.swapImagePath != null) {
+                       configuration.getBaseInformation().getDiskImage().setSwapDiskImage(factory.createDiskImageFormatType());
+                       configuration.getBaseInformation().getDiskImage().getSwapDiskImage().setFormat("qcow2"); //$NON-NLS-1$
+                       configuration.getBaseInformation().getDiskImage().getSwapDiskImage().setValue(newVM.swapImagePath);
+               }
+
+               configuration.getUsability().setLogging(factory.createUsabilityTypeLogging());
+               configuration.getUsability().getLogging().setLevel("NONE"); //$NON-NLS-1$
+               configuration.getUsability().setHwVirtualization(newVM.isHWVirtualization);
+                                                       /*&& CheckVirtualization.getInstance().isSupportVirtualization());*/
+               configuration.getUsability().setHwGLAcceleration(newVM.isGLAcceleration);
+               configuration.getUsability().setSupportSuspend(newVM.isSupportSuspend);
+
+               configuration.getUsability().setFileSharing(factory.createUsabilityTypeFileSharing());
+               if (!newVM.fileSharePath.isEmpty()) {
+                       configuration.getUsability().getFileSharing().setPath(newVM.fileSharePath);
+               }
+
+               configuration.getDevice().setDisplay(factory.createDisplayType());
+               configuration.getDevice().getDisplay().setResolution(factory.createDisplayTypeResolution());
+               configuration.getDevice().getDisplay().getResolution().setWidth(newVM.resolution.getWidth());
+               configuration.getDevice().getDisplay().getResolution().setHeight(newVM.resolution.getHeight());
+
+               configuration.getDevice().getDisplay().setDensity(factory.createDisplayTypeDensity());
+               configuration.getDevice().getDisplay().getDensity().setUnit("dpi"); //$NON-NLS-1$
+               configuration.getDevice().getDisplay().getDensity().setValue(newVM.dpi);
+
+//             if (newVM.screenSize > 0) {
+//                     configuration.getDevice().getDisplay().setScreenSize(factory.createDisplayTypeScreenSize());
+//                     configuration.getDevice().getDisplay().getScreenSize().setUnit("inch");
+//                     configuration.getDevice().getDisplay().getScreenSize().setValue(newVM.screenSize);
+//             }
+
+               configuration.getDevice().getDisplay().setSkinPath(factory.createDisplayTypeSkinPath());
+               if (newVM.skin != null) {
+                       configuration.getDevice().getDisplay().getSkinPath().setPath(newVM.skin.getPath());
+               } else if (newVM.skinPath != null) {
+                       configuration.getDevice().getDisplay().getSkinPath().setPath(newVM.skinPath);
+               }
+
+               ////// CPU //////
+               configuration.getDevice().setCPU(factory.createCpuType());
+               configuration.getDevice().getCPU().setValue(factory.createCpuTypeValue());
+               configuration.getDevice().getCPU().getValue().setUnit("cpu"); //$NON-NLS-1$
+               if (newVM.cpu == 0) {
+                       int max = CPU.getMaxCpuNum();
+                       newVM.cpu = max > 4 ? 4 : max;
+               }
+               configuration.getDevice().getCPU().getValue().setValue(newVM.cpu);
+
+
+               configuration.getDevice().setRAM(factory.createRamType());
+               configuration.getDevice().getRAM().setSize(factory.createRamTypeSize());
+               configuration.getDevice().getRAM().getSize().setUnit("MiB"); //$NON-NLS-1$
+               configuration.getDevice().getRAM().getSize().setValue(newVM.ramSize);
+
+               if (newVM.maxTouchCount >= 0) {
+                       configuration.getDevice().setTouch(factory.createTouchType());
+                       configuration.getDevice().getTouch().setMaxTouchPoint(newVM.maxTouchCount);
+               }
+
+               if (newVM.addOptions != null) {
+                       configuration.getUsability().setAdvancedOptions(newVM.addOptions);
+               }
+
+               if(newVM.ociOptions != null) {
+               //////OCI DEVICE//////
+                       configuration.setOci(factory.createOciType());
+                       configuration.getOci().setOciOptions(newVM.ociOptions);
+               }
+
+//             // extended option
+//             if (newVM.extendedOptions != null) {
+//                     configuration.getExtendedOption().addAll(newVM.extendedOptions);
+//             }
+
+               // advanced option
+               if (newVM.advancedVMOptionList.size() > 0) {
+                       if (configuration.getAdvancedOption() == null) {
+                               configuration.setAdvancedOption(factory.createAdvancedOptionType());
+                       } else {
+                               configuration.getAdvancedOption().getOption().clear();
+                       }
+                       for (VMOption option : newVM.advancedVMOptionList) {
+                               OptionType type = new OptionType();
+                               type.setName(option.getName());
+                               type.setValue(option.getValue());
+
+                               for (VMSubOption subOption : option.getSubOptionList()) {
+                                       SubOptionType subType = new SubOptionType();
+                                       subType.setName(subOption.getName());
+                                       subType.setValue(subOption.getValue());
+                                       type.getSubOption().add(subType);
+                               }
+                               configuration.getAdvancedOption().getOption().add(type);
+                       }
+               }
+
+       }
+}
index 2c6ec03..60bdfc1 100644 (file)
@@ -39,11 +39,7 @@ import org.tizen.emulator.manager.logging.EMLogger;
 import org.tizen.emulator.manager.platform.BaseImage;
 import org.tizen.emulator.manager.platform.Skin;
 import org.tizen.emulator.manager.resources.StringResources;
-import org.tizen.emulator.manager.vms.xml.DisplayType.Resolution;
-import org.tizen.emulator.manager.vms.xml.ExtendedOptionType;
 import org.tizen.emulator.manager.vms.xml.OptionType;
-import org.tizen.emulator.manager.vms.xml.SubOptionType;
-import org.tizen.emulator.manager.vms.xml.TouchType;
 
 
 // Wrapper for convenient property managing...
@@ -53,6 +49,9 @@ public class VMPropertyValue implements Cloneable {
        public String vmsName = ""; //$NON-NLS-1$
 
        public String baseImagePath;
+       // for create emulator
+       public String childImagePath;
+       public String swapImagePath;
 
 //     public RESOLUTION resolution = RESOLUTION.HD;
        public RESOLUTION resolution;
@@ -79,9 +78,12 @@ public class VMPropertyValue implements Cloneable {
 
        public boolean isSupportSuspend;
 
-       public List<ExtendedOptionType> extendedOptions = new ArrayList<ExtendedOptionType>();
+       public List<VMOption> advancedVMOptionList = new ArrayList<VMOption>();
 
-       public List<OptionType> advancedOptionList = new ArrayList<OptionType>(); // Advanced option list.
+       // using extended option ???
+       //public List<ExtendedOptionType> extendedOptions = new ArrayList<ExtendedOptionType>();
+
+       //public List<OptionType> advancedOptionList = new ArrayList<OptionType>(); // Advanced option list.
 
        private VMPropertyValue(){} // for clone
 
@@ -125,8 +127,7 @@ public class VMPropertyValue implements Cloneable {
                        this.template = property;
 
                        vmsName         = property.getName();
-                       baseImagePath = property.getConfiguration().getBaseInformation().getDiskImage()
-                                               .getBaseDiskImage().getValue();
+                       baseImagePath = property.getBaseImagePath();
 
 
                        settingConfigure(property);
@@ -201,26 +202,27 @@ public class VMPropertyValue implements Cloneable {
 
                dest.isSupportSuspend = this.isSupportSuspend;
 
-               dest.extendedOptions = new ArrayList<ExtendedOptionType>();
-               dest.extendedOptions.addAll(this.extendedOptions);
+//             dest.extendedOptions = new ArrayList<ExtendedOptionType>();
+//             dest.extendedOptions.addAll(this.extendedOptions);
 
-               cloneAdvancedOptions(dest.advancedOptionList);
+               cloneAdvancedOptions(dest.advancedVMOptionList);
 
                return dest;
        }
 
-       private void cloneAdvancedOptions(List<OptionType> targetList) {
-               for (OptionType src : advancedOptionList) {
-                       OptionType option = EmulatorVMList.getInstance().getObjectFactory().createOptionType();
+       private void cloneAdvancedOptions(List<VMOption> targetList) {
+               for (VMOption src : advancedVMOptionList) {
+                       VMOption option = new VMOption();
                        option.setName(src.getName());
                        option.setValue(src.getValue());
 
-                       for (SubOptionType srcSub : src.getSubOption()) {
-                               SubOptionType subOption = EmulatorVMList.getInstance().getObjectFactory().createSubOptionType();
+                       for (VMSubOption srcSub : src.getSubOptionList()) {
+                               VMSubOption subOption = new VMSubOption();
                                subOption.setName(srcSub.getName());
                                subOption.setValue(srcSub.getValue());
-                               option.getSubOption().add(subOption);
+                               option.addSubOption(subOption);
                        }
+
                        targetList.add(option);
                }
        }
@@ -318,11 +320,11 @@ public class VMPropertyValue implements Cloneable {
                        return false;
                }
 
-               if (!isExtendedOptionEquals(this.extendedOptions, dest.extendedOptions)) {
-                       return false;
-               }
+//             if (!isExtendedOptionEquals(this.extendedOptions, dest.extendedOptions)) {
+//             return false;
+//     }
 
-               if (!isAdvancedOptionEquals(dest.advancedOptionList)) {
+               if (!isAdvancedOptionEquals(dest.advancedVMOptionList)) {
                        return false;
                }
                return true;
@@ -333,83 +335,7 @@ public class VMPropertyValue implements Cloneable {
                        return;
                }
 
-               Resolution re = null;
-               for (RESOLUTION d : RESOLUTION.values()) {
-                       re = property.getConfiguration().getDevice().getDisplay().getResolution();
-                       if (d.getWidth() == re.getWidth()
-                                       && d.getHeight() == re.getHeight()) {
-                               resolution = d;
-                               break;
-                       }
-               }
-
-               dpi = property.getConfiguration().getDevice().getDisplay().getDensity().getValue();
-
-               if (resolution == null) {
-                       if (re != null) {
-                               resolution = new RESOLUTION(re.getWidth(), re.getHeight(), "", //$NON-NLS-1$
-                                       dpi);
-                       } else {
-                               // set default resolution
-                               resolution = RESOLUTION.HD;
-                       }
-               }
-
-
-               if (property.getConfiguration().getDevice().getDisplay().getSkinPath() != null) {
-                       skinPath = property.getConfiguration().getDevice().getDisplay().getSkinPath().getPath();
-               }
-
-               fileSharePath = property.getConfiguration().getUsability().getFileSharing().getPath();
-               if (fileSharePath  != null) {
-                       isFileShareSupport = true;
-                       fileSharePathName = fileSharePath.substring
-                                       (fileSharePath.lastIndexOf(File.separator) + 1, fileSharePath.length());
-               } else {
-                       fileSharePath = ""; //$NON-NLS-1$
-                       fileSharePathName = StringResources.None;
-               }
-
-               ramSize = property.getConfiguration().getDevice().getRAM().getSize().getValue();
-
-               /////// CPU TEST //////
-
-               if (property.getConfiguration().getDevice().getCPU() != null) {
-                       cpu = property.getConfiguration().getDevice().getCPU().getValue().getValue();
-               }
-
-               isHWVirtualization = property.getConfiguration().getUsability().isHwVirtualization();
-               isGLAcceleration = property.getConfiguration().getUsability().isHwGLAcceleration();
-
-               TouchType touchType = property.getConfiguration().getDevice().getTouch();
-               if (touchType != null) {
-                       maxTouchCount = touchType.getMaxTouchPoint();
-               } else {
-                       maxTouchCount = 0;
-               }
-
-               addOptions = property.getConfiguration().getUsability().getAdvancedOptions();
-
-               /////OCI TEST////
-
-               if(ociDevice == null) {
-                       OCIList.getInstance();
-               }
-               if (property.getConfiguration().getOci() != null) {
-                       ociOptions = property.getConfiguration().getOci().getOciOptions();
-               }
-
-               // TODO
-               isSupportSuspend = property.getConfiguration().getUsability().isSupportSuspend();
-
-               extendedOptions = new ArrayList<ExtendedOptionType>();
-               extendedOptions.addAll(property.getConfiguration().getExtendedOption());
-
-               if (property.getConfiguration().getAdvancedOption() != null) {
-                       advancedOptionList.clear();
-                       advancedOptionList.addAll(property.getConfiguration().getAdvancedOption().getOption());
-               }
-
+               property.getVMConfiguration().settingVMPropertyValue(this);
        }
 
        private void settingSkin() {
@@ -434,8 +360,14 @@ public class VMPropertyValue implements Cloneable {
                }
        }
 
+       // for plug-in -> will be deleted
+       @ Deprecated
        public OptionType getAdvancedOption(String optionName) {
-               for (OptionType option : advancedOptionList) {
+               return template.getVMConfiguration().getAdvancedOption(optionName);
+       }
+
+       public VMOption getVMAdvancedOption(String optionName) {
+               for (VMOption option : advancedVMOptionList) {
                        if (option.getName().equals(optionName)) {
                                return option;
                        }
@@ -444,7 +376,7 @@ public class VMPropertyValue implements Cloneable {
        }
 
        public String getAdvancedOptionValue(String optionName) {
-               for (OptionType option : advancedOptionList) {
+               for (VMOption option : advancedVMOptionList) {
                        if (option.getName().equals(optionName)) {
                                return option.getValue();
                        }
@@ -453,48 +385,39 @@ public class VMPropertyValue implements Cloneable {
        }
 
        public void setAdvancedOption(String name, String value) {
-               OptionType old = getAdvancedOption(name);
+               VMOption old = getVMAdvancedOption(name);
                if (old != null) {
-                       advancedOptionList.remove(old);
+                       advancedVMOptionList.remove(old);
                }
-               OptionType option = EmulatorVMList.getInstance().getObjectFactory().createOptionType();
-               option.setName(name);
+
+               VMOption option = new VMOption(name);
                option.setValue(value);
-               advancedOptionList.add(option);
+               advancedVMOptionList.add(option);
        }
 
        public void setAdvancedOptionSub(String name, String subName, String value) {
-               OptionType option = getAdvancedOption(name);
+               VMOption option = getVMAdvancedOption(name);
                if (option == null) {
-                       option = EmulatorVMList.getInstance().getObjectFactory().createOptionType();
-                       option.setName(name);
-                       advancedOptionList.add(option);
-               }
-//             SubOptionType subOption = getAdvancedOptionSub(option, subName);
-//             if (subOption != null) {
-//                      option.getSubOption().remove(subOption);
-//             }
-//
-//             subOption = EmulatorVMList.getInstance().getObjectFactory().createSubOptionType();
-//             subOption.setName(subName);
-//             subOption.setValue(value);
-//             option.getSubOption().add(subOption);
-               SubOptionType OldOption = getAdvancedOptionSub(option, subName);
-               if (OldOption != null) {
-                        option.getSubOption().remove(OldOption);
-               }
-               SubOptionType subOption = EmulatorVMList.getInstance().getObjectFactory().createSubOptionType();
-               subOption.setName(subName);
-               subOption.setValue(value);
-               option.getSubOption().add(subOption);
+                       option = new VMOption(name);
+                       option.setValue(value);
+                       advancedVMOptionList.add(option);
+               }
+
+               VMSubOption oldOption = getAdvancedOptionSub(option, subName);
+               if (oldOption != null) {
+                        option.getSubOptionList().remove(oldOption);
+               }
+               VMSubOption subOption = new VMSubOption(subName, value);
+               option.addSubOption(subOption);
        }
 
        public String getAdvancedOptionSubValue(String name, String subName) {
-               OptionType option = getAdvancedOption(name);
+               VMOption option = getVMAdvancedOption(name);
                if (option == null) {
                        return ""; //$NON-NLS-1$
                }
-               SubOptionType subOption = getAdvancedOptionSub(option, subName);
+
+               VMSubOption subOption = getAdvancedOptionSub(option, subName);
                if (subOption == null) {
                        return ""; //$NON-NLS-1$
                } else {
@@ -502,12 +425,12 @@ public class VMPropertyValue implements Cloneable {
                }
        }
 
-       private SubOptionType getAdvancedOptionSub(OptionType option, String subName){
-               List<SubOptionType> subOptionList = option.getSubOption();
+       private VMSubOption getAdvancedOptionSub(VMOption option, String subName){
+               List<VMSubOption> subOptionList = option.getSubOptionList();
                if (subOptionList == null) {
                        return null;
                }
-               for (SubOptionType type : subOptionList) {
+               for (VMSubOption type : subOptionList) {
                        if (type.getName().equals(subName)) {
                                return type;
                        }
@@ -515,81 +438,15 @@ public class VMPropertyValue implements Cloneable {
                return null;
        }
 
-       private ExtendedOptionType getExtendedOption(String optionName) {
-               for(ExtendedOptionType option : extendedOptions) {
-                       if (option.getName().equals(optionName)) {
-                               return option;
-                       }
-               }
-               return null;
-       }
-
-       public String getExtendedOptionVal(String optionName) {
-               for(ExtendedOptionType option : extendedOptions) {
-                       if (option.getName().equals(optionName)) {
-                               return option.getValue();
-                       }
-               }
-               return ""; //$NON-NLS-1$
-       }
-
-       public void setExtendedOption(String name, String value) {
-               ExtendedOptionType old = getExtendedOption(name);
-               if (getExtendedOption(name) != null) {
-                       extendedOptions.remove(old);
-               }
-
-               ExtendedOptionType type = EmulatorVMList.getInstance().getObjectFactory().createExtendedOptionType();
-               type.setName(name);
-               type.setValue(value);
-               extendedOptions.add(type);
-       }
-
-
-       private boolean isExtendedOptionEquals(List<ExtendedOptionType> srcList, List<ExtendedOptionType> destList) {
-               if (srcList == null){
-                       if (destList == null) {
-                               return true;
-                       } else {
-                               return false;
-                       }
-               } else {
-                       if (destList == null) {
-                               return false;
-                       } else {
-                               // Check if size is same.
-                               if(srcList.size() != destList.size()) {
-                                       return false;
-                               } else {
-                                       // Check if "name" & "value" is same.
-                                       for (ExtendedOptionType src : srcList) {
-                                               boolean equals = false;
-                                               for (ExtendedOptionType dest : destList) {
-                                                       if (src.getName().equals(dest.getName()) &&
-                                                                       src.getValue().equals(dest.getValue()) ) {
-                                                               equals = true;
-                                                               break;
-                                                       }
-                                               }
-                                               if (!equals) {
-                                                       return false;
-                                               }
-                                       }
-                                       return true;
-                               }
-                       }
-               }
-       }
-
-       public boolean isAdvancedOptionEquals(List<OptionType> destList) {
+       public boolean isAdvancedOptionEquals(List<VMOption> destList) {
                // Check size.
-               if(advancedOptionList.size() != destList.size()) {
+               if(advancedVMOptionList.size() != destList.size()) {
                        return false;
                } else {
                        // Check each option in both list.
-                       for (OptionType src : advancedOptionList) {
+                       for (VMOption src : advancedVMOptionList) {
                                boolean equals = false;
-                               for (OptionType dest : destList) {
+                               for (VMOption dest : destList) {
                                        if (isOptionEquals(src, dest)) {
                                                equals = true;
                                                break;
@@ -603,7 +460,7 @@ public class VMPropertyValue implements Cloneable {
                }
        }
 
-       private boolean isOptionEquals(OptionType src, OptionType dest) {
+       private boolean isOptionEquals(VMOption src, VMOption dest) {
                // Check name. Name is always not null.
                if (!src.getName().equals(dest.getName())) {
                        return false;
@@ -623,8 +480,8 @@ public class VMPropertyValue implements Cloneable {
                        }
                }
                // Check sub-options.
-               List<SubOptionType> srcList = src.getSubOption();
-               List<SubOptionType> destList = dest.getSubOption();
+               List<VMSubOption> srcList = src.getSubOptionList();
+               List<VMSubOption> destList = dest.getSubOptionList();
                if (srcList == null) {
                        if (destList == null) {
                                return true;
@@ -638,9 +495,9 @@ public class VMPropertyValue implements Cloneable {
                                if (srcList.size() != destList.size()) {
                                        return false;
                                }
-                               for (SubOptionType srcSubOpt : srcList) {
+                               for (VMSubOption srcSubOpt : srcList) {
                                        boolean isEquals = false;
-                                       for (SubOptionType destSubOpt : destList) {
+                                       for (VMSubOption destSubOpt : destList) {
                                                if (isSubOptionEquals(srcSubOpt, destSubOpt)) {
                                                        isEquals = true;
                                                        break;
@@ -655,7 +512,7 @@ public class VMPropertyValue implements Cloneable {
                }
        }
 
-       private boolean isSubOptionEquals(SubOptionType src, SubOptionType dest){
+       private boolean isSubOptionEquals(VMSubOption src, VMSubOption dest){
                // Check name. Name always not null.
                if (!src.getName().equals(dest.getName())) {
                        return false;
diff --git a/src/org/tizen/emulator/manager/vms/VMSubOption.java b/src/org/tizen/emulator/manager/vms/VMSubOption.java
new file mode 100644 (file)
index 0000000..36780e5
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * JiHye Kim <jihye424.kim@samsung.com>
+ * Minkee Lee <minkee.lee@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Sangho Park <sangho.p@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.emulator.manager.vms;
+
+
+public class VMSubOption {
+       private String name = "";
+       private String value = "";
+
+       public VMSubOption() {
+
+       }
+
+       public VMSubOption(String name) {
+               this.setName(name);
+       }
+
+       public VMSubOption(String name, String value) {
+               this.name = name;
+               this.value = value;
+       }
+
+       public String getName() {
+               return name;
+       }
+
+       public void setName(String name) {
+               this.name = name;
+       }
+
+       public String getValue() {
+               return value;
+       }
+
+       public void setValue(String value) {
+               this.value = value;
+       }
+}