device-template: draw device template dialog using XML.
authorminkee.lee <minkee.lee@samsung.com>
Wed, 14 Oct 2015 07:55:14 +0000 (16:55 +0900)
committerminkee.lee <minkee.lee@samsung.com>
Wed, 14 Oct 2015 08:00:12 +0000 (17:00 +0900)
- Now dialog use sample XML (/xsd/template-ui-mobile.xml)

Change-Id: I60d2eb237873500f21d26109f66f7e4ec6811e72
Signed-off-by: minkee.lee <minkee.lee@samsung.com>
16 files changed:
src/org/tizen/emulator/manager/devices/DeviceTemplateValue.java
src/org/tizen/emulator/manager/devices/SubDeviceItem.java
src/org/tizen/emulator/manager/template/TemplateLoader.java
src/org/tizen/emulator/manager/ui/renewal/dialog/ItemListLoader.java [new file with mode: 0644]
src/org/tizen/emulator/manager/ui/renewal/dialoghandler/DeviceTemplateDialogHandler.java
src/org/tizen/emulator/manager/ui/renewal/dialoghandler/VMModifyHandler.java
src/org/tizen/emulator/manager/ui/renewal/item/ItemName.java [new file with mode: 0644]
src/org/tizen/emulator/manager/ui/renewal/item/ItemType.java [new file with mode: 0644]
src/org/tizen/emulator/manager/ui/renewal/item/OptionName.java [new file with mode: 0644]
src/org/tizen/emulator/manager/ui/renewal/item/modify/common/CheckBoxItem.java
src/org/tizen/emulator/manager/ui/renewal/item/modify/common/ConnectivityItem.java [moved from src/org/tizen/emulator/manager/ui/renewal/item/modify/common/DeviceItem.java with 67% similarity]
src/org/tizen/emulator/manager/ui/renewal/item/modify/common/DisplayItem.java
src/org/tizen/emulator/manager/ui/renewal/item/modify/common/SensorItem.java
src/org/tizen/emulator/manager/ui/renewal/item/modify/comp/PropertyValue.java
src/org/tizen/emulator/manager/ui/renewal/item/modify/template/CameraItem.java
xsd/template-ui-mobile.xml [new file with mode: 0644]

