From: jihye424.kim Date: Sun, 18 Oct 2015 06:59:51 +0000 (+0900) Subject: Modify VM: select device template and save devie template X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9f8ae94dda982bf572bf832fe141e93252a2a903;p=sdk%2Femulator%2Femulator-manager.git Modify VM: select device template and save devie template - 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 --- diff --git a/src/org/tizen/emulator/manager/ui/renewal/dialoghandler/VMModifyHandler.java b/src/org/tizen/emulator/manager/ui/renewal/dialoghandler/VMModifyHandler.java index dd11307..2f7b60b 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/dialoghandler/VMModifyHandler.java +++ b/src/org/tizen/emulator/manager/ui/renewal/dialoghandler/VMModifyHandler.java @@ -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 getItemList(VMProperty property) { diff --git a/src/org/tizen/emulator/manager/ui/renewal/item/modify/comp/PropertyValue.java b/src/org/tizen/emulator/manager/ui/renewal/item/modify/comp/PropertyValue.java index b8edb3a..d32b5f9 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/item/modify/comp/PropertyValue.java +++ b/src/org/tizen/emulator/manager/ui/renewal/item/modify/comp/PropertyValue.java @@ -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()) { diff --git a/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/DeviceTemplateItem.java b/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/DeviceTemplateItem.java index 6318a34..9eb0b51 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/DeviceTemplateItem.java +++ b/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/DeviceTemplateItem.java @@ -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 diff --git a/src/org/tizen/emulator/manager/ui/renewal/tableviewer/VMListTable.java b/src/org/tizen/emulator/manager/ui/renewal/tableviewer/VMListTable.java index dc0d457..e6df3cb 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/tableviewer/VMListTable.java +++ b/src/org/tizen/emulator/manager/ui/renewal/tableviewer/VMListTable.java @@ -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() {