From 6c971bd39c763c7a9f5a6800ad337d2a96730352 Mon Sep 17 00:00:00 2001 From: Minkee Lee Date: Thu, 4 Feb 2016 16:47:54 +0900 Subject: [PATCH] VM-property: change setting base-image Change base image setting time. Change-Id: I01842e3c741e3daca3ec6f67307fb1d69fba2c6f Signed-off-by: Minkee Lee --- .../tizen/emulator/manager/platform/Profile.java | 59 ++++++++++++---------- .../manager/vms/VMPropertyConfiguration.java | 23 +++++++++ .../emulator/manager/vms/VMPropertyValue.java | 9 ++++ 3 files changed, 63 insertions(+), 28 deletions(-) diff --git a/src/org/tizen/emulator/manager/platform/Profile.java b/src/org/tizen/emulator/manager/platform/Profile.java index 3e2de81..abf5c53 100644 --- a/src/org/tizen/emulator/manager/platform/Profile.java +++ b/src/org/tizen/emulator/manager/platform/Profile.java @@ -55,7 +55,7 @@ public class Profile { private final List platformList = new ArrayList(); private List imageList = new ArrayList(); private List vmList = new ArrayList(); - private List templateList = new ArrayList(); + private final List templateList = new ArrayList(); protected String lastCreatedPropertyPath; @@ -190,42 +190,45 @@ public class Profile { return null; } - public void addEmulator(VMProperty vm) { - if (!vm.getImageProfile().equals(name)) { - return; - } + public BaseImage findBaseImage(FSImageType type, String imagePath, String imageName, + String platformName) { + //setting BaseImage - BaseImage image = vm.getPropertyValue().baseImage; - if (image == null) { - if (vm.getImageType().equals(FSImageType.standard)) { - for (BaseImage b : imageList) { - if (b.isStandard() && vm.getBaseImagePath().equals(b.getPath())) { - image = b; - break; - } + if (type.equals(FSImageType.standard)) { + for (BaseImage b : imageList) { + if (b.isStandard() && imagePath.equals(b.getPath())) { + return b; } - } else { // custom base image - for (BaseImage b : imageList) { - if (!b.isStandard() && vm.getBaseImageName().equals(b.getName())) { - image = b; - break; - } + } + + } else { // custom base image + for (BaseImage b : imageList) { + if (!b.isStandard() && imageName.equals(b.getName())) { + return b; } + } - if (image == null) { - for (Platform p : platformList) { - if (vm.getImagePlatform().equals(p.getName())) { - image = CustomBaseImageWorker.createCustomBaseImage(p, - vm.getBaseImagePath(), - vm.getBaseImageName()); - } - } + for (Platform p : platformList) { + if (platformName.equals(p.getName())) { + return CustomBaseImageWorker.createCustomBaseImage(p, + imagePath, + imageName); } } } + return null; + } + + public void addEmulator(VMProperty vm) { + if (!vm.getImageProfile().equals(name)) { + return; + } + + BaseImage image = vm.getPropertyValue().baseImage; + + // TODO image should not be null if (image != null) { - vm.getPropertyValue().setBaseImage(image); vmList.add(vm); if (!name.equals(StringResources.TOTAL_PROFILE)) { image.addEmulator(vm); diff --git a/src/org/tizen/emulator/manager/vms/VMPropertyConfiguration.java b/src/org/tizen/emulator/manager/vms/VMPropertyConfiguration.java index 5ed3a33..0fb9033 100644 --- a/src/org/tizen/emulator/manager/vms/VMPropertyConfiguration.java +++ b/src/org/tizen/emulator/manager/vms/VMPropertyConfiguration.java @@ -36,6 +36,9 @@ import java.util.Collections; import java.util.List; import org.tizen.emulator.manager.devices.DeviceTemplateList; +import org.tizen.emulator.manager.platform.BaseImage; +import org.tizen.emulator.manager.platform.Profile; +import org.tizen.emulator.manager.platform.ProfileList; import org.tizen.emulator.manager.resources.StringResources; import org.tizen.emulator.manager.vms.VMProperty.Architecture; import org.tizen.emulator.manager.vms.VMProperty.FSImageType; @@ -459,6 +462,26 @@ public class VMPropertyConfiguration { // advanced option property.advancedVMOptionList = getAdvancedOptionList(); + + } + + public void settingBaseImage(VMPropertyValue property) { + // XXX Remove null check. Image should not be null.. + BaseImage image = findBaseImage(); + if (image != null) { + property.setBaseImage(image); + } + } + + private BaseImage findBaseImage() { + Profile profile = ProfileList.getProfile(getBaseImageProfile()); + if (profile == null) { + return null; + } + return profile.findBaseImage(getBaseImageType(), + getBaseImagePath(), + getBaseImageName(), + getBaseImagePlatform()); } public void settingEmulatorConfiguration(VMPropertyValue newVM) { diff --git a/src/org/tizen/emulator/manager/vms/VMPropertyValue.java b/src/org/tizen/emulator/manager/vms/VMPropertyValue.java index 031e124..683e4b2 100644 --- a/src/org/tizen/emulator/manager/vms/VMPropertyValue.java +++ b/src/org/tizen/emulator/manager/vms/VMPropertyValue.java @@ -139,12 +139,14 @@ public class VMPropertyValue implements Cloneable { if (property != null) { this.template = property; settingConfigure(property); + settingBaseImage(property); } else { EMLogger.getLogger().warning("Failed to create VMPropertyValue because property is null"); //$NON-NLS-1$ } } + public void setBaseImage(BaseImage image) { // if (image == null) { // template.setAvailable(false); @@ -370,6 +372,13 @@ public class VMPropertyValue implements Cloneable { property.getVMConfiguration().settingVMPropertyValue(this); } + void settingBaseImage(VMProperty property) { + if (property == null) { + return; + } + property.getVMConfiguration().settingBaseImage(this); + } + private void settingSkin() { if (skinPath != null) { skin = baseImage.getPlatform().findSkinUsePath(skinPath); -- 2.7.4