index 3eaee07..4656178 100644 (file)
@@ -78,7 +78,9 @@ public class DeviceTemplateValue implements Cloneable {
                StringBuilder sb = new StringBuilder();
                sb.append("name : " + name + StringResources.NEW_LINE);
                sb.append("profile : " + profile + StringResources.NEW_LINE);
-               sb.append("resolution : " + resolution.toString() + StringResources.NEW_LINE);
+               if (resolution != null) {
+                       sb.append("resolution : " + resolution.toString() + StringResources.NEW_LINE);
+               }
                sb.append("width : " + displayWidth + StringResources.NEW_LINE);
                sb.append("height : " + displayHeight + StringResources.NEW_LINE);
                sb.append("size : " + displaySize + StringResources.NEW_LINE);
@@ -429,6 +431,55 @@ public class DeviceTemplateValue implements Cloneable {
                return true;
        }
 
+       private SubDevice findSubDevice(String name) {
+               for (SubDevice sub : additionalDevices) {
+                       if (sub.getName().equals(name)) {
+                               return sub;
+                       }
+               }
+               return null;
+       }
+
+
+       public void addOrUpdateSubDevices(SubDevice newSubDevice) {
+               SubDevice subDevice = findSubDevice(newSubDevice.getName());
+
+               if (subDevice == null) {
+                       // Add if not exist.
+                       additionalDevices.add(newSubDevice);
+
+               } else {
+                       updateSubDevice(subDevice, newSubDevice);
+               }
+       }
+
+       private void updateSubDevice(SubDevice oldOne, SubDevice newOne) {
+               for (SubDeviceItem newItem : newOne.getItems()) {
+                       SubDeviceItem subDeviceItem = findSubDeviceItem(oldOne, newItem.getId());
+                       if (subDeviceItem == null) {
+                               // Add
+                               oldOne.addSubDeviceItem(newItem);
+
+                       } else {
+                               updateSubDeviceItem(subDeviceItem, newItem);
+                       }
+               }
+       }
+
+       private void updateSubDeviceItem(SubDeviceItem oldItem, SubDeviceItem newItem) {
+               oldItem.setSupport(newItem.isSupport());
+               oldItem.setName(newItem.getName());
+       }
+
+       private SubDeviceItem findSubDeviceItem(SubDevice subDevice, String itemId) {
+               for (SubDeviceItem item : subDevice.getItems()) {
+                       if (item.getId().equals(itemId)) {
+                               return item;
+                       }
+               }
+               return null;
+       }
+
        public boolean isAdditionalDeviceEquals(List<SubDevice> destList) {
                if (additionalDevices == null && destList == null) {
                        return true;
index 70514e8..65a0195 100644 (file)
 
 package org.tizen.emulator.manager.devices;
 
+import java.util.ArrayList;
 import java.util.List;
 
 public class SubDeviceItem {
        private String id = "";
        private String name = "";
        private boolean isSupport = false;
-       private List<SubDeviceItemValue> values;
+       private List<SubDeviceItemValue> values = new ArrayList<SubDeviceItemValue>();
 
        public SubDeviceItem(String id) {
                this.id = id;
index dbaa365..6acff28 100644 (file)
@@ -122,7 +122,7 @@ public class TemplateLoader {
                return context;
        }
 
-       private static <T> Object loadTemplate (File f, Class<T> type) {
+       public static <T> Object loadTemplate (File f, Class<T> type) {
                JAXBElement<T> element = null;
                JAXBContext context = getContext(type);
                if (context != null) {
diff --git a/src/org/tizen/emulator/manager/ui/renewal/dialog/ItemListLoader.java b/src/org/tizen/emulator/manager/ui/renewal/dialog/ItemListLoader.java
new file mode 100644 (file)
index 0000000..5af5709
--- /dev/null
@@ -0,0 +1,199 @@
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 2015 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 <sangho1206.park@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.ui.renewal.dialog;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.tizen.emulator.manager.logging.EMLogger;
+import org.tizen.emulator.manager.ui.renewal.item.ItemName;
+import org.tizen.emulator.manager.ui.renewal.item.ItemType;
+import org.tizen.emulator.manager.ui.renewal.item.OptionName;
+import org.tizen.emulator.manager.ui.renewal.item.modify.common.CheckBoxItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.common.CheckItemData;
+import org.tizen.emulator.manager.ui.renewal.item.modify.common.ConnectivityItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.common.DisplayItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.common.ModifyDialogItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.common.NameItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.common.ProcessorItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.common.ProfileItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.common.RamSizeItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.common.SensorItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.template.CameraItem;
+import org.tizen.emulator.manager.vms.RESOLUTION;
+import org.tizen.emulator.manager.vms.xml.template2.Item;
+import org.tizen.emulator.manager.vms.xml.template2.ItemGroup;
+import org.tizen.emulator.manager.vms.xml.template2.ItemList2;
+import org.tizen.emulator.manager.vms.xml.template2.Option;
+
+public class ItemListLoader {
+
+       /** Get UI item for device-template dialog. */
+       public static List<ModifyDialogItem> getDeviceTemplateItemList(ItemList2 itemList2) {
+               if (itemList2 == null) {
+                       return null;
+               }
+
+               List<ItemGroup> groupList = itemList2.getItemGroup();
+               List<ModifyDialogItem> itemList = new ArrayList<ModifyDialogItem>();
+               for (ItemGroup group : groupList) {
+                       addItemList(group, itemList);
+                       break; // use first one item group.
+               }
+
+               return itemList;
+       }
+
+       private static void addItemList(ItemGroup group, List<ModifyDialogItem> itemList) {
+               String name;
+               String title;
+               String type;
+               for (Item item : group.getItem()) {
+                       ModifyDialogItem dialogItem = null;
+                       name = item.getName();
+                       title = item.getTitle();
+                       type = item.getType();
+
+                       // check item name
+                       if (name.equals(ItemName.NAME)) {
+                               dialogItem = new NameItem(name, title);
+
+                       } else if (name.equals(ItemName.PROFILE)) {
+                               dialogItem = new ProfileItem();
+
+                       } else if (name.equals(ItemName.DISPLAY)) {
+                               dialogItem = new DisplayItem(getResolutionList(item));
+
+                       } else if (name.equals(ItemName.PROCESSORS)) {
+                               dialogItem = new ProcessorItem();
+
+                       } else if (name.equals(ItemName.RAM_SIZE)) {
+                               dialogItem = new RamSizeItem();
+
+                       } else if (name.equals(ItemName.SENSOR)) {
+                               dialogItem = new SensorItem(getCheckBoxDataList(item));
+
+                       } else if (name.equals(ItemName.CONNECTIVITY)) {
+                               dialogItem = new ConnectivityItem(getCheckBoxDataList(item));
+
+                       } else if (name.equals(ItemName.CAMERA)) {
+                               dialogItem = new CameraItem(getCheckBoxDataList(item));
+                       }
+                       if (dialogItem != null) {
+                               itemList.add(dialogItem);
+                               continue;
+                       }
+
+                       // check item type
+                       if (type.equals(ItemType.CHECK_LABEL)) {
+                               dialogItem = new CheckBoxItem(name, title, getCheckBoxNumColumn(item),
+                                               getCheckBoxDataList(item));
+                       }
+                       if (dialogItem != null) {
+                               itemList.add(dialogItem);
+                       }
+               }
+       }
+
+       private static final int DEFAULT_NUM_COLUMN = 3;
+       private static int getCheckBoxNumColumn(Item item) {
+               int numColumn = DEFAULT_NUM_COLUMN;
+               String str = getOption(item.getOption(), OptionName.NUM_COLUMN);
+               if (str != null) {
+                       try {
+                               numColumn = Integer.parseInt(str);
+                       } catch (NumberFormatException e) {
+                               EMLogger.getLogger().warning(e.getMessage());
+                       }
+               }
+               return numColumn;
+       }
+
+       private static List<CheckItemData> getCheckBoxDataList(Item item) {
+               List<CheckItemData> dataList = new ArrayList<CheckItemData>();
+               for (Item subItem : item.getItem()) {
+                       dataList.add(new CheckItemData(subItem.getName(), subItem.getTitle(), true));
+               }
+               return dataList;
+
+       }
+
+       private static String getOption(List<Option> options, String optionName) {
+               String option = null;
+               for (Option opt : options) {
+                       if (opt.getName().equals(optionName)) {
+                               option = opt.getValue();
+                       }
+               }
+               return option;
+       }
+
+       private static List<RESOLUTION> getResolutionList(Item item) {
+               // get sub item(resolution item)
+               Item displayItem = getSubItem(item, ItemName.RESOLUTION);
+               if (displayItem == null) {
+                       return null;
+               }
+
+               // get resolution list
+               List<RESOLUTION> list = new ArrayList<RESOLUTION>();
+               for (Option opt : displayItem.getOption()) {
+                       String[] split = opt.getValue().split(","); //$NON-NLS-1$
+                       if (split.length == 4) { // name, width, height, dpi
+                               RESOLUTION resolution = null;
+                               for(String s : split) {
+                                       try{
+                                               String name = split[0].trim();
+                                               int width = Integer.parseInt(split[1].trim());
+                                               int height = Integer.parseInt(split[2].trim());
+                                               int dpi = Integer.parseInt(split[3].trim());
+                                               resolution = new RESOLUTION(width, height, name, dpi);
+                                       } catch(NumberFormatException e) {
+                                               EMLogger.getLogger().warning("Failed to parse Resolution : " + s); //$NON-NLS-1$
+                                       }
+                               }
+                               if (resolution != null) {
+                                       list.add(resolution);
+                               }
+                       }
+               }
+               return list;
+       }
+
+       private static Item getSubItem(Item item, String itemName) {
+               for (Item subItem : item.getItem()) {
+                       if (subItem.getName().equals(itemName)) {
+                               return subItem;
+                       }
+               }
+               return null;
+       }
+}
index a48a92c..6441bc8 100644 (file)
 
 package org.tizen.emulator.manager.ui.renewal.dialoghandler;
 
+import java.io.File;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import org.eclipse.swt.SWT;
 import org.tizen.emulator.manager.devices.DeviceTemplateValue;
+import org.tizen.emulator.manager.logging.EMLogger;
+import org.tizen.emulator.manager.template.TemplateLoader;
 import org.tizen.emulator.manager.ui.renewal.MainDialog;
 import org.tizen.emulator.manager.ui.renewal.dialog.DIALOG_MODE;
 import org.tizen.emulator.manager.ui.renewal.dialog.DeviceTemplateModifyDialog;
-import org.tizen.emulator.manager.ui.renewal.item.modify.common.DeviceItem;
+import org.tizen.emulator.manager.ui.renewal.dialog.ItemListLoader;
+import org.tizen.emulator.manager.ui.renewal.item.modify.common.ConnectivityItem;
 import org.tizen.emulator.manager.ui.renewal.item.modify.common.DisplayItem;
 import org.tizen.emulator.manager.ui.renewal.item.modify.common.ModifyDialogItem;
 import org.tizen.emulator.manager.ui.renewal.item.modify.common.NameItem;
@@ -49,7 +55,7 @@ import org.tizen.emulator.manager.ui.renewal.item.modify.common.ProfileItem;
 import org.tizen.emulator.manager.ui.renewal.item.modify.common.RamSizeItem;
 import org.tizen.emulator.manager.ui.renewal.item.modify.common.SensorItem;
 import org.tizen.emulator.manager.ui.renewal.item.modify.template.CameraItem;
-import org.tizen.emulator.manager.vms.VMProperty;
+import org.tizen.emulator.manager.vms.xml.template2.ItemList2;
 
 public class DeviceTemplateDialogHandler {
 
@@ -57,6 +63,8 @@ public class DeviceTemplateDialogHandler {
        public static final String TITLE_MODIFY = "Modify Template";
        public static final String TITLE_CLONE = "Clone Template";
 
+       public static Map<String, List<ModifyDialogItem>> itemListMap;
+
 
        public static DeviceTemplateValue create(DeviceTemplateValue value) {
                if (value == null) {
@@ -95,9 +103,11 @@ public class DeviceTemplateDialogHandler {
        private static DeviceTemplateValue createDialog(
                        String dialogTitle, DIALOG_MODE mode, DeviceTemplateValue value) {
 
+               System.out.println(value.getPrintValue());
                // open dialog
                DeviceTemplateModifyDialog dialog =
                                new DeviceTemplateModifyDialog(MainDialog.getShell(), dialogTitle);
+
                dialog.setDialogMode(mode);
                dialog.create(value, getItemList(null));
 
@@ -112,24 +122,58 @@ public class DeviceTemplateDialogHandler {
                return null;
        }
 
-       private static List<ModifyDialogItem> getItemList(VMProperty property) {
-               // TODO make item list using Image's item-template
-               return getTmpItemList();
 
+       private static List<ModifyDialogItem> getItemList(DeviceTemplateValue value) {
+               if (itemListMap == null) {
+                       itemListMap = new HashMap<String, List<ModifyDialogItem>>();
+               }
+
+               String profile;
+               if (value == null) {
+                       profile = "mobile";
+
+               } else {
+                       profile = value.getProfile();
+               }
+
+               List<ModifyDialogItem> itemList = itemListMap.get(profile);
+               if (itemList == null) {
+                       itemList = loadItemList(profile);
+                       itemListMap.put(profile, itemList);
+               }
+
+               if (itemList == null || itemList.size() == 0) {
+                       EMLogger.getLogger().info("Failed to load template item list. Use default item list");
+                       return getDefaultItemList();
+
+               } else {
+                       return itemListMap.get(profile);
+               }
+
+       }
+
+
+       private static List<ModifyDialogItem> loadItemList(String profile) {
+               // load XML
+               //  - TODO Fix file path.
+               String filePath = "xsd" + File.separator + "template-ui-mobile.xml";
+               ItemList2 xmlStruct = (ItemList2)TemplateLoader.loadTemplate(new File(filePath), ItemList2.class);
+
+               return ItemListLoader.getDeviceTemplateItemList(xmlStruct);
        }
 
-       // FOR TES
-       public static List<ModifyDialogItem> getTmpItemList() {
+       // default.
+       public static List<ModifyDialogItem> getDefaultItemList() {
                List<ModifyDialogItem> itemList = new ArrayList<ModifyDialogItem>();
 
                itemList.add(new NameItem("deviceTemplateName", "Device Name"));
                itemList.add(new ProfileItem());
-               itemList.add(new DisplayItem());
+               itemList.add(new DisplayItem(null));
                itemList.add(new RamSizeItem());
                itemList.add(new ProcessorItem());
-               itemList.add(new SensorItem());
-               itemList.add(new DeviceItem());
-               itemList.add(new CameraItem());
+               itemList.add(new SensorItem(null));
+               itemList.add(new ConnectivityItem(null));
+               itemList.add(new CameraItem(null));
 
 
 
index e8d21d9..dd11307 100644 (file)
@@ -38,7 +38,7 @@ import org.eclipse.swt.SWT;
 import org.tizen.emulator.manager.ui.renewal.MainDialog;
 import org.tizen.emulator.manager.ui.renewal.dialog.DIALOG_MODE;
 import org.tizen.emulator.manager.ui.renewal.dialog.VMModifyDialog;
-import org.tizen.emulator.manager.ui.renewal.item.modify.common.DeviceItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.common.ConnectivityItem;
 import org.tizen.emulator.manager.ui.renewal.item.modify.common.DisplayItem;
 import org.tizen.emulator.manager.ui.renewal.item.modify.common.ImageItem;
 import org.tizen.emulator.manager.ui.renewal.item.modify.common.ModifyDialogItem;
@@ -84,11 +84,11 @@ public class VMModifyHandler {
                itemList.add(new ImageItem());
                DeviceTemplateItem deviceItem = new DeviceTemplateItem();
                itemList.add(deviceItem);
-               itemList.add(new DisplayItem(deviceItem.getTreeRoot()));
+               itemList.add(new DisplayItem(deviceItem.getTreeRoot(), null));
                itemList.add(new RamSizeItem(deviceItem.getTreeRoot()));
                itemList.add(new ProcessorItem(deviceItem.getTreeRoot()));
-               itemList.add(new SensorItem(deviceItem.getTreeRoot()));
-               itemList.add(new DeviceItem(deviceItem.getTreeRoot()));
+               itemList.add(new SensorItem(deviceItem.getTreeRoot(), null));
+               itemList.add(new ConnectivityItem(deviceItem.getTreeRoot(), null));
 
 
 
diff --git a/src/org/tizen/emulator/manager/ui/renewal/item/ItemName.java b/src/org/tizen/emulator/manager/ui/renewal/item/ItemName.java
new file mode 100644 (file)
index 0000000..ae2ff35
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 2015 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 <sangho1206.park@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.ui.renewal.item;
+
+public class ItemName {
+       public static final String NAME = "name"; //$NON-NLS-1$
+       public static final String PROFILE = "profile"; //$NON-NLS-1$
+       public static final String BASE_IMAGE = "baseImage"; //$NON-NLS-1$
+       public static final String DISPLAY = "display"; //$NON-NLS-1$
+       public static final String RESOLUTION = "resolution";
+       public static final String RAM_SIZE = "ramSize"; //$NON-NLS-1$
+       public static final String MAX_TOUCH = "maxTouch"; //$NON-NLS-1$
+       public static final String SUSPEND_SUPPORT = "suspendSupport"; //$NON-NLS-1$
+       public static final String FILE_SHARE = "fileShare"; //$NON-NLS-1$
+       public static final String HW_SUPPORT = "hwSupport"; //$NON-NLS-1$
+       public static final String PROCESSORS = "processors"; //$NON-NLS-1$
+
+       public static final String CONNECTIVITY = "connectivity";
+       public static final String SENSOR = "sensor"; //$NON-NLS-1$
+       public static final String DEVICE = "device"; //$NON-NLS-1$
+       public static final String JACK = "jack"; //$NON-NLS-1$
+       public static final String CAMERA = "camera"; //$NON-NLS-1$
+
+       public static final String NET_CONFIG = "netConfig"; //$NON-NLS-1$
+       public static final String NET_PROXY = "proxy"; //$NON-NLS-1$
+       public static final String NET_CONNECT_TYPE = "netConnectType"; //$NON-NLS-1$
+       public static final String NET_TAP_DEVICE = "netTapDevice"; //$NON-NLS-1$
+       public static final String NET_IP_INFO = "netIpInfo"; //$NON-NLS-1$
+       public static final String NET_DNS = "netDns"; //$NON-NLS-1$
+       public static final String NET_MAC = "netMac"; //$NON-NLS-1$
+
+       public static final String NET_USE_DHCP = "useDHCP"; //$NON-NLS-1$
+       public static final String NET_IP = "ipAddr"; //$NON-NLS-1$
+       public static final String NET_SUBNET = "subnet"; //$NON-NLS-1$
+       public static final String NET_GATEWAY = "gateway"; //$NON-NLS-1$
+
+       public static final String OCI_DEVICE = "ociDevice"; //$NON-NLS-1$
+       public static final String EXTERNAL_INPUT = "externalInput"; //$NON-NLS-1$
+       public static final String TUNER = "tuner"; //$NON-NLS-1$
+
+       public static final String GL_VERSION = "glVersion"; //$NON-NLS-1$
+
+       public static final String DISPLAY_MODE = "displayMode"; //$NON-NLS-1$
+       public static final String QT_ENABLE = "qtEnable"; //$NON-NLS-1$
+
+       // tuner option
+       public static final String TUNER_NUMBER="number"; //$NON-NLS-1$
+       public static final String TUNER_SYSTEM="system"; //$NON-NLS-1$
+       public static final String TUNER_COUNTRY="country"; //$NON-NLS-1$
+       public static final String TUNER_FILE_PATH="tunerFilePath"; //$NON-NLS-1$
+       public static final String TUNER_FILE_NAME="tunerFileName"; //$NON-NLS-1$
+
+       // external input
+       public static final String INPUT_HDMI="hdmi"; //$NON-NLS-1$
+
+       // device option
+       public static final String DEVICE_SERIAL_LOG="serial_log"; //$NON-NLS-1$
+       public static final String DEVICE_CAMERA="camera"; //$NON-NLS-1$
+}
+
diff --git a/src/org/tizen/emulator/manager/ui/renewal/item/ItemType.java b/src/org/tizen/emulator/manager/ui/renewal/item/ItemType.java
new file mode 100644 (file)
index 0000000..e5defd4
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 2015 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 <sangho1206.park@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.ui.renewal.item;
+
+public class ItemType {
+       public static final String CHECK_LABEL = "checkLabel";
+
+}
diff --git a/src/org/tizen/emulator/manager/ui/renewal/item/OptionName.java b/src/org/tizen/emulator/manager/ui/renewal/item/OptionName.java
new file mode 100644 (file)
index 0000000..83c6a84
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 2015 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 <sangho1206.park@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.ui.renewal.item;
+
+public class OptionName {
+       public static final String NUM_COLUMN = "numColumn";
+
+}
index f9fcc32..72b0b8e 100644 (file)
@@ -34,11 +34,16 @@ import java.util.ArrayList;
 import java.util.List;
 
 import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.tizen.emulator.manager.ui.renewal.dialog.DIALOG_MODE;
 import org.tizen.emulator.manager.ui.renewal.item.modify.comp.ModifyItem;
 import org.tizen.emulator.manager.ui.renewal.item.modify.comp.PropertyValue;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.SubTreeModifyItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.TreeModifyItem;
 
-public abstract class CheckBoxItem extends ModifyDialogItem {
+public class CheckBoxItem extends ModifyDialogItem {
 
+       protected ModifyItem item;
        private final int ROW_HEIGHT = ModifyItem.ITEM_HEIGHT + ModifyItem.LINE_WIDTH;
        private int rowNum;
        private final int numColumns;
@@ -49,24 +54,61 @@ public abstract class CheckBoxItem extends ModifyDialogItem {
                return subItemList;
        }
 
-       // TODO should be structures that have name, title
-       private List<CheckItemData> dataList;
+       protected List<CheckItemData> dataList;
 
-       public CheckBoxItem(String name, String title, int numColomn) {
+       public CheckBoxItem(String name, String title, int numColomn,
+                       TreeModifyItem treeRoot, List<CheckItemData> dataList) {
                super(name, title);
                this.numColumns = numColomn;
+               this.dataList = dataList;
+               initSubTreeItem(treeRoot);
+       }
+
+       private void initSubTreeItem(TreeModifyItem treeRoot) {
+               initDataList();
+               item = new SubTreeModifyItem();
+               item.setItemHeight(getContentHeight());
+               treeRoot.addSubItem((SubTreeModifyItem)item);
        }
 
-       public void setDataList(List<CheckItemData> dataList) {
+
+       public CheckBoxItem(String name, String title, int numColomn,
+                       List<CheckItemData> dataList) {
+               super(name, title);
+               this.numColumns = numColomn;
                this.dataList = dataList;
+               init();
+       }
+
+
+       public void setDefaultData() {
+               // override if need
+       }
+
+       private void init() {
+               initDataList();
+               item = new ModifyItem();
+               item.setItemHeight(getContentHeight());
+       }
+
+       public void initDataList() {
+               if (dataList == null) {
+                       dataList = new ArrayList<CheckItemData>();
+                       setDefaultData();
+               }
                initRowNum();
        }
 
 
        private void initRowNum() {
-               rowNum = dataList.size() / numColumns;
-               if (dataList.size() % numColumns != 0) {
-                       rowNum++;
+               if (dataList == null || dataList.isEmpty()) {
+                       rowNum = 1;
+
+               } else {
+                       rowNum = dataList.size() / numColumns;
+                       if (dataList.size() % numColumns != 0) {
+                               rowNum++;
+                       }
                }
        }
 
@@ -80,6 +122,7 @@ public abstract class CheckBoxItem extends ModifyDialogItem {
                item.setBodyLayoutGrid(numColumns);
 
                CheckBoxSubItem checkBoxItem;
+               subItemList.clear(); //
                for (int i=0 ; i < dataList.size() ; i++) {
                        CheckItemData checkItemData = dataList.get(i);
                        checkBoxItem = new CheckBoxSubItem(this, item.getBody(),
@@ -99,18 +142,29 @@ public abstract class CheckBoxItem extends ModifyDialogItem {
                getDialog().checkValid();
        }
 
+       @Override
+       public int getHeight() {
+               return item.getHeight();
+       }
 
        @Override
        public void setInitialValue(PropertyValue value) {
-               List<CheckItemData> dataList = value.getCheckOptions(getName());
-               for (CheckItemData data : dataList) {
-                       String name = data.getName();
-                       boolean isChecked = data.isChecked();
-                       for (CheckItemData ownData : dataList) {
-                               if (ownData.getName().equals(name)) {
-                                       ownData.setChecked(isChecked);
+               if (getDialog().getDialogMode() == DIALOG_MODE.MODIFY) {
+                       List<CheckItemData> dataList = value.getCheckBoxOptions(getName());
+                       for (CheckItemData data : dataList) {
+                               String name = data.getName();
+                               boolean isChecked = data.isChecked();
+                               for (CheckItemData ownData : this.dataList) {
+                                       if (ownData.getName().equals(name)) {
+                                               ownData.setChecked(isChecked);
+                                       }
                                }
                        }
+
+               } else {
+                       for (CheckItemData data : this.dataList) {
+                               data.setChecked(true);
+                       }
                }
        }
 
@@ -124,7 +178,17 @@ public abstract class CheckBoxItem extends ModifyDialogItem {
                                        subItem.getName(),
                                        subItem.getTitle(), subItem.isChecked()));
                }
-               value.setCheckOptions(getName(), dataList);
+               value.setCheckBoxOptions(getName(), dataList);
+
+       }
+
+       @Override
+       public void create(Composite parent) {
+               item.init(parent);
+               item.setItemTitle(createIconTitle(item, null));
+               item.create();
+
+               createCheckBoxItems(item);
 
        }
 
 
 package org.tizen.emulator.manager.ui.renewal.item.modify.common;
 
-import java.util.ArrayList;
 import java.util.List;
 
 import org.eclipse.swt.widgets.Composite;
-import org.tizen.emulator.manager.ui.renewal.item.modify.comp.ModifyItem;
-import org.tizen.emulator.manager.ui.renewal.item.modify.comp.SubTreeModifyItem;
 import org.tizen.emulator.manager.ui.renewal.item.modify.comp.TreeModifyItem;
 
-public class DeviceItem extends CheckBoxItem {
+public class ConnectivityItem extends CheckBoxItem {
 
-       private final ModifyItem item;
+//     private final ModifyItem item;
 
        private static final String TITLE = "Device";
        private static final String NAME = "device";
@@ -48,30 +45,19 @@ public class DeviceItem extends CheckBoxItem {
 
        private static final int NUM_COLUMN = 3;
 
-       // TODO load from xml
-       private final List<CheckItemData> dataList =
-                       new ArrayList<CheckItemData>();
 
-       private void initDataList() {
+       @Override
+       public void setDefaultData() {
                dataList.add(new CheckItemData("nfc", "NFC"));
        }
 
        /** constructor for tree sub item */
-       public DeviceItem(TreeModifyItem treeRoot) {
-               super(NAME, TITLE, NUM_COLUMN);
-               initDataList();
-               setDataList(dataList);
-               item = new SubTreeModifyItem();
-               item.setItemHeight(getContentHeight());
-               treeRoot.addSubItem((SubTreeModifyItem)item);
+       public ConnectivityItem(TreeModifyItem treeRoot, List<CheckItemData> dataList) {
+               super(NAME, TITLE, NUM_COLUMN, treeRoot, dataList);
        }
 
-       public DeviceItem() {
-               super(NAME, TITLE, NUM_COLUMN);
-               initDataList();
-               setDataList(dataList);
-               item = new ModifyItem();
-               item.setItemHeight(getContentHeight());
+       public ConnectivityItem(List<CheckItemData> dataList) {
+               super(NAME, TITLE, NUM_COLUMN, dataList);
        }
 
 
@@ -85,10 +71,4 @@ public class DeviceItem extends CheckBoxItem {
 
        }
 
-       @Override
-       public int getHeight() {
-               return item.getHeight();
-       }
-
-
 }
index 9c03ff9..30d1681 100644 (file)
@@ -69,18 +69,20 @@ public class DisplayItem extends ModifyDialogItem {
 
 
        /** constructor for tree sub item */
-       public DisplayItem(TreeModifyItem treeRoot) {
+       public DisplayItem(TreeModifyItem treeRoot, List<RESOLUTION> resList) {
                super(NAME, TITLE);
                item = new SubTreeModifyItem();
                item.setItemHeight(ROW_HEIGHT * ROW_NUM);
                treeRoot.addSubItem((SubTreeModifyItem)item);
+               this.resList = resList;
        }
 
 
-       public DisplayItem() {
+       public DisplayItem(List<RESOLUTION> resList) {
                super(NAME, TITLE);
                item = new ModifyItem();
                item.setItemHeight(ROW_HEIGHT * ROW_NUM);
+               this.resList = resList;
        }
 
 
@@ -154,15 +156,25 @@ public class DisplayItem extends ModifyDialogItem {
        }
 
        private void initResolutionCombo() {
-               // init resolution list
-               // TODO from XML
-               resList = new ArrayList<RESOLUTION>();
-               resList.add(RESOLUTION.HD);
-               resList.add(RESOLUTION.HD1080);
-               resList.add(RESOLUTION.HVGA);
-               resList.add(RESOLUTION.QHD);
-               resList.add(RESOLUTION.R_360_480);
-               resList.add(RESOLUTION.WQXGA);
+               // default.
+               if (resList == null) {
+                       resList = new ArrayList<RESOLUTION>();
+                       resList.add(RESOLUTION.MINI);
+                       resList.add(RESOLUTION.R_360_480);
+                       resList.add(RESOLUTION.WQXGA);
+                       resList.add(RESOLUTION.WVGA);
+                       resList.add(RESOLUTION.WXGA);
+                       resList.add(RESOLUTION.HD);
+                       resList.add(RESOLUTION.HD1080);
+                       resList.add(RESOLUTION.HVGA);
+                       resList.add(RESOLUTION.QHD);
+               }
+
+               addResolutionComboListener();
+
+               if (resList.size() == 0) {
+                       return;
+               }
 
                // add combo list
                for (RESOLUTION res : resList) {
@@ -188,7 +200,7 @@ public class DisplayItem extends ModifyDialogItem {
                }
                resolutionComboSelected(re);
 
-               addResolutionComboListener();
+
        }
 
 
index 129ad56..65cb4d7 100644 (file)
 
 package org.tizen.emulator.manager.ui.renewal.item.modify.common;
 
-import java.util.ArrayList;
 import java.util.List;
 
 import org.eclipse.swt.widgets.Composite;
 import org.tizen.emulator.manager.renewal.resources.ImageResources;
-import org.tizen.emulator.manager.ui.renewal.item.modify.comp.ModifyItem;
-import org.tizen.emulator.manager.ui.renewal.item.modify.comp.PropertyValue;
-import org.tizen.emulator.manager.ui.renewal.item.modify.comp.SubTreeModifyItem;
 import org.tizen.emulator.manager.ui.renewal.item.modify.comp.TreeModifyItem;
 
 public class SensorItem extends CheckBoxItem {
 
-       private final ModifyItem item;
+//     private final ModifyItem item;
 
        private static final String TITLE = "Sensor";
        private static final String NAME = "sensor";
@@ -51,12 +47,8 @@ public class SensorItem extends CheckBoxItem {
 
        private static final int NUM_COLUMN = 3;
 
-
-       // TODO load from xml
-       private final List<CheckItemData> dataList =
-                       new ArrayList<CheckItemData>();
-
-       private void initDataList() {
+       @Override
+       public void setDefaultData() {
                dataList.add(new CheckItemData("accel", "Accelerometer"));
                dataList.add(new CheckItemData("gyro", "Gyroscope"));
                dataList.add(new CheckItemData("proxi", "Proximity"));
@@ -68,24 +60,13 @@ public class SensorItem extends CheckBoxItem {
        }
 
        /** constructor for tree sub item */
-       public SensorItem(TreeModifyItem treeRoot) {
-               super(NAME, TITLE, NUM_COLUMN);
-               item = new SubTreeModifyItem();
-               initDataList();
-               setDataList(dataList);
-
-               item.setItemHeight(getContentHeight());
-               treeRoot.addSubItem((SubTreeModifyItem)item);
+       public SensorItem(TreeModifyItem treeRoot, List<CheckItemData> dataList) {
+               super(NAME, TITLE, NUM_COLUMN, treeRoot, dataList);
        }
 
 
-       public SensorItem() {
-               super(NAME, TITLE, NUM_COLUMN);
-               initDataList();
-               setDataList(dataList);
-               item = new ModifyItem();
-               item.setItemHeight(getContentHeight());
-
+       public SensorItem(List<CheckItemData> dataList) {
+               super(NAME, TITLE, NUM_COLUMN, dataList);
        }
 
 
@@ -96,44 +77,7 @@ public class SensorItem extends CheckBoxItem {
                item.create();
 
                createCheckBoxItems(item);
-
-       }
-
-       @Override
-       public int getHeight() {
-               return item.getHeight();
-       }
-
-
-       @Override
-       public void setInitialValue(PropertyValue value) {
-               List<CheckItemData> dataList = value.getCheckOptions(getName());
-               for (CheckItemData data : dataList) {
-                       String name = data.getName();
-                       boolean isChecked = data.isChecked();
-                       for (CheckItemData ownData : this.dataList) {
-                               if (ownData.getName().equals(name)) {
-                                       ownData.setChecked(isChecked);
-                               }
-                       }
-               }
-       }
-
-
-       @Override
-       public void setValue(PropertyValue value) {
-
-               List<CheckItemData> dataList = new ArrayList<CheckItemData>();
-               for (CheckBoxSubItem subItem : getSubItemList()) {
-                       dataList.add(new CheckItemData(
-                                       subItem.getName(),
-                                       subItem.getTitle(), subItem.isChecked()));
-               }
-               value.setCheckOptions(getName(), dataList);
-
        }
 
 
-
-
 }
index 83d20f6..565204d 100644 (file)
@@ -48,6 +48,12 @@ public class PropertyValue {
        private VMPropertyValue vmValue;
        private DeviceTemplateValue templateValue;
 
+       public Object getValue() {
+               if (vmValue != null) {
+                       return vmValue;
+               }
+               return templateValue;
+       }
 
        public PropertyValue(Object value) {
                if (value instanceof VMPropertyValue) {
@@ -238,7 +244,7 @@ public class PropertyValue {
        }
 
 
-       public void setCheckOptions(String name,
+       public void setCheckBoxOptions(String name,
                        List<CheckItemData> dataList) {
                if (isVMValue()) {
                        // TODO
@@ -250,13 +256,12 @@ public class PropertyValue {
                                subDeviceItem.setSupport(data.isChecked());
                                subDevice.addSubDeviceItem(subDeviceItem);
                        }
-                       // TODO add is OK?
-                       templateValue.getAdditionalDevices().add(subDevice);
+                       templateValue.addOrUpdateSubDevices(subDevice);
                }
        }
 
 
-       public List<CheckItemData> getCheckOptions(String name) {
+       public List<CheckItemData> getCheckBoxOptions(String name) {
                List<CheckItemData> dataList = new ArrayList<CheckItemData>();
                // TODO
                if (isVMValue()) {
index d26a0d0..be2f4f5 100644 (file)
 
 package org.tizen.emulator.manager.ui.renewal.item.modify.template;
 
-import java.util.ArrayList;
 import java.util.List;
 
 import org.eclipse.swt.widgets.Composite;
 import org.tizen.emulator.manager.ui.renewal.item.modify.common.CheckBoxItem;
 import org.tizen.emulator.manager.ui.renewal.item.modify.common.CheckItemData;
-import org.tizen.emulator.manager.ui.renewal.item.modify.comp.ModifyItem;
 
 public class CameraItem extends CheckBoxItem {
 
-       private final ModifyItem item;
+//     private final ModifyItem item;
 
        private static final String TITLE = "Camera";
        private static final String NAME = "camera";
@@ -48,22 +46,15 @@ public class CameraItem extends CheckBoxItem {
 
        private static final int NUM_COLUMN = 2;
 
-       // TODO load from xml
-       private final List<CheckItemData> dataList =
-                       new ArrayList<CheckItemData>();
-
-       private void initDataList() {
+       @Override
+       public void setDefaultData() {
                dataList.add(new CheckItemData("rear", "Rear"));
                dataList.add(new CheckItemData("front", "Front"));
        }
 
 
-       public CameraItem() {
-               super(NAME, TITLE, NUM_COLUMN);
-               initDataList();
-               setDataList(dataList);
-               item = new ModifyItem();
-               item.setItemHeight(getContentHeight());
+       public CameraItem(List<CheckItemData> dataList) {
+               super(NAME, TITLE, NUM_COLUMN, dataList);
        }
 
 
@@ -77,9 +68,5 @@ public class CameraItem extends CheckBoxItem {
 
        }
 
-       @Override
-       public int getHeight() {
-               return item.getHeight();
-       }
 
 }
diff --git a/xsd/template-ui-mobile.xml b/xsd/template-ui-mobile.xml
new file mode 100644 (file)
index 0000000..4001635
--- /dev/null
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+
+<!-- This file describes dialog for device template create/modify -->
+
+<ItemList xmlns="http://www.tizen.org/em/template" version="2.0">
+       <information profile="mobile" />
+
+       <itemGroup name="default">
+               <item name="name" title="Device Name" type="textInput"/>
+               <item name="profile" title="Profile"/>
+               <item name="display" title="Display" type="label">
+                       <item name="resolution" title="Resolution" type="combo">
+                               <!-- name, width, height, dpi -->
+                               <option name="320"> ,320,320,316 </option>
+                               <option name="hvga"> HVGA,320,480,160 </option>
+                               <option name="wvga"> WVGA,480,800,233 </option>
+                               <option name="wsvga"> WSVGA,600,1024,207 </option>
+                               <option name="WSVGA"> WSVGA,600,1024,207 </option>
+                               <option name="qhd"> qHD,540,960,220 </option>
+                               <option name="hd"> HD,720,1280,306 </option>
+                               <option name="WXGA"> WXGA,1280,800,300 </option>
+                               <option name="WQXGA"> WQXGA,2560,1600,301 </option>
+                               <option name="FULLHD"> FULLHD,1080,1920,314 </option>
+                       </item>
+                       <item name="size" title="Size" type="textInput" />
+                       <item name="skin" title="Skin" type="combo"/>
+               </item>
+               <item name="processors" title="Processorse" type="combo" />
+               <item name="ramSize" title="Ram" type="combo" >
+                       <option name="list">512,768,1024</option>
+               </item>
+
+               <item name="sensor" title="Sensor" type="checkLabel" >
+                       <item name="accel" title="Accelerometer" type="checkbox" />
+                       <item name="gyro" title="Gyroscope" type="checkbox" />
+                       <item name="geo" title="Geo-magnetic" type="checkbox" />
+                       <item name="proxi" title="Proximity"  type="checkbox"/>
+                       <item name="light" title="Light" type="checkbox"/>
+                       <item name="haptic" title="Haptic" type="checkbox"/>
+                       <item name="press" title="Pressure" type="checkbox"/>
+                       <item name="uv" title="Ultraviolet" type="checkbox"/>
+                       <item name="hrm" title="Heartbeat Rate" type="checkbox"/>
+                       <item name="test" title="Test"/>
+                       <option name="numColumn">3</option>
+               </item>
+               <item name="connectivity" title="Connectivity" type="checkLabel">
+                       <item name="nfc" title="NFC" type="checkbox" />
+                       <option name="numColumn">3</option>
+               </item>
+               <item name="camera" title="Camera" type="checkLabel">
+                       <item name="rear" title="Rear" type="checkbox" />
+                       <item name="front" title="Front" type="checkbox" />
+                       <option name="numColumn">2</option>
+               </item>
+       </itemGroup>
+
+</ItemList>
+