ComboBox: add data item
authorjihye424.kim <jihye424.kim@samsung.com>
Sun, 18 Oct 2015 06:57:43 +0000 (15:57 +0900)
committerjihye424.kim <jihye424.kim@samsung.com>
Sun, 18 Oct 2015 06:57:43 +0000 (15:57 +0900)
- you can add to 'Object' item to combo box

Change-Id: Idcbf1a61edd5344e40e2d1b537a77c90d0deff00
Signed-off-by: jihye424.kim <jihye424.kim@samsung.com>
src/org/tizen/emulator/manager/ui/renewal/item/modify/common/ComboItem.java
src/org/tizen/emulator/manager/ui/renewal/widgets/ComboBox.java

index 10dbbd0..02a59c9 100644 (file)
@@ -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<String> 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();
index 65ddfbe..f139228 100644 (file)
@@ -68,15 +68,18 @@ public class ComboBox extends NinePatchBox {
        private Image arrowImageHover;
 
        private final List<String> items;
+       private final List<Object> 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<String>();
+               datas = new ArrayList<Object>();
                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<String> getItemList() {
                return items;
        }
 
+       public List<Object> 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());
        }