From: minkee.lee Date: Fri, 16 Oct 2015 08:16:10 +0000 (+0900) Subject: template-dialog: load item list for each profile. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4cf9b2abfdf5e3b569f1448eae456bfe8e16df3b;p=sdk%2Femulator%2Femulator-manager.git template-dialog: load item list for each profile. - Item list is changed when click profile button. Change-Id: I8d0d29ddb62b73cd1917998dc1a1cca0f42ba93b Signed-off-by: minkee.lee --- diff --git a/src/org/tizen/emulator/manager/ui/renewal/dialog/DeviceTemplateModifyDialog.java b/src/org/tizen/emulator/manager/ui/renewal/dialog/DeviceTemplateModifyDialog.java index b7bc922..f96ea69 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/dialog/DeviceTemplateModifyDialog.java +++ b/src/org/tizen/emulator/manager/ui/renewal/dialog/DeviceTemplateModifyDialog.java @@ -36,6 +36,9 @@ import java.util.List; import org.eclipse.swt.widgets.Shell; import org.tizen.emulator.manager.devices.DeviceTemplateValue; +import org.tizen.emulator.manager.platform.Profile; +import org.tizen.emulator.manager.platform.ProfileList; +import org.tizen.emulator.manager.ui.renewal.dialoghandler.DeviceTemplateDialogHandler; import org.tizen.emulator.manager.ui.renewal.item.modify.common.ModifyDialogItem; import org.tizen.emulator.manager.ui.renewal.item.modify.comp.PropertyValue; import org.tizen.emulator.manager.vms.VMProperty; @@ -58,13 +61,34 @@ public class DeviceTemplateModifyDialog extends ModifyDialog { // - init body super.create(new PropertyValue(value), itemList); + } + + public void setItemValue(VMProperty property) { } - public void setItemValue(VMProperty property) { + @Override + public void changeItemList(String profile) { + + Profile prop = ProfileList.getProfile(profile); + System.out.println("profile: " + prop); + if (prop != null) { + propertyValue = new PropertyValue(prop.getDefaultTemplate().getValue()); + for (ModifyDialogItem item : itemList) { + item.setInitialValue(propertyValue); + } + } + DeviceTemplateDialogHandler.changeItemList(itemList, profile); + + // update dialog layout + layoutScrolledComposite(); + } + @Override + public void sortItem(String profile) { + DeviceTemplateDialogHandler.sortItem(itemList, profile); } diff --git a/src/org/tizen/emulator/manager/ui/renewal/dialog/ItemListLoader.java b/src/org/tizen/emulator/manager/ui/renewal/dialog/ItemListUtil.java similarity index 99% rename from src/org/tizen/emulator/manager/ui/renewal/dialog/ItemListLoader.java rename to src/org/tizen/emulator/manager/ui/renewal/dialog/ItemListUtil.java index 5af5709..470c1f0 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/dialog/ItemListLoader.java +++ b/src/org/tizen/emulator/manager/ui/renewal/dialog/ItemListUtil.java @@ -54,7 +54,7 @@ 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 { +public class ItemListUtil { /** Get UI item for device-template dialog. */ public static List getDeviceTemplateItemList(ItemList2 itemList2) { @@ -140,7 +140,7 @@ public class ItemListLoader { private static List getCheckBoxDataList(Item item) { List dataList = new ArrayList(); for (Item subItem : item.getItem()) { - dataList.add(new CheckItemData(subItem.getName(), subItem.getTitle(), true)); + dataList.add(new CheckItemData(subItem.getName(), subItem.getTitle())); } return dataList; @@ -196,4 +196,5 @@ public class ItemListLoader { } return null; } + } diff --git a/src/org/tizen/emulator/manager/ui/renewal/dialog/ModifyDialog.java b/src/org/tizen/emulator/manager/ui/renewal/dialog/ModifyDialog.java index fc8b475..897d5fb 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/dialog/ModifyDialog.java +++ b/src/org/tizen/emulator/manager/ui/renewal/dialog/ModifyDialog.java @@ -46,11 +46,11 @@ import org.tizen.emulator.manager.ui.renewal.item.modify.comp.PropertyValue; public class ModifyDialog extends Dialog { private Composite scrolledContent; - private List itemList; + protected List itemList; private final static int BUTTON_STYLE = SWT.OK | SWT.CANCEL; - private PropertyValue propertyValue; + protected PropertyValue propertyValue; public ModifyDialog(Shell parent, String title, int width, int height) { super(parent, title, width, height, BUTTON_STYLE); @@ -73,16 +73,27 @@ public class ModifyDialog extends Dialog { makeModifyItem(); } + public void changeItemList(String profile) { + // override this. + } + + public void sortItem(String profile) { + // override this. + } + private void makeModifyItem() { for (ModifyDialogItem item : itemList) { item.setDialog(this); // TODO we need default value for dialog item.setInitialValue(propertyValue); - item.create(scrolledContent); + item.setVisible(); } + // sort composite + sortItem(propertyValue.getProfile()); + // set scrolled-content size computeScrolledContentSize(); } diff --git a/src/org/tizen/emulator/manager/ui/renewal/dialoghandler/DeviceTemplateDialogHandler.java b/src/org/tizen/emulator/manager/ui/renewal/dialoghandler/DeviceTemplateDialogHandler.java index 85ec9bb..5348b96 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/dialoghandler/DeviceTemplateDialogHandler.java +++ b/src/org/tizen/emulator/manager/ui/renewal/dialoghandler/DeviceTemplateDialogHandler.java @@ -45,7 +45,8 @@ 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.dialog.ItemListLoader; +import org.tizen.emulator.manager.ui.renewal.dialog.ItemListUtil; +import org.tizen.emulator.manager.ui.renewal.item.ItemType; 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; @@ -75,7 +76,7 @@ public class DeviceTemplateDialogHandler { DeviceTemplateModifyDialog dialog = new DeviceTemplateModifyDialog(MainDialog.getShell(), TITLE_DETAIL, SWT.OK); dialog.setDialogMode(DIALOG_MODE.DETAIL); - dialog.create(new PropertyValue(itemValue), getItemList(null)); + dialog.create(new PropertyValue(itemValue), getItemList(itemValue)); dialog.open(); } @@ -112,7 +113,6 @@ public class DeviceTemplateDialogHandler { } - private static DeviceTemplateValue createDialog( String dialogTitle, DIALOG_MODE mode, DeviceTemplateValue value) { @@ -122,7 +122,7 @@ public class DeviceTemplateDialogHandler { new DeviceTemplateModifyDialog(MainDialog.getShell(), dialogTitle); dialog.setDialogMode(mode); - dialog.create(value, getItemList(null)); + dialog.create(value, getItemList(value)); int retValue = dialog.open(); if (retValue == SWT.OK) { @@ -135,6 +135,142 @@ public class DeviceTemplateDialogHandler { return null; } + // Get All item list and change using profile item list + public static List getInitialItemList(String profile) { + if (profile == null || profile.isEmpty()) { + profile = "mobile"; + } + + // change AllItemlist using profile item list. + List allItemList = getAllItemList(); + changeItemList(allItemList, getItemList(profile) ); + + return allItemList; + } + + + private static List getItemList(String profile) { + List profileItemList = itemListMap.get(profile); + if (profileItemList == null) { + profileItemList = loadItemList(profile); + if (profileItemList == null || profileItemList.size() == 0) { + EMLogger.getLogger().info("Failed to load template item list. Use default item list"); + profileItemList = getDefaultItemList(); + + } + itemListMap.put(profile, profileItemList); + } + return profileItemList; + } + + + public static void changeItemList(List currentItemList, String profile) { + changeItemList(currentItemList, getItemList(profile)); + } + + + public static void sortItem(List currentItemList, String profile) { + sortItem(currentItemList, getItemList(profile)); + } + + /** Sort composite in currenItemList + * - Move item which exist in profileItemList to first + * - Traverse profileItemList backward + */ + private static void sortItem(List currentItemList, + List profileItemList ) { + for (int i = profileItemList.size() - 1; i >= 0 ; i--) { + ModifyDialogItem profileItem = profileItemList.get(i); + for (ModifyDialogItem currentItem : currentItemList) { + if (currentItem.getName().equals(profileItem.getName())) { + currentItem.moveItemAbove(); + } + } + } + } + + + private static void changeItemList(List currentItemList, + List profileItemList ) { + + sortItem(currentItemList, profileItemList); + + // - set visible for each item. : call setUse() + // - set UI data with new one. + for (ModifyDialogItem currentItem : currentItemList) { + boolean exist = false; + for (ModifyDialogItem profileItem : profileItemList) { + if (currentItem.getName().equals(profileItem.getName())) { + exist = true; + currentItem.changeItem(profileItem); + break; + } + } + currentItem.setItemVisible(exist); + } + + } + + + + private static List getAllItemList() { + + List allItemList = itemListMap.get("all"); + if (allItemList == null) { + itemListMap.put("mobile", loadItemList("mobile")); + itemListMap.put("tv", loadItemList("tv")); + itemListMap.put("wearable", loadItemList("wearable")); + + allItemList = createAllItemList(); + itemListMap.put("all", allItemList); + } + return allItemList; + } + + + private static List createAllItemList() { + List allItemList = new ArrayList(); + + for (String key : itemListMap.keySet()) { + addItems(allItemList, itemListMap.get(key)); + } + + return allItemList; + } + + + // Add items from srcList to destList except duplicated item. + private static void addItems(List destList, + List srcList) { + + for (ModifyDialogItem srcItem : srcList) { + + // check if srcItem exists in destList. + ModifyDialogItem existItem = null; + for (ModifyDialogItem destItem : destList) { + if (destItem.getName().equals(srcItem.getName())) { + existItem = destItem; + break; + } + } + if (existItem != null) { + mergeItem(existItem, srcItem); + + } else { + destList.add(srcItem.cloneItem()); + } + } + + } + + private static void mergeItem(ModifyDialogItem destItem, ModifyDialogItem srcItem) { + // some items need merge. + + // checkbox item. + if (srcItem.getType().equals(ItemType.CHECK_LABEL)) { + destItem.mergeUIData(srcItem); + } + } private static List getItemList(DeviceTemplateValue value) { if (itemListMap == null) { @@ -148,38 +284,64 @@ public class DeviceTemplateDialogHandler { } else { profile = value.getProfile(); } + return getInitialItemList(profile); + } - List 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(); + private static List loadItemList(String profile) { - } else { - return itemListMap.get(profile); + // 1. use real xml. + String filePath = getTemplatePath(profile); + ItemList2 itemList2 = loadItemList(new File(filePath)); + if (itemList2 != null) { + return ItemListUtil.getDeviceTemplateItemList(itemList2); } + // 2. use default xml. (in source) + filePath = getDefaultTemplatePath(profile); + itemList2 = loadItemList(new File(filePath)); + if (itemList2 != null) { + return ItemListUtil.getDeviceTemplateItemList(itemList2); + } + + // 3. return default item list. + return getDefaultItemList(); } - private static List 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); + private static ItemList2 loadItemList(File file) { + if (!file.exists()) { + return null; + } + return (ItemList2)TemplateLoader.loadTemplate(file, ItemList2.class); + } + - return ItemListLoader.getDeviceTemplateItemList(xmlStruct); + private static String getTemplatePath(String profile) { + // TODO return real xml path. + return ""; } + + private static String getDefaultTemplatePath(String profile) { + // + String filePath = ""; + if (profile.equals("tv")) { + filePath = "xsd" + File.separator + "devicetemplate-ui-tv.xml"; + + } else if (profile.equals("wearable")) { + filePath = "xsd" + File.separator + "devicetemplate-ui-wearable.xml"; + + } else { + filePath = "xsd" + File.separator + "devicetemplate-ui-mobile.xml"; + } + return filePath; + } // default. public static List getDefaultItemList() { List itemList = new ArrayList(); - itemList.add(new NameItem("deviceTemplateName", "Device Name")); + itemList.add(new NameItem("name", "Device Name")); itemList.add(new ProfileItem()); itemList.add(new DisplayItem(null)); itemList.add(new RamSizeItem()); @@ -188,8 +350,6 @@ public class DeviceTemplateDialogHandler { itemList.add(new ConnectivityItem(null)); itemList.add(new CameraItem(null)); - - return itemList; } diff --git a/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/CheckBoxItem.java b/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/CheckBoxItem.java index 72b0b8e..fba1887 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/CheckBoxItem.java +++ b/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/CheckBoxItem.java @@ -31,11 +31,14 @@ package org.tizen.emulator.manager.ui.renewal.item.modify.common; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; -import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.FormAttachment; +import org.eclipse.swt.layout.FormData; import org.eclipse.swt.widgets.Composite; -import org.tizen.emulator.manager.ui.renewal.dialog.DIALOG_MODE; +import org.tizen.emulator.manager.ui.renewal.item.ItemType; 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; @@ -43,7 +46,6 @@ import org.tizen.emulator.manager.ui.renewal.item.modify.comp.TreeModifyItem; 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; @@ -55,15 +57,29 @@ public class CheckBoxItem extends ModifyDialogItem { } protected List dataList; + protected Map valueMap = new HashMap(); public CheckBoxItem(String name, String title, int numColomn, TreeModifyItem treeRoot, List dataList) { - super(name, title); + super(name, title, ItemType.CHECK_LABEL); this.numColumns = numColomn; this.dataList = dataList; initSubTreeItem(treeRoot); } + + public List getDataList() { + return dataList; + } + + public CheckBoxItem(String name, String title, int numColomn, + List dataList) { + super(name, title, ItemType.CHECK_LABEL); + this.numColumns = numColomn; + this.dataList = dataList; + init(); + } + private void initSubTreeItem(TreeModifyItem treeRoot) { initDataList(); item = new SubTreeModifyItem(); @@ -71,16 +87,142 @@ public class CheckBoxItem extends ModifyDialogItem { treeRoot.addSubItem((SubTreeModifyItem)item); } + @Override + public ModifyDialogItem cloneItem() { + List dataList = new ArrayList(); + dataList.addAll(this.dataList); + return new CheckBoxItem(getName(), getTitle(), numColumns, dataList); + } - public CheckBoxItem(String name, String title, int numColomn, - List dataList) { - super(name, title); - this.numColumns = numColomn; - this.dataList = dataList; - init(); + + @Override + public void mergeUIData(ModifyDialogItem srcDialogItem) { + if (!(srcDialogItem instanceof CheckBoxItem)) { + return; + } + CheckBoxItem srcItem = (CheckBoxItem)srcDialogItem; + + for (CheckItemData srcData : srcItem.getDataList()) { + boolean exist = false; + for (CheckItemData destData : dataList) { + if (srcData.getName().equals(destData.getName())) { + exist = true; + break; + } + } + if (!exist) { + dataList.add((CheckItemData)srcData.clone()); + } + } } + @Override + public void changeItem(ModifyDialogItem srcDialogItem) { + + if (!(srcDialogItem instanceof CheckBoxItem)) { + return; + } + CheckBoxItem srcItem = (CheckBoxItem)srcDialogItem; + + dataList.clear(); + for (CheckItemData data : srcItem.getDataList()) { + dataList.add((CheckItemData)data.clone()); + } + + if (item == null || item.getItemComp() == null || item.getItemComp().isDisposed()) { + return; + } + + // 1. add new subItems. + for (CheckItemData data : dataList) { + boolean isItemExist = false; + for (CheckBoxSubItem subItem : subItemList) { + if (data.getName().equals(subItem.getName())) { + isItemExist = true; + break; + } + } + + if (isItemExist) { + + } else { + CheckBoxSubItem newItem = new CheckBoxSubItem(this, item.getBody(), + data.getName(), data.getTitle(), valueMap.get(data.getName())); + newItem.create(null); + subItemList.add(newItem); + + } + } + + // 2. set isUse() + for (CheckBoxSubItem subItem : subItemList) { + boolean isDataExist = false; + for (CheckItemData data : dataList) { + if (data.getName().equals(subItem.getName())) { + isDataExist = true; + subItem.setChecked(getChecked(data.getName())); + break; + } + } + subItem.setUse(isDataExist); + } + + // 3. layout subitems. + layoutCheckBoxSubItems(); + + } + + + private boolean getChecked(String name) { + Boolean isCheck = valueMap.get(name); + if (isCheck == null) { + return false; + } + return isCheck; + } + + + private void layoutCheckBoxSubItems() { + + // layout subitems + int top = 0; + int left = 0; + int width = ModifyItem.BODY_CONTENT_WIDTH / numColumns; + int columnIndex = 0; + int rowIndex = 0; + for (CheckBoxSubItem subItem : subItemList) { + FormData data = new FormData(); + if (subItem.isUse()) { + left = ModifyItem.BODY_MARGIN_LEFT + columnIndex * width; + top = rowIndex * ROW_HEIGHT; + data.left = new FormAttachment(0, left); + data.top = new FormAttachment(0, top); + data.height = ROW_HEIGHT; + data.width = width; + + columnIndex++; + if (columnIndex == numColumns) { + columnIndex = 0; + rowIndex++; + } + } else { + data.width = 0; + data.height = 0; + + } + subItem.setLayoutData(data); + + } + + + // layout this items (title, body) + initRowNum(); + item.updateLayout(getContentHeight()); + + + } + public void setDefaultData() { // override if need } @@ -101,6 +243,7 @@ public class CheckBoxItem extends ModifyDialogItem { private void initRowNum() { + rowNum = 0; if (dataList == null || dataList.isEmpty()) { rowNum = 1; @@ -119,25 +262,23 @@ public class CheckBoxItem extends ModifyDialogItem { protected void createCheckBoxItems(ModifyItem item) { - item.setBodyLayoutGrid(numColumns); + item.setBodyLayoutForm(); - CheckBoxSubItem checkBoxItem; + CheckBoxSubItem checkBoxSubItem; subItemList.clear(); // for (int i=0 ; i < dataList.size() ; i++) { CheckItemData checkItemData = dataList.get(i); - checkBoxItem = new CheckBoxSubItem(this, item.getBody(), - checkItemData.getName(), checkItemData.getTitle(), checkItemData.isChecked()); - - // set checkbox item layout - GridData data = new GridData(); - data.heightHint = ROW_HEIGHT; - data.widthHint = ModifyItem.BODY_CONTENT_WIDTH / numColumns; - checkBoxItem.create(data); - - subItemList.add(checkBoxItem); + String name = checkItemData.getName(); + checkBoxSubItem = new CheckBoxSubItem(this, item.getBody(), + name, checkItemData.getTitle(), getChecked(name)); + checkBoxSubItem.create(null); + subItemList.add(checkBoxSubItem); } + + layoutCheckBoxSubItems(); } + public void checkBoxSelected() { getDialog().checkValid(); } @@ -149,36 +290,26 @@ public class CheckBoxItem extends ModifyDialogItem { @Override public void setInitialValue(PropertyValue value) { - if (getDialog().getDialogMode() == DIALOG_MODE.MODIFY) { - List 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); - } - } + Map valueMap = value.getCheckBoxOptions(getName()); + this.valueMap = valueMap; +// if (getDialog().getDialogMode() == DIALOG_MODE.MODIFY) { +// +// +// } else { +// for (CheckItemData data : this.dataList) { +// data.setChecked(true); +// } +// } } @Override public void setValue(PropertyValue value) { - - List dataList = new ArrayList(); + valueMap.clear(); for (CheckBoxSubItem subItem : getSubItemList()) { - dataList.add(new CheckItemData( - subItem.getName(), - subItem.getTitle(), subItem.isChecked())); + valueMap.put(subItem.getName(), subItem.isChecked()); } - value.setCheckBoxOptions(getName(), dataList); + value.setCheckBoxOptions(getName(), valueMap); } diff --git a/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/CheckBoxSubItem.java b/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/CheckBoxSubItem.java index 11635eb..b73e9b0 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/CheckBoxSubItem.java +++ b/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/CheckBoxSubItem.java @@ -58,6 +58,8 @@ public class CheckBoxSubItem { private Composite comp; private CheckBoxButton checkBox; // TODO + private boolean isUse = true; + public static final int CHECK_BOX_WIDTH = 15; private final int CHECK_BOX_HEIGHT = 14; public static final int SPACING = 2; @@ -73,10 +75,29 @@ public class CheckBoxSubItem { this.isChecked = isChecked; } + public Composite getComp() { + return comp; + } + + public void setLayoutData(Object layoutData) { + + comp.setLayoutData(layoutData); + } + + public void setUse(boolean isUse) { + this.isUse = isUse; + } + + public boolean isUse() { + return isUse; + } + public void create(Object layoutData) { // init comp comp = new Composite(parentComp, SWT.NONE); - comp.setLayoutData(layoutData); + if (layoutData != null) { + comp.setLayoutData(layoutData); + } comp.setLayout(new FormLayout()); createCheckBox(); @@ -85,6 +106,7 @@ public class CheckBoxSubItem { } + private void createCheckBox() { FormData data = new FormData(CHECK_BOX_WIDTH, CHECK_BOX_HEIGHT); @@ -156,7 +178,9 @@ public class CheckBoxSubItem { public void setChecked(boolean isChecked) { this.isChecked = isChecked; + checkBox.setSelection(isChecked); } + // public } diff --git a/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/CheckItemData.java b/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/CheckItemData.java index 8ba0ab9..7f4386e 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/CheckItemData.java +++ b/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/CheckItemData.java @@ -34,12 +34,17 @@ package org.tizen.emulator.manager.ui.renewal.item.modify.common; public class CheckItemData { private String name; private String title; - private boolean isChecked; public String getTitle() { return title; } + + @Override + public Object clone() { + return new CheckItemData(name, title); + } + public void setTitle(String title) { this.title = title; } @@ -52,23 +57,11 @@ public class CheckItemData { this.name = name; } - public boolean isChecked() { - return isChecked; - } - - public void setChecked(boolean isChecked) { - this.isChecked = isChecked; - } - public CheckItemData(String name, String title) { - this(name, title, false); - } - - public CheckItemData(String name, String title, boolean isChecked) { this.name = name; this.title = title; - this.isChecked = isChecked; } + } diff --git a/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/ComboItem.java b/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/ComboItem.java index 8ad14ff..10dbbd0 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/ComboItem.java +++ b/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/ComboItem.java @@ -44,7 +44,7 @@ import org.tizen.emulator.manager.ui.renewal.widgets.ComboBox; public abstract class ComboItem extends ModifyDialogItem { - private ComboBox comboBox; + protected ComboBox comboBox; public ComboItem(String name, String title) { super(name, title); @@ -114,4 +114,5 @@ public abstract class ComboItem extends ModifyDialogItem { // This is called when combo item is selected // TODO override this. } + } diff --git a/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/ConnectivityItem.java b/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/ConnectivityItem.java index d5cedf9..57ad2e2 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/ConnectivityItem.java +++ b/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/ConnectivityItem.java @@ -37,8 +37,6 @@ import org.tizen.emulator.manager.ui.renewal.item.modify.comp.TreeModifyItem; public class ConnectivityItem extends CheckBoxItem { -// private final ModifyItem item; - private static final String TITLE = "Device"; private static final String NAME = "device"; // private final ImageResources TITLE_ICON_RESOURCE = ImageResources.ICON_TITLE_DEVICE; diff --git a/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/DisplayItem.java b/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/DisplayItem.java index 3af6a77..fefecf1 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/DisplayItem.java +++ b/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/DisplayItem.java @@ -60,8 +60,6 @@ import org.tizen.emulator.manager.vms.RESOLUTION; public class DisplayItem extends ModifyDialogItem { - private final ModifyItem item; - private static final String TITLE = "Display"; private static final String NAME = "display"; private final ImageResources TITLE_ICON_RESOURCE = ImageResources.ICON_TITLE_DISPLAY; @@ -87,6 +85,13 @@ public class DisplayItem extends ModifyDialogItem { this.resList = resList; } + @Override + public ModifyDialogItem cloneItem() { + List resList = new ArrayList(); + resList.addAll(this.resList); + return new DisplayItem(resList); + } + @Override public void create(Composite parent) { @@ -211,10 +216,17 @@ public class DisplayItem extends ModifyDialogItem { data.height = ModifyItem.WIDGET_HEIGHT; resolutionCombo = new ComboBox(getDialog().getShell(), comp, SWT.NONE); resolutionCombo.setLayoutData(data); + addResolutionComboListener(); } private void initResolutionCombo() { + if (resolutionCombo == null || resolutionCombo.isDisposed() ) { + return; + } + + resolutionCombo.clear(); + // default. if (resList == null) { resList = new ArrayList(); @@ -229,8 +241,6 @@ public class DisplayItem extends ModifyDialogItem { resList.add(RESOLUTION.QHD); } - addResolutionComboListener(); - if (resList.size() == 0) { return; } @@ -250,16 +260,25 @@ public class DisplayItem extends ModifyDialogItem { } // select combobox + int index = -1; for (int i=0 ; i < resolutionCombo.getItemList().size() ; i++) { String str = resolutionCombo.getItemList().get(i); if (str.equals(re)) { - resolutionCombo.select(i); + index = i; break; } } - resolutionComboSelected(re); + if (index == -1) { + resolutionCombo.select(0); + resolution = resList.get(0); + } else { + resolutionCombo.select(index); + } + resolutionComboSelected(re); + // close popup if it is opened. + resolutionCombo.closeComboBox(); } @@ -392,10 +411,11 @@ public class DisplayItem extends ModifyDialogItem { } private void selectSize() { - // TODO default value - sizeTextBox.setText("5.0"); + if (sizeTextBox == null || sizeTextBox.isDisposed()) { + return; + } - displaySize = sizeTextBox.getValue(); + sizeTextBox.setText(displaySize); getDialog().checkValid(); } @@ -510,6 +530,28 @@ public class DisplayItem extends ModifyDialogItem { return true; } + public List getResolutionList() { + return resList; + } + @Override + public void changeItem(ModifyDialogItem srcDialogItem) { + + if (!(srcDialogItem instanceof DisplayItem)) { + return; + } + + // change size + DisplayItem srcItem = (DisplayItem)srcDialogItem; + resList = srcItem.getResolutionList(); + initResolutionCombo(); + + // change size + selectSize(); + + + } + + } diff --git a/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/IModifyDialogItem.java b/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/IModifyDialogItem.java index f986be6..b009629 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/IModifyDialogItem.java +++ b/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/IModifyDialogItem.java @@ -45,4 +45,6 @@ public interface IModifyDialogItem { /** set dialog data to property value */ public void setValue(PropertyValue value); + + public abstract ModifyDialogItem cloneItem(); } diff --git a/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/ImageItem.java b/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/ImageItem.java index b5adda1..daff57c 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/ImageItem.java +++ b/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/ImageItem.java @@ -62,4 +62,9 @@ public class ImageItem extends TextLabelItem { // TODO Auto-generated method stub } + + @Override + public ModifyDialogItem cloneItem() { + return new ImageItem(); + } } diff --git a/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/ModifyDialogItem.java b/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/ModifyDialogItem.java index 6b0a7ef..a114de5 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/ModifyDialogItem.java +++ b/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/ModifyDialogItem.java @@ -31,6 +31,7 @@ package org.tizen.emulator.manager.ui.renewal.item.modify.common; +import org.eclipse.swt.layout.GridData; import org.tizen.emulator.manager.renewal.resources.ImageResources; import org.tizen.emulator.manager.ui.renewal.dialog.ModifyDialog; import org.tizen.emulator.manager.ui.renewal.item.modify.comp.IconItemTitle; @@ -41,16 +42,43 @@ import org.tizen.emulator.manager.ui.renewal.item.modify.comp.SubTreeModifyItem; public abstract class ModifyDialogItem implements IModifyDialogItem { + protected ModifyItem item; + private String title; private String name; + private String type = ""; + private ModifyDialog dialog; - public ModifyDialogItem(String name, String title) { + // decide item's visibility in dialog + private final boolean isUse = true; + + public ModifyDialogItem(String name, String title, String type) { + this(name, title); + if (type != null) { + this.type = type; + } + } + + public void mergeUIData(ModifyDialogItem srcDialogItem) { + // override this. + } + + public void changeItem(ModifyDialogItem srcDialogItem) { + // override this. + } + + + public ModifyDialogItem(String name, String title) { this.title = title; this.name = name; } + public String getType() { + return type; + } + public String getName() { return name; } @@ -86,4 +114,32 @@ public abstract class ModifyDialogItem implements IModifyDialogItem { public boolean isValid() { return true; } + + + public void setItemVisible(boolean isVisible) { + if (item == null || item.getItemComp() == null + || item.getItemComp().isDisposed()) { + return; + } + + GridData data = (GridData)item.getItemComp().getLayoutData(); + if (isVisible) { + data.heightHint = item.getItemHeight() + ModifyItem.LINE_WIDTH; + + } else { + data.heightHint = 0; + } + } + + public void setVisible() { + setItemVisible(isUse); + } + + public void moveItemAbove() { + if (item == null || item.getItemComp() == null + || item.getItemComp().isDisposed()) { + return; + } + item.getItemComp().moveAbove(null); // move to top + } } diff --git a/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/NameItem.java b/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/NameItem.java index 489edb7..84c9cdc 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/NameItem.java +++ b/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/NameItem.java @@ -59,6 +59,15 @@ public class NameItem extends TextInputBoxItem { this.value = value.getName(); } + @Override + public void changeItem(ModifyDialogItem srcDialogItem) { + if (textBox == null || textBox.isDisposed()) { + return; + } + textBox.setText(value); + + } + @Override public void textModified() { @@ -82,4 +91,10 @@ public class NameItem extends TextInputBoxItem { value.setName(this.value); } + + @Override + public ModifyDialogItem cloneItem() { + return new NameItem(getName(), getTitle()); + } + } diff --git a/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/ProcessorItem.java b/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/ProcessorItem.java index 3f75ef4..0765eb1 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/ProcessorItem.java +++ b/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/ProcessorItem.java @@ -51,8 +51,6 @@ import org.tizen.emulator.manager.vms.CPU; public class ProcessorItem extends ComboItem { - private final ModifyItem item; - private static final String TITLE = "Processor"; private static final String NAME = "processor"; private final ImageResources TITLE_ICON_RESOURCE = ImageResources.ICON_TITLE_PROCESSOR; @@ -71,8 +69,6 @@ public class ProcessorItem extends ComboItem { public ProcessorItem() { super(NAME, TITLE); item = new ModifyItem(); - - } @Override @@ -101,13 +97,14 @@ public class ProcessorItem extends ComboItem { WidgetHelper.drawText(canvas, String.valueOf(cpuNum), SWT.NONE); } - private void initProcessorCombo() { - + private void initComboList() { // init combo list for (CPU r : CPU.values()) { addComboItem(r.toString()); } + } + private void selectItem() { // select item int index = 0; for (int i=0 ; i < getComboItemList().size() ; i++) { @@ -120,6 +117,10 @@ public class ProcessorItem extends ComboItem { comboSelected(); } + private void initProcessorCombo() { + initComboList(); + selectItem(); + } private void comboSelected() { @@ -177,4 +178,10 @@ public class ProcessorItem extends ComboItem { value.setCpuNum(cpuNum); } + + @Override + public ModifyDialogItem cloneItem() { + // TODO ProcessorItem(TreeModifyItem treeRoot) ?? + return new ProcessorItem(); + } } diff --git a/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/ProfileItem.java b/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/ProfileItem.java index 3765e15..4da6e8f 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/ProfileItem.java +++ b/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/ProfileItem.java @@ -47,6 +47,8 @@ import org.eclipse.swt.widgets.Canvas; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Listener; +import org.tizen.emulator.manager.platform.Profile; +import org.tizen.emulator.manager.platform.ProfileList; 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; @@ -55,8 +57,6 @@ import org.tizen.emulator.manager.ui.renewal.widgets.WSTATE; public class ProfileItem extends ModifyDialogItem { - - private ModifyItem item; private Canvas imageCanvas; private String currentProfile = "mobile"; // TODO this is temp default. @@ -71,7 +71,7 @@ public class ProfileItem extends ModifyDialogItem { private final int IMAGE_SPACING = 4; // TODO profileList from XML ? - private final String[] profileList = new String[]{MOBILE,WEARABLE,TV}; + private final String[] buttonList = new String[]{MOBILE,WEARABLE,TV}; private final Map buttonMap = @@ -155,58 +155,75 @@ public class ProfileItem extends ModifyDialogItem { private void createProfileButton() { item.getBody().setLayout(new FormLayout()); + + // create button + for (Profile profile : ProfileList.getProfileList()) { + String name = profile.getName(); + if (name.equals(MOBILE)) { + createMobileButton(); + + } else if (name.equals(WEARABLE)) { + createWearableButton(); + + } else if (name.equals(TV)) { + createTVButton(); + } + } + + // TODO for test +// createWearableButton(); +// createTVButton(); + + + // layout + int top = (ModifyItem.ITEM_HEIGHT - PROFILE_IMAGE_HEIGHT) / 2; + int left = ModifyItem.BODY_MARGIN_LEFT; + for (String profile : buttonList) { + ImageRadioButton button = buttonMap.get(profile); + if (button == null) { + continue; + } + FormData data = new FormData(); + data.top = new FormAttachment(0, top); + data.left = new FormAttachment(0, left); + data.width = PROFILE_IMAGE_WIDTH; + data.height = PROFILE_IMAGE_HEIGHT; + button.setLayoutData(data); + left += (PROFILE_IMAGE_WIDTH + IMAGE_SPACING); + } + + addSelectListener(); + selectButton(); + + } + + private void createMobileButton() { ImageRadioButton mobileButton = new ImageRadioButton(item.getBody()); mobileButton.setImage(WSTATE.NORMAL, ImageResources.BTN_PROFILE_MOBILE_UNSELECTED_NML); mobileButton.setImage(WSTATE.HOVER, ImageResources.BTN_PROFILE_MOBILE_UNSELECTED_HOVER); mobileButton.setImage(WSTATE.SELECTED, ImageResources.BTN_PROFILE_MOBILE_SELECTED); mobileButton.setToolTipText(MOBILE); + buttonMap.put(MOBILE, mobileButton); + } + private void createWearableButton() { ImageRadioButton wearableButton = new ImageRadioButton(item.getBody()); wearableButton.setImage(WSTATE.NORMAL, ImageResources.BTN_PROFILE_WEARABLE_UNSELECTED_NML); wearableButton.setImage(WSTATE.HOVER, ImageResources.BTN_PROFILE_WEARABLE_UNSELECTED_HOVER); wearableButton.setImage(WSTATE.SELECTED, ImageResources.BTN_PROFILE_WEARABLE_SELECTED); wearableButton.setToolTipText(WEARABLE); + buttonMap.put(WEARABLE, wearableButton); + } + private void createTVButton() { ImageRadioButton tvButton = new ImageRadioButton(item.getBody()); tvButton.setImage(WSTATE.NORMAL, ImageResources.BTN_PROFILE_TV_UNSELECTED_NML); tvButton.setImage(WSTATE.HOVER, ImageResources.BTN_PROFILE_TV_UNSELECTED_HOVER); tvButton.setImage(WSTATE.SELECTED, ImageResources.BTN_PROFILE_TV_SELECTED); tvButton.setToolTipText(TV); - - - int top = (ModifyItem.ITEM_HEIGHT - PROFILE_IMAGE_HEIGHT) / 2; - - FormData data = new FormData(); - data.top = new FormAttachment(0, top); - data.left = new FormAttachment(0, ModifyItem.BODY_MARGIN_LEFT); - data.width = PROFILE_IMAGE_WIDTH; - data.height = PROFILE_IMAGE_HEIGHT; - mobileButton.setLayoutData(data); - - data = new FormData(); - data.top = new FormAttachment(0, top); - data.left = new FormAttachment(mobileButton, IMAGE_SPACING); - data.width = PROFILE_IMAGE_WIDTH; - data.height = PROFILE_IMAGE_HEIGHT; - wearableButton.setLayoutData(data); - - data = new FormData(); - data.top = new FormAttachment(0, top); - data.left = new FormAttachment(wearableButton, IMAGE_SPACING); - data.width = PROFILE_IMAGE_WIDTH; - data.height = PROFILE_IMAGE_HEIGHT; - tvButton.setLayoutData(data); - - buttonMap.put(MOBILE, mobileButton); - buttonMap.put(WEARABLE, wearableButton); buttonMap.put(TV, tvButton); - - addSelectListener(); - selectButton(); - } - private void addSelectListener() { for (final String profile : buttonMap.keySet()) { @@ -214,7 +231,11 @@ public class ProfileItem extends ModifyDialogItem { @Override public void handleEvent(Event e) { if (e.type == SWT.Selection) { - currentProfile = profile; + if (!currentProfile.equals(profile)) { +// System.out.println("profile changed : " + profile); + currentProfile = profile; + getDialog().changeItemList(profile); + } } } }); @@ -242,4 +263,9 @@ public class ProfileItem extends ModifyDialogItem { } + @Override + public ModifyDialogItem cloneItem() { + return new ProfileItem(); + } + } diff --git a/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/RamSizeItem.java b/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/RamSizeItem.java index d6e9b95..1992ffa 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/RamSizeItem.java +++ b/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/RamSizeItem.java @@ -49,8 +49,6 @@ import org.tizen.emulator.manager.vms.RAM_SIZE; public class RamSizeItem extends ComboItem { - private final ModifyItem item; - private static final String TITLE = "Ram"; private static final String NAME = "ram"; @@ -107,6 +105,15 @@ public class RamSizeItem extends ComboItem { addComboItem(r.toString()); } + selectItem(); + + } + + private void selectItem() { + if (comboBox == null || comboBox.isDisposed()) { + return; + } + // select item int index = 0; for (int i=0 ; i < getComboItemList().size() ; i++) { @@ -132,6 +139,12 @@ public class RamSizeItem extends ComboItem { getDialog().checkValid(); } + + @Override + public void changeItem(ModifyDialogItem srcDialogItem) { + selectItem(); + } + private void addLabel() { FormData data = new FormData(); int left = ModifyItem.BODY_MARGIN_LEFT + COMBO_WIDTH + 6; @@ -167,4 +180,10 @@ public class RamSizeItem extends ComboItem { // TODO override this. comboSelected(); } + + @Override + public ModifyDialogItem cloneItem() { + // TODO RamSizeItem(TreeModifyItem treeRoot) ?? + return new RamSizeItem(); + } } diff --git a/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/SensorItem.java b/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/SensorItem.java index 65cb4d7..9986d7c 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/SensorItem.java +++ b/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/SensorItem.java @@ -39,8 +39,6 @@ import org.tizen.emulator.manager.ui.renewal.item.modify.comp.TreeModifyItem; public class SensorItem extends CheckBoxItem { -// private final ModifyItem item; - private static final String TITLE = "Sensor"; private static final String NAME = "sensor"; private final ImageResources TITLE_ICON_RESOURCE = ImageResources.ICON_TITLE_SENSOR; @@ -52,7 +50,7 @@ public class SensorItem extends CheckBoxItem { dataList.add(new CheckItemData("accel", "Accelerometer")); dataList.add(new CheckItemData("gyro", "Gyroscope")); dataList.add(new CheckItemData("proxi", "Proximity")); - dataList.add(new CheckItemData("geo-magnetic", "Geo-magnetic")); + dataList.add(new CheckItemData("geo", "Geo-magnetic")); dataList.add(new CheckItemData("light", "Light")); dataList.add(new CheckItemData("haptic", "Haptic")); dataList.add(new CheckItemData("pressure", "Pressure")); diff --git a/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/TextInputBoxItem.java b/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/TextInputBoxItem.java index e0e046f..316d3cd 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/TextInputBoxItem.java +++ b/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/TextInputBoxItem.java @@ -47,8 +47,7 @@ import org.tizen.emulator.manager.ui.renewal.widgets.WidgetHelper; public abstract class TextInputBoxItem extends ModifyDialogItem { - private ModifyItem item; - private TextInputBox textBox; + protected TextInputBox textBox; protected String value = ""; @@ -74,6 +73,7 @@ public abstract class TextInputBoxItem extends ModifyDialogItem { makeBody(textBoxWidth); + } @@ -98,6 +98,7 @@ public abstract class TextInputBoxItem extends ModifyDialogItem { textBox = new TextInputBox(item.getBody(), SWT.NONE); textBox.setLayoutData(data); + textBox.setText(value); addTextListener(); } diff --git a/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/TextLabelItem.java b/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/TextLabelItem.java index 905e07a..8cabe4a 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/TextLabelItem.java +++ b/src/org/tizen/emulator/manager/ui/renewal/item/modify/common/TextLabelItem.java @@ -47,7 +47,6 @@ import org.tizen.emulator.manager.ui.renewal.item.modify.comp.ModifyItem; public abstract class TextLabelItem extends ModifyDialogItem { - private ModifyItem item; private Canvas canvas; protected String value = ""; diff --git a/src/org/tizen/emulator/manager/ui/renewal/item/modify/comp/ModifyItem.java b/src/org/tizen/emulator/manager/ui/renewal/item/modify/comp/ModifyItem.java index f6d69ba..779b892 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/item/modify/comp/ModifyItem.java +++ b/src/org/tizen/emulator/manager/ui/renewal/item/modify/comp/ModifyItem.java @@ -35,9 +35,11 @@ import org.eclipse.swt.events.PaintEvent; import org.eclipse.swt.events.PaintListener; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.layout.FormLayout; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Layout; import org.tizen.emulator.manager.renewal.resources.ColorResources; import org.tizen.emulator.manager.ui.renewal.dialog.VMModifyDialog; @@ -60,7 +62,7 @@ public class ModifyItem { private int itemHeight = ITEM_HEIGHT; - protected int getItemHeight() { + public int getItemHeight() { return itemHeight; } @@ -137,6 +139,14 @@ public class ModifyItem { setBodyLayoutGrid(1); } + public void setBodyLayout(Layout layout) { + bodyComp.setLayout(layout); + } + + public void setBodyLayoutForm() { + setBodyLayout(new FormLayout()); + } + public void setBodyLayoutGrid(int numColumns) { GridLayout layout = new GridLayout(); layout.numColumns = numColumns; @@ -174,4 +184,12 @@ public class ModifyItem { comp.setLayout(layout); } + // update Item height; + public void updateLayout(int height) { + this.itemHeight = height; + GridData data = (GridData)comp.getLayoutData(); + data.heightHint = getItemHeight() + LINE_WIDTH; + comp.layout(true,true); + } + } 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 bc649be..b8edb3a 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 @@ -32,14 +32,13 @@ package org.tizen.emulator.manager.ui.renewal.item.modify.comp; -import java.util.ArrayList; -import java.util.List; +import java.util.HashMap; +import java.util.Map; import org.tizen.emulator.manager.devices.DeviceTemplateValue; import org.tizen.emulator.manager.devices.SubDevice; import org.tizen.emulator.manager.devices.SubDeviceItem; import org.tizen.emulator.manager.platform.Skin; -import org.tizen.emulator.manager.ui.renewal.item.modify.common.CheckItemData; import org.tizen.emulator.manager.vms.RESOLUTION; import org.tizen.emulator.manager.vms.SKIN_SHAPE; import org.tizen.emulator.manager.vms.VMPropertyValue; @@ -275,15 +274,15 @@ public class PropertyValue { public void setCheckBoxOptions(String name, - List dataList) { + Map valueMap) { if (isVMValue()) { // TODO } else if (isTemplateValue()) { SubDevice subDevice = new SubDevice(name); - for (CheckItemData data : dataList) { - SubDeviceItem subDeviceItem = new SubDeviceItem(data.getName()); - subDeviceItem.setSupport(data.isChecked()); + for (String key : valueMap.keySet()) { + SubDeviceItem subDeviceItem = new SubDeviceItem(key); + subDeviceItem.setSupport(valueMap.get(key)); subDevice.addSubDeviceItem(subDeviceItem); } templateValue.addOrUpdateSubDevices(subDevice); @@ -291,8 +290,8 @@ public class PropertyValue { } - public List getCheckBoxOptions(String name) { - List dataList = new ArrayList(); + public Map getCheckBoxOptions(String name) { + Map valueMap = new HashMap(); // TODO if (isVMValue()) { // TODO @@ -301,14 +300,13 @@ public class PropertyValue { for (SubDevice subDevice : templateValue.getAdditionalDevices()) { if (subDevice.getName().equals(name)) { for (SubDeviceItem subDeviceItem : subDevice.getItems()) { - CheckItemData data = new CheckItemData( - subDeviceItem.getId(), "", subDeviceItem.isSupport()); - dataList.add(data); + valueMap.put(subDeviceItem.getId(), subDeviceItem.isSupport()); + } } } } - return dataList; + return valueMap; } diff --git a/src/org/tizen/emulator/manager/ui/renewal/item/modify/template/CameraItem.java b/src/org/tizen/emulator/manager/ui/renewal/item/modify/template/CameraItem.java index be2f4f5..c16e468 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/item/modify/template/CameraItem.java +++ b/src/org/tizen/emulator/manager/ui/renewal/item/modify/template/CameraItem.java @@ -38,8 +38,6 @@ import org.tizen.emulator.manager.ui.renewal.item.modify.common.CheckItemData; public class CameraItem extends CheckBoxItem { -// private final ModifyItem item; - private static final String TITLE = "Camera"; private static final String NAME = "camera"; // private final ImageResources TITLE_ICON_RESOURCE = ImageResources.ICON_TITLE_SENSOR; 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 429dfb0..6318a34 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 @@ -33,6 +33,7 @@ package org.tizen.emulator.manager.ui.renewal.item.modify.vm; import org.eclipse.swt.widgets.Composite; 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; import org.tizen.emulator.manager.ui.renewal.item.modify.comp.TreeItemTitle; import org.tizen.emulator.manager.ui.renewal.item.modify.comp.TreeModifyItem; @@ -42,33 +43,35 @@ public class DeviceTemplateItem extends ComboItem { private static final String TITLE = "Device"; private static final String NAME = "deviceTemplate"; - private final TreeModifyItem item; + private final TreeModifyItem treeModifyItem; private final int COMBO_WIDTH = 200; public TreeModifyItem getTreeRoot() { - return item; + return (TreeModifyItem)item; } public DeviceTemplateItem() { super(NAME, TITLE); - item = new TreeModifyItem(); +// item = new TreeModifyItem(); + treeModifyItem = new TreeModifyItem(); + item = treeModifyItem; } @Override public void create(Composite parent) { - item.init(parent); - item.setItemTitle(new TreeItemTitle(item, getTitle())); - item.create(); + treeModifyItem.init(parent); + treeModifyItem.setItemTitle(new TreeItemTitle(treeModifyItem, getTitle())); + treeModifyItem.create(); - item.setModifyDialogItem(this); + treeModifyItem.setModifyDialogItem(this); - createCombo(item, COMBO_WIDTH); + createCombo(treeModifyItem, COMBO_WIDTH); } @Override public int getHeight() { - return item.getHeight(); + return treeModifyItem.getHeight(); } @Override @@ -89,4 +92,9 @@ public class DeviceTemplateItem extends ComboItem { // TODO Auto-generated method stub } + + @Override + public ModifyDialogItem cloneItem() { + return new DeviceTemplateItem(); + } } diff --git a/src/org/tizen/emulator/manager/ui/renewal/widgets/ComboBox.java b/src/org/tizen/emulator/manager/ui/renewal/widgets/ComboBox.java index 3a8b205..65ddfbe 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/widgets/ComboBox.java +++ b/src/org/tizen/emulator/manager/ui/renewal/widgets/ComboBox.java @@ -84,6 +84,12 @@ public class ComboBox extends NinePatchBox { } + public void clear() { + if (items != null) { + items.clear(); + } + } + public Shell getParentShell() { return parentShell; @@ -153,6 +159,10 @@ public class ComboBox extends NinePatchBox { } + public void closeComboBox() { + popup.close(); + } + private void drawText() { textCanvas.addPaintListener(new PaintListener() { diff --git a/src/org/tizen/emulator/manager/ui/renewal/widgets/ComboBoxPopup.java b/src/org/tizen/emulator/manager/ui/renewal/widgets/ComboBoxPopup.java index 5fbc05e..0477ef5 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/widgets/ComboBoxPopup.java +++ b/src/org/tizen/emulator/manager/ui/renewal/widgets/ComboBoxPopup.java @@ -104,6 +104,12 @@ public class ComboBoxPopup { return false; } + public void close() { + if (!isClosed()) { + dispose(); + } + } + private void initCanvas() { popupCanvas = new Canvas(popupShell, SWT.DOUBLE_BUFFERED); popupCanvas.setForeground(ColorResources.CONTENT_FONT.getColor()); diff --git a/xsd/devicetemplate-ui-mobile.xml b/xsd/devicetemplate-ui-mobile.xml new file mode 100644 index 0000000..e48e4f4 --- /dev/null +++ b/xsd/devicetemplate-ui-mobile.xml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd/devicetemplate-ui-tv.xml b/xsd/devicetemplate-ui-tv.xml new file mode 100644 index 0000000..99cdaea --- /dev/null +++ b/xsd/devicetemplate-ui-tv.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd/devicetemplate-ui-wearable.xml b/xsd/devicetemplate-ui-wearable.xml new file mode 100644 index 0000000..8afce0e --- /dev/null +++ b/xsd/devicetemplate-ui-wearable.xml @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +