From 5a0518ae244ccc95c99ae3ef709a1f09d2e657eb Mon Sep 17 00:00:00 2001 From: jihye kim Date: Fri, 2 Nov 2012 15:21:19 +0900 Subject: [PATCH] [Title] emulator manager : modify skin select routine [Desc.] change skin class structure and add handling null point and empty array. [Issue] N/A --- .../tizen/emulator/manager/console/ActionList.java | 32 ++++- .../emulator/manager/console/ConsoleCreateVM.java | 80 +++++++----- .../emulator/manager/console/ConsoleModifyVM.java | 4 +- src/org/tizen/emulator/manager/image/Skin.java | 13 ++ src/org/tizen/emulator/manager/image/SkinList.java | 142 +++++++++++++++++++++ src/org/tizen/emulator/manager/image/Skins.java | 9 +- src/org/tizen/emulator/manager/tool/FilePath.java | 7 + .../tizen/emulator/manager/tool/SelectSkin.java | 69 ---------- .../emulator/manager/ui/detail/TableWidget.java | 51 ++++++-- .../emulator/manager/ui/detail/VMPropertyView.java | 5 +- src/org/tizen/emulator/manager/vms/Creator.java | 15 ++- src/org/tizen/emulator/manager/vms/Modifier.java | 6 +- src/org/tizen/emulator/manager/vms/RESOLUTION.java | 9 +- .../emulator/manager/vms/VMPropertyValue.java | 77 +++++++++-- 14 files changed, 367 insertions(+), 152 deletions(-) create mode 100644 src/org/tizen/emulator/manager/image/SkinList.java delete mode 100644 src/org/tizen/emulator/manager/tool/SelectSkin.java diff --git a/src/org/tizen/emulator/manager/console/ActionList.java b/src/org/tizen/emulator/manager/console/ActionList.java index c496815..41d33ae 100644 --- a/src/org/tizen/emulator/manager/console/ActionList.java +++ b/src/org/tizen/emulator/manager/console/ActionList.java @@ -35,6 +35,8 @@ import java.util.ArrayList; import java.util.logging.Level; import java.util.logging.Logger; +import org.tizen.emulator.manager.image.SkinList; +import org.tizen.emulator.manager.image.Skin; import org.tizen.emulator.manager.logging.EMLogger; import org.tizen.emulator.manager.tool.FilePath; import org.tizen.emulator.manager.tool.SelectTemplate; @@ -337,7 +339,11 @@ class Create extends Action { // Options String resolution = ""; for (RESOLUTION r : RESOLUTION.values()) { - resolution += (r.getType() + " | "); + if (!r.getType().isEmpty()) { + resolution += (r.getType() + " | "); + } else { + resolution += (r.getValue() + " | "); + } } resolution = resolution.substring(0, resolution.length() - 3); commandList.add(new Command("r", Actions.OP_RESOLUTION, @@ -347,10 +353,15 @@ class Create extends Action { "DPI. (100 ~ 480)", Integer.toString(property.dpi), false, true)); /** TODO : resolution and skin..***********************************************/ + ArrayList skinList = SkinList.getInstance().findSkinList(RESOLUTION.HD.getValue()); String skinType = ""; int i = 1; - skinType += Integer.toString(i++) + "(phone_shape_skin) | "; - skinType += Integer.toString(i++) + "(general_purpose_skin)"; + 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, "Select skin style (" + skinType + ")", "1", false, true)); @@ -405,7 +416,11 @@ class Modify extends Action { // Options String resolution = ""; for (RESOLUTION r : RESOLUTION.values()) { - resolution += (r.getType() + " | "); + if (!r.getType().isEmpty()) { + resolution += (r.getType() + " | "); + } else { + resolution += (r.getValue() + " | "); + } } resolution = resolution.substring(0, resolution.length() - 3); commandList.add(new Command("r", Actions.OP_RESOLUTION, @@ -415,10 +430,15 @@ class Modify extends Action { "DPI. (100 ~ 480)", Integer.toString(property.dpi), false, true)); /** TODO : resolution and skin..***********************************************/ + ArrayList skinList = SkinList.getInstance().findSkinList(RESOLUTION.HD.getValue()); String skinType = ""; int i = 1; - skinType += Integer.toString(i++) + "(phone_shape_skin) | "; - skinType += Integer.toString(i++) + "(general_purpose_skin)"; + 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, "Select skin style (" + skinType + ")", "1", false, true)); diff --git a/src/org/tizen/emulator/manager/console/ConsoleCreateVM.java b/src/org/tizen/emulator/manager/console/ConsoleCreateVM.java index aa2b100..1fa5701 100644 --- a/src/org/tizen/emulator/manager/console/ConsoleCreateVM.java +++ b/src/org/tizen/emulator/manager/console/ConsoleCreateVM.java @@ -36,9 +36,9 @@ import java.util.ArrayList; import org.tizen.emulator.manager.EmulatorManager; import org.tizen.emulator.manager.image.BaseImage; import org.tizen.emulator.manager.image.Platform; +import org.tizen.emulator.manager.image.Skin; +import org.tizen.emulator.manager.image.SkinList; import org.tizen.emulator.manager.tool.CheckVirtualization; -import org.tizen.emulator.manager.tool.SelectSkin; -import org.tizen.emulator.manager.tool.StringResource; import org.tizen.emulator.manager.ui.detail.VMPropertyView; import org.tizen.emulator.manager.vms.Creator; import org.tizen.emulator.manager.vms.EmulatorVMs; @@ -73,7 +73,7 @@ public class ConsoleCreateVM { System.out.println("Error: One of '--base' and '--path' shoud come as option of 'create'"); return false; } else { - property.setSkin(SelectSkin.getInstance().getDefaultSkin()); + //property.setSkin(SelectSkin.getInstance().getDefaultSkin()); if (isStandard) { property.isStandard = true; return createStandardVM(list, property); @@ -105,6 +105,7 @@ public class ConsoleCreateVM { } } } + selectSkin(prop); } catch (ConsoleException e) { System.out.println("Error: "); System.out.println(e.getMessage()); @@ -158,6 +159,7 @@ public class ConsoleCreateVM { } } } + selectSkin(prop); } catch (ConsoleException e) { System.out.println("Error: "); System.out.println(e.getMessage()); @@ -178,22 +180,12 @@ public class ConsoleCreateVM { } 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) { - RESOLUTION r = checkResolution(c.getCurrentValue()); - prop.resolution = r; - prop.dpi = r.getDPI(); - if (skinCommand != null) { - selectSkin(skinCommand, prop); - skinCommand = null; - } else { - if (prop.skin != null && - !prop.skin.getResolution().equals(StringResource.SKIN_GENERAL)) { - selectSkin(null, prop); - } - } + resolutionCommand = c; } else if (c.getLongName() == Actions.OP_DPI) { check = false; @@ -209,7 +201,6 @@ public class ConsoleCreateVM { } else if (c.getLongName() == Actions.OP_SKIN) { skinCommand = c; - selectSkin(c, prop); } /* else if (c.getLongName() == Actions.OP_KEYTYPE) { @@ -257,29 +248,49 @@ public class ConsoleCreateVM { } } - private void selectSkin(Command c, VMPropertyValue prop) throws ConsoleException { - // phone shape skin - if (c == null || c.getCurrentValue().equals("1")) { - prop.skin = prop.skinList.findSkin(prop.resolution.getValue()); - if (prop.skin == null) { - System.out.println("There is not match skin to resolution(" + prop.resolution + ")"); - prop.skin = prop.skinList.findGeneralSkin(); - if (prop.skin == null) { - System.out.println("There is not general skin. Skin path may be null."); - } + public void selectSkin(VMPropertyValue prop) throws ConsoleException { + if (resolutionCommand != null) { + RESOLUTION r = checkResolution(resolutionCommand.getCurrentValue()); + prop.resolution = r; + prop.dpi = r.getDPI(); + ArrayList list = SkinList.getInstance().findSkinList(prop.resolution.getValue()); + if (!list.isEmpty()) { + prop.skin = list.get(0); + } else { + prop.skin = null; } if (prop.skin != null) { prop.skinPath = prop.skin.getPath(); - } - } else if (c.getCurrentValue().equals("2")) { - prop.skin = prop.skinList.findGeneralSkin(); - if (prop.skin == null) { - System.out.println("There is not general skin. Skin path may be null."); } else { - prop.skinPath = prop.skin.getPath(); + prop.skinPath = null; + } + if (skinCommand != null) { + System.out.println("Because You change resolution, skin path chage follow reslution."); } } else { - throw new ConsoleException("Skin value (" + c.getCurrentValue() + ") is not avaliable."); + if (skinCommand != null) { + ArrayList list = null; + int i = 0; + try { + i = Integer.parseInt(skinCommand.getCurrentValue()); + list = SkinList.getInstance().findSkinList(prop.resolution.getValue()); + } catch (Throwable t) { + throw new ConsoleException("Skin value (" + skinCommand.getCurrentValue() + ") is not avaliable."); + } + if (!list.isEmpty()) { + if (i <= 0 || i > list.size()) { + throw new ConsoleException("Skin value (" + skinCommand.getCurrentValue() + ") is not avaliable."); + } + prop.skin = list.get(i-1); + } else { + prop.skin = null; + } + if (prop.skin != null) { + prop.skinPath = prop.skin.getPath(); + } else { + prop.skinPath = null; + } + } } } @@ -326,6 +337,9 @@ public class ConsoleCreateVM { if (r.getType().equals(value)) { return r; } + if (r.getValue().equals(value)) { + return r; + } } throw new ConsoleException("This " + Actions.OP_RESOLUTION + " (" + value + ") is not avaliable."); diff --git a/src/org/tizen/emulator/manager/console/ConsoleModifyVM.java b/src/org/tizen/emulator/manager/console/ConsoleModifyVM.java index d4773e5..6e275ba 100644 --- a/src/org/tizen/emulator/manager/console/ConsoleModifyVM.java +++ b/src/org/tizen/emulator/manager/console/ConsoleModifyVM.java @@ -31,7 +31,6 @@ package org.tizen.emulator.manager.console; import java.util.ArrayList; -import org.tizen.emulator.manager.tool.SelectSkin; import org.tizen.emulator.manager.vms.VMPropertyValue; import org.tizen.emulator.manager.vms.VMsProperty; import org.tizen.emulator.manager.vms.VMsWorkerException; @@ -63,7 +62,7 @@ public class ConsoleModifyVM { } oldVM = prop.getPropertyValue(); - oldVM.setSkin(SelectSkin.getInstance().getDefaultSkin()); + //oldVM.setSkin(SelectSkin.getInstance().getDefaultSkin()); newVM = oldVM.clone(); ConsoleCreateVM creator = new ConsoleCreateVM(); try { @@ -80,6 +79,7 @@ public class ConsoleModifyVM { */ } } + creator.selectSkin(newVM); } catch (ConsoleException e) { System.out.println("Error: "); System.out.println(e.getMessage()); diff --git a/src/org/tizen/emulator/manager/image/Skin.java b/src/org/tizen/emulator/manager/image/Skin.java index 3bd409c..444aed0 100644 --- a/src/org/tizen/emulator/manager/image/Skin.java +++ b/src/org/tizen/emulator/manager/image/Skin.java @@ -121,4 +121,17 @@ public class Skin { public String toString() { return name; } + + public boolean equals(Object obj) { + if (!(obj instanceof Skin)) { + return false; + } + + if (((Skin)obj).getName().equals(name)) { + return true; + } + + return false; + } + } diff --git a/src/org/tizen/emulator/manager/image/SkinList.java b/src/org/tizen/emulator/manager/image/SkinList.java new file mode 100644 index 0000000..9620ede --- /dev/null +++ b/src/org/tizen/emulator/manager/image/SkinList.java @@ -0,0 +1,142 @@ +/* + * Emulator Manager + * + * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * SeokYeon Hwang + * JiHye Kim + * YeongKyoon Lee + * + * 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.image; + +import java.io.File; +import java.util.ArrayList; + +import org.tizen.emulator.manager.logging.EMLogger; +import org.tizen.emulator.manager.tool.FilePath; +import org.tizen.emulator.manager.tool.StringResource; + +public class SkinList { + private ArrayList skinsList = new ArrayList(); + private ArrayList skinList = new ArrayList(); + //private Skins defaultSkin = null; + + private static SkinList instance = null; + static { + instance = new SkinList(); + } + + public static SkinList getInstance() { + return instance; + } + + private SkinList() { + try { + skinsList.add(new Skins(new File(FilePath.getInstance().getSkinPath()))); + //defaultSkin = skinsList.get(0); + } catch (Exception e) { + EMLogger.getLogger().warning(e.getMessage()); + } + + try { + skinsList.add(new Skins(new File(FilePath.getInstance().getDataSkinPath()))); + } catch (Exception e) { + EMLogger.getLogger().warning(e.getMessage()); + } + + for (Skins skins : skinsList) { + for (Skin s : skins.getSkinList()) { + if (!skinList.contains(s)) { + skinList.add(s); + } + } + } + } + + public ArrayList getSkinsList() { + return skinsList; + } + + public ArrayList getSkinList() { + return skinList; + } + + public Skin findSkinUsePath(String path) { + if (skinList != null) { + for (Skin skin : skinList) { + if (skin.getPath().equals(path)) { + return skin; + } + } + } + return null; + } + + public Skin findSkinUseName(String name) { + if (skinList != null) { + for (Skin skin : skinList) { + if (skin.getName().equals(name)) { + return skin; + } + } + } + return null; + } + + private ArrayList returnSkins = new ArrayList(); + public ArrayList findSkinList(String resolution) { + returnSkins.clear(); + if (skinList != null) { + for (Skin skin : skinList) { + if (skin.getResolution().equals(resolution)) { + returnSkins.add(skin); + } + if (skin.getResolution().equals(StringResource.SKIN_GENERAL)) { + returnSkins.add(skin); + } + } + } + return returnSkins; + } + + public ArrayList findGeneralSkinList() { + returnSkins.clear(); + if (skinList != null) { + for (Skin skin : skinList) { + if (skin.getResolution().equals(StringResource.SKIN_GENERAL)) { + returnSkins.add(skin); + } + } + } + return returnSkins; + } +/* + public Skins getDefaultSkin() { + return defaultSkin; + } + + public void setDefaultSkin(Skins defaultSkin) { + this.defaultSkin = defaultSkin; + } +*/ +} diff --git a/src/org/tizen/emulator/manager/image/Skins.java b/src/org/tizen/emulator/manager/image/Skins.java index 5131c34..eca3ff8 100644 --- a/src/org/tizen/emulator/manager/image/Skins.java +++ b/src/org/tizen/emulator/manager/image/Skins.java @@ -33,7 +33,6 @@ import java.io.File; import java.io.FileFilter; import java.util.ArrayList; import org.tizen.emulator.manager.logging.EMLogger; -import org.tizen.emulator.manager.tool.StringResource; public class Skins { private ArrayList skins = null; @@ -64,7 +63,7 @@ public class Skins { throw new Exception("This directory does not exist (" + path + ")"); } } - +/* public Skin findSkin(String resolution) { // TODO : result value is not single. ?? if (skins != null) { @@ -125,7 +124,7 @@ public class Skins { } return skinList; } - +*/ /* public String findSkinPath(String resolution) { if (skins == null) { @@ -143,4 +142,8 @@ public class Skins { public String getSkinsPath() { return path; } + + public ArrayList getSkinList() { + return skins; + } } diff --git a/src/org/tizen/emulator/manager/tool/FilePath.java b/src/org/tizen/emulator/manager/tool/FilePath.java index ec389c1..04780e4 100644 --- a/src/org/tizen/emulator/manager/tool/FilePath.java +++ b/src/org/tizen/emulator/manager/tool/FilePath.java @@ -83,6 +83,7 @@ public class FilePath { private static String biosPath; private static String sdcardPath; private static String swapPath; + private static String dataSkinPath; private static String baseSwapPath; @@ -216,6 +217,7 @@ public class FilePath { workspacePath = EmulatorVMs.getInstance().getVMsBaseDirectory(); vmsPath = EmulatorVMs.getInstance().getVMsConfigDirectory(); swapPath = workspacePath + File.separator + swap_suffix; + dataSkinPath = workspacePath + File.separator + skin_suffix; EmulatorVMs.makeSDKDataPath(tizenSDKDataPath); setVMSPath(); @@ -226,6 +228,7 @@ public class FilePath { workspacePath = EmulatorVMs.getInstance().getVMsBaseDirectory(); vmsPath = EmulatorVMs.getInstance().getVMsConfigDirectory(); swapPath = workspacePath + File.separator + swap_suffix; + dataSkinPath = workspacePath + File.separator + skin_suffix; //testPrintPath(); } @@ -366,4 +369,8 @@ public class FilePath { public String getTemplatePath() { return templatePath; } + + public String getDataSkinPath() { + return dataSkinPath; + } } diff --git a/src/org/tizen/emulator/manager/tool/SelectSkin.java b/src/org/tizen/emulator/manager/tool/SelectSkin.java deleted file mode 100644 index a9dcbc4..0000000 --- a/src/org/tizen/emulator/manager/tool/SelectSkin.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Emulator Manager - * - * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * SeokYeon Hwang - * JiHye Kim - * YeongKyoon Lee - * - * 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.tool; - -import java.io.File; -import java.util.ArrayList; - -import org.tizen.emulator.manager.image.Skins; -import org.tizen.emulator.manager.logging.EMLogger; - -public class SelectSkin { - private ArrayList skinsList = new ArrayList(); - private Skins defaultSkin = null; - - private static SelectSkin instance = null; - static { - instance = new SelectSkin(); - } - - public static SelectSkin getInstance() { - return instance; - } - - private SelectSkin() { - try { - skinsList.add(new Skins(new File(FilePath.getInstance().getSkinPath()))); - defaultSkin = skinsList.get(0); - } catch (Exception e) { - EMLogger.getLogger().warning(e.getMessage()); - } - - - } - - public Skins getDefaultSkin() { - return defaultSkin; - } - - public void setDefaultSkin(Skins defaultSkin) { - this.defaultSkin = defaultSkin; - } -} diff --git a/src/org/tizen/emulator/manager/ui/detail/TableWidget.java b/src/org/tizen/emulator/manager/ui/detail/TableWidget.java index 58b70b4..2134121 100644 --- a/src/org/tizen/emulator/manager/ui/detail/TableWidget.java +++ b/src/org/tizen/emulator/manager/ui/detail/TableWidget.java @@ -49,8 +49,8 @@ import org.eclipse.swt.widgets.Spinner; import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.Text; import org.tizen.emulator.manager.EmulatorManager; +import org.tizen.emulator.manager.image.SkinList; import org.tizen.emulator.manager.image.Skin; -import org.tizen.emulator.manager.image.Skins; import org.tizen.emulator.manager.tool.CheckVirtualization; import org.tizen.emulator.manager.tool.StringResource; import org.tizen.emulator.manager.ui.MenuHandling; @@ -479,7 +479,6 @@ class SkinCombo extends TableWidget { Combo skinCombo; Skin oldSkin; Skin newSkin; - Skins skins; VMCreateHelper helper; public SkinCombo(boolean isCreate) { @@ -503,31 +502,34 @@ class SkinCombo extends TableWidget { value.skin = newSkin; if (newSkin != null) { value.skinPath = newSkin.getPath(); + } else { + value.skinPath = null; } } public boolean settingWidget(Table table, VMPropertyValue value) { oldSkin = newSkin = value.skin; - skins = value.getSkin(); ArrayList skinList = null; - if (skins != null) { - skinList = skins.findSkinList(value.resolution.getValue()); - } else { - skinList = new ArrayList(); - } + skinList = SkinList.getInstance().findSkinList(value.resolution.getValue()); helper = new VMCreateHelper(); skinCombo = helper.makeCombo(table); helper.addComboItem(skinCombo, skinList.toArray(), 0); if (!isCreateMode() && oldSkin != null) { + boolean find = false; for (int i = 0; i < skinCombo.getItemCount(); i++) { if (skinCombo.getItem(i).equals(oldSkin.toString())) { skinCombo.select(i); + find = true; break; } } + if (!find) { + skinCombo.add(oldSkin.toString(), 0); + skinCombo.select(0); + } } return true; } @@ -537,7 +539,10 @@ class SkinCombo extends TableWidget { skinCombo.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { String name = skinCombo.getItem(skinCombo.getSelectionIndex()); - newSkin = skins.findSkinUseName(name); + newSkin = SkinList.getInstance().findSkinUseName(name); + if (newSkin == null && name.equals(oldSkin)){ + newSkin = oldSkin; + } if (!isCreateMode()) { getListener().ChangeValue(getThis()); } @@ -552,13 +557,31 @@ class SkinCombo extends TableWidget { public void selectResolution(String resolution) { skinCombo.removeAll(); ArrayList skinList = null; - if (skins != null) { - skinList = skins.findSkinList(resolution); + skinList = SkinList.getInstance().findSkinList(resolution); + + helper.addComboItem(skinCombo, skinList.toArray(), 0); + + if (!isCreateMode() && oldSkin != null + && oldSkin.getResolution().equals(StringResource.SKIN_GENERAL)) { + boolean find = false; + for (int i = 0; i < skinCombo.getItemCount(); i++) { + if (skinCombo.getItem(i).equals(oldSkin.toString())) { + find = true; + break; + } + } + if (!find) { + skinList.add(0, oldSkin); + skinCombo.add(oldSkin.toString(), 0); + skinCombo.select(0); + } + } + + if (!skinList.isEmpty()) { + newSkin = skinList.get(0); } else { - skinList = new ArrayList(); + newSkin = null; } - helper.addComboItem(skinCombo, skinList.toArray(), 0); - newSkin = skinList.get(0); } public void closeWidget() { diff --git a/src/org/tizen/emulator/manager/ui/detail/VMPropertyView.java b/src/org/tizen/emulator/manager/ui/detail/VMPropertyView.java index 7fcf899..2a95bdb 100644 --- a/src/org/tizen/emulator/manager/ui/detail/VMPropertyView.java +++ b/src/org/tizen/emulator/manager/ui/detail/VMPropertyView.java @@ -38,7 +38,6 @@ import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.TableItem; import org.tizen.emulator.manager.image.BaseImage; -import org.tizen.emulator.manager.tool.SelectSkin; import org.tizen.emulator.manager.ui.MessageDialog; import org.tizen.emulator.manager.vms.Creator; import org.tizen.emulator.manager.vms.VMPropertyValue; @@ -130,7 +129,7 @@ public class VMPropertyView implements TableWidgetChangeListener { public void modifyView(Button confirm) { // TODO: select Skins... - oldValue.setSkin(SelectSkin.getInstance().getDefaultSkin()); + //oldValue.setSkin(SelectSkin.getInstance().getDefaultSkin()); newValue = oldValue.clone(); confirmButton = confirm; @@ -139,7 +138,7 @@ public class VMPropertyView implements TableWidgetChangeListener { public void createView(Button confirm) { // TODO: select Skins... - oldValue.setSkin(SelectSkin.getInstance().getDefaultSkin()); + //oldValue.setSkin(SelectSkin.getInstance().getDefaultSkin()); newValue = oldValue.clone(); confirmButton = confirm; diff --git a/src/org/tizen/emulator/manager/vms/Creator.java b/src/org/tizen/emulator/manager/vms/Creator.java index 9d2f0ff..8ab0508 100644 --- a/src/org/tizen/emulator/manager/vms/Creator.java +++ b/src/org/tizen/emulator/manager/vms/Creator.java @@ -34,6 +34,8 @@ import java.io.File; import java.util.ArrayList; import java.util.List; +import org.tizen.emulator.manager.image.Skin; +import org.tizen.emulator.manager.image.SkinList; import org.tizen.emulator.manager.tool.FilePath; import org.tizen.emulator.manager.tool.StringResource; import org.tizen.emulator.manager.vms.xml.EmulatorConfiguration; @@ -197,12 +199,13 @@ public class Creator { newVM.resolutionType.setHeight(Integer.valueOf(newVM.resolution.substring(i+1,newVM.resolution.length()))); */ // TODO - /* - if (newVM.getSkin() != null) { - newVM.skinPath = newVM.getSkin().findSkin(newVM.resolution.getValue()).getPath(); - }else { - newVM.skinPath = null; - }*/ + + if (newVM.skin == null) { + ArrayList list = SkinList.getInstance().findSkinList(newVM.resolution.getValue()); + if (!list.isEmpty()) { + newVM.skin = list.get(0); + } + } } private void createRam() {} diff --git a/src/org/tizen/emulator/manager/vms/Modifier.java b/src/org/tizen/emulator/manager/vms/Modifier.java index 0e9daa3..1dcccb8 100644 --- a/src/org/tizen/emulator/manager/vms/Modifier.java +++ b/src/org/tizen/emulator/manager/vms/Modifier.java @@ -76,7 +76,11 @@ public class Modifier { } if (newVM.skin != oldVM.skin) { - property.getConfiguration().getDevice().getDisplay().getSkinPath().setPath(newVM.skin.getPath()); + if (newVM.skin != null) { + property.getConfiguration().getDevice().getDisplay().getSkinPath().setPath(newVM.skin.getPath()); + } else { + property.getConfiguration().getDevice().getDisplay().getSkinPath().setPath(null); + } } if (newVM.ramSize != oldVM.ramSize) { diff --git a/src/org/tizen/emulator/manager/vms/RESOLUTION.java b/src/org/tizen/emulator/manager/vms/RESOLUTION.java index 64a5af7..e10232f 100644 --- a/src/org/tizen/emulator/manager/vms/RESOLUTION.java +++ b/src/org/tizen/emulator/manager/vms/RESOLUTION.java @@ -32,7 +32,8 @@ package org.tizen.emulator.manager.vms; import org.tizen.emulator.manager.vms.xml.DisplayType.Resolution; public enum RESOLUTION { - /*HVGA(320, 480,"HVGA", 160),*/ WVGA(480,800,"WVGA", 207), /*WSVGA(600,1024, "WSVGA", 224),*/ HD(720, 1280, "HD", 316); + HVGA(320, 480,"HVGA", 160), WVGA(480,800,"WVGA", 207), /*WSVGA(600,1024, "WSVGA", 224),*/ HD(720, 1280, "HD", 316), + HIGH(2560, 1600, "", 316), MID(1280, 800, "", 316), FULLHD(1920, 1080, "", 316); private Resolution resolution; private String type; @@ -48,7 +49,11 @@ public enum RESOLUTION { this.dpi = dpi; strValue = width +"x" + height; - str = type + "(" + width + "x" + height + ")"; + if (type.isEmpty()) { + str = width + "x" + height; + } else { + str = type + "(" + width + "x" + height + ")"; + } } public int getDPI() { diff --git a/src/org/tizen/emulator/manager/vms/VMPropertyValue.java b/src/org/tizen/emulator/manager/vms/VMPropertyValue.java index d9ea31e..62dec3a 100644 --- a/src/org/tizen/emulator/manager/vms/VMPropertyValue.java +++ b/src/org/tizen/emulator/manager/vms/VMPropertyValue.java @@ -31,19 +31,23 @@ package org.tizen.emulator.manager.vms; import java.io.File; +import java.util.ArrayList; import org.tizen.emulator.manager.image.BaseImage; +import org.tizen.emulator.manager.image.SkinList; import org.tizen.emulator.manager.image.Skin; -import org.tizen.emulator.manager.image.Skins; +import org.tizen.emulator.manager.logging.EMLogger; import org.tizen.emulator.manager.tool.CheckVirtualization; -import org.tizen.emulator.manager.tool.SelectSkin; import org.tizen.emulator.manager.vms.xml.DisplayType.Resolution; import org.tizen.emulator.manager.vms.xml.TouchType; // Wrapper for convenient property managing... public class VMPropertyValue implements Cloneable { + public static ArrayList customSkins; + static { + customSkins = new ArrayList(); + } public BaseImage image; - public Skins skinList; public VMsProperty template; public String vmsName; @@ -78,6 +82,7 @@ public class VMPropertyValue implements Cloneable { public VMPropertyValue(BaseImage image, VMsProperty template) { this.image = image; this.template = template; + vmsName = ""; if (this.image == null) { @@ -91,13 +96,15 @@ public class VMPropertyValue implements Cloneable { baseImagePath = image.getPath(); baseImagePathName = image.getImagePathName(); settingConfigure(template); - if (skin == null && skinList != null) { - skin = skinList.findSkin(resolution.getValue()); - } - if (skin != null) { - skinPath = skin.getPath(); - } } +/* + if (skin == null && skinList != null) { + skin = skinList.findSkin(resolution.getValue()); + } + if (skin != null) { + skinPath = skin.getPath(); + } +*/ } public VMPropertyValue(VMsProperty property) { @@ -123,7 +130,7 @@ public class VMPropertyValue implements Cloneable { public VMPropertyValue clone() { VMPropertyValue dest = new VMPropertyValue(); dest.image = this.image; - dest.skinList = this.skinList; + //dest.skinList = this.skinList; dest.template = this.template; dest.vmsName = this.vmsName; @@ -226,12 +233,50 @@ public class VMPropertyValue implements Cloneable { if (d.getResolution().getWidth() == re.getWidth() && d.getResolution().getHeight() == re.getHeight()) { resolution = d; + break; } } dpi = property.getConfiguration().getDevice().getDisplay().getDensity().getValue(); // TODO : Skin Type.. keyType = 1; + + if (property.getConfiguration().getDevice().getDisplay().getSkinPath() != null) { + skinPath = property.getConfiguration().getDevice().getDisplay().getSkinPath().getPath(); + } + + if (skinPath != null) { + skin = SkinList.getInstance().findSkinUsePath(skinPath); + + // add custom skin + if (skin == null) { + for (Skin s : customSkins) { + if (s.getPath().equals(skinPath)) { + skin = s; + break; + } + } + if (skin == null) { + try { + skin = new Skin(new File(skinPath)); + } catch (Exception e) { + EMLogger.getLogger().warning(e.getMessage()); + skin = null; + } + if (skin != null) { + customSkins.add(skin); + } + } + } + } else { + /* + ArrayList list = SkinList.getInstance().findSkinList(resolution.getValue()); + if (!list.isEmpty()) { + skin = list.get(0); + } + */ + } + /* if (SelectSkin.getInstance().getDefaultSkin() != null) { if (property.getConfiguration().getDevice().getDisplay().getSkinPath() != null) { skinPath = property.getConfiguration().getDevice().getDisplay().getSkinPath().getPath(); @@ -246,6 +291,7 @@ public class VMPropertyValue implements Cloneable { } else { skin = null; } + */ // fileSharePath = property.getConfiguration().getUsability().getFileSharing().getPath(); @@ -279,11 +325,15 @@ public class VMPropertyValue implements Cloneable { dpi = RESOLUTION.HD.getDPI(); // this value be related to resolution // TODO : Skin Path //skinPath = FilePath.getInstance().getDefaultSkinPath() + File.separator + "emul_" + resolution; - if (SelectSkin.getInstance().getDefaultSkin() != null) { - skin = SelectSkin.getInstance().getDefaultSkin().findSkin(resolution.getValue()); + ArrayList list = SkinList.getInstance().findSkinList(resolution.getValue()); + if (!list.isEmpty()) { + skin = list.get(0); } + if (skin!= null) { skinPath = skin.getPath(); + } else { + skinPath = null; } keyType = 1; @@ -312,7 +362,7 @@ public class VMPropertyValue implements Cloneable { settingConfigure(template); } - +/* public void setSkin(Skins skin) { this.skinList = skin; } @@ -320,4 +370,5 @@ public class VMPropertyValue implements Cloneable { public Skins getSkin() { return skinList; } +*/ } -- 2.7.4