From 3e55da1a4f156cd8c3376f105f413ccd363f8aec Mon Sep 17 00:00:00 2001 From: "jihye424.kim" Date: Sat, 13 Feb 2016 16:53:08 +0900 Subject: [PATCH] CLI: add platform and device option to 'create' - remove base image option Change-Id: I16f9145159caf9dc5a485914680d900ff0e7660c Signed-off-by: jihye424.kim --- resource/strings/climessages.properties | 49 +- src/org/tizen/emulator/manager/console/Action.java | 6 +- .../tizen/emulator/manager/console/ActionList.java | 41 +- .../emulator/manager/console/CheckVMOption.java | 193 +++++++ .../emulator/manager/console/ConsoleCreateVM.java | 626 +++++---------------- .../emulator/manager/console/ConsoleModifyVM.java | 9 +- .../manager/devices/DeviceTemplateList.java | 39 ++ .../manager/platform/StandardPlatform.java | 8 +- 8 files changed, 418 insertions(+), 553 deletions(-) create mode 100644 src/org/tizen/emulator/manager/console/CheckVMOption.java diff --git a/resource/strings/climessages.properties b/resource/strings/climessages.properties index 0ce4a35..9671378 100644 --- a/resource/strings/climessages.properties +++ b/resource/strings/climessages.properties @@ -1,6 +1,6 @@ Action.AddOptionHelp=Add other qemu's options. -Action.BaseImageIDHelp.0=Select ID of base disk image. -Action.BaseImageIDHelp.1=\t\t(Available disk image can be found using 'list-image' command) +Action.DeviceHelp.0=Select device template. +Action.DeviceHelp.1=\t\t(Available device template can be found using 'list-device' command) Action.BaseImageIDHelp.2=Select path of base target image. Action.CompressImage=Create compressed image. Action.CountHelp=Display count of VM list (only display number). @@ -13,7 +13,7 @@ Action.DetailHelp.2=\t\t\tIf you do not enter a name, emulator manager's informa Action.DPIHelp=DPI. (100 ~ 480) Action.ExportAsPath=Setting Location to generate base target image. Action.ExportName=Name of VM to create base target image. -Action.FileShareHelp=File sharing path. If path is "", file sharing is disabled +Action.FileShareHelp=File sharing path. If path is "", file sharing is disabled. Action.GPIHelp=Select enable or disable hardware GL acceleration.(yes | no) Action.Help=Display information of specific command. Action.LaunchName=Name of VM to start. @@ -21,7 +21,7 @@ Action.LaunchPath=Setting path of emulator program. Action.Name=Name of new VM. Action.NameMod=Name of VM. Action.PlatformHelp.0=Select Platform of base disk image. -Action.PlatformHelp.1=\t\t(Available disk image can be found using 'list-image' command) +Action.PlatformHelp.1=\t\t(Available platform can be found using 'list-platform' command) Action.ProfileHelp.0=Select profile Action.DetailPlatformHelp.0=Display more information of platform Action.RAMSizenDescription.0=RAM size. ( @@ -44,12 +44,13 @@ ActionList.Clone.1=clone -n test -t target ActionList.CloneBaseNameOption=Name of VM to create base target image. ActionList.CloneTargetNameOption=Input new VM's name. ActionList.Create.0=Create new 'Virtual Machine'. -ActionList.Create.1=Standard Image: create -n test -b 1 [options] +ActionList.Create.1=Standard Image: create -n test [options] ActionList.Create.2=\tStandard Image: create -n test -p mobile-2.4 [options] -ActionList.Create.3=\tStandard Image: create -n test -b 1 -p mobile-2.4 [options] +ActionList.Create.3=\tStandard Image: create -n test -p mobile-2.4 -d HD-Mobile [options] ActionList.Create.4=\tCustom Image: create -n test -c path [options] -ActionList.Create.5=\tCustom Image: create -n test -c path [options] -p mobile-2.4 -ActionList.Create.6=\tYou can not use both '-b' and '-c' at the same time. +ActionList.Create.5=\tCustom Image: create -n test -c path -p mobile-2.4 [options] +ActionList.Create.6=\tCustom Image: create -n test -c path -p mobile-2.4 -d HD-Mobile [options] +ActionList.Create.7=\tIf SDK has one or more platforms, you have to choose one platform. ActionList.CreateOptionError.0=Error: Option of 'create' is allowed only one of two.(--base or --path) ActionList.CreateOptionError.1=Error: One of '--base' and '--path' should come as option of 'create' ActionList.Delete.0=Delete selected VM. @@ -73,7 +74,7 @@ ActionList.RAMSizeOption=RAM size. ActionList.RemoteClone.0=Create new remote VM which has the same configurations as you selected.. ActionList.RemoteClone.1=remote-clone -n test -t target -e IP -u account [options] ActionList.RemoteCreate.0=Create new 'Remote Virtual Machine'. -ActionList.RemoteCreate.1=Standard Image: remote-create -e IP -u account -n test -b 1 [options] +ActionList.RemoteCreate.1=\tStandard Image: remote-create -e IP -u account -n test -b 1 [options] ActionList.RemoteCreate.2=\tStandard Image: remote-create -e IP -u account -n test -p mobile-2.4 [options] ActionList.RemoteCreate.3=\tStandard Image: remote-create -e IP -u account -n test -b 1 -p mobile-2.4 [options] ActionList.RemoteCreate.4=\tCustom Image: remote-create -e IP -u account -n test -c path [options] @@ -115,15 +116,11 @@ CommandLineParser.GOpitonError.0GOpitonError.3=) is not global options. CommandLineParser.GOpitonError.1=) is not a valid global option. CommandLineParser.GOpitonError.2=This ( CommandLineParser.GOpitonError.4=Please check global options. -ConsoleCreateVM.ARMImageInfo.0=If base disk image is arm, 'GLAcceleration' value is always false. -ConsoleCreateVM.ARMImageInfo.1=So this value set false. -ConsoleCreateVM.ARMImageInfo.2=If base disk image is arm, 'HWVirtualization' value is always false. -ConsoleCreateVM.ARMImageInfo.3=So this value set false. -ConsoleCreateVM.BaseImageError.0=Path of base disk image is empty. +ConsoleCreateVM.BaseImageError.0=Path of platform image is empty. ConsoleCreateVM.BaseImageError.1=This directory does not exist. (Path : -ConsoleCreateVM.BaseImageError.2=This base image not ready yet. +ConsoleCreateVM.BaseImageError.2=This platform image not ready yet. ConsoleCreateVM.BaseImageError.3=Please select again in a few seconds. -ConsoleCreateVM.BaseImageError.4=Path of base image has problem : +ConsoleCreateVM.BaseImageError.4=Path of platform image has problem : ConsoleCreateVM.DPIError.0=DPI value ( ConsoleCreateVM.DPIError.1=) is not available. ConsoleCreateVM.FailedCreate.0=It is failed to create new Virtual Machine. @@ -131,22 +128,16 @@ ConsoleCreateVM.FileShareError.0=Path is empty. ConsoleCreateVM.FileShareError.1=This directory does not exist. (Path : ConsoleCreateVM.GPUInfo.0=This computer does not support GPU. ConsoleCreateVM.GPUValue.0=Please, check your input ( -ConsoleCreateVM.GPUValue.2=Available value is true or false. -ConsoleCreateVM.ImageError.0=Base image file format is not available. -ConsoleCreateVM.ImageIDError.0=Entered base image id's platform does not match Entered platform name. -ConsoleCreateVM.ImageIDError.1=Base Image ID Platform: -ConsoleCreateVM.ImageIDError.2=, Input platform: -ConsoleCreateVM.ImageIDError.3=The ID ( -ConsoleCreateVM.ImageIDError.4=) is not available. +ConsoleCreateVM.GPUValue.2=Available value is yes or no. +ConsoleCreateVM.DeviceError.0=Entered device name is not available. ConsoleCreateVM.OptionError.0=Error: Option of 'create' is allowed only one of there. ConsoleCreateVM.OptionError.1=--base-id or --platform or (--base-id and --platform) or --custom-path or (--custom-path and --platform) ConsoleCreateVM.OptionError.2=Error: One of --base-id or --platform or (--base-id and --platform) or --custom-path or (--custom-path and --platform) ConsoleCreateVM.OptionError.3=\ should come as option of 'create' ConsoleCreateVM.PlatformError.0=The Platform ( ConsoleCreateVM.PlatformError.1=) is not available. -ConsoleCreateVM.PlatformError.2=There not available custom platform. -ConsoleCreateVM.PlatformError.3=Entered platform name does not match Entered base image id's platform. -ConsoleCreateVM.PlatformError.4=Can not found matching platform +ConsoleCreateVM.PlatformError.2=You have to choose one platform. +ConsoleCreateVM.PlatformError.3= Failed to create custom platform. ConsoleCreateVM.ProfileError.0=There not available profile. ConsoleCreateVM.RAMSizeError.0=This RAM size ( ConsoleCreateVM.RAMSizeError.1=) is not available. @@ -155,8 +146,8 @@ ConsoleCreateVM.ResolutionError.1=) is not available. ConsoleCreateVM.ResolutionInfo.0=Because You change resolution, skin path change follow resolution. ConsoleCreateVM.SkinError.0=Skin value ( ConsoleCreateVM.SkinError.1=) is not available. -ConsoleCreateVM.SkinError.2=Profile specific skin is not available with this resolution. -ConsoleCreateVM.SkinError.3=> General skin is used. +ConsoleCreateVM.SkinError.2=Selected skin type is not available with this resolution. +ConsoleCreateVM.SkinError.3=> Default skin will be used. ConsoleCreateVM.SuccessCreate.0=Success: To create new Virtual Machine is completed. ConsoleCreateVM.TouchPointError.0=is not available. Available multi-touch point is 1 - 10. ConsoleCreateVM.VMNameError.0=Max length of virtual target name is @@ -167,7 +158,7 @@ ConsoleCreateVM.VMNameError.4=) already exists\! ConsoleCreateVM.VMNameError.5=The name is empty. Please enter the name of VM. ConsoleCreateVM.VTInfo.0=This computer does not support hardware virtualization. ConsoleCreateVM.VTValue.0=Please, check your input ( -ConsoleCreateVM.VTValue.1=Available value is true or false. +ConsoleCreateVM.VTValue.1=Available value is yes or no. ConsoleModifyVM.ModfiySuccess.0=Success: To modify Virtual Machine is completed. ConsoleModifyVM.ModifyError.0=Error: It is failed to modify Virtual Machine. ConsoleModifyVM.NameError.0=This name( diff --git a/src/org/tizen/emulator/manager/console/Action.java b/src/org/tizen/emulator/manager/console/Action.java index 616735c..1dee56f 100644 --- a/src/org/tizen/emulator/manager/console/Action.java +++ b/src/org/tizen/emulator/manager/console/Action.java @@ -279,7 +279,7 @@ class Actions { public final static String OP_DETAIL = "detail"; //$NON-NLS-1$ public final static String OP_PATH = "custom-path"; //$NON-NLS-1$ public final static String OP_PLATFORM = "platform"; //$NON-NLS-1$ - public final static String OP_BASE = "base-id"; //$NON-NLS-1$ + public final static String OP_DEVICE = "device"; //$NON-NLS-1$ public final static String OP_TARGET = "target-name"; //$NON-NLS-1$ public final static String OP_TEST = "test"; //$NON-NLS-1$ public final static String OP_COUNT = "count"; //$NON-NLS-1$ @@ -314,9 +314,9 @@ class Actions { public final static String DESC_DELETE_NAME = Messages.getString("Action.DeleteName"); //$NON-NLS-1$ public final static String DESC_RESET_NAME = Messages.getString("Action.ResetName"); //$NON-NLS-1$ public final static String DESC_EXPORT_NAME = Messages.getString("Action.ExportName"); //$NON-NLS-1$ - public final static String DESC_BASE = Messages.getString("Action.BaseImageIDHelp.0") //$NON-NLS-1$ + public final static String DESC_DEVICE = Messages.getString("Action.DeviceHelp.0") //$NON-NLS-1$ + StringResources.NEW_LINE - + Messages.getString("Action.BaseImageIDHelp.1"); //$NON-NLS-1$ + + Messages.getString("Action.DeviceHelp.1"); //$NON-NLS-1$ public final static String DESC_COMPRESS_IMAGE = Messages.getString("Action.CompressImage"); public final static String DESC_PATH = Messages.getString("Action.BaseImageIDHelp.2"); //$NON-NLS-1$ public final static String DESC_LAUNCH_PATH = Messages.getString("Action.LaunchPath"); //$NON-NLS-1$ diff --git a/src/org/tizen/emulator/manager/console/ActionList.java b/src/org/tizen/emulator/manager/console/ActionList.java index 7cc785c..dbc1421 100644 --- a/src/org/tizen/emulator/manager/console/ActionList.java +++ b/src/org/tizen/emulator/manager/console/ActionList.java @@ -77,6 +77,7 @@ public class ActionList { //addAction(new RemoteClone()); addAction(new RemoteReset()); addAction(new RemoteCreateBaseImage()); + } public Action getGlobalAction() { @@ -407,46 +408,22 @@ class Create extends Action { Messages.getString("ActionList.Create.3") + StringResources.NEW_LINE + //$NON-NLS-1$ Messages.getString("ActionList.Create.4") + StringResources.NEW_LINE + //$NON-NLS-1$ Messages.getString("ActionList.Create.5") + StringResources.NEW_LINE + //$NON-NLS-1$ - Messages.getString("ActionList.Create.6"); //$NON-NLS-1$ + Messages.getString("ActionList.Create.6") + StringResources.NEW_LINE + //$NON-NLS-1$ + Messages.getString("ActionList.Create.7"); //$NON-NLS-1$ commandList.add(new Command("n", Actions.OP_NAME, //$NON-NLS-1$ Actions.DESC_NAME, "", true, true)); //$NON-NLS-1$ - // b : standard image - // p : custom image - commandList.add(new Command("b", Actions.OP_BASE, //$NON-NLS-1$ - Actions.DESC_BASE, Actions.DEFAULT_BASE, false, true)); commandList.add(new Command("c", Actions.OP_PATH, //$NON-NLS-1$ Actions.DESC_PATH, "", false, true)); //$NON-NLS-1$ commandList.add(new Command("p", Actions.OP_PLATFORM, //$NON-NLS-1$ - Actions.DESC_PLATFORM, - "", false, true)); //$NON-NLS-1$ + Actions.DESC_PLATFORM, "", false, true)); //$NON-NLS-1$ + commandList.add(new Command("d", Actions.OP_DEVICE, //$NON-NLS-1$ + Actions.DESC_DEVICE, "", false, true)); // Options - commandList.add(new Command("r", Actions.OP_RESOLUTION, //$NON-NLS-1$ - Actions.DESC_RESOLUTION - , RESOLUTION.HD.getType(), false, true)); - - /** TODO: support dpi option, make resolution and skin list..*******************/ - /* - commandList.add(new Command("d", Actions.OP_DPI, //$NON-NLS-1$ - Actions.DESC_DPI, Integer.toString(RESOLUTION.HD.getDPI()), false, true)); - - ArrayList skinList = SkinList.getInstance().findSkinList(RESOLUTION.HD); - String skinType = ""; - int i = 1; - for (Skin skin : skinList) { - skinType += i++ + " - " + skin.getName() + " | "; - } - if (skinType.length() > 3) { - skinType = skinType.substring(0, skinType.length() - 3); - } - */ - /********************************************************************************/ - commandList.add(new Command("k", Actions.OP_SKIN, //$NON-NLS-1$ Actions.DESC_SKIN, Actions.DEFAULT_SKIN, false, true)); - commandList.add(new Command("s", Actions.OP_RAM, //$NON-NLS-1$ Actions.DESC_RAM, RAM_SIZE.RAM512.toString(), false, true)); commandList.add(new Command("f", Actions.OP_FILESHAREPATH, //$NON-NLS-1$ @@ -457,8 +434,6 @@ class Create extends Action { commandList.add(new Command("g", Actions.OP_GLACCELERATION, //$NON-NLS-1$ Actions.DESC_GLACCELERATION, CheckGPU.isGPUSupported() ? "yes" : "no", false, true)); //$NON-NLS-1$ //$NON-NLS-2$ - commandList.add(new AddOptions("a", Actions.OP_ADDOPTION, //$NON-NLS-1$ - Actions.DESC_ADDOPTION, "", false, true)); //$NON-NLS-1$ } @Override @@ -483,8 +458,8 @@ class RemoteCreate extends Action { // b : standard image // p : custom image - commandList.add(new Command("b", Actions.OP_BASE, //$NON-NLS-1$ - Actions.DESC_BASE, "", false, true)); //$NON-NLS-1$ + commandList.add(new Command("d", Actions.OP_DEVICE, //$NON-NLS-1$ + Actions.DESC_DEVICE, "", false, true)); //$NON-NLS-1$ commandList.add(new Command("p", Actions.OP_PATH, //$NON-NLS-1$ Actions.DESC_PATH, "", false, true)); //$NON-NLS-1$ commandList.add(new Command("u", Actions.OP_USER_ACCOUNT, //$NON-NLS-1$ diff --git a/src/org/tizen/emulator/manager/console/CheckVMOption.java b/src/org/tizen/emulator/manager/console/CheckVMOption.java new file mode 100644 index 0000000..3429f92 --- /dev/null +++ b/src/org/tizen/emulator/manager/console/CheckVMOption.java @@ -0,0 +1,193 @@ +/* + * Emulator Manager + * + * Copyright (C) 2016 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * JiHye Kim + * Minkee Lee + * SeokYeon Hwang + * Sangho Park + * + * 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.console; + +import java.io.File; +import java.util.List; + +import org.tizen.emulator.manager.job.CheckGPU; +import org.tizen.emulator.manager.job.CheckVT; +import org.tizen.emulator.manager.platform.Skin; +import org.tizen.emulator.manager.resources.StringResources; +import org.tizen.emulator.manager.vms.RAM_SIZE; +import org.tizen.emulator.manager.vms.SKIN_TYPE; +import org.tizen.emulator.manager.vms.VMProperty; +import org.tizen.emulator.manager.vms.VMPropertyValue; +import org.tizen.emulator.manager.vms.helper.HelperClass; + +public class CheckVMOption { + public void setOptions(Command c, VMPropertyValue prop) throws ConsoleException { + // Options + if (c.getLongName() == Actions.OP_NAME) { + prop.vmsName = checkVMName(c.getCurrentValue()); + } + else if (c.getLongName() == Actions.OP_SKIN) { + prop.skin = checkSkin(c.getCurrentValue(), prop); + } + else if (c.getLongName() == Actions.OP_RAM) { + prop.ramSize = checkRAMSize(c.getCurrentValue()).getSize(); + } + else if (c.getLongName() == Actions.OP_FILESHAREPATH) { + if (c.getCurrentValue().isEmpty()) { + prop.isFileShareSupport = false; + prop.fileSharePath = ""; //$NON-NLS-1$ + } else { + checkFileSharePath(c.getCurrentValue()); + prop.isFileShareSupport = true; + prop.fileSharePath = c.getCurrentValue(); + } + } + else if (c.getLongName() == Actions.OP_VIRTUALIZATION) { + prop.isHWVirtualization = checkHWVirtualization(c.getCurrentValue()); + } + else if (c.getLongName() == Actions.OP_GLACCELERATION) { + prop.isGLAcceleration = checkGLAcceleration(c.getCurrentValue()); + } + else if (c.getLongName() == Actions.OP_MAXTOUCH) { + int i = Integer.valueOf(c.getCurrentValue()); + if (i != 1 && i != 2 && i != 3) { + throw new ConsoleException("This value(" + c.getCurrentValue() + ") " //$NON-NLS-1$ //$NON-NLS-2$ + + Messages.getString("ConsoleCreateVM.TouchPointError.0")); //$NON-NLS-1$ + } + prop.maxTouchCount = i; + } + else if (c.getLongName() == Actions.OP_ADDOPTION) { + prop.addOptions = c.getCurrentValue(); + } + } + + private Skin checkSkin(String value, VMPropertyValue prop) throws ConsoleException { + List skinList = prop.getPlatform().findSkinList(prop.resolution); + if (skinList == null || skinList.isEmpty()) { + return null; + } + + // 1: General purpose + // 2: Phone shape (profile specific) + SKIN_TYPE type = null; + if (Integer.toString(1).equals(value)) { + type = SKIN_TYPE.GENERAL; + } else { + type = SKIN_TYPE.PROFILE_SPECIFIC; + } + + if (type == null ){ + throw new ConsoleException(Messages.getString("ConsoleCreateVM.SkinError.0") + value + + Messages.getString("ConsoleCreateVM.SkinError.1")); + } + + for (Skin s : skinList) { + if (s.getType() == type) { + return s; + } + } + + System.out.println(Messages.getString("ConsoleCreateVM.SkinError.2")); //$NON-NLS-1$ + System.out.println(Messages.getString("ConsoleCreateVM.SkinError.3")); //$NON-NLS-1$ + + return null; + } + + private boolean checkGLAcceleration(String currentValue) throws ConsoleException{ + String value = currentValue.toLowerCase(); + if (value.equals("yes")) { //$NON-NLS-1$ + if (!CheckGPU.isGPUSupported()) { + throw new ConsoleException(Messages.getString("ConsoleCreateVM.GPUInfo.0")); //$NON-NLS-1$ + } else { + return true; + } + } else if (value.equals("no")) { //$NON-NLS-1$ + return false; + } else { + throw new ConsoleException(Messages.getString("ConsoleCreateVM.GPUValue.0") + currentValue + ") " //$NON-NLS-1$ //$NON-NLS-2$ + + Messages.getString("ConsoleCreateVM.GPUValue.2")); //$NON-NLS-1$ + } + } + + private boolean checkHWVirtualization(String currentValue) throws ConsoleException { + String value = currentValue.toLowerCase(); + if (value.equals("yes")) { //$NON-NLS-1$ + if (!CheckVT.isVTSupported()) { + throw new ConsoleException(Messages.getString("ConsoleCreateVM.VTInfo.0")); //$NON-NLS-1$ + } else { + return true; + } + } else if (value.equals("no")) { //$NON-NLS-1$ + return false; + } else { + throw new ConsoleException(Messages.getString("ConsoleCreateVM.VTValue.0") + currentValue + ") " //$NON-NLS-1$ //$NON-NLS-2$ + + Messages.getString("ConsoleCreateVM.VTValue.1")); //$NON-NLS-1$ + } + } + + private RAM_SIZE checkRAMSize(String value) throws ConsoleException { + for (RAM_SIZE r : RAM_SIZE.values()) { + if (r.toString().equals(value)) { + return r; + } + } + throw new ConsoleException(Messages.getString("ConsoleCreateVM.RAMSizeError.0") //$NON-NLS-1$ + + value + Messages.getString("ConsoleCreateVM.RAMSizeError.1")); //$NON-NLS-1$ + } + + private void checkFileSharePath(String value) throws ConsoleException { + if (value == null) { + throw new ConsoleException(Messages.getString("ConsoleCreateVM.FileShareError.0")); //$NON-NLS-1$ + } + + File f = new File(value); + if (!f.exists()) { + throw new ConsoleException(Messages.getString("ConsoleCreateVM.FileShareError.1") + value + ")"); //$NON-NLS-1$ //$NON-NLS-2$ + } + } + + private String checkVMName(String name) throws ConsoleException { + if (name.length() > VMProperty.MAX_NAME_LEN) { + throw new ConsoleException(Messages.getString("ConsoleCreateVM.VMNameError.0") //$NON-NLS-1$ + + Integer.toString(VMProperty.MAX_NAME_LEN) + "."); //$NON-NLS-1$ + } + + if (!HelperClass.checkString(name)) { + throw new ConsoleException(Messages.getString("ConsoleCreateVM.VMNameError.1") + StringResources.NEW_LINE + //$NON-NLS-1$ + Messages.getString("ConsoleCreateVM.VMNameError.2")); //$NON-NLS-1$ + } + + if (HelperClass.checkDupulicateName(name) != null) { + throw new ConsoleException(Messages.getString("ConsoleCreateVM.VMNameError.3") + name + Messages.getString("ConsoleCreateVM.VMNameError.4")); //$NON-NLS-1$ //$NON-NLS-2$ + } + + if (name.isEmpty()) { + throw new ConsoleException(Messages.getString("ConsoleCreateVM.VMNameError.5")); //$NON-NLS-1$ + } + + return name; + } +} diff --git a/src/org/tizen/emulator/manager/console/ConsoleCreateVM.java b/src/org/tizen/emulator/manager/console/ConsoleCreateVM.java index d9b924e..0a01104 100644 --- a/src/org/tizen/emulator/manager/console/ConsoleCreateVM.java +++ b/src/org/tizen/emulator/manager/console/ConsoleCreateVM.java @@ -32,559 +32,221 @@ package org.tizen.emulator.manager.console; import java.io.File; import java.io.IOException; import java.util.ArrayList; -import java.util.List; - -import org.tizen.emulator.manager.job.CheckGPU; -import org.tizen.emulator.manager.job.CheckVT; -import org.tizen.emulator.manager.logging.EMLogger; -import org.tizen.emulator.manager.platform.Skin; -import org.tizen.emulator.manager.platform.backup.BaseImage; -import org.tizen.emulator.manager.platform.backup.Platform; -import org.tizen.emulator.manager.platform.backup.Profile; -import org.tizen.emulator.manager.platform.backup.ProfileList; + +import org.tizen.emulator.manager.devices.DeviceTemplate; +import org.tizen.emulator.manager.devices.DeviceTemplateList; +import org.tizen.emulator.manager.platform.Platform; +import org.tizen.emulator.manager.platform.custom.CustomPlatformImageValue; import org.tizen.emulator.manager.resources.StringResources; import org.tizen.emulator.manager.vms.Creator; -import org.tizen.emulator.manager.vms.RAM_SIZE; -import org.tizen.emulator.manager.vms.RESOLUTION; -import org.tizen.emulator.manager.vms.SKIN_TYPE; -import org.tizen.emulator.manager.vms.VMProperty; -import org.tizen.emulator.manager.vms.VMProperty.Architecture; +import org.tizen.emulator.manager.vms.SKIN_SHAPE; import org.tizen.emulator.manager.vms.VMPropertyValue; import org.tizen.emulator.manager.vms.exception.VMWorkerException; import org.tizen.emulator.manager.vms.helper.HelperClass; public class ConsoleCreateVM { private String platformName = null; + private String deviceName = null; + private String imagePath = null; + private boolean needPrintPlatformList = false; + private boolean needPrintDeviceList = false; public boolean createVM(ArrayList list) { - boolean isStandard = false; - boolean isCustom = false; + boolean isStandard = true; boolean setPlatform = false; for (Command c : list) { - if (c.isInCommandLine()) { - switch(c.getShortName().charAt(0)) { - case 'b': - isStandard = true; - break; - case 'p': - setPlatform = true; - platformName = c.getCurrentValue(); - break; - case 'c': - isCustom = true; - break; - } + if (!c.isInCommandLine()) { + continue; + } + switch(c.getShortName().charAt(0)) { + case 'd': + deviceName = c.getCurrentValue(); + break; + case 'p': + setPlatform = true; + platformName = c.getCurrentValue(); + break; + case 'c': + isStandard = false; + imagePath = c.getCurrentValue(); + break; } } - if (!isCustom && setPlatform) { - isStandard = true; + if (!setPlatform && Platform.getPlatformList().size() > 1) { + // TODO: have to choose platform + System.out.println("Error: "); + System.out.println(Messages.getString("ConsoleCreateVM.PlatformError.2")); + printAvailablePlatforms(); + return false; } - if (isStandard && isCustom) { - System.out.println(Messages.getString("ConsoleCreateVM.OptionError.0") //$NON-NLS-1$ - + StringResources.NEW_LINE - + Messages.getString("ConsoleCreateVM.OptionError.1")); //$NON-NLS-1$ - return false; - } else if (!isStandard && !isCustom) { - System.out.println(Messages.getString("ConsoleCreateVM.OptionError.2") //$NON-NLS-1$ - + StringResources.NEW_LINE - + Messages.getString("ConsoleCreateVM.OptionError.3")); //$NON-NLS-1$ - return false; - } else { + Platform platform = null; + try { if (isStandard) { - return createStandardVM(list); + platform = getStandardPlatform(); } else { - return createCustomVM(list); - } - } - } - - public boolean createCustomVM(ArrayList list) { - VMPropertyValue property = null; - - - try { - BaseImage image = null; - Platform platform = null; - // setting platform - if (platformName != null) { - for (Profile profile : ProfileList.getProfileList()) { - for (Platform p : profile.getPlatformList()) { - if (p.getName().equals(platformName)) { - platform = p; - break; - } - } - } - - if (platform == null) { - throw new ConsoleException(Messages.getString("ConsoleCreateVM.PlatformError.0") - + platformName +Messages.getString("ConsoleCreateVM.PlatformError.1")); //$NON-NLS-1$ - } - } - - // setting image - for (Command c : list) { - if (c.isInCommandLine()) { - if (c.getShortName() == "c") { //$NON-NLS-1$ - String path = checkImagePath(c.getCurrentValue()); - if (platform == null) { - // select first available platform - for (Profile profile : ProfileList.getProfileList()) { - platform = profile.getAvailablePlatform(); - if (platform != null) { - break; - } - } - - if (platform == null) { - throw new ConsoleException("There are not exist available platform"); - } - } - - String archList = ""; - for (Architecture arch : platform.getArchitectureList()) { - if (!archList.isEmpty()) { - archList += ", "; - } - // check architecture - if (path.endsWith(arch.toString())) { - image = new BaseImage(platform, path); - property = VMPropertyValue.createValueForNewVM(image); - } - archList += arch.toString(); - } - - if (image == null) { - throw new ConsoleException(Messages.getString("ConsoleCreateVM.ImageError.0") - + StringResources.NEW_LINE - + "Platform: " + platform.getName() - + StringResources.NEW_LINE - + "Available file format: " + archList); //$NON-NLS-1$ - } - } - } + platform = getCustomPlatform(); } - // setting option - for (Command c : list) { - if (c.isInCommandLine()) { - if (c.getShortName() == "n") { //$NON-NLS-1$ - checkVMName(c.getCurrentValue()); - property.vmsName = c.getCurrentValue(); - } else { - // Options - setOptions(c, property); - } - } - } + createEmulator(platform, list); - selectSkin(property); } catch (ConsoleException e) { System.out.println("Error: "); //$NON-NLS-1$ System.out.println(e.getMessage()); + if (needPrintPlatformList) { + printAvailablePlatforms(); + } + if (needPrintDeviceList) { + printAvailableDevices(platform); + } return false; } - try { - Creator.create(property); - } catch (VMWorkerException e) { - System.out.println("Error: "); //$NON-NLS-1$ - System.out.println(e.getMessage()); - return false; - } - - // success - System.out.println(Messages.getString("ConsoleCreateVM.SuccessCreate.0")); //$NON-NLS-1$ return true; } - public boolean createStandardVM(ArrayList list) { - VMPropertyValue property = null; + private Platform getStandardPlatform() throws ConsoleException { Platform platform = null; - try { - // setting platform - if (platformName != null) { - for (Profile profile : ProfileList.getProfileList()) { - for (Platform p : profile.getPlatformList()) { - if (p.getName().equals(platformName)) { - platform = p; - break; - } - } - } - - if (platform == null) { - throw new ConsoleException(Messages.getString("ConsoleCreateVM.PlatformError.0") - + platformName + Messages.getString("ConsoleCreateVM.PlatformError.1")); //$NON-NLS-1$ - } - - // Find property from platform's image list - for (Profile profile : ProfileList.getProfileList()) { - for (BaseImage image : profile.getImageList()) { - if (image.getPlatformName().equals(platform.getName())) { - if (image.getName().contains("standard")) { //$NON-NLS-1$ - property = VMPropertyValue.createValueForNewVM(image); - break; - } - } - } - } - - if (property == null) { - for (Profile profile : ProfileList.getProfileList()) { - for (BaseImage image : profile.getImageList()) { - if (image.getPlatformName().equals(platform.getName())) { - property = VMPropertyValue.createValueForNewVM(image); - break; - } - } - } - } - } + if (platformName == null) { + platform = Platform.getPlatformList().get(0); + } else { + platform = Platform.findPlatform(platformName); + } - // setting base image - for (Command c : list) { - if (c.isInCommandLine()) { - if (c.getShortName() == "b") { //$NON-NLS-1$ - BaseImage image = null; - - for (Profile profile : ProfileList.getProfileList()) { - for (BaseImage i : profile.getImageList()) { - if (i.getID().equals(c.getCurrentValue())) { - image = i; - break; - } - } - } - - if (image == null) { - throw new ConsoleException(Messages.getString("ConsoleCreateVM.ImageIDError.3") - + c.getCurrentValue() +Messages.getString("ConsoleCreateVM.ImageIDError.4")); //$NON-NLS-1$ - } - - if (property != null) { - if (!property.getPlatformName().equals(image.getPlatformName())) { - throw new ConsoleException(Messages.getString("ConsoleCreateVM.ImageIDError.0") //$NON-NLS-1$ - + StringResources.NEW_LINE - + Messages.getString("ConsoleCreateVM.ImageIDError.1") + image.getPlatformName() //$NON-NLS-1$ - + Messages.getString("ConsoleCreateVM.ImageIDError.2") + property.getPlatformName()); //$NON-NLS-1$ - } - property.settingBaseImage(image); - } else { -// property = new VMPropertyValue(image, image.getPlatform().getTemplate()); - property = VMPropertyValue.createValueForNewVM(image); - } - } - } - } + if (platform == null) { + needPrintPlatformList = true; + throw new ConsoleException( + Messages.getString("ConsoleCreateVM.PlatformError.0") + + platformName + + Messages.getString("ConsoleCreateVM.PlatformError.1")); + } - if (property == null) { - throw new ConsoleException(Messages.getString("ConsoleCreateVM.FailedCreate.0") //$NON-NLS-1$ - + StringResources.NEW_LINE - + Messages.getString("ConsoleCreateVM.PlatformError.4")); //$NON-NLS-1$ - } + return platform; + } - for (Command c : list) { - if (c.isInCommandLine()) { - if (c.getShortName() == "n") { //$NON-NLS-1$ - checkVMName(c.getCurrentValue()); - property.vmsName = c.getCurrentValue(); - } else { - // Options - setOptions(c, property); - } - } - } - selectSkin(property); + private Platform getCustomPlatform() throws ConsoleException { + Platform platform = null; + Platform basePlatform = null; - } catch (ConsoleException e) { - System.out.println("Error: "); //$NON-NLS-1$ - System.out.println(e.getMessage()); - return false; + // find base platform + if (platformName == null) { + basePlatform = Platform.getPlatformList().get(0); + } else { + basePlatform = Platform.findPlatform(platformName); } - try { - Creator.create(property); - } catch (VMWorkerException e) { - System.out.println(Messages.getString("ConsoleCreateVM.FailedCreate.0")); //$NON-NLS-1$ - System.out.println(e.getMessage()); - return false; + if (basePlatform == null) { + needPrintPlatformList = true; + throw new ConsoleException( + Messages.getString("ConsoleCreateVM.PlatformError.0") + + platformName + + Messages.getString("ConsoleCreateVM.PlatformError.1")); } - // success - System.out.println(Messages.getString("ConsoleCreateVM.SuccessCreate.0")); //$NON-NLS-1$ - return true; - } + // create custom platform + imagePath = checkImagePath(imagePath); - private Command skinCommand = null; - private Command resolutionCommand = null; - public void setOptions(Command c, VMPropertyValue prop) throws ConsoleException { - boolean check = false; - // Options - if (c.getLongName() == Actions.OP_RESOLUTION) { - resolutionCommand = c; + CustomPlatformImageValue value = new CustomPlatformImageValue(imagePath, basePlatform); + platform = Platform.createCustomInstance(value); + if (platform == null) { + throw new ConsoleException(Messages.getString("ConsoleCreateVM.PlatformError.3")); } - else if (c.getLongName() == Actions.OP_DPI) { - check = false; - int dpi = Integer.valueOf(c.getCurrentValue()); - if (dpi >= VMProperty.MIN_DPI && dpi <= VMProperty.MAX_DPI) { - prop.dpi = dpi; - check = true; - } - if (!check) { - throw new ConsoleException(Messages.getString("ConsoleCreateVM.DPIError.0") + c.getCurrentValue() + Messages.getString("ConsoleCreateVM.DPIError.1")); //$NON-NLS-1$ //$NON-NLS-2$ - } - } - else if (c.getLongName() == Actions.OP_SKIN) { - skinCommand = c; - } - /* - else if (c.getLongName() == Actions.OP_KEYTYPE) { - check = false; - int key = Integer.valueOf(c.getCurrentValue()); - if (key == 1 || key == 3) { - prop.keyType = key; - check = true; - } - if (!check) { - throw new ConsoleException("This key type (" - + c.getCurrentValue() + ") is not avaliable. Avaliable key type is 1 or 3."); - } - } - */ - else if (c.getLongName() == Actions.OP_RAM) { - prop.ramSize = checkRAMSize(c.getCurrentValue()).getSize(); - } - else if (c.getLongName() == Actions.OP_FILESHAREPATH) { - if (c.getCurrentValue().isEmpty()) { - prop.isFileShareSupport = false; - prop.fileSharePath = ""; //$NON-NLS-1$ - } else { - checkFileSharePath(c.getCurrentValue()); - prop.isFileShareSupport = true; - prop.fileSharePath = c.getCurrentValue(); - } - } - else if (c.getLongName() == Actions.OP_VIRTUALIZATION) { - prop.isHWVirtualization = checkHWVirtualization(c.getCurrentValue(), false); - } - else if (c.getLongName() == Actions.OP_GLACCELERATION) { - prop.isGLAcceleration = checkGLAcceleration(c.getCurrentValue(), false); - } - else if (c.getLongName() == Actions.OP_MAXTOUCH) { - int i = Integer.valueOf(c.getCurrentValue()); - if (i != 1 && i != 2 && i != 3) { - throw new ConsoleException("This value(" + c.getCurrentValue() + ") " //$NON-NLS-1$ //$NON-NLS-2$ - + Messages.getString("ConsoleCreateVM.TouchPointError.0")); //$NON-NLS-1$ - } - prop.maxTouchCount = i; - } - else if (c.getLongName() == Actions.OP_ADDOPTION) { - prop.addOptions = c.getCurrentValue(); - } + return platform; } - public void selectSkin(VMPropertyValue prop) throws ConsoleException { - if (resolutionCommand != null) { - RESOLUTION r = checkResolution(resolutionCommand.getCurrentValue()); - prop.resolution = r; - prop.dpi = r.getDPI(); - List list = null; - if (prop.getBaseImage() != null) { - list = prop.getBaseImage().getPlatform().findSkinList(prop.resolution); - } - - if (list != null && !list.isEmpty()) { - prop.skin = list.get(0); - } else { - prop.skin = null; - } - if (prop.skin != null) { - prop.skinPath = prop.skin.getPath(); - } else { - prop.skinPath = null; - } - if (skinCommand != null) { - System.out.println(Messages.getString("ConsoleCreateVM.ResolutionInfo.0")); //$NON-NLS-1$ - } - } else { - if (skinCommand != null) { - List list = null; - int i = 0; - i = Integer.parseInt(skinCommand.getCurrentValue()); - if (prop.getBaseImage() != null) { - list = prop.getBaseImage().getPlatform().findSkinList(prop.resolution); - } - - if (list != null && !list.isEmpty()) { -// if (i <= 0 || i > list.size()) { -// throw new ConsoleException("Skin value (" + skinCommand.getCurrentValue() + ") is not avaliable."); -// } -// prop.skin = list.get(i-1); - if (i <= 0 || i > 2) { - throw new ConsoleException(Messages.getString("ConsoleCreateVM.SkinError.0") + skinCommand.getCurrentValue() + Messages.getString("ConsoleCreateVM.SkinError.1")); //$NON-NLS-1$ //$NON-NLS-2$ - } - prop.skin = getSkin(list, i == 1); - } else { - prop.skin = null; - } - if (prop.skin != null) { - prop.skinPath = prop.skin.getPath(); - } else { - prop.skinPath = null; - } - } else { // resolutionCommon == null and skinComman == null - List list = null; - list = prop.getBaseImage().getPlatform().findGeneralSkinList(); - if (list != null && !list.isEmpty()) { - prop.skin = list.get(0); - return; - } - list = prop.getBaseImage().getPlatform().findSkinList(prop.resolution); - if (list != null && !list.isEmpty()) { - prop.skin = list.get(0); - return; - } - } + private void createEmulator(Platform platform, ArrayList list) throws ConsoleException { + if (platform == null) { + needPrintPlatformList = true; + throw new ConsoleException(Messages.getString("ConsoleCreateVM.PlatformError.2")); } - } - private Skin getSkin(List list, boolean isGeneralSkin) { - Skin skin = null; - if (isGeneralSkin) { - for (Skin s : list) { - if (s.getType() == SKIN_TYPE.GENERAL) { - skin = s; - } - } + VMPropertyValue property = null; + property = VMPropertyValue.createValueForNewVM(platform, platform.getDefaultProperty()); + // need to set device template + DeviceTemplate template = null; + if (deviceName != null) { + deviceName = deviceName.replace("-", " "); + template = DeviceTemplateList.findDeviceTemplateByName(deviceName); } else { - for (Skin s : list) { - if (s.getType() == SKIN_TYPE.PROFILE_SPECIFIC) { - skin = s; - } - } - if (skin == null) { - System.out.println(Messages.getString("ConsoleCreateVM.SkinError.2")); //$NON-NLS-1$ - System.out.println(Messages.getString("ConsoleCreateVM.SkinError.3")); //$NON-NLS-1$ - } + template = DeviceTemplateList.findDefaultTemplate(platform); } - return (skin == null) ? list.get(0) : skin; - } - private boolean checkGLAcceleration(String currentValue, boolean isArm) throws ConsoleException{ - String value = currentValue.toLowerCase(); - if (value.equals("yes")) { //$NON-NLS-1$ - if (isArm) { - System.out.println(Messages.getString("ConsoleCreateVM.ARMImageInfo.0")); //$NON-NLS-1$ - System.out.println(Messages.getString("ConsoleCreateVM.ARMImageInfo.1")); //$NON-NLS-1$ - return false; - } - if (!CheckGPU.isGPUSupported()) { - throw new ConsoleException(Messages.getString("ConsoleCreateVM.GPUInfo.0")); //$NON-NLS-1$ - } else { - return true; - } - } else if (value.equals("no")) { //$NON-NLS-1$ - return false; - } else { - throw new ConsoleException(Messages.getString("ConsoleCreateVM.GPUValue.0") + currentValue + ") " //$NON-NLS-1$ //$NON-NLS-2$ - + Messages.getString("ConsoleCreateVM.GPUValue.2")); //$NON-NLS-1$ + if (template == null) { + needPrintDeviceList = true; + throw new ConsoleException(Messages.getString("ConsoleCreateVM.DeviceError.0")); } - } - private boolean checkHWVirtualization(String currentValue, boolean isArm) throws ConsoleException { - String value = currentValue.toLowerCase(); - if (value.equals("yes")) { //$NON-NLS-1$ - if (isArm) { - System.out.println(Messages.getString("ConsoleCreateVM.ARMImageInfo.2")); //$NON-NLS-1$ - System.out.println(Messages.getString("ConsoleCreateVM.ARMImageInfo.3")); //$NON-NLS-1$ - return false; - } - if (!CheckVT.isVTSupported()) { - throw new ConsoleException(Messages.getString("ConsoleCreateVM.VTInfo.0")); //$NON-NLS-1$ - } else { - return true; - } - } else if (value.equals("no")) { //$NON-NLS-1$ - return false; - } else { - throw new ConsoleException(Messages.getString("ConsoleCreateVM.VTValue.0") + currentValue + ") " //$NON-NLS-1$ //$NON-NLS-2$ - + Messages.getString("ConsoleCreateVM.VTValue.1")); //$NON-NLS-1$ - } - } + property.setDeviceTemplate(template); - private RAM_SIZE checkRAMSize(String value) throws ConsoleException { - for (RAM_SIZE r : RAM_SIZE.values()) { - if (r.toString().equals(value)) { - return r; + CheckVMOption checkOption = new CheckVMOption(); + // setting option + for (Command c : list) { + if (c.isInCommandLine()) { + // Options + checkOption.setOptions(c, property); } } - throw new ConsoleException(Messages.getString("ConsoleCreateVM.RAMSizeError.0") //$NON-NLS-1$ - + value + Messages.getString("ConsoleCreateVM.RAMSizeError.1")); //$NON-NLS-1$ - } - private RESOLUTION checkResolution(String value) throws ConsoleException { - for (RESOLUTION r : RESOLUTION.values()) { - if (r.getType().equals(value)) { - return r; - } - if (r.getStrValue().equals(value)) { - return r; - } + // setting skin and skin path + if (property.skin == null) { + property.skin = platform.findAvailableSkin(property.resolution); } - // Check custom resolution. - String[] arr = value.toLowerCase().split("x"); //$NON-NLS-1$ - if (arr != null && arr.length == 2) { - try { - int width = Integer.parseInt(arr[0]); - int height = Integer.parseInt(arr[1]); - int dpi = 316; // TODO - if ( (width >= 320 && width <= 1920) - && (height >= 320 && height <= 1920)) { - return new RESOLUTION(width, height, "", dpi); //$NON-NLS-1$ - } - } catch (NumberFormatException e) { - EMLogger.getLogger().warning(e.getMessage()); - } + if (property.skin != null) { + property.skinPath = property.skin.getPath(); } - throw new ConsoleException(Messages.getString("ConsoleCreateVM.ResolutionError.0") + Actions.OP_RESOLUTION + " (" + //$NON-NLS-1$ //$NON-NLS-2$ - value + Messages.getString("ConsoleCreateVM.ResolutionError.1")); //$NON-NLS-1$ - } + // - private void checkFileSharePath(String value) throws ConsoleException { - if (value == null) { - throw new ConsoleException(Messages.getString("ConsoleCreateVM.FileShareError.0")); //$NON-NLS-1$ + // create emulator + try { + Creator.create(property); + } catch (VMWorkerException e) { + throw new ConsoleException(e.getMessage()); } - File f = new File(value); - if (!f.exists()) { - throw new ConsoleException(Messages.getString("ConsoleCreateVM.FileShareError.1") + value + ")"); //$NON-NLS-1$ //$NON-NLS-2$ - } + // success + System.out.println(Messages.getString("ConsoleCreateVM.SuccessCreate.0")); //$NON-NLS-1$ } - private void checkVMName(String name) throws ConsoleException { - if (name.length() > VMProperty.MAX_NAME_LEN) { - throw new ConsoleException(Messages.getString("ConsoleCreateVM.VMNameError.0") //$NON-NLS-1$ - + Integer.toString(VMProperty.MAX_NAME_LEN) + "."); //$NON-NLS-1$ - } + private void printAvailableDevices(Platform platform) { + System.out.println(""); - if (!HelperClass.checkString(name)) { - throw new ConsoleException(Messages.getString("ConsoleCreateVM.VMNameError.1") + StringResources.NEW_LINE + //$NON-NLS-1$ - Messages.getString("ConsoleCreateVM.VMNameError.2")); //$NON-NLS-1$ + String profile = null; + if (platform != null) { + profile = platform.getProfile().getName(); } - if (HelperClass.checkDupulicateName(name) != null) { - throw new ConsoleException(Messages.getString("ConsoleCreateVM.VMNameError.3") + name + Messages.getString("ConsoleCreateVM.VMNameError.4")); //$NON-NLS-1$ //$NON-NLS-2$ + if (profile == null) { + System.out.println("Available devices: "); + for (DeviceTemplate template : DeviceTemplateList.getDeviceTemplateList(false)) { + System.out.println(template.getValue().getName().replace(" ", "-")); + } + } else { + System.out.println("Available devices of " + profile + ": "); + for (DeviceTemplate template : DeviceTemplateList.getDeviceTemplateList(false)) { + if (!template.getValue().getProfile().equals(profile)) { + continue; + } + + if (template.getValue().getSkinShape() == SKIN_SHAPE.NONE + || template.getValue().getSkinShape() == platform.getImageSkinShape()) { + System.out.println(template.getValue().getName().replace(" ", "-")); + } + } } + } - if (name.isEmpty()) { - throw new ConsoleException(Messages.getString("ConsoleCreateVM.VMNameError.5")); //$NON-NLS-1$ + private void printAvailablePlatforms() { + System.out.println(""); + System.out.println("Available platform: "); + for (Platform platform : Platform.getPlatformList()) { + if (platform.isImageExist()) { + System.out.println(platform.getName()); + } } } diff --git a/src/org/tizen/emulator/manager/console/ConsoleModifyVM.java b/src/org/tizen/emulator/manager/console/ConsoleModifyVM.java index 5def8ad..0925664 100644 --- a/src/org/tizen/emulator/manager/console/ConsoleModifyVM.java +++ b/src/org/tizen/emulator/manager/console/ConsoleModifyVM.java @@ -62,13 +62,12 @@ public class ConsoleModifyVM { } oldVM = prop.getPropertyValue(); - //oldVM.setSkin(SelectSkin.getInstance().getDefaultSkin()); newVM = oldVM.clone(); - ConsoleCreateVM creator = new ConsoleCreateVM(); + CheckVMOption checkOption = new CheckVMOption(); try { for (Command c : list) { if (c.isInCommandLine()) { - creator.setOptions(c, newVM); + checkOption.setOptions(c, newVM); /* // check resolution because can not change dpi @@ -79,7 +78,9 @@ public class ConsoleModifyVM { */ } } - creator.selectSkin(newVM); + if (newVM.skin == null) { + newVM.skin = newVM.getPlatform().findAvailableSkin(newVM.resolution); + } } catch (ConsoleException e) { System.out.println("Error: "); //$NON-NLS-1$ System.out.println(e.getMessage()); diff --git a/src/org/tizen/emulator/manager/devices/DeviceTemplateList.java b/src/org/tizen/emulator/manager/devices/DeviceTemplateList.java index a2c90ac..6ffa9cb 100644 --- a/src/org/tizen/emulator/manager/devices/DeviceTemplateList.java +++ b/src/org/tizen/emulator/manager/devices/DeviceTemplateList.java @@ -47,8 +47,10 @@ import javax.xml.transform.stream.StreamSource; import org.tizen.emulator.manager.device.xml.template.DeviceConfiguration; import org.tizen.emulator.manager.logging.EMLogger; +import org.tizen.emulator.manager.platform.Platform; import org.tizen.emulator.manager.resources.FilePathResources; import org.tizen.emulator.manager.resources.StringResources; +import org.tizen.emulator.manager.vms.SKIN_SHAPE; public class DeviceTemplateList { static private JAXBContext context = null; @@ -94,6 +96,43 @@ public class DeviceTemplateList { return null; } + public static DeviceTemplate findDeviceTemplateByName(String name) { + for (DeviceTemplate template : templateList) { + if (template.getValue().getName().equals(name)) { + return template; + } + } + return null; + } + + public static DeviceTemplate findDefaultTemplate(Platform platform) { + String profile = platform.getProfile().getName(); + List list = new ArrayList(); + + for (DeviceTemplate template : templateList) { + DeviceTemplateValue value = template.getValue(); + if (!value.getProfile().equals(profile)) { + continue; + } + if (value.getSkinShape() != SKIN_SHAPE.NONE + && value.getSkinShape() != platform.getImageSkinShape()) { + continue; + } + + if (value.getPriority() == DeviceTemplatePriority.DEFAULT) { + return template; + } + + list.add(template); + } + + if (list.isEmpty()) { + return null; + } + + return list.get(0); + } + public static void reloadDeviceConfiguration(DeviceTemplate template) { DeviceConfiguration conf = parseXML(template.getTemplateFile()); template.setConf(conf); diff --git a/src/org/tizen/emulator/manager/platform/StandardPlatform.java b/src/org/tizen/emulator/manager/platform/StandardPlatform.java index 57ddeff..913218e 100644 --- a/src/org/tizen/emulator/manager/platform/StandardPlatform.java +++ b/src/org/tizen/emulator/manager/platform/StandardPlatform.java @@ -176,8 +176,12 @@ public class StandardPlatform extends Platform { @Override public Skin findAvailableSkin(RESOLUTION resolution) { - // TODO - if (! skinList.isEmpty()) { + List list = findSkinList(resolution); + if (!list.isEmpty()) { + return list.get(0); + } + + if (!skinList.isEmpty()) { return skinList.get(0); } else { return null; -- 2.7.4