[Title] emulator-manager : add select skin menu to the CLI
authorjihye kim <jihye1128.kim@samsung.com>
Wed, 31 Oct 2012 02:57:23 +0000 (11:57 +0900)
committerjihye kim <jihye1128.kim@samsung.com>
Wed, 31 Oct 2012 02:57:23 +0000 (11:57 +0900)
[Desc.] add select skin menu to the CLI
[Issue] N/A

package/changelog
package/pkginfo.manifest
src/org/tizen/emulator/manager/console/Action.java
src/org/tizen/emulator/manager/console/ActionList.java
src/org/tizen/emulator/manager/console/ConsoleCreateVM.java
src/org/tizen/emulator/manager/image/Skins.java
src/org/tizen/emulator/manager/ui/detail/TableWidget.java
src/org/tizen/emulator/manager/vms/Creator.java
src/org/tizen/emulator/manager/vms/Modifier.java
src/org/tizen/emulator/manager/vms/VMPropertyValue.java

index 4155071..d341f23 100644 (file)
@@ -1,3 +1,9 @@
+*1.3.49
+- add 'select skin path' menu.
+- modify console mode.
+- add 'Skin' class
+== 김지혜 <jihye1128.kim@samsung.com> 2012-10-31
+
 *1.3.48
 - change multi touch's max point 3->6
 - update version
index 066240f..1462b84 100644 (file)
@@ -1,5 +1,5 @@
 Source: emulator-manager
-Version: 1.3.48
+Version: 1.3.49
 Maintainer: Yeong-Kyoon Lee<yeongkyoon.lee@samsung.com>
 
 Package: emulator-manager
index 58c09f1..43ec543 100644 (file)
@@ -253,6 +253,7 @@ class Actions {
 
     public final static String OP_RESOLUTION    = "resolution";
     public final static String OP_DPI                   = "dpi";
+    public final static String OP_SKIN                  = "skin";
     public final static String OP_KEYTYPE               = "key-type";
     public final static String OP_RAM                   = "ram-size";
     public final static String OP_FILESHARE     = "file-sharing";
index 873eb97..c496815 100644 (file)
@@ -345,6 +345,17 @@ class Create extends Action {
                                , RESOLUTION.HD.getType(), false, true));
                commandList.add(new Command("d", Actions.OP_DPI,
                                "DPI. (100 ~ 480)", Integer.toString(property.dpi), false, true));
