From 748e14ad5b6f715c4d6cf38d371c5ce99af3d366 Mon Sep 17 00:00:00 2001 From: "jihye424.kim" Date: Mon, 11 Jan 2016 14:48:29 +0900 Subject: [PATCH] create viewer: find the next best skin for emulator - if skin of new emulator does not exist -- find the next best skin for emulator - found skin -- resolution of this skin would be different from resolution of new emulator -- skin shape of this skin would be different from skin shape of new emulator -- but this skin makes the emulator launchable Change-Id: I88209ed24b5ee5f67662a8076c25d6d3a65da154 Signed-off-by: jihye424.kim --- .../tizen/emulator/manager/platform/Platform.java | 26 ++++++++++++ .../renewal/tableviewer/CreateVMTableViewer.java | 46 ++++++++++++++++++++++ src/org/tizen/emulator/manager/vms/Creator.java | 18 +-------- 3 files changed, 73 insertions(+), 17 deletions(-) diff --git a/src/org/tizen/emulator/manager/platform/Platform.java b/src/org/tizen/emulator/manager/platform/Platform.java index b931f98..48bf84a 100644 --- a/src/org/tizen/emulator/manager/platform/Platform.java +++ b/src/org/tizen/emulator/manager/platform/Platform.java @@ -255,6 +255,32 @@ public class Platform { return SkinList.findSkinUseName(name, skinList); } + /** + * Find available skin. If there not exist proper skin, this method use general skin. + * If there not exist general skin either, this method use first skin in skin list. + * This skin does not match resolution or skin shape to parameters. + * But if emulator doesn't have skin, emulator can't be launched... + * So, this method will find usable skin for emulator. + * @param resoluion + * @param skinShape + * @return available skin or null + */ + public Skin findAvailableSkin(RESOLUTION resoluion, SKIN_SHAPE skinShape) { + List skinList = findSkinList(resoluion, skinShape); + if (!skinList.isEmpty()) { + return skinList.get(0); + } + skinList = findGeneralSkinList(); + if (!skinList.isEmpty()) { + return skinList.get(0); + } + skinList = getSkins(); + if (!skinList.isEmpty()) { + return skinList.get(0); + } + return null; + } + public List findSkinList(RESOLUTION resolution) { return SkinList.findSkinList(resolution, skinList); } diff --git a/src/org/tizen/emulator/manager/ui/renewal/tableviewer/CreateVMTableViewer.java b/src/org/tizen/emulator/manager/ui/renewal/tableviewer/CreateVMTableViewer.java index 7e19ad9..e24e94f 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/tableviewer/CreateVMTableViewer.java +++ b/src/org/tizen/emulator/manager/ui/renewal/tableviewer/CreateVMTableViewer.java @@ -53,6 +53,7 @@ import org.tizen.emulator.manager.renewal.resources.PatchImageResources; import org.tizen.emulator.manager.resources.StringResources; import org.tizen.emulator.manager.ui.Messages; import org.tizen.emulator.manager.ui.renewal.MainDialog; +import org.tizen.emulator.manager.ui.renewal.dialog.MessageBox; import org.tizen.emulator.manager.ui.renewal.item.ItemName; import org.tizen.emulator.manager.ui.renewal.item.OptionName; import org.tizen.emulator.manager.ui.renewal.item.modify.comp.AdvancedPropertyViewer; @@ -397,6 +398,51 @@ public class CreateVMTableViewer extends AbstractTableViewer { // set advanced option value advancedViewer.saveDataInto(); + // find available skin + if (newValue.skin == null) { + Skin skin = baseImage.getPlatform().findAvailableSkin(newValue.resolution, baseImage.getSkinShape()); + String message = "The perfectly matched skin for your emulator does not exist." + + StringResources.NEW_LINE + + StringResources.NEW_LINE; + + if (skin != null) { + message += "This skin is the next best for emulator." + StringResources.NEW_LINE + + "This emulator may be displayed with different resolution or skin shape." + + StringResources.NEW_LINE; + message += "\tSkin: " + skin.getName() + StringResources.NEW_LINE + + "\tSkin Resolution: " + skin.getResolution() + StringResources.NEW_LINE + + "\tSkin Shape: " + skin.getSkinShape() + StringResources.NEW_LINE + + StringResources.NEW_LINE + + StringResources.NEW_LINE; + message += "Do you want to use this skin?" + + StringResources.NEW_LINE + + StringResources.NEW_LINE; + message += "** If you select NO, the emulator will not be launched **"; + int re = MessageBox.openMessageBox(message, SWT.YES | SWT.NO); + if (re == SWT.YES) { + newValue.skin = skin; + newValue.skinPath = skin.getPath(); + } else { + // TODO + // The emulator does not have a skin + // Is it right to continue creating emulator??? + } + } else { + message += "There is not available skin for your emulator." + StringResources.NEW_LINE; + message += "Emulator will be failed to launch." + StringResources.NEW_LINE; + message += "Do you want to continue creating emulator?"; + int re = MessageBox.openMessageBox(message, SWT.OK | SWT.CANCEL); + if (re == SWT.CANCEL) { + // cancel to create emulator + return; + } else { + // TODO + // The emulator does not have a skin + // Is it right to continue creating emulator??? + } + } + } + VMProperty prop = null; try { prop = Creator.create(newValue); diff --git a/src/org/tizen/emulator/manager/vms/Creator.java b/src/org/tizen/emulator/manager/vms/Creator.java index c490e35..18a0a00 100644 --- a/src/org/tizen/emulator/manager/vms/Creator.java +++ b/src/org/tizen/emulator/manager/vms/Creator.java @@ -42,7 +42,6 @@ import org.tizen.emulator.manager.Messages; import org.tizen.emulator.manager.logging.EMLogger; import org.tizen.emulator.manager.platform.Profile; import org.tizen.emulator.manager.platform.ProfileList; -import org.tizen.emulator.manager.platform.Skin; import org.tizen.emulator.manager.resources.FilePathResources; import org.tizen.emulator.manager.resources.StringResources; import org.tizen.emulator.manager.vms.helper.QemuImgProc; @@ -246,22 +245,7 @@ public class Creator { // Device private void createDisplay() throws VMCreatorException { - /* - int i = newVM.resolution.indexOf('x'); - newVM.resolutionType = new Resolution(); - newVM.resolutionType.setWidth(Integer.valueOf(newVM.resolution.substring(0,i))); - newVM.resolutionType.setHeight(Integer.valueOf(newVM.resolution.substring(i+1,newVM.resolution.length()))); - */ - // TODO - - if (newVM.skin == null && newVM.skinPath == null) { - if (newVM.baseImage != null) { - List list = newVM.baseImage.getPlatform().findSkinList(newVM.resolution); - if (!list.isEmpty()) { - newVM.skin = list.get(0); - } - } - } + // empty method } private void createRam() {} -- 2.7.4