comboBox.addItem(item);
}
+ protected void addComboItem(String item, Object data) {
+ comboBox.addItem(item, data);
+ }
+
protected List<String> getComboItemList() {
return comboBox.getItemList();
}
return comboBox.getItemList().get(index);
}
+ protected Object getCobmoData(int index) {
+ return comboBox.getDataList().get(index);
+ }
protected void selectComboItem(int index) {
comboBox.select(index);
return comboBox.getSelectedItem();
}
+ protected Object getSelectedData() {
+ return comboBox.getSelectedData();
+ }
protected void createCombo(ModifyItem item, int width) {
// item.setBodyLayoutDefault();
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();
if (items != null) {
items.clear();
}
+
+ if (datas != null) {
+ datas.clear();
+ }
}
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() {
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()) {
selectedIndex = index;
selectedItem = items.get(index);
+ selectedData = datas.get(index);
notifyListeners(SWT.Selection, new Event());
}