From 5b2d5ee06d04571d2c6ff3e9e0460f2f0c0db931 Mon Sep 17 00:00:00 2001 From: "jihye424.kim" Date: Sun, 18 Oct 2015 15:57:43 +0900 Subject: [PATCH] ComboBox: add data item - you can add to 'Object' item to combo box Change-Id: Idcbf1a61edd5344e40e2d1b537a77c90d0deff00 Signed-off-by: jihye424.kim --- .../ui/renewal/item/modify/common/ComboItem.java | 10 ++++++++++ .../manager/ui/renewal/widgets/ComboBox.java | 20 ++++++++++++++++++++ 2 files changed, 30 insertions(+) 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 10dbbd0..02a59c9 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 @@ -55,6 +55,10 @@ public abstract class ComboItem extends ModifyDialogItem { comboBox.addItem(item); } + protected void addComboItem(String item, Object data) { + comboBox.addItem(item, data); + } + protected List getComboItemList() { return comboBox.getItemList(); } @@ -63,6 +67,9 @@ public abstract class ComboItem extends ModifyDialogItem { return comboBox.getItemList().get(index); } + protected Object getCobmoData(int index) { + return comboBox.getDataList().get(index); + } protected void selectComboItem(int index) { comboBox.select(index); @@ -72,6 +79,9 @@ public abstract class ComboItem extends ModifyDialogItem { return comboBox.getSelectedItem(); } + protected Object getSelectedData() { + return comboBox.getSelectedData(); + } protected void createCombo(ModifyItem item, int width) { // item.setBodyLayoutDefault(); 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 65ddfbe..f139228 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/widgets/ComboBox.java +++ b/src/org/tizen/emulator/manager/ui/renewal/widgets/ComboBox.java @@ -68,15 +68,18 @@ public class ComboBox extends NinePatchBox { private Image arrowImageHover; private final List items; + private final List datas; private final ComboBoxPopup popup; private int selectedIndex = 0; private String selectedItem = ""; + private Object selectedData; public ComboBox(Shell parentShell, Composite parent, int style) { super(parent, style); this.parentShell = parentShell; popup = new ComboBoxPopup(this); items = new ArrayList(); + datas = new ArrayList(); initNinePatchResourceMap(); initBox(); createText(); @@ -88,6 +91,10 @@ public class ComboBox extends NinePatchBox { if (items != null) { items.clear(); } + + if (datas != null) { + datas.clear(); + } } @@ -97,8 +104,13 @@ public class ComboBox extends NinePatchBox { public void addItem(String item) { items.add(item); + datas.add(null); } + public void addItem(String item, Object data) { + items.add(item); + datas.add(data); + } @Override public void redraw() { @@ -110,10 +122,17 @@ public class ComboBox extends NinePatchBox { return selectedItem; } + public Object getSelectedData() { + return selectedData; + } + public List getItemList() { return items; } + public List getDataList() { + return datas; + } public void setIndex(int index) { if (index < 0 || index >= items.size()) { @@ -135,6 +154,7 @@ public class ComboBox extends NinePatchBox { selectedIndex = index; selectedItem = items.get(index); + selectedData = datas.get(index); notifyListeners(SWT.Selection, new Event()); } -- 2.7.4