Modify VM: select device template and save devie template
authorjihye424.kim <jihye424.kim@samsung.com>
Sun, 18 Oct 2015 06:59:51 +0000 (15:59 +0900)
committerjihye424.kim <jihye424.kim@samsung.com>
Sun, 18 Oct 2015 07:01:50 +0000 (16:01 +0900)
- click modify vm button
-- show device template list
-- select device template
-- save device template value to vm property

Change-Id: I170b38ac0fec3e5e9c58b42e81bbc35558c4c011
Signed-off-by: jihye424.kim <jihye424.kim@samsung.com>
src/org/tizen/emulator/manager/ui/renewal/dialoghandler/VMModifyHandler.java
src/org/tizen/emulator/manager/ui/renewal/item/modify/comp/PropertyValue.java
src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/DeviceTemplateItem.java
src/org/tizen/emulator/manager/ui/renewal/tableviewer/VMListTable.java

index dd11307..2f7b60b 100644 (file)
@@ -49,23 +49,27 @@ 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.vm.DeviceTemplateItem;
 import org.tizen.emulator.manager.vms.VMProperty;
+import org.tizen.emulator.manager.vms.VMPropertyValue;
 
 public class VMModifyHandler {
 
-       public static void modify(VMProperty property) {
+       public static VMPropertyValue modify(VMProperty property) {
 
                // open modify dialog
                VMModifyDialog dialog = new VMModifyDialog(MainDialog.getShell());
                dialog.setDialogMode(DIALOG_MODE.MODIFY);
-               dialog.create(property.getPropertyValue(), getItemList(property));
+               VMPropertyValue newValue = property.getPropertyValue().clone();
+               dialog.create(newValue, getItemList(property));
 
                // TODO set display value to dialog
 
                int retValue = dialog.open();
 
                if (retValue == SWT.OK) {
-                       // TODO do modify
+                       dialog.saveDataInto(newValue);
+                       return newValue;
                }
+               return null;
        }
 
        private static List<ModifyDialogItem> getItemList(VMProperty property) {
index b8edb3a..d32b5f9 100644 (file)
@@ -35,6 +35,7 @@ package org.tizen.emulator.manager.ui.renewal.item.modify.comp;
 import java.util.HashMap;
 import java.util.Map;
 
+import org.tizen.emulator.manager.devices.DeviceTemplate;
 import org.tizen.emulator.manager.devices.DeviceTemplateValue;
 import org.tizen.emulator.manager.devices.SubDevice;
 import org.tizen.emulator.manager.devices.SubDeviceItem;
@@ -75,6 +76,20 @@ public class PropertyValue {
                return templateValue != null;
        }
 
+       public DeviceTemplate getDeivceTemplate() {
+               if (isVMValue()) {
+                       return vmValue.device;
+               } else if (isTemplateValue()) {
+                       return templateValue.getTemplate();
+               }
+               return null;
+       }
+
+       public void setDeviceTemplate(DeviceTemplate template) {
+               if (isVMValue()) {
+                       vmValue.device = template;
+               }
+       }
 
        public String getName() {
                if (isVMValue()) {
index 6318a34..9eb0b51 100644 (file)
@@ -32,6 +32,9 @@
 package org.tizen.emulator.manager.ui.renewal.item.modify.vm;
 
 import org.eclipse.swt.widgets.Composite;
+import org.tizen.emulator.manager.devices.DeviceTemplate;
+import org.tizen.emulator.manager.platform.Profile;
+import org.tizen.emulator.manager.platform.ProfileList;
 import org.tizen.emulator.manager.ui.renewal.item.modify.common.ComboItem;
 import org.tizen.emulator.manager.ui.renewal.item.modify.common.ModifyDialogItem;
 import org.tizen.emulator.manager.ui.renewal.item.modify.comp.PropertyValue;
@@ -47,6 +50,8 @@ public class DeviceTemplateItem extends ComboItem {
 
        private final int COMBO_WIDTH = 200;
 
+       private Profile profile;
+       private DeviceTemplate template;
        public TreeModifyItem getTreeRoot() {
                return (TreeModifyItem)item;
        }
@@ -67,6 +72,13 @@ public class DeviceTemplateItem extends ComboItem {
                treeModifyItem.setModifyDialogItem(this);
 
                createCombo(treeModifyItem, COMBO_WIDTH);
+
+               if (profile != null) {
+                       // TODO
+                       for (DeviceTemplate temp : profile.getTemplateList()) {
+                               comboBox.addItem(temp.getValue().getName(), temp);
+                       }
+               }
        }
 
        @Override
@@ -76,21 +88,22 @@ public class DeviceTemplateItem extends ComboItem {
 
        @Override
        public void setInitialValue(PropertyValue value) {
-               // TODO Auto-generated method stub
-
+               // TODO
+               template = null;
+               profile = ProfileList.getProfile(value.getProfile());
        }
 
        @Override
        public void itemSelected(ComboBox comboBox) {
                // TODO change item list for selected template.
                System.out.println("item selected:" + comboBox.getSelectedItem());
+               template = (DeviceTemplate)comboBox.getSelectedData();
 
        }
 
        @Override
        public void setValue(PropertyValue value) {
-               // TODO Auto-generated method stub
-
+               value.setDeviceTemplate(template);
        }
 
        @Override
index dc0d457..e6df3cb 100644 (file)
@@ -323,7 +323,9 @@ public class VMListTable {
                        item.setImage(0, null);
                }
                item.setText(2, value.vmsName);
-               item.setText(3, "Samsung Z3");
+               item.setText(3, value.device != null
+                                               ? value.device.getValue().getName()
+                                               : "");
                item.setText(4, value.baseImage.getName());
                item.setText(5, value.resolution.getStrTypeValue());
                if (value.fileSharePath == null ||  value.fileSharePath.isEmpty()) {
@@ -426,7 +428,21 @@ public class VMListTable {
                if (table.getSelectionCount() != 1) {
                        return;
                }
-               VMModifyHandler.modify((VMProperty)table.getSelection()[0].getData());
+               TableItem item = table.getSelection()[0];
+               VMProperty property = (VMProperty)item.getData();
+               VMPropertyValue newValue = VMModifyHandler.modify(property);
+
+               if (newValue != null) {
+                       try {
+                               property.getWorker().modifyVM(newValue);
+                               property.setPropertyValue(newValue);
+                               setTableItemProperty(item, property);
+                               table.redraw();
+                       } catch (VMWorkerException e) {
+                               // TODO Auto-generated catch block
+                               e.printStackTrace();
+                       }
+               }
        }
 
        public void launchEmulator() {