skin: support multiple skin shape
authorminkee.lee <minkee.lee@samsung.com>
Mon, 25 Jan 2016 14:11:31 +0000 (23:11 +0900)
committerSeokYeon Hwang <syeon.hwang@samsung.com>
Thu, 28 Jan 2016 05:20:07 +0000 (14:20 +0900)
Skin (info.ini) is changed to define multiple skin shape.
So, emulator-manager should support it.

Change-Id: If55b12e52c506fd85ee502cc22f651f8a72b4bf2
Signed-off-by: minkee.lee <minkee.lee@samsung.com>
12 files changed:
src/org/tizen/emulator/manager/devices/DeviceTemplate.java
src/org/tizen/emulator/manager/devices/DeviceTemplateValue.java
src/org/tizen/emulator/manager/platform/Skin.java
src/org/tizen/emulator/manager/platform/SkinList.java
src/org/tizen/emulator/manager/ui/renewal/item/modify/common/ResolutionSubItem.java
src/org/tizen/emulator/manager/ui/renewal/item/modify/common/SkinShapeItem.java
src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/DeviceTemplateItem.java
src/org/tizen/emulator/manager/ui/renewal/tableviewer/CreateVMTable.java
src/org/tizen/emulator/manager/ui/renewal/tableviewer/CreateVMTableViewer.java
src/org/tizen/emulator/manager/ui/renewal/tableviewer/VMListTable.java
src/org/tizen/emulator/manager/ui/widgets/VMButton.java
src/org/tizen/emulator/manager/vms/SkinShapeList.java [new file with mode: 0644]

index 81d8f67..f18949e 100644 (file)
@@ -347,8 +347,8 @@ public class DeviceTemplate {
                                } else {
                                        value.setSkinPath(skinPath);
                                        value.setSkinName(skinName);
-                                       value.setSkinShape(skinShape);
                                }
+                               value.setSkinShape(skinShape);
                        }
                }
 