+               
+               /** TODO : resolution and skin..***********************************************/
+               String skinType = "";
+               int i = 1;
+               skinType += Integer.toString(i++) + "(phone_shape_skin) | ";
+               skinType += Integer.toString(i++) + "(general_purpose_skin)";
+
+               commandList.add(new Command("k", Actions.OP_SKIN,
+                               "Select skin style (" + skinType + ")", "1", false, true));
+               /*****************************************************************************/
+
                /*
                commandList.add(new Command("k", Actions.OP_KEYTYPE,
                                "Skin'front button type. (1 | 3)", Integer.toString(property.keyType), false, true));
@@ -403,6 +414,16 @@ class Modify extends Action {
                commandList.add(new Command("d", Actions.OP_DPI,
                                "DPI. (100 ~ 480)", Integer.toString(property.dpi), false, true));
 
+               /** TODO : resolution and skin..***********************************************/
+               String skinType = "";
+               int i = 1;
+               skinType += Integer.toString(i++) + "(phone_shape_skin) | ";
+               skinType += Integer.toString(i++) + "(general_purpose_skin)";
+
+               commandList.add(new Command("k", Actions.OP_SKIN,
+                               "Select skin style (" + skinType + ")", "1", false, true));
+               /*****************************************************************************/
+
                /*
                commandList.add(new Command("k", Actions.OP_KEYTYPE,
                                "Skin'front button type. (1 | 3)", Integer.toString(property.keyType), false, true));
index a6c859c..aa2b100 100644 (file)
@@ -38,6 +38,7 @@ import org.tizen.emulator.manager.image.BaseImage;
 import org.tizen.emulator.manager.image.Platform;
 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;
@@ -176,6 +177,7 @@ public class ConsoleCreateVM {
                return true;
        }
 
+       private Command skinCommand = null;
        public void setOptions(Command c, VMPropertyValue prop) throws ConsoleException {
                boolean check = false;
                // Options
@@ -183,6 +185,15 @@ public class ConsoleCreateVM {
                        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);
+                               }
+                       }
                }
                else if (c.getLongName() == Actions.OP_DPI) {
                        check = false;
@@ -196,6 +207,10 @@ public class ConsoleCreateVM {
                                throw new ConsoleException("DPI value (" + c.getCurrentValue() + ") is not avaliable.");
                        }       
                }
+               else if (c.getLongName() == Actions.OP_SKIN) {
+                       skinCommand = c;
+                       selectSkin(c, prop);
+               }
                /*
                else if (c.getLongName() == Actions.OP_KEYTYPE) {
                        check = false;
@@ -242,6 +257,32 @@ 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.");
+                               }
+                       }
+                       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();
+                       }
+               } else {
+                       throw new ConsoleException("Skin value (" + c.getCurrentValue() + ") is not avaliable.");
+               }
+       }
+
        private boolean checkGLAcceleration(String currentValue) throws ConsoleException{
                String value = currentValue.toLowerCase();
                if (value.equals("true")) {
index 040be06..5131c34 100644 (file)
@@ -36,8 +36,8 @@ import org.tizen.emulator.manager.logging.EMLogger;
 import org.tizen.emulator.manager.tool.StringResource;
 
 public class Skins {
-       private ArrayList<Skin> skins;
-       private String path;
+       private ArrayList<Skin> skins = null;
+       private String path = null;
 
        public Skins(File dir) throws Exception {
                if (dir.exists()) {
@@ -77,6 +77,17 @@ public class Skins {
                return null;
        }
 
+       public Skin findGeneralSkin() {
+               if (skins != null) {
+                       for (Skin skin : skins) {
+                               if (skin.getResolution().equals(StringResource.SKIN_GENERAL)) {
+                                       return skin;
+                               }
+                       }
+               }
+               return null;
+       }
+
        public Skin findSkinUsePath(String path) {
                if (skins != null) {
                        for (Skin skin : skins) {
index 6427a64..58b70b4 100644 (file)
@@ -492,18 +492,30 @@ class SkinCombo extends TableWidget {
        }
 
        public String getValue(VMPropertyValue value) {
-               return value.skin.getName();
+               if (value.skin != null) {
+                       return value.skin.getName();
+               } else {
+                       return "";
+               }
        }
 
        public void setValue(VMPropertyValue value) {
                value.skin = newSkin;
+               if (newSkin != null) {
+                       value.skinPath = newSkin.getPath();
+               }
        }
 
        public boolean settingWidget(Table table, VMPropertyValue value) {
                oldSkin = newSkin = value.skin;
 
                skins = value.getSkin();
-               ArrayList<Skin> skinList = skins.findSkinList(value.resolution.getValue());
+               ArrayList<Skin> skinList = null;
+               if (skins != null) {
+                       skinList = skins.findSkinList(value.resolution.getValue());
+               } else {
+                       skinList = new ArrayList<Skin>();
+               }
 
                helper = new VMCreateHelper();
                skinCombo = helper.makeCombo(table);
@@ -539,7 +551,12 @@ class SkinCombo extends TableWidget {
 
        public void selectResolution(String resolution) {
                skinCombo.removeAll();
-               ArrayList<Skin> skinList = skins.findSkinList(resolution);
+               ArrayList<Skin> skinList = null;
+               if (skins != null) {
+                       skinList = skins.findSkinList(resolution);
+               } else {
+                       skinList = new ArrayList<Skin>();
+               }
                helper.addComboItem(skinCombo, skinList.toArray(), 0);
                newSkin = skinList.get(0);
        }
index 2553671..9d2f0ff 100644 (file)
@@ -275,7 +275,11 @@ public class Creator {
                ec.getDevice().getDisplay().getDensity().setValue(newVM.dpi);
 
                ec.getDevice().getDisplay().setSkinPath(factory.createDisplayTypeSkinPath());
-               ec.getDevice().getDisplay().getSkinPath().setPath(newVM.skin.getPath());
+               if (newVM.skin != null) {
+                       ec.getDevice().getDisplay().getSkinPath().setPath(newVM.skin.getPath());
+               } else if (newVM.skinPath != null) {
+                       ec.getDevice().getDisplay().getSkinPath().setPath(newVM.skinPath);
+               }
 
                ec.getDevice().setRAM(factory.createRamType());
                ec.getDevice().getRAM().setSize(factory.createRamTypeSize());
index a2a24a9..0e9daa3 100644 (file)
@@ -56,10 +56,12 @@ public class Modifier {
                        }
                        */
                        if (newVM.skin != null) {
-                               //newVM.skinPath = newVM.getSkin().findSkin(newVM.resolution.getValue()).getPath();
-                               property.getConfiguration().getDevice().getDisplay().getSkinPath().setPath(newVM.skin.getPath());
+                               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;
+                               newVM.skinPath = null;
                        }
                }
                /* else {
index 9e3589a..d9ea31e 100644 (file)
@@ -58,7 +58,7 @@ public class VMPropertyValue implements Cloneable {
        public int dpi;
        public int keyType;
        public Skin skin;
-       //public String skinPath;
+       public String skinPath;
 
        public int ramSize;
 
@@ -94,6 +94,9 @@ public class VMPropertyValue implements Cloneable {
                        if (skin == null && skinList != null) {
                                skin = skinList.findSkin(resolution.getValue());
                        }
+                       if (skin != null) {
+                               skinPath = skin.getPath();
+                       }
                }
        }
 
@@ -134,7 +137,7 @@ public class VMPropertyValue implements Cloneable {
                dest.resolution         = this.resolution;
                dest.dpi                        = this.dpi;
                dest.skin                       = this.skin;
-               //dest.skinPath                 = this.skinPath;
+               dest.skinPath           = this.skinPath;
                dest.keyType            = this.keyType;
 
                dest.ramSize = this.ramSize;
@@ -231,10 +234,14 @@ public class VMPropertyValue implements Cloneable {
                keyType = 1;
                if (SelectSkin.getInstance().getDefaultSkin() != null) {
                        if (property.getConfiguration().getDevice().getDisplay().getSkinPath() != null) {
+                               skinPath = property.getConfiguration().getDevice().getDisplay().getSkinPath().getPath();
                                skin = SelectSkin.getInstance().getDefaultSkin().findSkinUsePath
-                                               (property.getConfiguration().getDevice().getDisplay().getSkinPath().getPath());
+                                               (skinPath);
                        } else {
-                               skin = SelectSkin.getInstance().getDefaultSkin().findSkin(resolution.getValue());;
+                               skin = SelectSkin.getInstance().getDefaultSkin().findSkin(resolution.getValue());
+                               if (skin != null) {
+                                       skinPath = skin.getPath();
+                               }
                        }
                } else {
                        skin = null;
@@ -275,6 +282,10 @@ public class VMPropertyValue implements Cloneable {
                if (SelectSkin.getInstance().getDefaultSkin() != null) {
                        skin = SelectSkin.getInstance().getDefaultSkin().findSkin(resolution.getValue());
                }
+               if (skin!= null) {
+                       skinPath = skin.getPath();
+               }
+
                keyType = 1;
                //