index db686e2..1175c64 100644 (file)
@@ -85,6 +85,7 @@ public class DeviceTemplateValue implements Cloneable {
                if (skin != null) {
                        sb.append("skin: " + skin.getName() + StringResources.NEW_LINE);
                }
+               sb.append("skin shape : " + skinShape.toString() + StringResources.NEW_LINE);
                sb.append("size : " + displaySize + StringResources.NEW_LINE);
                sb.append("ram : " + ramSize + StringResources.NEW_LINE);
                sb.append("processor : " + cpuCount + StringResources.NEW_LINE);
@@ -284,7 +285,6 @@ public class DeviceTemplateValue implements Cloneable {
                this.skin = skin;
                skinName = skin.getName();
                skinPath = skin.getPath();
-               skinShape = skin.getSkinShape();
        }
 
        public void setSkinByManager(Skin skin) {
@@ -402,6 +402,10 @@ public class DeviceTemplateValue implements Cloneable {
                        return false;
                }
 
+               if (skinShape != dest.skinShape) {
+                       return false;
+               }
+
                // TODO need to check rest variables ?
 
                if (!isAdditionalDeviceEquals(dest.getAdditionalDevices())) {
index 4a26a4a..0f5f602 100644 (file)
@@ -38,8 +38,8 @@ import java.util.logging.Level;
 import org.tizen.emulator.manager.logging.EMLogger;
 import org.tizen.emulator.manager.resources.StringResources;
 import org.tizen.emulator.manager.vms.RESOLUTION;
-import org.tizen.emulator.manager.vms.SKIN_SHAPE;
 import org.tizen.emulator.manager.vms.SKIN_TYPE;
+import org.tizen.emulator.manager.vms.SkinShapeList;
 
 public class Skin {
        private String name;
@@ -49,7 +49,7 @@ public class Skin {
 //     private SKIN_BUTTON_TYPE buttonType;
        private int priorty = 5;
        private String profile;
-       private SKIN_SHAPE skinShape;
+       private SkinShapeList skinShapeList;
 
        public Skin(File path) throws IOException {
                loadProperty(path);
@@ -69,7 +69,7 @@ public class Skin {
                                String height = prop.getProperty(StringResources.SKIN_HEIGHT);
                                priorty = Integer.valueOf(prop.getProperty(StringResources.SKIN_PRIORITY, "5")); //$NON-NLS-1$
                                profile = prop.getProperty(StringResources.SKIN_PROFILE, StringResources.SKIN_GENERAL);
-                               skinShape = SKIN_SHAPE.find(prop.getProperty(StringResources.SKIN_SHAPE, "square")); //$NON-NLS-1$
+                               skinShapeList = SkinShapeList.create(prop.getProperty(StringResources.SKIN_SHAPE, "square")); //$NON-NLS-1$
 
                                String re = ""; //$NON-NLS-1$
                                if(width.equals(StringResources.SKIN_GENERAL) && height.equals(StringResources.SKIN_GENERAL)) {
@@ -141,8 +141,8 @@ public class Skin {
                this.path = path;
        }
 
-       public SKIN_SHAPE getSkinShape() {
-               return skinShape;
+       public SkinShapeList getSkinShapeList() {
+               return skinShapeList;
        }
 
        @ Override
index 5a27104..562ecff 100644 (file)
@@ -80,7 +80,7 @@ public class SkinList {
                if (list != null) {
                        for (Skin skin : list) {
                                if (skin.getType() == SKIN_TYPE.GENERAL || skin.getResolution().equals(resolution)) {
-                                       if (skinShape == SKIN_SHAPE.NONE || skinShape == skin.getSkinShape()){
+                                       if (skinShape == SKIN_SHAPE.NONE || skin.getSkinShapeList().hasShape(skinShape)){
                                                returnSkins.add(skin);
                                        }
                                }
index 3c30944..47b4c1a 100644 (file)
@@ -405,6 +405,10 @@ public class ResolutionSubItem {
 
 
        public boolean isResolutionExist(RESOLUTION re) {
+               if (re == null) {
+                       return false;
+               }
+
                for (RESOLUTION r : resList) {
                        if (r.getStrValue().equals(re.getStrValue())) {
                                return true;
index 235f60d..359aba5 100644 (file)
@@ -229,6 +229,7 @@ public class SkinShapeItem extends ComboItem {
        public void itemSelected(ComboBox comboBox) {
                // This is called when combo item is selected
                skinShape = (SKIN_SHAPE)getSelectedData();
+               setValue();
                comboSelected();
        }
 
index d43bc72..1c60bc7 100644 (file)
@@ -43,6 +43,7 @@ import org.tizen.emulator.manager.ui.renewal.item.modify.comp.SubTreeModifyItem;
 import org.tizen.emulator.manager.ui.renewal.item.modify.comp.TreeItemTitle;
 import org.tizen.emulator.manager.ui.renewal.item.modify.comp.TreeModifyItem;
 import org.tizen.emulator.manager.ui.renewal.widgets.ComboBox;
+import org.tizen.emulator.manager.vms.SKIN_SHAPE;
 
 public class DeviceTemplateItem extends ComboItem {
 
@@ -78,16 +79,22 @@ public class DeviceTemplateItem extends ComboItem {
 
                if (getItemListComp().isDetailMode()) {
                        createDetailItem();
+                       return;
+               }
+               createCombo(treeModifyItem, COMBO_WIDTH);
+
+               if (profile == null) {
+                       return;
+               }
 
-               } else {
-                       createCombo(treeModifyItem, COMBO_WIDTH);
-                       if (profile != null) {
-                               // TODO
-                               for (DeviceTemplate temp : profile.getTemplateList()) {
-                                       comboBox.addItem(temp.getValue().getName(), temp);
-                               }
+               SKIN_SHAPE imageSkinShape = propertyValue.getImageSkinShape();
+               for (DeviceTemplate temp : profile.getTemplateList()) {
+                       if (imageSkinShape == SKIN_SHAPE.NONE ||
+                                       imageSkinShape == temp.getValue().getSkinShape()) {
+                               comboBox.addItem(temp.getValue().getName(), temp);
                        }
                }
+
                selectItem(false);
        }
 
index 143a735..e92ffea 100644 (file)
@@ -50,7 +50,7 @@ import org.tizen.emulator.manager.vms.SKIN_SHAPE;
 public class CreateVMTable {
        private Table table;
 
-       private CreateVMTableViewer viewer;
+       private final CreateVMTableViewer viewer;
 
        private BaseImage image;
 
index 8715137..4120727 100644 (file)
@@ -410,7 +410,7 @@ public class CreateVMTableViewer extends AbstractTableViewer {
                                                + StringResources.NEW_LINE;
                                message += "\tSkin: " + skin.getName() + StringResources.NEW_LINE
                                                + "\tSkin Resolution: " + skin.getResolution() + StringResources.NEW_LINE
-                                               + "\tSkin Shape: " + skin.getSkinShape() + StringResources.NEW_LINE
+                                               + "\tSkin Shape: " + skin.getSkinShapeList().toString() + StringResources.NEW_LINE
                                                + StringResources.NEW_LINE
                                                + StringResources.NEW_LINE;
                                message += "Do you want to use this skin?"
index 966eb95..f0d4a27 100644 (file)
@@ -64,7 +64,7 @@ import org.tizen.emulator.manager.vms.VMPropertyValue;
 import org.tizen.emulator.manager.vms.exception.VMWorkerException;
 
 public class VMListTable {
-       private VMListTableViewer viewer;
+       private final VMListTableViewer viewer;
        private Table table;
 
        public VMListTable(VMListTableViewer viewer) {
@@ -424,7 +424,7 @@ public class VMListTable {
                        displayTip = displayTip + StringResources.NEW_LINE + StringResources.NEW_LINE
                        + "Skin: " + value.skin.getName()
                        + StringResources.NEW_LINE
-                       + "Skin shape: " + value.skin.getSkinShape().toString();
+                       + "Skin shape: " + value.skin.getSkinShapeList().toString();
                }
                item.setToolTipText(5, displayTip);
                // 6 - file sharing
index d201620..38bc741 100644 (file)
@@ -88,7 +88,7 @@ public class VMButton extends ImageButton {
        private int BUTTON_Y_OFFSET = 3;
        private int TEXT_X_POINT = 50 + BUTTON_X_OFFSET;
        private int TEXT_Y_POINT = 36 + BUTTON_Y_OFFSET;
-       private int TEXT_Y_GAP = 18;
+       private final int TEXT_Y_GAP = 18;
        private int TITLE_X_OFFSET = 9;
        private int TITLE_Y_OFFSET = 6;
 
@@ -135,7 +135,7 @@ public class VMButton extends ImageButton {
                if (button.getProperty() != null) {
                        Skin skin = button.getProperty().getPropertyValue().skin;
                        if (skin != null) {
-                               skinShape = skin.getSkinShape();
+                               skinShape = skin.getSkinShapeList().get(0);
                        }
                }
 
@@ -320,7 +320,7 @@ public class VMButton extends ImageButton {
                }
        }
 
-       private PaintListener VMButtonPaintListener = new PaintListener() {
+       private final PaintListener VMButtonPaintListener = new PaintListener() {
 
                @Override
                public void paintControl(PaintEvent e) {
@@ -336,7 +336,7 @@ public class VMButton extends ImageButton {
                        if (button.getProperty() != null) {
                                Skin skin = button.getProperty().getPropertyValue().skin;
                                if (skin != null) {
-                                       skinShape = skin.getSkinShape();
+                                       skinShape = skin.getSkinShapeList().get(0);
                                }
 
                                // If VM is custom,
@@ -393,7 +393,7 @@ public class VMButton extends ImageButton {
                }
        };
 
-       private Listener mouseListener = new Listener() {
+       private final Listener mouseListener = new Listener() {
 
                @Override
                public void handleEvent(Event event) {
diff --git a/src/org/tizen/emulator/manager/vms/SkinShapeList.java b/src/org/tizen/emulator/manager/vms/SkinShapeList.java
new file mode 100644 (file)
index 0000000..ef77e6e
--- /dev/null
@@ -0,0 +1,99 @@
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Minkee Lee <minkee.lee@samsung.com>
+ * JiHye Kim <jihye424.kim@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Sangho Park <sangho.p@samsung.com>
+ *
+ * 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.vms;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class SkinShapeList {
+
+       private final List<SKIN_SHAPE> list = new ArrayList<SKIN_SHAPE>();
+
+       private SkinShapeList() {}
+
+       // return new instance
+       public static SkinShapeList create(String shapeProperty) {
+               SkinShapeList skinShapeList = new SkinShapeList();
+
+               if (shapeProperty == null) {
+                       shapeProperty = SKIN_SHAPE.SQUARE.name();
+               }
+
+               String arr[] = shapeProperty.split(",");
+               for (String str : arr) {
+                       skinShapeList.add(SKIN_SHAPE.find(str.trim()));
+               }
+
+               // set default
+               if (skinShapeList.list.size() == 0) {
+                       skinShapeList.add(SKIN_SHAPE.SQUARE);
+               }
+
+               return skinShapeList;
+       }
+
+       public void add(SKIN_SHAPE shape) {
+               if (!hasShape(shape)) {
+                       list.add(shape);
+               }
+       }
+
+       public SKIN_SHAPE get(int index) {
+               if (list.size()  >=  index + 1) {
+                       return list.get(index);
+               }
+               return null;
+       }
+
+       public int size() {
+               return list.size();
+       }
+
+       public boolean hasShape(SKIN_SHAPE shape) {
+               for (SKIN_SHAPE thisShape : list) {
+                       if (thisShape == shape) {
+                               return true;
+                       }
+               }
+               return false;
+       }
+
+       @Override
+       public String toString() {
+               String str = "";
+               for (SKIN_SHAPE shape : list) {
+                       str = str.isEmpty() ? shape.toString() : str + ", " + shape.toString();
+               }
+               return str;
+       }
+
+}